feat(android): support opt-in background location#100967
Conversation
Co-authored-by: Iori Kojima <iori@iori.dev>
04f45c8 to
8c4698d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04f45c8f40
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| val backgroundGranted = | ||
| ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_BACKGROUND_LOCATION) == | ||
| PackageManager.PERMISSION_GRANTED | ||
| return (fineGranted || coarseGranted) && backgroundGranted |
There was a problem hiding this comment.
Check location services before adding location FGS type
With Always selected and permissions granted, turning the device-level Location switch off leaves these permission checks true, so this returns true and startForegroundWithTypes() passes FOREGROUND_SERVICE_TYPE_LOCATION. For targetSdk 36 Android enforces the location foreground-service prerequisites at startForeground() (device location services enabled plus coarse/fine grant), so third-party builds can crash on service start or notification refresh instead of staying connected. Gate this on LocationManager.isLocationEnabled/PermissionChecker before returning active.
Useful? React with 👍 / 👎.
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: feat(android): support opt-in background location This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Land-ready verification complete for head
The repo-native review artifacts and exact-head hosted prepare gates passed with no findings. |
|
@steipete Thanks for finding my earlier PR and preserving the credit! |
* feat(android): support background location Co-authored-by: Iori Kojima <iori@iori.dev> * chore(android): refresh native i18n inventory * docs(android): move release note to app changelog --------- Co-authored-by: Iori Kojima <iori@iori.dev>
* feat(android): support background location Co-authored-by: Iori Kojima <iori@iori.dev> * chore(android): refresh native i18n inventory * docs(android): move release note to app changelog --------- Co-authored-by: Iori Kojima <iori@iori.dev>
Closes #68581
What Problem This Solves
Android nodes reject
location.getwhenever the app is backgrounded, even when a sideloaded build's user explicitly wants background location access.Why This Change Was Made
Third-party builds now offer an explicit
Alwaysmode using Android's incremental foreground-then-background permission flow and the existing persistent node service. The Play flavor remains foreground-only and does not declare background location; this carries forward the useful design work from #61232 while tightening flavor, grant, notification, and service-type gates.User Impact
Users of third-party Android builds can choose Settings → Phone Capabilities → Location → Always, review why access is needed, and grant Allow all the time in Android settings. Background checks remain request-driven, appear as
Location: Alwaysin the persistent node notification, and stop working immediately when the mode or Android grant is removed.Evidence
tbx_01kwvy3yr4res531vj34bqvwj5:./gradlew :app:testPlayDebugUnitTest :app:testThirdPartyDebugUnitTest :app:assemblePlayDebug :app:assembleThirdPartyDebugACCESS_BACKGROUND_LOCATION/FOREGROUND_SERVICE_LOCATIONwhile third-party includes both and thelocationservice typenode --import tsx scripts/native-app-i18n.ts check— clean, 2702 entries:app:ktlintCheckreport — all touched Kotlin files clean; the full task still reports unrelated formatting debt already present onmainContributor credit is preserved in the implementation commit for @ioridev's earlier work in #61232.