Skip to main content

Use the reviewed background execution contract

Driver App background execution coordinates AppState changes, local permission state, authenticated account state, language readiness, background-location setup, direct location refresh, account refresh, event logging, and provider callbacks.

Mounting the app or moving it between foreground and background can start work without a task button press. This contract describes source responsibilities only; it does not prove runtime isolation, location delivery, provider success, or a deployed backend.

Availability

Background-location setup is source-defined only after the Root-local permission gate reports granted, a token is available, and language loading has settled. The reviewed start branch checks ready/disabled state and the local user-enabled flag but does not explicitly require current authentication before it can issue start intent. A later stop branch checks unauthenticated state. Treat explicit authentication-before-start as a required responsibility, not proven behavior.

Requested/declared/effective OS permission, local grant state, provider authorization, location trust, user availability and server acceptance remain separate.

Prerequisites

  • Reviewed native permission declarations and effective merged build state.
  • Explicit foreground/background product and privacy requirements.
  • Authenticated Driver identity and per-request authorization.
  • Zero sensitive logging and clear provider/network egress ownership.
  • Deterministic listener/subscription cleanup and account-generation isolation.
  • A serial, independently reviewed runtime harness before any execution.

Responsibility boundaries

BoundaryResponsibilityLimit
Root AppState listenerObserve active/inactive/background and request configured developer-mode, location, user refresh, permission recheck or event-log work.Registered once with initial closure state; captured auth/user/loaded values can be stale.
Permission providerSupply current local location-permission state and app-state rechecks.Permission-completeness finding and listener cleanup remain blocked.
Background setupConfigure provider, HTTP/location callbacks, headers, templates, notification and accuracy/lifecycle behavior.Setup is not start, delivery, trust or cleanup success.
Start/stop effectReviewed ordering can request start for ready-disabled plus locally enabled user before the later unauthenticated stop branch.Require explicit current auth/account generation before start; source conditions do not prove provider state.
Location callbackObserve provider location events.A callback value is not fresh/mock-safe/server-stored proof.
HTTP callbackObserve provider response, request direct location refresh, and locally logout on unauthorized response.Response/logging/follow-ons can be partial.
Direct location refreshRead current device location and request Driver-location publication.C07/C08 trust/storage/broadcast/trail boundaries apply.
API/AppState refreshRefresh current user and record background/connectivity events conditionally.Captured initial state and failures can suppress or misroute work.

Inputs and result

Input/stateSource transitionObservable/client resultLimit
Local permission not grantedSetup returns after clearing local loading.Provider not configured by that call.Effective OS state/currentness separate.
Missing tokenExisting provider listeners are requested for removal.No configured authenticated setup.Removal completion/provider state unproven.
Permission + token + language readyFollow location and await provider ready.Ready/enabled state stored locally.Provider/server success unproven.
Ready, disabled, user enabledStart can be requested without an explicit current-auth check in that branch.Provider state may change later.Authentication/account generation and location delivery remain unproven.
Not ready/auth absent/user disabledLater branch can request stop.Provider stop intent.Stop ordering cannot erase a prior stale-user start intent; cleanup unproven.
AppState active/background/inactiveHandler can request location/user work; background can request event log.Async work may begin.Initial closure can hold null user/token/loaded false.
Provider HTTP unauthorizedLocal logout requested.Local auth/navigation can change.Server/provider/local cleanup separate.

Security and privacy

  • Never persist or expose precise coordinates, raw HTTP/provider responses, tokens, user/order data, provider identifiers or verbose location logs.
  • Treat location collection, current/last storage, availability broadcast, customer sharing, order trail/effects and retention as separate approvals.
  • Do not assume simulator, background mode or provider debug settings are hermetic.
  • Bind callbacks and late results to the current account/session generation.
  • Require cleanup to remove every location/HTTP/AppState/permission/provider listener and prove no egress remains.

Limits and failure states

StateMeaningMaintainer response
AppState callback has stale closureListener registered with initial Root values.Do not infer current auth/user/loaded behavior.
Async setup returns cleanup functionCleanup is returned by an async function.Calling effect does not return/consume it; listeners can remain across dependency changes.
Permission listener lacks cleanupProvider context can retain lifecycle listener.Fix/test before completeness claim.
Provider ready but not startedConfiguration settled, start condition separate.Keep state explicit.
Start/stop requestedProvider command intent.Verify actual state only in isolated harness.
Location/HTTP callbackProvider supplied data/response.No trust/storage/completion inference.
Unauthorized callbackLocal logout requested.Cleanup/session/provider effects separate.

Troubleshooting

SymptomInspectSafe diagnostic
Expected AppState refresh does not occurInitial closure values, listener mount and current account generationUse static trace; do not background a real authenticated app.
Duplicate location/HTTP callbacks appearAsync setup cleanup consumption and permission-provider listener cleanupCount synthetic listener registrations in an isolated harness.
Provider shows ready but no location resultReady, start, permission, auth, user-enabled and egress states separatelyDo not use real coordinates to diagnose.
Logout occurs after provider responseHTTP response handling and session cleanup ownershipTreat session/provider state as partial until reconciled.
Location appears stored/broadcast unexpectedlyC07/C08 publication, availability and order-trail boundariesStop runtime and use privacy/security review.

Re-review this contract whenever AppState dependencies, permission provider, background setup/start/stop, listener cleanup, location publication, provider callbacks, unauthorized handling or account-generation isolation changes.

Related guides: Device permissions · Location permissions · Location validation · Authenticated bootstrap