DEV Community

Cover image for I built a 444 KB offline Android running tracker in pure Java (zero Gradle, zero INTERNET permission)
Ayush Kumar
Ayush Kumar

Posted on

I built a 444 KB offline Android running tracker in pure Java (zero Gradle, zero INTERNET permission)

Most running apps today are 150–300 MB, require sign-ups, and run background telemetry.

I wanted something tiny that runs smoothly on budget hardware and keeps all route and health data strictly on the phone. So I built Corvo — a 444 KB open-source (GPLv3) Android running tracker written in pure Java and XML, compiled directly with aapt2 + javac + d8 (no Gradle).

And android.permission.INTERNET is completely absent from AndroidManifest.xml.

Corvo Home & Timer

What it does

  • Offline Vector Area Maps (.cmap): Instead of shipping gigabytes of map tiles, you cut your exact running park or road loop in the browser using the included corvo-map-cutter.html (~40–150 KB per pack) and import it once. Supports pinch zoom, 2-finger rotate, live route trail, and turnaround markers completely offline.
  • CroSite 3-Layer Distance Engine: Combines GPS, a 50 Hz accelerometer motion guard (stops drift while standing at signals), and self-calibrating stride bridging under trees or flyovers.
  • Target Mode & 0.85x Voice Coach: Set a time or distance target with auto-finish, warm-up drills, cadence metronome, and offline TTS callouts.
  • Camera Pulse (Optical PPG): Cover the rear camera and flash lightly for a 15s Resting/Post-Run BPM check, 25s morning HRV readiness, or 60s HRR-60 recovery drop (exposure + white-balance locked after settle, 2-pass tremor detrend + autocorrelation).
  • Recovery Brain & Tools: Workload tracking, 5-axis performance radar, Time Machine history scrubber, strength/body-fat trackers, and single-file JSON backup.

Corvo Map Cutter & Camera PPG

Links

If you build pure-Java Android apps or test FOSS sideloads, I would genuinely appreciate feedback on the PPG signal filter or CroSite GPS logic.

(https://github.com/Ayushxxy/Corvo)

Top comments (2)

Collapse
 
userxnom profile image
Abdullah Naseer •

The .cmap idea is the part I'd steal — cutting just your running loop in the browser instead of shipping gigabytes of tiles is the kind of constraint that makes 444 KB possible. And the 50 Hz accelerometer motion guard tells me you actually ran with it: GPS drift while standing at a signal is exactly where most trackers quietly add phantom distance.

One question: with no INTERNET permission at all, how does the 25-second morning HRV reading work across days — is the baseline stored purely on-device, and does the Recovery Brain compare against a rolling average or a fixed threshold?

Collapse
 
ayushxxy profile image
Ayush Kumar •

Ok Man First of All Very Sorry For Late Response !!!!!!!

NOW THE THING IS VERY SORTED ,
Everything runs 100% locally — zero network calls, zero cloud sync. Here is how the 25s HRV pipeline and Recovery Brain work under the hood:

  1. 25s Capture & On-Device DSP (PulseEngine.java)

Frames come from Camera2 (YUV_420_888) with the flash on, sampling only the inverted red-channel intensity from the center crop.
Since camera frame timing jitters, raw samples are first resampled onto a uniform 30 Hz grid (after a 1s settling window), then passed through a 2-pass zero-phase centered moving-average detrend + 3-tap smoothing to strip breathing and hand-tremor drift.
Systolic peaks use parabolic sub-sample interpolation (so beat timing isn't quantized to 33 ms frames), followed by median IBI outlier rejection (0.75×–1.25× median, successive diff ≤ 220 ms), and RMSSD is computed across valid beat pairs (clamped 5–180 ms, requiring at least 6 valid pairs and an autocorrelation lock conf ≥ 0.42).

  1. Purely On-Device Storage (SharedPreferences)

Readings are persisted locally in private app storage (SharedPreferences("carvo") under the "pulse_log" JSON array, newest-first, capped at the latest 100 entries, storing timestamp, date, BPM, tag, and RMSSD rounded to 0.1 ms).
It's also included in the manual local JSON export/import backup so you don't lose history across devices.

  1. Rolling Personal Baseline vs. Fixed Threshold (baselineHrv + recoveryDialog)

It does not use a fixed global millisecond cutoff (since baseline RMSSD varies hugely from person to person).
Instead, PulseEngine.baselineHrv() computes a rolling mean over your last up to 20 valid readings (hrvMs >= 5.0), and MainActivity.recoveryDialog() compares today's latest reading against your own rolling baseline using relative percentage drop thresholds (once baseline >= 15 ms):
Normal / Green: within 10% of your baseline or higher (pct > -0.10)
Caution / Amber: 10% to 25% below your baseline (pct <= -0.10)
Recovery Needed / Red: ≥ 25% below your baseline (pct <= -0.25)

  1. How it interacts with the Recovery Brain verdict

Intentionally, the main readiness state (PRIMED / STEADY / CAUTION / REST CALL / LEARNING in RunStore.recovery()) is driven purely by training load (thisWk / prevWk), 14-day pace intensity, consecutive run days, and pre/post-run mood trend.
HRV is shown inside the Recovery Brain modal as an independent diagnostic signal bar rather than overriding the verdict—because smartphone camera PPG can swing with finger pressure or cold hands, and I didn't want a noisy scan forcing a false rest call.