Skip to content

PulseStages 0.4.0

Choose a tag to compare

@github-actions github-actions released this 17 Oct 21:45
· 26 commits to main since this release

PulseStages can now ask Sleep as Android to import a night it wrote and, 10 minutes later, to add the night's heart
rate, without tapping "Sync now" ("Ask Sleep as Android to sync", on by default; without Sleep as Android nothing
happens, and the request carries no data). New nights can be looked for every 15 or 30 minutes, while the look for
late heart rate stays at most about hourly. Install it over 0.3.0 like any update (same signing key): the app keeps its
data and the check interval you chose, and no night becomes stale
(user guide).

Added

  • Ask Sleep as Android to sync (Settings → "Written sessions" → "Ask Sleep as Android to sync",
    write.requestSleepAsAndroidSync, on by default; turn it off there). Sleep as Android imports from Health Connect
    only when it syncs, and it attaches heart rate and SpO2 only to the nights it had before a sync. With the setting on,
    every run that wrote or rewrote a session (the automatic checks, "Estimate new", a backfill, a recompute; also one
    that stopped after writing, on a Health Connect error or because WorkManager stopped it) sends Sleep as Android its
    public sync request, "Request Backup Sync" (com.urbandroid.sleep.REQUEST_SYNC, restricted to its package, without
    extras or data), if Sleep as Android is installed; after a new or recomputed night it sends one more 10 minutes later
    (the one-time work sleep-as-android-follow-up, its due time kept in the sync state; a work that runs early waits for
    that time), so that the night it imported gets its heart rate and SpO2. A run that only updated nights after late
    heart rate gets no second request, and Sleep as Android keeps the stages it imported first: to get an automatic update
    there, delete the night in Sleep as Android and recompute it. Confirmed on the development phone: the request runs
    Sleep as Android's backup and its other enabled syncs and, 10 seconds later, a Health Connect sync of the last 30 days
    (not described in its documentation, so it may change), the second request 10 minutes later does the same, its own
    sessions in Health Connect do not grow, and a second sync attaches heart rate to the nights it imported. Observed with
    Sleep as Android 20261006 but not yet confirmed on the development phone: its heart-rate awake detection can then add
    awake stretches over the stages; repeated syncs probably add further 10-minute heart-rate values (its log shows them
    offered again); and it may write the heart rate and SpO2 of its own nights to Health Connect. It
    is on by default because without Sleep as Android it does nothing and the request carries no data; with Sleep as
    Android installed, every write therefore also brings its backup, its other syncs and these heart-rate effects, so turn
    the setting off if you do not want them. Not part of the params hash. The manifest now queries com.urbandroid.sleep,
    only to check that it is installed; the message of a run you started adds "Sleep as Android was asked to sync.", and
    the privacy screen has a point about the request. English and Russian texts
    (user guide,
    health-connect.md §8.3,
    privacy.md §2, PLAN.md §2).

Changed

  • Checks every 15 or 30 minutes. Settings → "Schedule" → "Check for new nights every" is now a list: "15 min",
    "30 min" or 1 to 24 hours (1 h by default); 15 minutes is WorkManager's minimum period. Health Connect cannot notify
    an app of new data, so a shorter interval brings new nights sooner, and a check that finds nothing costs one
    change-log read (health-connect.md §7.2). The setting's key is now
    schedule.periodicMinutes instead of schedule.periodicHours: stored settings and exports of 0.3.0 and older keep
    loading, their hours converted to minutes (also a quoted number; schedule.periodicMinutes wins when a file has
    both), and exports contain only schedule.periodicMinutes, so 0.3.0 reads the interval of an export of this version
    as 1 h. The periodic work is enqueued again once after the update (its schedule tag is now
    schedule:periodic:<minutes>min:…), and its log line says "periodic check every … min". Home's "New nights" no
    longer says "every hour" (settings reference).
  • Recent nights are re-checked at most about once an hour. The retry of recent nights without an estimate and the
    refresh of written nights after late heart rate form one late-data pass, which runs at most every 55 minutes
    (NewNightsSync.MIN_RECHECK_GAP_MS), measured from the start of the run whose pass last completed (kept in the sync
    state, late_data_pass_at). So it stays about hourly with a 15- or 30-minute check, also for a night whose check
    records nothing, and a backlog of more than 8 due nights is worked off one pass at a time; late arrivals keep their
    schedule of about 1, 2, 4, 8, 16 and 32 hours. A pass cut short by a quota error or a refused access is repeated by
    the next run. "Estimate new" runs the pass at once, and the next automatic pass waits 55 minutes from it. With the
    default of 1 h little changes: only a run less than 55 minutes after the last pass, such as the daily run shortly
    after a periodic one, now skips it (user guide,
    health-connect.md §5).
  • The retry skips nights of disabled sources. A night without an estimate whose app was disabled on the Sources
    screen is never found by the read of its time window, so it was retried, and cost a sleep-session read, on every
    run; it is no longer retried (architecture.md §6.7).

Fixed

  • Sleep as Android's read window in the documentation. The syncs it starts itself, after saving a record and when
    its tracking ends, read Health Connect for the last 30 days like "Sync now", not 14 days as the 0.3.0 notes said
    (observed with Sleep as Android 20261006, not yet confirmed on the development phone): they send the same sync request that "Ask Sleep as
    Android to sync" sends (health-connect.md §8.3,
    user guide).

Downloads

File Use
PulseStages-0.4.0.apk Signed release build for everyday use. Later releases install over it as updates.
PulseStages-0.4.0-debug.apk Debug build for testing, with the demo mode.
SHA256SUMS.txt SHA-256 checksums of both APKs: sha256sum -c --ignore-missing SHA256SUMS.txt

The two APKs are signed with different keys, so neither can update the other. To switch, uninstall first.
The sessions PulseStages wrote stay in Health Connect; grant its permissions again after the reinstall.

To get every later release installed as an update, add PulseStages to Obtainium
(user guide).

Release signing certificate SHA-256: ce5546e83c03eac9837b93fc2c04d2e37abd1b778c3ef9e01b67cd1602e35be5

Debug signing certificate SHA-256: b557d5d55ea3c6d98e72493b1e82f228465201e7271d93f7ace577ff1c5b35cc (a later debug APK installs over an earlier one only if this value is the same)