fix(android): migrate aw-watcher-android-test buckets on startup - #244
Conversation
The server-side rename from aw-server-rust#628 never ran because BackgroundService only called migrateHostname(). Wire the JNI and mark the preference complete only when no aw-watcher-android-test* buckets remain, so a collision leftover retries on the next start. Collision merge itself is ActivityWatch/aw-server-rust#661; this PR does not bump the submodule, so the current pin still rename-only skips the both-buckets-exist case. Refs: ActivityWatch#149, ActivityWatch#150, ActivityWatch#243
Greptile SummaryThe PR invokes the existing native Android watcher-bucket migration during background-service startup and records completion only after confirming that no legacy bucket IDs remain.
Confidence Score: 5/5The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking defects identified. The startup path invokes the migration off the main thread, preserves retries after native failures or collision leftovers, and marks completion only after the legacy bucket prefix is absent. Important Files Changed
Sequence DiagramsequenceDiagram
participant OS as Android
participant Service as BackgroundService
participant Prefs as AWPreferences
participant Native as RustInterface
OS->>Service: Start or recreate service
Service->>Native: startServerTask()
Service->>Prefs: Read migration flags
opt Hostname migration pending
Service->>Native: migrateHostname(deviceName)
Native-->>Service: Migration result
Service->>Prefs: Mark hostname migrated on success
end
opt Watcher bucket migration pending
Service->>Native: migrateWatcherAndroidBucketNames()
Native-->>Service: Migration result
Service->>Native: getBucketsJSON()
alt No legacy bucket IDs remain
Service->>Prefs: Mark watcher migration complete
else Legacy bucket IDs remain
Service->>Service: Log and retry next startup
end
end
Reviews (1): Last reviewed commit: "fix(android): call migrateWatcherAndroid..." | Re-trigger Greptile |
|
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. |
Takes ActivityWatch#250 (shared DeviceHostname helper), ActivityWatch#242, ActivityWatch#234, ActivityWatch#244, ActivityWatch#248, ActivityWatch#245. Deliberately NOT taken: ActivityWatch#249's Kotlin half. It declares private external fun setDataDir(path: String) and calls it from SyncInterface's init block, but this fork's android.rs exports no Java_..._SyncInterface_setDataDir - the constructor would throw UnsatisfiedLinkError and SyncScheduler would disable itself, which is Blocker 6 verbatim. This fork already gets the same fix via XDG_DATA_HOME (step 1.0b), which needs no new JNI symbol. The refusal is documented at the call site so the next merge re-checks it. Submodule pointer kept at our fork (c6f7df2); upstream's 2ded7d7 has none of the aw-sync fixes from Phase 1. getDeviceName() now delegates to upstream's deviceHostname(), which is byte-for-byte equivalent to the implementation it replaces - no device directory in the shared folder changes name.
Summary
aw-server-rust#628addedmigrateWatcherAndroidBucketNames(), butBackgroundServicenever called it. Upgrades from pre-rename builds keep writing/readingaw-watcher-android-test_*history that the Activity view no longer queries (#243).This PR:
hasMigratedWatcherAndroidBucketNames. Completes the preference only when noaw-watcher-android-test*buckets remain. Collision leftovers retry on the next start instead of being marked done forever.WatcherAndroidBucketMigrationwith JVM unit tests.What this does not do
The current
aw-server-rustsubmodule pin still usesUPDATE OR IGNORE. If both the legacy and canonical buckets exist, the rename is skipped. The SQL merge for that collision case is ActivityWatch/aw-server-rust#661. After that merges, bump this submodule — the Kotlin leftover check already matches the new merge (including partial overlap leftovers).I did not bump the submodule in this PR: the merge commit is not yet on
ActivityWatch/aw-server-rust, so a SHA bump would break CI checkout.Tests
WatcherAndroidBucketMigrationTest(canonical ID, leftover detection, success-prefix parsing)Refs