# dustinmcafee/android-open-network-location-provider architecture

> Architecture diagram of the GitHub repository dustinmcafee/android-open-network-location-provider, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dustinmcafee/android-open-network-location-provider
- Repository: https://github.com/dustinmcafee/android-open-network-location-provider

## Overview

This is an Android AOSP NETWORK_PROVIDER replacement. AOSP requests enter NetworkLocationService, which drives FusionEngine; Wi-Fi and cell observations feed prioritized offline-cache, online Wi-Fi, and cell-database positioning, and fixes return to the framework. GPS and successful Wi-Fi positioning help warm the learned cache. The README also documents AOSP integration and first-boot cell-database fetching. Source excerpts establish the main runtime calls; links for unsampled integration behavior rely on README documentation.

Main entry points: [`src/main/java/com/github/dustinmcafee/nlp/fusion/FusionEngine.kt`](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/fusion/FusionEngine.kt) (Fusion engine), [`src/main/java/com/github/dustinmcafee/nlp/source/AppleWpsSource.kt`](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/source/AppleWpsSource.kt) (Apple WPS source), [`src/main/java/com/github/dustinmcafee/nlp/NetworkLocationService.kt`](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/NetworkLocationService.kt) (Network service), [`src/main/java/com/github/dustinmcafee/nlp/source/OfflineCellDbSource.kt`](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/source/OfflineCellDbSource.kt) (Cell DB source)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_provider["Provider and fusion"]
  node_service["Network service"]
  node_fusion["Fusion engine<br/>[FusionEngine.kt]"]
end

subgraph group_positioning["Inputs and positioning"]
  node_wifi["Wi-Fi observer<br/>[WifiObserver.kt]"]
  node_cellobs["Cell observer<br/>[CellObserver.kt]"]
  node_gps["GPS learner"]
  node_learned["Learned cache source"]
  node_apple["Apple WPS source<br/>[AppleWpsSource.kt]"]
  node_celldbsource["Cell DB source"]
end

subgraph group_network["WPS protocol"]
  node_http["HTTP client<br/>[HttpClient.kt]"]
  node_envelope["ARPC envelope<br/>[ArpcEnvelope.kt]"]
  node_proto["Apple WPS codec<br/>[AppleWpsProto.kt]"]
  node_wire["Wire format<br/>[WireFormat.kt]"]
end

subgraph group_state["State and integration"]
  node_cachedb[("Learned cache DB<br/>[LearnedCacheDb.kt]")]
  node_celldb[("Offline cell DB<br/>[OfflineCellDb.kt]")]
  node_fetch["Cell DB fetch setup"]
end

node_aosp(("AOSP framework"))
node_appleapi{{"Apple WPS endpoint"}}

node_aosp -->|"requests fixes"| node_service
node_service -->|"sets requests"| node_fusion
node_service -->|"reports fixes"| node_aosp
node_fusion -->|"scans Wi-Fi"| node_wifi
node_fusion -->|"reads cells"| node_cellobs
node_fusion -->|"starts learning"| node_gps
node_fusion -->|"tries cache"| node_learned
node_fusion -->|"queries fallback"| node_apple
node_fusion -->|"tries cells"| node_celldbsource
node_fusion -->|"stores WPS results"| node_cachedb
node_learned -->|"reads entries"| node_cachedb
node_gps -->|"learns positions"| node_cachedb
node_apple -->|"posts request"| node_http
node_apple -->|"unwraps response"| node_envelope
node_apple -->|"encodes and parses"| node_proto
node_proto -->|"uses primitives"| node_wire
node_http -->|"sends HTTPS"| node_appleapi
node_celldbsource -->|"matches observations"| node_cellobs
node_celldbsource -->|"looks up towers"| node_celldb
node_fetch -->|"downloads database"| node_celldb

