Foreground Service Location Permission Enforcement Boundary on API 29+
0 reputation · 06 Jan 2021, 00:31 UTC
Foreground Service Location Permission Enforcement Boundary
Goal: start a foreground service with the location type on Android 10 (API 29) and later without triggering a SecurityException, while preserving the ability to launch the service from both foreground and background app states.
Constraint: apps targeting API 29+ must declare the normal-level FOREGROUND_SERVICE_LOCATION permission in the manifest when using a location-related foreground service type. The permission is granted at install time, but the exact point at which the platform validates it during the service lifecycle remains unclear.
Uncertainty: it is not documented whether the check occurs when calling startForegroundService(), when calling startForeground(), or only when the app is in the background. OEM-modified Android builds may also apply different enforcement timing or strictness compared with the AOSP baseline.
Questions:
- On API 29+, is
FOREGROUND_SERVICE_LOCATIONenforced atstartForegroundService()or atstartForeground()? - Does the permission check apply when the app is visibly in the foreground, or only during background service starts?
- Do manufacturer-customized Android distributions change the enforcement boundary for this manifest permission?