Soundscape Service
Foreground service that provides location updates, device orientation updates, requests tiles, data persistence with realmDB. It inherits from MediaSessionService so that we can receive Media Transport button presses to act as a remote control whilst the phone is locked.
Properties
True while the user is actively navigating the audio menu. Suppresses auto callouts.
True while sleep mode's wake on leave is waiting for the user to move off. The service runs in the foreground only so that the app keeps receiving locations with the phone locked, and so that waking is a call into it rather than a foreground service start from the background, which Android 12+ refuses. The geo engine isn't started until wakeFromSnooze.
Functions
isAudioEngineBusy returns true if there is more than one entry in the audio engine queue. The queue consists of earcons and text-to-speech.
Media3's default implementation posts its own media notification and, every time the notification is refreshed, calls Context.startForegroundService() on this service followed by startForeground() with only the mediaPlayback type (or stopForeground() when it decides playback has stopped). Those calls are posted asynchronously, so one that lands after stopSelf() re-creates the service record with a pending "must call startForeground()", and the system then kills the app with a RemoteServiceException as soon as that record is stopped again (e.g. stopWithTask on exit). We own the foreground state and the notification ourselves, so Media3 must not touch either.
Stops the foreground service and removes the notification. Can be called from inside or outside the service.
Stops a snoozing service when the user turns wake on leave off, going back to plain sleep. Unlike stopForegroundService this doesn't save the playback state: sleep already did, and nothing has played since, so saving again would forget what to resume.
streetPreviewGo is called when the 'GO' button is pressed when in StreetPreview mode. It indicates that the user has selected the direction of travel in which they which to move.
Ends wake on leave's snooze, starting the geo engine as a fresh service start would.