Skip to content

Defunct apps, robust launcher set-default, Tweaks menu, Display diagnostics, Snapshot/Restore#18

Merged
bryanroscoe merged 3 commits into
mainfrom
feat/cleanup-and-features
May 8, 2026
Merged

Defunct apps, robust launcher set-default, Tweaks menu, Display diagnostics, Snapshot/Restore#18
bryanroscoe merged 3 commits into
mainfrom
feat/cleanup-and-features

Conversation

@bryanroscoe
Copy link
Copy Markdown
Owner

Big consolidated PR per user request. Five distinct items, each with on-device verification against a real Shield (Android 11) at 192.168.42.71.

1. Defunct streaming apps added to bloat list

Adds Funimation, Stadia, Quibi, and the orphaned HBO Now (com.hbo.hbonow) to the existing "Dead/defunct apps" section of `CommonAppList`. All four have confirmed shutdown dates — descriptions explain why so users see the receipts.

2. Launcher set-default actually works on Shield Android 11

PR #17's role-API switch wasn't enough. Real-device debug session uncovered three layered issues:

  • `cmd role` is not supported on the Shield's Android 11 build at all ("Unknown command: get-role-holders"). Old regex didn't match this phrase.
  • The chosen launcher was disabled before the wizard ran. `set-home-activity` won't promote a disabled package to default on every build.
  • Projectivy's HOME activity is `.ui.home.MainActivity` — deeply nested. The dumpsys-based parser missed it; common-name guesses (`.MainActivity` etc.) didn't match.

Fix: `pm enable` first, recognize "Unknown command" and skip role API faster, swap dumpsys parsing for `cmd package query-activities --components -a android.intent.action.MAIN -c android.intent.category.HOME` (returns components directly in `/` form), retry across both `cmd package` and `pm` aliases with `--user 0`, verify after each attempt, surface the captured ADB error in the WARNING so failures are debuggable. Live-tested: `Set-DefaultLauncher -PackageName "com.spocky.projengmenu"` returns `True` on the user's Shield, Projectivy retained as default.

3. New "Tweaks" device action (shortcut K)

`Set-DisplayInputTuning` shows current values for HDMI-CEC sub-toggles (master, auto-wake, auto-off, audio routing), `match_content_frame_rate`, and `long_press_timeout`, then lets the user flip each independently. `Set-BoolSetting` helper centralizes the ON/OFF/Reset/Cancel pattern. Namespaces verified on-device.

4. Display & Audio diagnostics in Health Report

`Get-DisplayMode` parses `dumpsys display` for active resolution + refresh rate (matched by modeId from the supportedModes table), decodes `HdrCapabilities mSupportedHdrTypes` (1=Dolby Vision, 2=HDR10, 3=HLG, 4=HDR10+), and pulls audio device from `dumpsys audio`. Health Report now shows `Display: 3840x2160 / 59.94 Hz / HDR10 / HDMI` so users can confirm their TV is actually negotiating 4K@60.

Live result on Shield: `Resolution: 3840x2160, Refresh: 59.94 Hz, HDR: HDR10, Audio: HDMI`.

5. Snapshot / Restore (shortcut N)

  • `Save-Snapshot` captures disabled-package list, current launcher, and the settings keys this tool can write (animation triple, all four HDMI-CEC keys, match-content-frame-rate, long-press-timeout). Writes JSON to `./snapshots/_.json`.
  • `Apply-Snapshot` lists snapshots, shows a preview of what will change, then re-disables packages from the list (skipping missing and already-disabled), invokes `Set-DefaultLauncher` with the saved launcher, writes the recorded settings back. Never re-enables a currently-enabled package — that would undo user work.
  • Survives factory resets and major OTAs.

Verification

  • `make lint` — Syntax OK
  • `make test` — 121 passed / 4 skipped / 0 failed
  • Real-device runs against authorized Shield at 192.168.42.71 confirming the launcher round-trip, Display Mode parse, and snapshot data sources.

Adds Funimation, Stadia, Quibi, and the orphaned HBO Now (pre-Max) to
the Dead/defunct apps section of CommonAppList. All four are confirmed
dead services (Funimation: Apr 2024, Stadia: Jan 2023, Quibi: Dec 2020,
HBO Now: rolled into com.wbd.stream). DefaultOptimize=Y for all so the
optimize wizard will surface them by default.

Also reworks Set-DefaultLauncher and friends after a real-device repro
where both the role API and the legacy set-home-activity command
failed silently on a Shield running Android 11:

- Get-HomeRoleHolder rejects empty/error/usage strings instead of
  greedily matching any identifier-shaped substring.
