# #37 — Phone energy profiling

Target build: Android 0.14.0-trip-data (`cd429ac`), physical TECNO KF8, Android 11 / API 30. The device stays attached to the PC for debugging. Measurements were collected on 2026-09-19.

## Measurement boundary

The phone exposes Android Batterystats per-UID modeled consumption in mAh, CPU time, network traffic and GPS/wakelock activity. It does not expose a `powerstats` service. The kernel battery supply reports USB charging; its charge counter and battery percentage are therefore not measurements of app consumption. No charging-disable interface was found in the inspected battery/charger paths.

For diagnostic accounting, `dumpsys battery unplug` can make the framework collect on-battery statistics while USB still physically supplies power. This does **not** stop charging and is not a battery discharge experiment. Every run must retain both framework and kernel battery status and restore `dumpsys battery reset` afterward. Report modeled mAh separately from measured activity counters, never as hardware energy or a savings percentage. Resetting Batterystats clears diagnostic counters on this dedicated debugging phone.

References: [Android dumpsys metrics](https://developer.android.com/tools/dumpsys), [Android battery profiling](https://developer.android.com/topic/performance/power/setup-battery-historian). Battery use estimates depend on the device power profile and may omit unattributed system/renderer costs; they are not a substitute for an external power meter or a controlled physical discharge test.

## Scenarios and controls

Use equal 120-second measurement windows, two repeats per condition, the same APK/device/network/location settings, screen off, and the same sampling commands. Warm the app/catalogue before the window. Record device temperature, framework screen-off time, effective location accuracy and any missing fixes. Run order must be stated; startup and warm-up costs are outside the measurement window.

1. Idle: no navigation or recording service. Verify no app location listener or held wake lock.
2. Active trip: navigation plus recording with the screen off, one shared location listener, guidance cadence 2 s and recorder cadence 5 s. Record accepted samples and guidance state.
3. Replanning: the same active scenario plus a bounded replan request, with network outcome, completion time, surviving guidance and recording continuity recorded.

A stationary real-GNSS run can profile acquisition/tracking, but cannot verify moving turn instructions. A synthetic replay can verify deterministic guidance and replan behavior, but its mocked fixes do not measure real GNSS receiver energy. Keep these interpretations separate. Existing #32/#33 moving replay evidence is functional evidence only.

## Decision rule and completion gates

Change location cadence or wake-lock behavior only if repeatable measurements identify unnecessary work. If no defensible finding emerges, retain the existing cadence and report that no savings claim is established. Any change requires rerunning the affected energy scenarios and navigation/recording checks.

After each active run, stop both owners and verify zero app location subscriptions and no app-held wake lock using native status plus Android dumps. Restore databases, model/plan documents, radio settings, permissions and mock providers. Export only aggregate, non-location results into the tracked report; raw diagnostics stay in ignored runtime storage.

## Results: primary 120-second cohort

Order was idle, active, replan, replan, active, idle. All six actual accounting windows were entirely screen-off. The same Wi-Fi connection and device settings were retained; the mid-matrix network snapshot reported 5765 MHz / −59 dBm. The phone was stationary with real GNSS; initial routes, profile and SOC were synthetic. Replans used the real online provider. Polling over ADB/CDP every five seconds adds overhead to every condition, including idle. Startup/catalogue refresh and initial GNSS acquisition are excluded.

| Order / condition | Accounting (s) | Modeled UID mAh | Modeled mAh/h | CPU user + system (ms) | GPS attribution (s) | Temperature °C | New samples |
| --- | ---: | ---: | ---: | ---: | ---: | --- | ---: |
| 1 idle | 120.470 | 0.00712 | 0.2128 | 1772 | unavailable | 35.9 → 35.6 | 0 |
| 2 active | 120.519 | 1.19 | 35.5463 | 2313 | 120.518 | 35.6 → 35.4 | 4 |
| 3 replan | 120.486 | 1.20 | 35.8548 | 5792 | 120.485 | 35.4 → 35.2 | 1 |
| 4 replan | 120.482 | 1.20 | 35.8560 | 5629 | 120.482 | 35.2 → 35.1 | 1 |
| 5 active | 120.504 | 1.19 | 35.5507 | 1909 | 120.503 | 35.1 → 34.9 | 1 |
| 6 idle | 120.530 | 0.00655 | 0.1956 | 1601 | unavailable | 34.9 → 34.7 | 0 |

Values use the end-of-run cumulative UID counters since the explicit reset and the corresponding framework accounting window, not nominal duration or a subtraction from an absent start record. Rates are accounting normalizations, not forecasts of hourly physical discharge. [Machine-readable aggregate](/omox/37-energy-results.json) contains availability and reliability fields. No coordinates, SSID, BSSID or personal journey data are published.

Missing UID rows mean unavailable attribution, not zero consumption. GPS rows are absent in idle; native and Android post-stop checks independently establish listener cleanup. Network attribution is missing in five runs and reports zero bytes in the other despite a successful real HTTP replan. Network-byte accounting is therefore unusable for comparison on this device. The report makes no zero-traffic claim.

Both replans completed (`planned`, `guidanceUpdated=true`) in 5.536 and 6.397 seconds from the submitted observation timestamp to native completion. Navigation and recording remained active with two consumers sharing one platform listener. Screen-off samples continued, but only 1–4 fixes were accepted per window. At the end, navigation reported uncertain location in all active windows; both replans ended with the recorder reporting unavailable/stale location. Stationary displacement filtering and fix freshness limit this evidence: it proves lifecycle/replan behavior, not uninterrupted moving guidance. Moving turn/voice and degraded-location behavior have separate [#32](/omox/32-navigation/) and [#33](/omox/33-live-replan/) validation.

After **each of six runs**, native status reported zero consumers and zero platform listeners; Android power dumps contained no app-held wake lock. Location dumps were checked for active registrations rather than historical mentions. The process completed its cleanup without an error. Physical battery status remained Charging throughout.

## Reproducibility and tool review

The tracked measurement script (local project tool; not included in this public collection) accepts `--serial`, `--duration` (minimum 60 seconds) and an empty `--output` directory. Run from the workspace root with `uv run --with websocket-client python apps/omox/tools/measure_energy.py`. A locked device can use `OMOX_DEVICE_PIN` from the private environment; do not put secrets in tracked arguments or reports.

Before fixtures are written, it force-stops the app, validates and saves original plans/models/binding preferences and SQLite databases with companions. Failed reads abort; confirmed absent files are distinguished from errors. Finally it independently attempts battery reset, process stop, byte-verified file restoration, permission restoration, reopening and forwarding cleanup, retaining disk backups and a restoration report. Raw location/network diagnostics and backups belong only in the ignored runtime directory. This script resets system diagnostic counters and is intended for the dedicated debugging phone with no active trip.

The first collection helper defaulted absent counters to zero; publication was rebuilt from retained raw CSV with explicit missing values. The tracked script fixes that ambiguity. A separate six-run 60-second cohort validated the hardened script and restoration; it is not pooled with the 120-second cohort. Its results are retained in the same aggregate:

| Order / condition | Accounting (s) | Modeled UID mAh | CPU user + system (ms) | New samples | Replan outcome |
| --- | ---: | ---: | ---: | ---: | --- |
| 1 idle | 60.567 | 0.00576 | 1293 | 0 | — |
| 2 active | 60.586 | 0.600 | 1644 | 3 | — |
| 3 replan | 60.577 | 0.610 | 4779 | 3 | planned, guidance updated, 5.605 s |
| 4 replan attempt | 60.547 | 0.608 | 3642 | 3 | rejected as invalid, guidance not updated |
| 5 active | 60.495 | 0.601 | 1469 | 1 | — |
| 6 idle | 60.565 | 0.00521 | 1354 | 0 | — |

All six accounting windows were screen-off; temperatures were 34.8–35.1 °C. Wi-Fi context was saved for each run. The second replan returned the combined SOC/fresh-position/remaining-destination validation error; the capture does not identify which subcondition failed. It is a rejected attempt, not a successful recalculation benchmark. Existing navigation/recording remained active and location uncertainty remained visible. Do not average it with successful replan costs.

All six cleanup checks again passed. The tracked script exited successfully with `restoration.json: complete=true, failures=[]`; each saved file was restored and verified byte-for-byte before reopening. Backup copies of both databases also passed SQLite integrity checks. Final inspection confirmed framework battery simulation was reset, USB power was physical, the intended app build was installed, there was no ADB reverse mapping and no app wake lock.

## Interpretation and decision

No app cadence or wake-lock change is justified by these short runs. Active GPS accounting dominates the modeled difference from idle; replan increases CPU work while keeping one location listener. Neither observation demonstrates an avoidable leak or establishes that slowing fixes would preserve guidance. Keep the current shared-listener/cancellation behavior.

Two short stationary repeats per condition are exploratory diagnostics. Temperature drift, USB power, instrumentation, incomplete UID attribution and the device power profile prevent a physical energy or savings claim. There is no before/after optimization claim, no road prediction accuracy claim and no assertion that the app meets a numeric battery-saving target. A future optimization needs an appropriate physical-power/discharge study plus moving-route reliability comparisons.

Standards review: previous backup/counter/restoration findings resolved, no remaining must-fix. Spec review: primary results meet the diagnostic measurement scope; the separate rejected attempt and physical-energy limitations remain explicit. No application code changed after the passing 66 Node / 24 JVM tests, Android build and lint recorded in [#35](/omox/35-trip-data/).
