Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

Launcher: settings_key_clear_task, so Back from Settings goes Home on MediaTek gears

hmaheshwari1996c0cc2cf4389a
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md
index ad10fc884..5ec0aac91 100644
--- a/docs/TROUBLESHOOTING.md
+++ b/docs/TROUBLESHOOTING.md
@@ -1237,6 +1237,14 @@ turned off in Settings stays off.
TCL 55Q7D Pro (`G08_4K_GB`, Google TV 14, `UTT2.250416.001 AU02`), in SmartTube and on Home.
Press the real button; a key injected over ADB does not reach the helper. Holding volume may step only
once while the helper is bound, which is the usual trade on these two boards.
+- **The gear opens Settings, but Back lands on Display & Sound** (Skyworth 2K NSTV, MediaTek, Google TV 14,
+ `UKNV.260211.001`): the gear sends keycode 83 and, on most presses, `KEYCODE_SETTINGS` (scan 139).
+ `dumpsys window policy` routes `KEYCODE_SETTINGS` to `com.mediatek.tv.service/.hotkey.dispatcher.GlobalKeyReceiver`,
+ which opens `com.android.tv.settings/.partnercustomizer.DisplayAndSoundActivity` as the key goes down, before
+ the helper can take it (`logcat` shows `HotKey_SettingsAction`). Settings then opens in the same task, on top of
+ it. Set `settings_key_clear_task` (with `settings_key_panel` off) and add 139 to `settings_key_scancodes`:
+ Settings replaces that page and Back goes Home. The shell cannot disable a single receiver, so this is the
+ route without root.
- **The list still names the helper but `accessibility_enabled` is `0`**, so nothing is bound and the
button does nothing (not the force stop below): on a TCL C6K Pro (`G08`, Android 14,
[#1047](https://github.com/Gathin23/cleanyourtv/issues/1047)) a reboot left
diff --git a/docs/switches.md b/docs/switches.md
index 0c97ea111..c327732fd 100644
--- a/docs/switches.md
+++ b/docs/switches.md
@@ -69,3 +69,4 @@ rule sit on its wanted list until a screenshot arrives.
| `game_day` | <img src="switches/game_day.jpg" width="320" alt="game_day: Minnesota Vikings at Detroit Lions, Kickoff in 5d 13h, with four dots, under the clock on a TV"> |
| `clock_format` | <img src="switches/clock_format.jpg" width="320" alt="clock_format on a TV"> |
| `glow_snap` | <img src="switches/glow_snap.jpg" width="320" alt="glow_snap on a TV: the glow in Netflix red behind the dock"> |
+| `settings_key_clear_task` | <img src="switches/settings_key_clear_task.jpg" width="320" alt="settings_key_clear_task on a TV: the TV Settings screen the gear opens"> |
diff --git a/docs/switches/settings_key_clear_task.jpg b/docs/switches/settings_key_clear_task.jpg
new file mode 100644
index 000000000..e434a80da
Binary files /dev/null and b/docs/switches/settings_key_clear_task.jpg differ
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Config.java b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
index 1ae0abfe4..55f88b201 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -138,6 +138,8 @@ final class Config {
final boolean backOpensClock;
/** The ambient glow takes a new app's colour in one frame instead of dipping and fading (config.xml / theme glow_snap). */
final boolean glowSnap;
+ /** The remote's Settings button clears the TV Settings task before opening it (config.xml / theme settings_key_clear_task). */
+ final boolean settingsKeyClearTask;
/** App library as a round button in the top bar (config.xml library_button); needs app_library. */
final boolean libraryButton;
/** The App library pill after the last Home row; false hides it while libraryButton is on (show_library_pill). */
@@ -294,7 +296,8 @@ final class Config {
boolean keyFilter, boolean dockGlass, String glowStyle, boolean wallpaperCaptions,
boolean handleViewInputs, boolean tileMenu, boolean dockEvenPadding, boolean dockBand, boolean cinematicDots, boolean cinematicWhiteFocus, boolean wifiStatusColor, int cinematicScrim, int cinematicArt,
Map<String, Set<String>> wallpaperMoods, boolean gamepadPassthrough, boolean consumeVolumeKeys, boolean homeIgnoreChannelKeys, boolean powerOnHome, boolean homeLongPressHome, boolean wifiStatusWarnings, List<String> topBarApps, boolean showGreeting, boolean headerWhite, boolean clockWallpaper, int clockWallpaperDim, boolean clockGlow, String glassStyle, boolean singleRow, boolean dockBandAll, boolean lunarDate, int lunarUtcOffset, boolean dateBelowClock, boolean vpnPill, String locale, boolean powerOnHomeAlways, boolean inputsConnectedOnly, boolean inputsCecStateOnly,
- int openOnStartNetworkWait, boolean openOnStartOnWake, boolean iconOnlyVpn, String clockFormat, boolean backOpensClock, boolean glowSnap) {
+ int openOnStartNetworkWait, boolean openOnStartOnWake, boolean iconOnlyVpn, String clockFormat, boolean backOpensClock, boolean glowSnap,
+ boolean settingsKeyClearTask) {
this.handleViewInputs = handleViewInputs;
this.tileMenu = tileMenu;
this.inputKeycodes = inputKeycodes;
@@ -346,6 +349,7 @@ final class Config {
this.iconOnlyVpn = iconOnlyVpn;
this.backOpensClock = backOpensClock;
this.glowSnap = glowSnap;
+ this.settingsKeyClearTask = settingsKeyClearTask;
this.libraryButton = libraryButton;
this.showLibraryPill = showLibraryPill;
this.wifiLabelWidth = wifiLabelWidth;
@@ -478,6 +482,7 @@ final class Config {
boolean iconOnlyVpn = res.getBoolean(R.bool.icon_only_vpn);
boolean backOpensClock = res.getBoolean(R.bool.back_opens_clock);
boolean glowSnap = res.getBoolean(R.bool.glow_snap);
+ boolean settingsKeyClearTask = res.getBoolean(R.bool.settings_key_clear_task);
boolean libraryButton = res.getBoolean(R.bool.library_button);
boolean showLibraryPill = res.getBoolean(R.bool.show_library_pill);
int wifiLabelWidth = res.getInteger(R.integer.wifi_label_width);
@@ -593,6 +598,7 @@ final class Config {
iconOnlyVpn = bool(json, "icon_only_vpn", iconOnlyVpn);
backOpensClock = bool(json, "back_opens_clock", backOpensClock);
glowSnap = bool(json, "glow_snap", glowSnap);
+ settingsKeyClearTask = bool(json, "settings_key_clear_task", settingsKeyClearTask);
libraryButton = bool(json, "library_button", libraryButton);
showLibraryPill = bool(json, "show_library_pill", showLibraryPill);
wifiLabelWidth = integer(json, "wifi_label_width", wifiLabelWidth, 0, 300);
@@ -720,7 +726,8 @@ final class Config {
consumeVolumeKeys, homeIgnoreChannelKeys, powerOnHome, homeLongPressHome, wifiStatusWarnings, topBarApps, showGreeting, headerWhite, clockWallpaper,
Math.max(0, Math.min(90, clockWallpaperDim)), clockGlow, glassStyle, singleRow && dockRow, dockBandAll, lunar, lunarOffset,
dateBelowClock, vpnPill, locale, powerOnHomeAlways, inputsConnectedOnly, inputsCecStateOnly,
- Math.max(0, Math.min(600, openOnStartNetworkWait)), openOnStartOnWake, iconOnlyVpn, clockFormat, backOpensClock, glowSnap);
+ Math.max(0, Math.min(600, openOnStartNetworkWait)), openOnStartOnWake, iconOnlyVpn, clockFormat, backOpensClock, glowSnap,
+ settingsKeyClearTask);
}
/**
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
index 5f0c136e3..a7c9d776b 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
@@ -57,6 +57,7 @@ public class HomeKeyService extends AccessibilityService {
private int[] settingsScancodes = new int[0];
private int[] settingsKeycodes = new int[0];
private boolean settingsPanel;
+ private boolean settingsClearTask;
/** consume_volume_keys: Volume Up/Down go to VolumeKeys instead of on to the firmware. */
private boolean consumeVolumeKeys;
/** app_keys, the same maps InputKeyService reads, for setups that run only this service. */
@@ -191,6 +192,7 @@ public class HomeKeyService extends AccessibilityService {
if (repairRecord) ServiceRepair.connected(this, getClass());
settingsKeycodes = config.settingsKeycodes;
settingsPanel = config.settingsKeyPanel;
+ settingsClearTask = config.settingsKeyClearTask;
consumeVolumeKeys = config.consumeVolumeKeys;
appKeys = RemoteKeys.parseAppKeys(config.appKeys);
appScancodes = RemoteKeys.parseAppScancodes(config.appKeys);
@@ -268,6 +270,9 @@ public class HomeKeyService extends AccessibilityService {
if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) {
Intent open = settingsPanel ? new Intent(this, QuickSettingsActivity.class)
: SystemSettings.intent(this, Settings.ACTION_SETTINGS);
+ // settings_key_clear_task: on MediaTek boards KEYCODE_SETTINGS is also a global key that opens Display &
+ // Sound in the Settings task before this helper sees it; cleared, Back from Settings goes Home, not there.
+ if (settingsClearTask && !settingsPanel) open.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
try {
startActivity(open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} catch (ActivityNotFoundException | SecurityException unavailable) {
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
index 76251f1f3..c6ea94706 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -256,6 +256,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
/** config settings_key_keycodes / settings_key_panel, so the Settings button works on Home without HomeKeyService. */
private int[] settingsKeycodes = new int[0];
private boolean settingsKeyPanel;
+ private boolean settingsKeyClearTask;
/** Calmer motion for weak GPUs (config.xml, reduced_motion): stiff spring, short fades, no replay. */
private boolean reducedMotion;
/** config.xml dock_row: the first row is a separate dock (band, parked low, top shelf) rather than plain grid. */
@@ -472,6 +473,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
applyViewInputsHandler(cfg.handleViewInputs);
settingsKeycodes = cfg.settingsKeycodes;
settingsKeyPanel = cfg.settingsKeyPanel;
+ settingsKeyClearTask = cfg.settingsKeyClearTask;
COLUMNS = cfg.columns;
animations = cfg.animations;
advancedEffects = cfg.animations && cfg.advancedEffects;
@@ -1399,8 +1401,11 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
for (int code : settingsKeycodes) {
if (event.getKeyCode() != code) continue;
if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) {
- open(settingsKeyPanel ? new Intent(this, QuickSettingsActivity.class)
- : systemIntent(Settings.ACTION_SETTINGS));
+ Intent settings = settingsKeyPanel ? new Intent(this, QuickSettingsActivity.class)
+ : systemIntent(Settings.ACTION_SETTINGS);
+ // settings_key_clear_task, as in HomeKeyService: Back from Settings goes Home, not to a vendor page.
+ if (settingsKeyClearTask && !settingsKeyPanel) settings.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ open(settings);
}
return true;
}
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index 5909262de..809a2f181 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -177,6 +177,11 @@
with TV settings, Display, Network, Apps (re-enable an app) and Launcher settings, over whatever is on screen.
Both keys can also be set from a theme's config.json ("settings_key_keycodes": [83]). -->
<bool name="settings_key_panel">false</bool>
+ <!-- true: those Settings buttons clear the TV Settings task before opening Settings (with settings_key_panel off).
+ On some MediaTek boards KEYCODE_SETTINGS is also a global key: com.mediatek.tv.service opens Display & Sound in
+ the same task before the helper sees the press, so Settings stacked on it and Back landed there (Skyworth
+ 2K NSTV, Google TV 14). Also "settings_key_clear_task" in a theme's config.json. -->
+ <bool name="settings_key_clear_task">false</bool>
<!-- A force stop of the launcher (Settings, a cleaner app, am force-stop) takes HomeKeyService and InputKeyService
off the enabled list. true: Home puts the helpers that were running back when it starts; one turned off in
diff --git a/themes/README.md b/themes/README.md
index e3736d7f7..c88a47b85 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -166,6 +166,7 @@ A new key needs one there in the same pull request.
| `accent_color` | `#RRGGBB` | Colour of the focus glow while the festive skin is on; diya gold if not set, pumpkin orange for `halloween` |
| `settings_key_scancodes` | list, `config.xml` only | The same buttons by Linux scancode, for `HomeKeyService` (`HOME_KEY_SERVICE=1`); the Xiaomi/Fengmi projector remote's gear is scan 384. `Config.java` reads `settings_key_keycodes` out of a theme but never this one, so a `config.json` that sets it is dropped - it belongs in `config.xml` before the build. Find a code with `tools/tv.py 'getevent -lt'` |
| `settings_key_keycodes` | list of keycodes | Remote buttons that open Settings, for `HomeKeyService` (TCL Google TV gear: `[83]`) |
+| `settings_key_clear_task` | bool | With `settings_key_panel` off, those buttons clear the TV Settings task before opening Settings, so Back goes Home. For boards whose firmware also opens its own page in that task from the same press: a Skyworth 2K NSTV (Google TV 14) gear sends `KEYCODE_SETTINGS` too, which `com.mediatek.tv.service` turns into Display & Sound under Settings (`false` by default) |
| `settings_key_panel` | bool | Those buttons open a small quick settings panel (TV settings, Display, Network, Apps, Launcher settings) instead of the TV's Settings |
| `settings_fallback_components` | list, `config.xml` only | Vendor screens tried in order when nothing usable answers the standard Settings action (Xiaomi China, TCL/FFALCON, and Fire OS, where the real menu lives in its launcher), each as `package/activity`; the first one whose package is installed wins, and when none is, the standard intent is sent anyway and may open nothing. Fire OS answers that intent with a `CTSDummy` stub, which counts as missing so the fallback runs. A package named here also has to be listed in the launcher's `<queries>` (Android 11 package visibility), so a set whose settings app is neither of these needs a build, not a theme push. Not read from a theme |
| `restore_key_services` | bool | After a force stop of the launcher, Home puts the remote's accessibility helpers (`HomeKeyService`, `InputKeyService`) back on the enabled list; needs `RESTORE_KEY_SERVICES=1` (`-RestoreKeyServices` on Windows) on every install, since an install without it takes the grant back. Off by default |