Repository navigation
Handset probe: taos-kiosk.service alone marks a DESK as a phone; require plasma-mobile.service too in hardware._detect_device_class and session-mode availability #3967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| ### Fixed: a desk machine set up with the kiosk session is no longer treated as a phone | ||
| - `hardware._detect_device_class()` now returns "mobile" only when BOTH `taos-kiosk.service` AND `plasma-mobile.service` units exist (via `systemctl cat`). | ||
| - `routes.system._session_mode_state()` reports `available: true` only when BOTH units are present. | ||
| - The AVAILABILITY comment in `routes/system.py` is updated to reflect that a handset requires both the kiosk unit (taOS shell) and the plasma unit (Plasma Mobile fallback). |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| """Device class probe: a handset requires BOTH kiosk and plasma units.""" | ||
|
|
||
| import subprocess | ||
| from unittest.mock import patch | ||
| from tinyagentos import hardware | ||
|
|
||
|
|
||
| def test_desk_with_kiosk_but_no_plasma_is_not_mobile(monkeypatch): | ||
| """A desk with only taos-kiosk.service must NOT be detected as mobile.""" | ||
| calls = [] | ||
|
|
||
| def fake_run(cmd, *args, **kwargs): | ||
| calls.append(cmd) | ||
| if cmd == ["systemctl", "cat", "taos-kiosk.service"]: | ||
| return subprocess.CompletedProcess(cmd, 0, stdout="# taos-kiosk.service", stderr="") | ||
| if cmd == ["systemctl", "cat", "plasma-mobile.service"]: | ||
| return subprocess.CompletedProcess(cmd, 1, stdout="", stderr="No files found") | ||
| return subprocess.CompletedProcess(cmd, 1, stdout="", stderr="") | ||
|
|
||
| monkeypatch.setattr(subprocess, "run", fake_run) | ||
| assert hardware._detect_device_class() is None | ||
| assert calls.count(["systemctl", "cat", "taos-kiosk.service"]) == 1 | ||
| assert calls.count(["systemctl", "cat", "plasma-mobile.service"]) == 1 | ||
|
|
||
|
|
||
| def test_handset_with_both_units_is_mobile(monkeypatch): | ||
| """A handset with both taos-kiosk.service and plasma-mobile.service is mobile.""" | ||
| calls = [] | ||
|
|
||
| def fake_run(cmd, *args, **kwargs): | ||
| calls.append(cmd) | ||
| if cmd == ["systemctl", "cat", "taos-kiosk.service"]: | ||
| return subprocess.CompletedProcess(cmd, 0, stdout="# taos-kiosk.service", stderr="") | ||
| if cmd == ["systemctl", "cat", "plasma-mobile.service"]: | ||
| return subprocess.CompletedProcess(cmd, 0, stdout="# plasma-mobile.service", stderr="") | ||
| return subprocess.CompletedProcess(cmd, 1, stdout="", stderr="") | ||
|
|
||
| monkeypatch.setattr(subprocess, "run", fake_run) | ||
| assert hardware._detect_device_class() == "mobile" | ||
| assert calls.count(["systemctl", "cat", "taos-kiosk.service"]) == 1 | ||
| assert calls.count(["systemctl", "cat", "plasma-mobile.service"]) == 1 | ||
|
|
||
|
|
||
| def test_missing_kiosk_unit_is_not_mobile(monkeypatch): | ||
| """A machine without taos-kiosk.service must NOT be detected as mobile.""" | ||
| calls = [] | ||
|
|
||
| def fake_run(cmd, *args, **kwargs): | ||
| calls.append(cmd) | ||
| if cmd == ["systemctl", "cat", "taos-kiosk.service"]: | ||
| return subprocess.CompletedProcess(cmd, 1, stdout="", stderr="No files found") | ||
| return subprocess.CompletedProcess(cmd, 1, stdout="", stderr="") | ||
|
|
||
| monkeypatch.setattr(subprocess, "run", fake_run) | ||
| assert hardware._detect_device_class() is None | ||
| assert calls.count(["systemctl", "cat", "taos-kiosk.service"]) == 1 |
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔎 Supported by static analysis
Script executed:
Repository: jaylfc/taOS
Length of output: 3625
Script executed:
Repository: jaylfc/taOS
Length of output: 13584
Preserve the cache when class detection is unavailable.
A stale cached
"mobile"class can reachget_hardware_profile()when another detector raises. However, calling_detect_device_class()in that fallback is unsafe because it returnsNoneboth for a confirmed kiosk-only desk and for an unavailablesystemctlprobe. Use a tri-state result and updatedevice_classonly when the probe completes. Preserve the cached value when the probe is unavailable.