click node_service "https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/NetworkLocationService.kt"
click node_fusion "https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/fusion/FusionEngine.kt"
click node_wifi "https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/observe/WifiObserver.kt"
click node_cellobs "https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/observe/CellObserver.kt"
click node_gps "https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/observe/GpsLearningObserver.kt"
click node_learned "https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/source/LearnedCacheSource.kt"
click node_apple "https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/source/AppleWpsSource.kt"
click node_celldbsource "https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/source/OfflineCellDbSource.kt"
click node_http "https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/net/HttpClient.kt"
click node_envelope "https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/net/ArpcEnvelope.kt"
click node_proto "https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/net/proto/AppleWpsProto.kt"
click node_wire "https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/net/proto/WireFormat.kt"
click node_cachedb "https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/store/LearnedCacheDb.kt"
click node_celldb "https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/store/OfflineCellDb.kt"
click node_fetch "https://github.com/dustinmcafee/android-open-network-location-provider/tree/main/integration/init"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_service,node_fusion toneBlue
class node_wifi,node_cellobs,node_gps,node_learned,node_apple,node_celldbsource toneAmber
class node_http,node_envelope,node_proto,node_wire toneMint
class node_cachedb,node_celldb,node_fetch toneRose
class node_aosp,node_appleapi toneIndigo
```

## Components

### Provider and fusion

- [Network service](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/NetworkLocationService.kt): `src/main/java/com/github/dustinmcafee/nlp/NetworkLocationService.kt`
- [Fusion engine](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/fusion/FusionEngine.kt): `src/main/java/com/github/dustinmcafee/nlp/fusion/FusionEngine.kt`

### Inputs and positioning

- [Wi-Fi observer](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/observe/WifiObserver.kt): `src/main/java/com/github/dustinmcafee/nlp/observe/WifiObserver.kt`
- [Cell observer](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/observe/CellObserver.kt): `src/main/java/com/github/dustinmcafee/nlp/observe/CellObserver.kt`
- [GPS learner](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/observe/GpsLearningObserver.kt): `src/main/java/com/github/dustinmcafee/nlp/observe/GpsLearningObserver.kt`
- [Learned cache source](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/source/LearnedCacheSource.kt): `src/main/java/com/github/dustinmcafee/nlp/source/LearnedCacheSource.kt`
- [Apple WPS source](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/source/AppleWpsSource.kt): `src/main/java/com/github/dustinmcafee/nlp/source/AppleWpsSource.kt`
- [Cell DB source](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/source/OfflineCellDbSource.kt): `src/main/java/com/github/dustinmcafee/nlp/source/OfflineCellDbSource.kt`

### WPS protocol

- [HTTP client](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/net/HttpClient.kt): `src/main/java/com/github/dustinmcafee/nlp/net/HttpClient.kt`
- [ARPC envelope](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/net/ArpcEnvelope.kt): `src/main/java/com/github/dustinmcafee/nlp/net/ArpcEnvelope.kt`
- [Apple WPS codec](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/net/proto/AppleWpsProto.kt): `src/main/java/com/github/dustinmcafee/nlp/net/proto/AppleWpsProto.kt`
- [Wire format](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/net/proto/WireFormat.kt): `src/main/java/com/github/dustinmcafee/nlp/net/proto/WireFormat.kt`

### State and integration

- [Learned cache DB](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/store/LearnedCacheDb.kt): `src/main/java/com/github/dustinmcafee/nlp/store/LearnedCacheDb.kt`
- [Offline cell DB](https://github.com/dustinmcafee/android-open-network-location-provider/blob/main/src/main/java/com/github/dustinmcafee/nlp/store/OfflineCellDb.kt): `src/main/java/com/github/dustinmcafee/nlp/store/OfflineCellDb.kt`
- [Cell DB fetch setup](https://github.com/dustinmcafee/android-open-network-location-provider/tree/main/integration/init): `integration/init`

### Other components

- **AOSP framework**
- **Apple WPS endpoint**

## Connections

- AOSP framework → Network service: requests fixes (evidence: `src/main/java/com/github/dustinmcafee/nlp/NetworkLocationService.kt`)
- Network service → Fusion engine: sets requests (evidence: `src/main/java/com/github/dustinmcafee/nlp/NetworkLocationService.kt`)
- Network service → AOSP framework: reports fixes (evidence: `src/main/java/com/github/dustinmcafee/nlp/NetworkLocationService.kt`)
- Fusion engine → Wi-Fi observer: scans Wi-Fi (evidence: `src/main/java/com/github/dustinmcafee/nlp/fusion/FusionEngine.kt`)
- Fusion engine → Cell observer: reads cells (evidence: `src/main/java/com/github/dustinmcafee/nlp/fusion/FusionEngine.kt`)
- Fusion engine → GPS learner: starts learning (evidence: `src/main/java/com/github/dustinmcafee/nlp/fusion/FusionEngine.kt`)
- Fusion engine → Learned cache source: tries cache (evidence: `src/main/java/com/github/dustinmcafee/nlp/fusion/FusionEngine.kt`)
- Fusion engine → Apple WPS source: queries fallback (evidence: `src/main/java/com/github/dustinmcafee/nlp/fusion/FusionEngine.kt`)
- Fusion engine → Cell DB source: tries cells (evidence: `src/main/java/com/github/dustinmcafee/nlp/fusion/FusionEngine.kt`)
- Fusion engine → Learned cache DB: stores WPS results (evidence: `src/main/java/com/github/dustinmcafee/nlp/fusion/FusionEngine.kt`)
- Learned cache source → Learned cache DB: reads entries (evidence: `src/main/java/com/github/dustinmcafee/nlp/source/LearnedCacheSource.kt`)
- GPS learner → Learned cache DB: learns positions (evidence: `src/main/java/com/github/dustinmcafee/nlp/observe/GpsLearningObserver.kt`)
- Apple WPS source → HTTP client: posts request (evidence: `src/main/java/com/github/dustinmcafee/nlp/source/AppleWpsSource.kt`)
- Apple WPS source → ARPC envelope: unwraps response (evidence: `src/main/java/com/github/dustinmcafee/nlp/source/AppleWpsSource.kt`)
- Apple WPS source → Apple WPS codec: encodes and parses (evidence: `src/main/java/com/github/dustinmcafee/nlp/source/AppleWpsSource.kt`)
- Apple WPS codec → Wire format: uses primitives (evidence: `src/main/java/com/github/dustinmcafee/nlp/net/proto/AppleWpsProto.kt`)
- HTTP client → Apple WPS endpoint: sends HTTPS (evidence: `README.md`)
- Cell DB source → Cell observer: matches observations (evidence: `src/main/java/com/github/dustinmcafee/nlp/source/OfflineCellDbSource.kt`)
- Cell DB source → Offline cell DB: looks up towers (evidence: `src/main/java/com/github/dustinmcafee/nlp/source/OfflineCellDbSource.kt`)
- Cell DB fetch setup → Offline cell DB: downloads database (evidence: `README.md`)
