From 0b41fcf9848201cc3b799fe107cc67391ab1e917 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 25 Aug 2026 11:06:01 +0000 Subject: [PATCH] fix(android): report the app's version from /api/0/info The webui footer showed `v0.14.0 (rust)` on a `v0.14.0b2` install: the server reported the aw-server-rust package version, which is the version of a component rather than of the app the user installed. Bump aw-server-rust to pick up `setVersionOverride` (#656) and call it at startup with the app's own versionName, read the same way MainActivity already reads it. The `(rust)` suffix is kept: aw-webui checks the version string for it to decide whether to offer the API browser link, which aw-server-rust does not serve. Part of #236. --- aw-server-rust | 2 +- .../activitywatch/android/RustInterface.kt | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/aw-server-rust b/aw-server-rust index 75722f3c..77defefd 160000 --- a/aw-server-rust +++ b/aw-server-rust @@ -1 +1 @@ -Subproject commit 75722f3c51269615fbd2ffaf2a946824d7cc8ccd +Subproject commit 77defefd4945ecceedc417eea711c2613b451f2e diff --git a/mobile/src/main/java/net/activitywatch/android/RustInterface.kt b/mobile/src/main/java/net/activitywatch/android/RustInterface.kt index e3b56743..16360637 100644 --- a/mobile/src/main/java/net/activitywatch/android/RustInterface.kt +++ b/mobile/src/main/java/net/activitywatch/android/RustInterface.kt @@ -1,6 +1,7 @@ package net.activitywatch.android import android.content.Context +import android.content.pm.PackageManager import android.os.Handler import android.os.Looper import android.provider.Settings @@ -33,6 +34,32 @@ class RustInterface(context: Context? = null) { initialize() if (context != null) { setDataDir(context.filesDir.absolutePath) + appVersionString(context)?.let { setVersionOverride(it) } + } + } + + /** + * The version to report from `GET /api/0/info`, which the webui footer shows. + * + * Without an override the server reports the aw-server-rust package version, + * which is the version of a component rather than of the app the user + * installed: the footer read `v0.14.0 (rust)` on a `v0.14.0b2` install. + * + * The `(rust)` suffix is kept deliberately — aw-webui checks the version + * string for it to decide whether to offer the API browser link, which + * aw-server-rust does not serve. + * + * Returns null if the version can't be read, leaving the server's default. + */ + private fun appVersionString(context: Context): String? { + return try { + val versionName = + context.packageManager.getPackageInfo(context.packageName, 0).versionName + ?: return null + "v$versionName (rust)" + } catch (e: PackageManager.NameNotFoundException) { + Log.w(TAG, "Could not read the app's own version, reporting the server's", e) + null } } @@ -44,6 +71,7 @@ class RustInterface(context: Context? = null) { private external fun greeting(pattern: String): String private external fun startServer() private external fun setDataDir(path: String) + private external fun setVersionOverride(version: String) external fun getBuckets(): String external fun createBucket(bucket: String): String external fun getEvents(bucket_id: String, limit: Int): String