Skip to content

mobile: drop ACCESS_BACKGROUND_LOCATION from the manifest - #450

Merged
aojea merged 1 commit into
google:mainfrom
aojea:mobile-drop-background-location
Sep 19, 2026
Merged

aojea merged 1 commit into
google:mainfrom
aojea:mobile-drop-background-location

Conversation

@aojea

@aojea aojea commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

What

Removes android.permission.ACCESS_BACKGROUND_LOCATION from the Android manifest. ACCESS_COARSE_LOCATION, FOREGROUND_SERVICE_LOCATION and the service's foregroundServiceType="location" stay.

Why

Play Console flagged the permission on the first AAB upload and asked for a background-location declaration ("Let us know why your app accesses location in the background").

The app does not need it:

  • The only location feature is the opt-in get_location tool in MainActivity.kt, which reads getLastKnownLocation(NETWORK_PROVIDER) and rounds it to ~1 km.
  • It only ever requests ACCESS_COARSE_LOCATION at runtime; ACCESS_BACKGROUND_LOCATION was never requested, so no user was prompted for "Allow all the time" and nothing depended on it.
  • The node runs in SamNodeForegroundService, started from the activity with foregroundServiceType="location" when coarse location is granted. Android counts location reads made while such a service is running as foreground access, which is exactly the "agent queries the phone in your pocket" case.

Play's policy says apps that access location via a foreground service do not need ACCESS_BACKGROUND_LOCATION, and the declaration form is triggered by the manifest entry alone. Background-location approval also requires the feature to be core to the app plus a demo video, which an optional sensor toggle would not satisfy.

Zero behavior change. The next AAB built from this drops the "undeclared Location permissions" block in the console; ACCESS_COARSE_LOCATION only needs to be reflected in the Data safety section.

The permission was declared but never requested at runtime, so no user
was ever prompted for it and nothing depended on it. get_location reads
the network provider's last known position from inside the foreground
service, which is declared with foregroundServiceType="location"; Android
treats that as foreground access while the node runs off-screen, and it
needs only ACCESS_COARSE_LOCATION.

Play Console flagged the declared-but-unused permission and asked for a
background-location declaration, which an optional sensor toggle would
not pass. Removing it makes the form moot.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the ACCESS_BACKGROUND_LOCATION permission from the Android manifest file and adds an explanatory comment clarifying that location services are handled via a foreground service. I have no feedback to provide as there are no review comments and the changes are straightforward.

@aojea
aojea merged commit 108d29e into google:main Sep 19, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant