VpsLocalForegroundService
Optional camera-type foreground service that lets VpsLocalLocationSource keep scanning while the app is backgrounded or the screen is off (e.g. room-to-room detection where the phone is on a lanyard).
Android restricts camera access from the background per app process (UID): while any camera-type foreground service is running, the whole process may keep the camera open. So this service does not run the scan loop — that stays in VpsLocalLocationSource's own coroutine scope. It only holds the foreground-service privilege, a partial wake lock (CPU stays awake with the screen off), and the required ongoing notification.
Opt-in — the consuming app owns the manifest obligation
This module's manifest does not declare the service or its permissions, so apps that don't need background scanning are unaffected. An app that does need it must add, to its own manifest:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<service
android:name="com.getwemap.sdk.positioning.wemapvpslocal.VpsLocalForegroundService"
android:foregroundServiceType="camera"
android:exported="false" />CAMERA and the camera <uses-feature> are also merged in from this AAR, but a foregroundServiceType="camera" service requires them declared in the same manifest as the service (lint ForegroundServicePermission / PermissionImpliesUnsupportedChromeOsHardware do not credit library-merged entries), so declare them explicitly. required="false" keeps the app installable on camera-less devices, where it still runs with the map and other location sources.
The app must also pass a Config to the VpsLocalLocationSource constructor. It builds the Notification (and creates its channel) so it fully owns the notification UX — tap action, "Stop" action, branding.
The service is started by the source (never directly by the app). On Android 14+ a camera FGS can only be started while the app is in the foreground, which is why the source starts it from start() (called while the map is visible); it then survives the app going to the background.
Types
What the app supplies to enable background scanning: the ongoing notification shown while the service runs and the notificationId it is posted under.