Skip to content

fix(sync): pick up aw-server-rust API-key JNI client and set data dir - #249

Merged
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:bump/aw-server-rust-sync-apikey
Aug 31, 2026
Merged

fix(sync): pick up aw-server-rust API-key JNI client and set data dir#249
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:bump/aw-server-rust-sync-apikey

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Follow-up to ActivityWatch/aw-server-rust#666 (merged). Ships the v0.14.0b2 sync 401 fix into the app (ActivityWatch/aw-android#247).

Problem

Sync appeared to run but the chosen folder never changed: GET /api/0/buckets 401'd because the Android JNI client did not forward [auth].api_key from filesDir/config.toml.

Fix

  • Bump aw-server-rust 77defef2ded7d7 (includes #666).
  • Call SyncInterface.setDataDir(filesDir) after loadLibrary("aw_sync"). libaw_sync.so has its own ANDROID_DATA_DIR static; RustInterface.setDataDir only updates libaw_server.so. The hardcoded default is the release user-0 path — debug (.debug suffix) and work-profile installs still 401 without this.

XDG env (XDG_DATA_HOME=$filesDir/data) stays as the fallback for current Kotlin that had not called setDataDir.

Also picked up in the same bump: #654 (Rust panics to logcat, #220), #657, #658, #660, #661, #642.

Does not close #247: remaining items are sync UX/discoverability and category-import save persistence.

Testing

  • JNI symbol Java_net_activitywatch_android_SyncInterface_setDataDir present at the pinned SHA.
  • Local :mobile:compileDebugKotlin not run here (no JAVA_HOME on this host); CI build is the check.

@greptile-apps

greptile-apps Bot commented Aug 31, 2026

Copy link
Copy Markdown

Greptile Summary

The PR updates the bundled Rust server and configures the separate sync native library to use the app-specific files directory.

  • Advances the aw-server-rust submodule to include API-key forwarding support.
  • Calls the sync library’s data-directory setter after loading libaw_sync.so, aligning its configuration path with the embedded server.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
mobile/src/main/java/net/activitywatch/android/SyncInterface.kt Initializes the sync library with the application-specific files directory immediately after loading it.
aw-server-rust Advances the native dependency to the revision containing the corresponding sync API-key and JNI support.

Sequence Diagram

sequenceDiagram
    participant K as SyncInterface
    participant N as libaw_sync.so
    participant C as filesDir/config.toml
    K->>K: Set XDG fallback paths
    K->>N: Load aw_sync
    K->>N: setDataDir(filesDir)
    N->>C: Read sync configuration and API key
Loading

Reviews (2): Last reviewed commit: "fix(sync): pick up aw-server-rust API-ke..." | Re-trigger Greptile

ActivityWatch#247: sync appeared to run but wrote nothing
because GET /api/0/buckets 401'd. The JNI client now forwards
[auth].api_key (ActivityWatch/aw-server-rust#666).

Bump the submodule to 2ded7d7 (includes #666) and call
SyncInterface.setDataDir so libaw_sync.so reads filesDir/config.toml
on debug and work-profile installs, not only the release user-0 path.

Git-Session-Id: e6b1
@TimeToBuildBob
TimeToBuildBob force-pushed the bump/aw-server-rust-sync-apikey branch from dcf5880 to 0a74595 Compare August 31, 2026 15:23
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

@greptileai review

@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.

@ErikBjare
ErikBjare merged commit e5ff57f into ActivityWatch:master Aug 31, 2026
8 checks passed
Judemasic added a commit to Judemasic/aw-android that referenced this pull request Sep 2, 2026
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.
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.

User feedback on v0.14.02b

2 participants