Skip to content

use population density for coarse locations - #423

Open
soupslurpr wants to merge 6 commits into
GrapheneOS:17from
soupslurpr:population-density-provider
Open

use population density for coarse locations#423
soupslurpr wants to merge 6 commits into
GrapheneOS:17from
soupslurpr:population-density-provider

Conversation

@soupslurpr

@soupslurpr soupslurpr commented Aug 5, 2026

Copy link
Copy Markdown
Member

Use population density to select S2 granularity for coarse locations. Replace AOSP's density-result cache and fixed-grid fallback with location-specific queries. Keep AOSP's asynchronous AIDL and callback path, bridging each query with a bounded 100 ms wait at LocationFudger's existing synchronous delivery boundary. Do not use the default-level path or a static fallback.

Quantize query coordinates, trust only provider-returned S2 levels, and derive output cells locally. The proxy does not retain completed provider answers. Suppress a fix when the provider is unavailable, fails, changes binding, or times out. Keep streaming and current-location registrations after suppressed real fixes so transient failures can recover on a later delivery.

Pin the provider to NetworkLocation and require its population density service to declare android.permission.BIND_POPULATION_DENSITY_PROVIDER_SERVICE as its bind permission. Bound batch coarsening work, preserve the completed oldest-to-newest prefix when its deadline is reached, correct the S2 edge table, and synchronize offset reads, updates, resets, and cache invalidation.

Testing:

  • API checks and affected builds: m checkapi FrameworksMockingServicesTests NetworkLocation NetworkLocationTests NetworkLocationPopulationDensityColdStartTests
  • focused FrameworksMockingServicesTests classes: 129 passed
  • NetworkLocation provider, service, local-data-source, and cold-start tests: 25 passed

Related repository: GrapheneOS/platform_external_population-density.

Related changes:

Replace AOSP's asynchronous density-result cache with location-specific
queries at LocationFudger's synchronous boundary. Keep provider Binder
calls asynchronous and bound each wait to 100 ms. Do not retain provider
answers.
Fail closed when population density coarsening is unavailable instead
of reverting to a fixed grid. Retain streaming and current-location
registrations after suppressed real fixes so transient provider faults
recover on a later delivery. Preserve null timeout completion for
current-location requests and move the app-op note after coarsening.
Stop before each LocationResult query once the batch-wide budget is
spent. Deliver the completed oldest-to-newest prefix, or fail closed
when the deadline expires before the first location. Keep direct
Location coarsening outside the batch deadline and cover both paths
with deterministic clocks.
Bind population density only from NetworkLocation. Require the service
to protect its Binder entry point with the platform bind permission.
Add a permission-aware config supplier overload while preserving the
existing internal call shape for other service watchers.
Restore the geometric halving sequence at levels 9 and 11. Extend
the edge test across both corrected entries and their shared neighbor.
Refresh, read, and reset both random offset components under the same
monitor. This preserves a consistent pair and establishes visibility for
security-motivated resets.
@soupslurpr
soupslurpr force-pushed the population-density-provider branch from 8542977 to 93f61e5 Compare August 10, 2026 11:20
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