Skip to content

feat(android): support opt-in background location#100967

Merged
steipete merged 3 commits into
mainfrom
codex/android-background-location
Jul 6, 2026
Merged

feat(android): support opt-in background location#100967
steipete merged 3 commits into
mainfrom
codex/android-background-location

Conversation

@steipete

@steipete steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Closes #68581

What Problem This Solves

Android nodes reject location.get whenever 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 Always mode 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: Always in the persistent node notification, and stop working immediately when the mode or Android grant is removed.

Evidence

  • Blacksmith Testbox tbx_01kwvy3yr4res531vj34bqvwj5:
    • ./gradlew :app:testPlayDebugUnitTest :app:testThirdPartyDebugUnitTest :app:assemblePlayDebug :app:assembleThirdPartyDebug
    • both unit suites and both debug builds passed
    • merged-manifest assertions proved Play excludes ACCESS_BACKGROUND_LOCATION / FOREGROUND_SERVICE_LOCATION while third-party includes both and the location service type
  • node --import tsx scripts/native-app-i18n.ts check — clean, 2702 entries
  • scoped :app:ktlintCheck report — all touched Kotlin files clean; the full task still reports unrelated formatting debt already present on main
  • two fresh Codex autoreviews — no accepted/actionable findings
  • Android 16 Pixel: isolated third-party validation APK installed successfully and package inspection confirmed both location declarations. The device remained PIN-locked, so no tap-through screenshot or live Gateway invocation is claimed here.

Contributor credit is preserved in the implementation commit for @ioridev's earlier work in #61232.

@steipete
steipete requested a review from obviyus July 6, 2026 15:11
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: android App: android size: L maintainer Maintainer-authored PR labels Jul 6, 2026
@steipete
steipete force-pushed the codex/android-background-location branch from 04f45c8 to 8c4698d Compare July 6, 2026 15:15

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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

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.

P2 Badge 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

clawsweeper Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

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.

@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready verification complete for head 8c4698dc3112ace52b5ef85b47432288bef5e082.

  • Hosted CI: run 28802189460 — success, including android-build-play, android-test-play, android-test-third-party, native i18n, docs, lint, and QA Smoke.
  • Blacksmith Testbox tbx_01kwvy3yr4res531vj34bqvwj5: ./gradlew :app:testPlayDebugUnitTest :app:testThirdPartyDebugUnitTest :app:assemblePlayDebug :app:assembleThirdPartyDebug — passed.
  • Merged-manifest assertions confirmed the Play artifact excludes background location while third-party declares ACCESS_BACKGROUND_LOCATION, FOREGROUND_SERVICE_LOCATION, and the service location type.
  • node --import tsx scripts/native-app-i18n.ts checkentries=2702 changed=false.
  • Two fresh Codex autoreviews — no accepted/actionable findings.
  • Android 16 Pixel: isolated third-party APK installed and package declarations verified. Remaining proof gap: the device stayed PIN-locked, so no tap-through screenshot or live Gateway invocation is claimed.

The repo-native review artifacts and exact-head hosted prepare gates passed with no findings.

@steipete
steipete merged commit 063eeb6 into main Jul 6, 2026
77 checks passed
@steipete
steipete deleted the codex/android-background-location branch July 6, 2026 15:37
@ioridev

ioridev commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

@steipete Thanks for finding my earlier PR and preserving the credit!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
* 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>
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android docs Improvements or additions to documentation maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android node: support location.enabledMode: always (background location via foreground service)

2 participants