Skip to content

fix(android): open Activity view with device hostname, not unknown - #250

Merged
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/activity-view-hostname
Aug 31, 2026
Merged

fix(android): open Activity view with device hostname, not unknown#250
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/activity-view-hostname

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Problem

v0.14.0b2 user report on #247: the hamburger-menu Activity entry works, but the left-swipe drawer Activity item opens the same page with hostname unknown and default (non-Android) visualizations.

Cause: the drawer item and notification-tap path hardcoded /#/activity/unknown/. The in-app hamburger builds /activity/<real-hostname> from buckets, so it gets Android views. unknown is a sentinel (stopwatch / missing host), not a device.

Fix

  • Build /#/activity/<sanitized-device-hostname>/ using the same hostname as Android bucket creation (Settings.Global.DEVICE_NAME / Build.DEVICE).
  • One helper for that sanitization, shared by RustInterface and SyncInterface.

Does not close #247. Remaining there: sync UX/discoverability, last-sync / success-fail UI, category-import save persistence. Sync 401 is #249.

Testing

JAVA_HOME=/opt/android-studio/jbr ANDROID_HOME=/home/bob/Android/Sdk \
  ./gradlew :mobile:testDebugUnitTest \
  --tests net.activitywatch.android.MainActivityNavigationTest \
  --tests net.activitywatch.android.DeviceHostnameTest \
  --tests net.activitywatch.android.DashboardAuthTest \
  --no-daemon

Passed (14 tests).

The left-swipe drawer and notification taps hardcoded
/#/activity/unknown/, so visualizations used desktop defaults for a
host with no Android buckets. The in-app hamburger already built
/activity/<real-hostname> from buckets.

Use the same sanitized device hostname as bucket creation.
@greptile-apps

greptile-apps Bot commented Aug 31, 2026

Copy link
Copy Markdown

Greptile Summary

The PR replaces hardcoded unknown Activity routes with the same sanitized device hostname used by Android buckets and synchronization.

  • Adds a shared helper for resolving and sanitizing the Android device hostname.
  • Uses the resolved hostname for drawer and notification Activity navigation.
  • Refactors server and synchronization interfaces to share the helper.
  • Adds unit coverage for hostname sanitization and Activity-route generation.

Confidence Score: 5/5

The PR appears safe to merge, with device-hostname routing consistently applied across the affected navigation, bucket, and synchronization paths.

The shared helper preserves existing hostname normalization while replacing the erroneous hardcoded Activity host, and the changed navigation paths continue to construct authenticated local dashboard URLs.

Important Files Changed

Filename Overview
mobile/src/main/java/net/activitywatch/android/DeviceHostname.kt Introduces a shared hostname resolver while preserving the previous normalization and fallback behavior.
mobile/src/main/java/net/activitywatch/android/MainActivity.kt Routes all Activity navigation entry points to the sanitized device hostname while retaining dashboard authentication.
mobile/src/main/java/net/activitywatch/android/RustInterface.kt Replaces duplicated device-name normalization with the shared helper without changing the effective bucket identity contract.
mobile/src/main/java/net/activitywatch/android/SyncInterface.kt Reuses the shared hostname helper for native synchronization without changing effective behavior.
mobile/src/test/java/net/activitywatch/android/DeviceHostnameTest.kt Covers empty, invalid, mixed-case, spaced, hyphenated, and underscored hostname inputs.
mobile/src/test/java/net/activitywatch/android/MainActivityNavigationTest.kt Verifies dashboard defaults and hostname-aware Activity route construction.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Android device name] --> B[deviceHostname]
    B --> C[sanitizeDeviceHostname]
    C --> D[Bucket hostname]
    C --> E[Sync hostname]
    C --> F[Activity route]
    F --> G[Embedded ActivityWatch dashboard]
Loading

Reviews (1): Last reviewed commit: "fix(android): open Activity view with de..." | Re-trigger Greptile

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Greptile is 5/5 and the unit-test job passed. The Android 29 E2E job is still running, so no merge action is available yet; this repo is maintainer-merge only for Bob.

@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 86a712e 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