fix: use Build.DEVICE instead of Build.MODEL for hostname fallback#183
Merged
ErikBjare merged 4 commits intoJul 12, 2026
Merged
Conversation
Build.MODEL returns the OEM marketing name (e.g. 'Poco F8 Ultra') which contains spaces that break hostname-based bucket matching in aw-webui and aw-server. Build.DEVICE returns the device codename (e.g. 'poco_f8_ultra') which is lower-case, underscore-delimited, and safe to use as a hostname. Fixes the class of bug reported in ActivityWatch#176 where Xiaomi/Poco devices produced space-containing hostnames.
5 tasks
Greptile SummaryThis PR makes Android hostname fallback and normalization safer. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (4): Last reviewed commit: "fix: filter blank DEVICE_NAME before fal..." | Re-trigger Greptile |
Settings.Global.DEVICE_NAME can itself contain spaces (e.g. 'Poco F8 Ultra') so the previous fix only addressed the fallback path. Sanitize the final hostname by trimming, lowercasing, and replacing spaces with underscores, ensuring bucket hostname matching works even when DEVICE_NAME is configured with a human-readable name.
Contributor
Author
|
@greptileai review |
Use strict regex [^a-z0-9_-]+ instead of only space replacement, so configured device names with quotes or other special chars don't break bucket JSON. Also guard whitespace-only DEVICE_NAME with takeIf so it falls through to Build.DEVICE rather than resolving to empty string.
Contributor
Author
|
@greptileai review |
Contributor
Author
|
@greptileai review |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
getDeviceName()inRustInterface.ktandSyncInterface.ktfalls back toandroid.os.Build.MODELwhenSettings.Global.DEVICE_NAMEis null.Build.MODELreturns the OEM marketing name (e.g."Poco F8 Ultra") which contains spaces — that breaks hostname-based bucket matching in aw-webui and aw-server.Reported in #176: a Xiaomi Poco F8 Ultra produced
"Poco F8 Ultra"as its hostname. The webui then fails to associate it with the Android bucket view because the hostname contains spaces.Fix
Replace the
Build.MODELfallback withBuild.DEVICE, which returns the device codename (poco_f8_ultra— lowercase, underscore-delimited, no spaces). This is the correct format for a network hostname.Settings.Global.DEVICE_NAME"Poco F8 Ultra"Build.MODEL"Poco F8 Ultra"Build.DEVICE"poco_f8_ultra"Changes
RustInterface.kt:Build.MODEL→Build.DEVICESyncInterface.kt:Build.MODEL→Build.DEVICECloses #176 (contributes — the hostname fix is one part of the broader stability tracker).