Skip to content

MVP: six collectors, local config, own disk queue, wake_policy (#2) - #7

Merged
groupsky merged 7 commits into
mainfrom
hq-job/aoda-2-build/r-20261113-130003-bdec
Nov 15, 2026
Merged

groupsky merged 7 commits into
mainfrom
hq-job/aoda-2-build/r-20261113-130003-bdec

Conversation

@groupsky

@groupsky groupsky commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

The MVP of #2: a new app/ module (the spike stays in spike/).

What it does

  • Collectors: battery, power, boot (with an OTLP log record per boot), network, device (RAM, /data), thermal. Each on/off with its own interval (default 60 s). Names, types and units: README table.
  • Own disk queue (from the spike): one OTLP/HTTP protobuf body per file, sent in order, deleted only after a 2xx. Size cap and max age drop the oldest first. Redirects, 401/403/404/415, 408, 429 and 5xx keep the file; only 400/413/422 drop it.
  • One foreground service, wake_policy never | when_charging (default) | always. Waking: an exact alarm (setExactAndAllowWhileIdle) and a short wake lock per reading; without the exact-alarm permission, a partial wake lock between readings. Not waking: a plain timer, no alarm, no wake lock.
  • Config: defaults + a local JSON file, imported by file picker, share sheet ("Open with", QR scanner text) or adb shell am broadcast (protected by the DUMP permission). The screen shows each value with its source.
  • Screen: status (last export, queue, each collector's last values and time), setup checklist with buttons, config in use.
  • No app.installation.id; no SSID/BSSID. OpenTelemetry held at 1.66.0 with enforcedPlatform. The app builds the OTLP bodies itself (SDK data classes + the OTLP marshalers), without opentelemetry-android: its disk buffer is not used, and this keeps each point at the time of its reading and stops a collector that is turned off at once.
  • CI: unit tests, debug build, lintVitalRelease. Release workflow: signed APK on a v* tag (docs/release.md); the signing secrets are set.

Tests

docs/mvp-tests.md (emulator, Android 15, 2026-11-13): a query for each collector, collector off, wake_policy on battery and on the charger (dumpsys power, dumpsys alarm), the 30 min network cut with an app restart in it (largest gap 60 s, no reading lost), config import by file, share sheet and adb. 37 unit tests.

Waiting for the follow-up (a job on 2026-11-14): the 1 h charger test and the 24 h test on a Redmi Note 12S on HyperOS 2 (the install needs a tap at the phone), then the merge, the v0.1.0 release, and the results here.

Phone settings changed

None yet. The follow-up will set, for this app only and with the owner's OK: Autostart on, Battery saver "No restrictions", Alarms & reminders allowed. It lists them here so they can be undone.

Reviews

A correctness review found 4 bugs plus one more in the second pass; all fixed (Wi-Fi "connected" without location permission, queue loss on 3xx/401/404/415, an alarm or wake lock after stop, a crash loop on a full disk). A privacy review found nothing.

🤖 Generated with Claude Code

groupsky and others added 4 commits November 13, 2026 13:15
New module app/ (the spike stays in spike/):
- collectors: battery, power, boot, network, device, thermal; each on/off with its own interval
- config: built-in defaults plus a local JSON file (file, share sheet, QR text, adb broadcast); shows each value's source
- own file queue (from the spike): one OTLP/HTTP protobuf body per file, size cap and max age
- one foreground service; wake_policy never | when_charging | always, default when_charging
- no app.installation.id; OpenTelemetry pinned to 1.66.0 with enforcedPlatform
- unit tests, CI (build + unit tests + lint), release workflow for a signed APK

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… race, disk-full crash

- Wi-Fi: Android hides networkId without location permission, so 'connected'
  comes from the network transports and the supplicant state
- sender: do not follow redirects; drop a file only on 400/413/415/422,
  keep it and stop on any other answer
- service: no alarm or wake lock from a tick that runs while the service stops
- boot record and config save: catch IO errors instead of crashing
- tools/vm_report.py: gaps split by charger/battery, screen share, process starts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… body)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@groupsky

Copy link
Copy Markdown
Contributor Author

Test on a OnePlus Nord CE 2 Lite (Android 12), 2026-11-13

A second real phone, next to the planned HyperOS test.

  • The debug build of this PR (0.1.0-dev, 13:51 build) was installed with adb.
  • The receiver was a throw-away VictoriaMetrics container. The phone reached it over adb reverse (no VPN).
  • "Allow background activity" was on (setup checklist). wake_policy was the default when_charging. All six collectors were on.

Start. The config import by adb broadcast worked. The broadcast could not start the service from the background (ForegroundServiceStartNotAllowedException). The app showed a message about this, as designed. Start in the app worked. All six collectors read at once, and the first export was ok.

1 h on the charger, screen off (13:05:43 → 14:06:29 UTC):

readings: 51
process starts: 1
readings on the charger: 51, on battery: 0
screen on: 0.04 of the readings
timer wakes the CPU: 1.00 of the readings
largest gap: 90 s
gaps over 120 s on the charger: 0

So the check "no gap over 120 s for 1 h on the charger" passes on this phone.

OnePlus delays the exact alarm. The app calls setExactAndAllowWhileIdle, but dumpsys alarm shows the alarm with windowLength 45000. So a 60 s interval gives a reading every 60 to 90 s. In 35 min, 16 of 28 gaps were about 90 s and 12 were about 60 s. That is about 51 readings per hour, not 60. It still meets the 120 s goal. Suggest one line about this in the OnePlus part of the setup checklist.

Network cut. The phone was unplugged, and adb (so the path to the receiver) was gone for about 20 min. The readings waited in the queue and arrived in order when the path came back. No process restart.

On battery with when_charging.

  • Real unplug (2 readings on battery, around 13:01–13:05 UTC): one gap of 202 s. This is expected: the timer does not wake the CPU on battery.
  • Simulated unplug (dumpsys battery unplug, 14:06:37 → 14:10 UTC): no alarm from the app in dumpsys alarm, no wake lock from the app in dumpsys power, device.agent.wake = 0. After dumpsys battery reset, the next reading had device.agent.wake = 1, and the alarm was back.

Bug: battery current. device.battery.current is 1000× too small on this phone, and the sign is the other way (the phone gives mA, negative while charging). Filed as #9 so it is not lost. This does not block this PR.

…rt tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
groupsky and others added 2 commits November 14, 2026 10:16
No gap over 120 s on the charger with when_charging; the app holds no
wake lock between readings. Lists the phone settings changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@groupsky
groupsky marked this pull request as ready for review November 15, 2026 19:54
@groupsky
groupsky merged commit 4e8cd8a into main Nov 15, 2026
1 check passed
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