- Set-HomeRoleHolder verifies success by reading the role holder back
  rather than trusting the cmd's stdout (some Shield builds silently
  no-op).
- Set-DefaultLauncher tries: role API → cmd package set-home-activity
  --user 0 → pm set-home-activity --user 0 (with both the dumpsys-
  discovered activity and common-name fallbacks) → HOME-intent kick
  (when other launchers are disabled, system auto-picks the only one
  left). Each attempt is verified by re-querying the active launcher.
- $Script:LastSetHomeError captures the underlying ADB response so
  Setup-Launcher's WARNING can show *why* it failed instead of a
  generic "manual selection" string.
Real-device debug session on a Shield (Android 11) revealed three
distinct reasons the wizard couldn't set the default launcher:

1. `cmd role` is not supported on the Shield's customized Android 11
   build — it returns "Unknown command: get-role-holders". The previous
   regex matched "Exception|Error|denied|Usage:" but not this phrase,
   so the role API was treated as a transient failure rather than
   universally unavailable.
2. The chosen launcher was disabled before the wizard ran (a previous
   session disabled it). `set-home-activity` won't promote a disabled
   package to default on every build.
3. Projectivy's HOME activity is `.ui.home.MainActivity` — deeply
   nested, not at the package root. The dumpsys-based parser missed it
   entirely, falling through to common-name guesses (`.MainActivity`
   etc.) which don't match.

Fixes:

- `Set-DefaultLauncher` now runs `pm enable <pkg>` first, which is a
  no-op for already-enabled packages and unblocks the disabled case.
- `Get-LauncherActivity` uses
  `cmd package query-activities --components -a android.intent.action.MAIN
  -c android.intent.category.HOME`, which returns the components
  directly in `<pkg>/<activity>` form — verified to find Projectivy's
  `.ui.home.MainActivity` correctly. Dumpsys parser kept as a fallback
  for older Androids.
- `Get-HomeRoleHolder` and `Set-HomeRoleHolder` recognize
  "Unknown command" and short-circuit, skipping the verification
  round-trip.
- Each set attempt now uses `--user 0` explicitly and is verified by
  re-resolving the active HOME activity.

End-to-end tested against the user's Shield at 192.168.42.71:
Set-DefaultLauncher returned True, Projectivy retained as default.
Three feature additions in one shot, building on the Set-DefaultLauncher
fix earlier in this branch.

Tweaks (new device action menu item, shortcut K)
- New Set-DisplayInputTuning sub-menu shows current values for HDMI-CEC
  (master, auto-wake, auto-off, audio routing), match_content_frame_rate,
  and long_press_timeout, then lets the user toggle each independently.
- Set-BoolSetting helper centralizes the ON/OFF/Reset/Cancel pattern.
- Verified the namespace + key choices against a real Shield: hdmi_*
  keys live in `global`, match_content_frame_rate and long_press_timeout
  live in `secure`.

Display diagnostics (added to Run-Report)
- New Get-DisplayMode parses `dumpsys display` to extract active mode's
  resolution + refresh rate (matched by id from supportedModes table),
  decodes HdrCapabilities mSupportedHdrTypes (1=Dolby Vision, 2=HDR10,
  3=HLG, 4=HDR10+), and pulls audio output device from `dumpsys audio`.
- Health Report now shows "Display: 3840x2160 / 59.94 Hz / HDR10 / HDMI"
  so users can confirm their TV is actually negotiating 4K@60 instead
  of falling back to 1080p — the most common silent-misconfiguration
  question on Android TV setups.

Snapshot / Restore (new device action menu item, shortcut N)
- Save-Snapshot captures: full disabled-package list, current launcher,
  and the Tweaks-relevant settings keys (animation triple, HDMI-CEC,
  match_content_frame_rate, long_press_timeout). Writes JSON to
  ./snapshots/<safe-name>_<timestamp>.json.
- Apply-Snapshot lists existing snapshots, shows what each will do,
  re-disables packages that are currently enabled (skipping missing
  and already-disabled), runs Set-DefaultLauncher with the saved
  launcher, and writes the recorded settings back. Never re-enables a
  package that's currently enabled — that would undo the user's work.
- Show-SnapshotMenu sub-menu wires Save / Apply / open-folder.
- Survives factory resets and major OTAs: re-apply after fresh setup
  to get back to your tuned state.

Verified against the user's authorized Shield (192.168.42.71):
- Get-DisplayMode returns "3840x2160 / 59.94 Hz / HDR10 / HDMI"
- Snapshot-source queries enumerate 23 disabled packages, current
  launcher, and the captured setting keys correctly.
@bryanroscoe bryanroscoe merged commit a046bc5 into main May 8, 2026
4 checks passed
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.

1 participant