Skip to content

fix(android): load background settings from datastore - #237

Merged
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/widget-settings-from-datastore
Aug 25, 2026
Merged

fix(android): load background settings from datastore#237
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/widget-settings-from-datastore

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

What

Why

Android enables bearer authentication by default. The widget and background worker did not send that token, so their localhost settings requests returned 401 (or failed when the HTTP server was down) and silently used defaults. The widget then classified the same events with different category rules than the Activity view.

ActivityWatch/aw-server-rust#653 fixes androidQuery by loading settings.classes from the datastore and adds the matching getSetting JNI method for the remaining background settings reads.

Verification

  • full debug unit suite: ./gradlew :mobile:testDebugUnitTest
  • targeted widget and NotifyWorker tests pass (19 tests)
  • PR quality gate: 94/100, OPEN
  • no localhost settings HTTP calls remain in widget or NotifyWorker

Deliberate scope

  • localStorage-only class migration stays in aw-webui. Automatically writing a browser fallback from Android could overwrite settings from another browser; saving Categorization settings once already persists settings.classes.
  • NotifyWorker's pre-existing hour-only startOfDay model is unchanged; the widget continues to preserve minutes.
  • fix(sync): log native panics to logcat (#220) #235 also changes the aw-server-rust gitlink. Whichever submodule bump lands second must use a master descendant containing both #653 and #654.

Refs #142. Device confirmation with custom categories remains before the issue itself is complete.

@TimeToBuildBob
TimeToBuildBob force-pushed the fix/widget-settings-from-datastore branch from 30c213e to 305ff9e Compare August 24, 2026 20:41
@TimeToBuildBob
TimeToBuildBob force-pushed the fix/widget-settings-from-datastore branch from 305ff9e to f34f9a8 Compare August 24, 2026 20:42
@greptile-apps

greptile-apps Bot commented Aug 24, 2026

Copy link
Copy Markdown

Greptile Summary

The PR moves widget and notification-worker settings reads from unauthenticated localhost HTTP calls to the native datastore interface.

  • Adds the Kotlin getSetting JNI declaration and advances the native server submodule.
  • Reads startOfDay and aw-notify through RustInterface.
  • Adds parsing fallbacks and unit coverage for valid, missing, and malformed values.

Confidence Score: 5/5

The reviewed Kotlin changes appear safe to merge, with no concrete changed-code defect identified.

The new datastore reads preserve the existing defaults, validate malformed day boundaries and alert data, run on background execution paths, and remain enclosed by the callers’ existing failure handling.

Important Files Changed

Filename Overview
aw-server-rust Advances the native dependency to provide datastore-backed settings and category-query behavior; the referenced submodule commit was unavailable for direct inspection.
mobile/src/main/java/net/activitywatch/android/RustInterface.kt Adds the Kotlin declaration for the native getSetting operation with no concrete contract mismatch identified.
mobile/src/main/java/net/activitywatch/android/widget/CategoryTimeWidgetUpdater.kt Replaces the localhost startOfDay request with a native read and safely defaults malformed or out-of-range values.
mobile/src/main/java/net/activitywatch/android/workers/NotifyWorker.kt Loads notification settings through the native interface while retaining defaults for missing, empty, or malformed data.
mobile/src/test/java/net/activitywatch/android/widget/CategoryTimeWidgetUpdaterTest.kt Adds coverage for minute-preserving, missing, and invalid widget day-boundary values.
mobile/src/test/java/net/activitywatch/android/workers/NotifyWorkerTest.kt Adds coverage for native start-of-day and notification-alert setting parsing and fallback behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  W[Widget updater] --> RI[RustInterface.getSetting]
  N[NotifyWorker] --> RI
  RI --> DS[Native ActivityWatch datastore]
  DS --> S[startOfDay]
  DS --> A[aw-notify]
  S --> WQ[Widget logical-day query]
  S --> NQ[Notification logical-day query]
  A --> NC[Notification threshold checks]
Loading

Reviews (1): Last reviewed commit: 30c213e | Re-trigger Greptile

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click.

This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted.

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.

2 participants