ReviewOS

also looking at this

craft-native/craft

Android: Bluetooth heart-rate straps, and offline media on WorkManager

#370
Merged chris wants to merge feat/android-heart-rate into main
21 files +2307 -56
10 days ago

Two Android features, both already on iOS:

Offline media on WorkManager (stacksjs/hq.training#290)

  • Each craft.media.keep is a unique WorkManager job. A Wi-Fi-only keep waits for an unmetered network.
  • A part file left by an earlier attempt is resumed with a Range request (CraftResumableDownload, JVM-tested against a local server).
  • A keep the phone can't fetch now answers at once with reason offline or cellular and queued, as on iOS.
  • prune cancels jobs no longer wanted, and clear cancels every job behind a generation counter.

Bluetooth heart-rate straps (stacksjs/hq.training#240)

  • enableHeartRate on Android:
    • same craft.heartRate API and craftHeartRate events as iOS (scan on 0x180D, connect, remembered strap, reconnect after a dropped link);
    • a recording kept natively, with a foreground service while it runs;
    • an emulator stand-in.
  • The parser and recording store are in CraftHeartRateCore.kt.template, tested on a plain JVM against iOS's vectors.
  • Gaps versus iOS:
    • a strap another app already has connected isn't listed;
    • ids are Bluetooth addresses, so a remembered strap doesn't carry between platforms;
    • Android 11 and older need location turned on to scan.

Tested so far

  • Locally: packages/android index/native-shell/page-script 154/154, packages/typescript 736/736, and the Kotlin core fixture on Kotlin 2.2.10 with JDK 17.
  • Not yet: the Gradle template compile runs here in CI (no local headroom), and nothing has been tried on an emulator or with a real strap.

21 changed files on the files tab, with 0 review threads.

Sign in to comment on this pull request.