Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.
Python adbadblockandroid-tvandroid-tv-launcherapple-tvbloatware-removalclaude-codedebloatfire-tvgoogle-tvlauncherprivacysmart-tvsony-braviatclvibe-codingxiaomi
Launcher: a short Menu press opens the tile menu on Xiaomi China firmware (#1637)
Luis412b3f70c6a5
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.javaindex a5acd794b..0a02a34b0 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java@@ -1264,7 +1264,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {int position = focusedTilePosition();if (position >= 0 && position < adapter.appCount()&& !getPackageName().equals(adapter.packageAt(position))) {- if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) {+ if (RemoteKeys.menuReleased(event.getAction(), event.getFlags())) {onTileLongPress(position, getCurrentFocus());}return true;diff --git a/launcher/app/src/main/java/com/gathin/tvhome/RemoteKeys.java b/launcher/app/src/main/java/com/gathin/tvhome/RemoteKeys.javaindex 105fabc89..bb45a2e0c 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/RemoteKeys.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/RemoteKeys.java@@ -262,6 +262,21 @@ final class RemoteKeys {}}+ /**+ * The flags on the KEYCODE_MENU pair that Xiaomi's China firmware (MiTV-MFTR0, Android 11) injects for a short+ * press of the remote's Menu key, after keeping the real press for itself (#1637). They include FLAG_CANCELED,+ * so the pair reads as a cancelled press, and the undocumented 0x1000, 0x2000 and 0x4000, which no real+ * cancelled press carries.+ */+ static final int XIAOMI_SHORT_MENU_FLAGS = 0x7531;++ /** True for the UP that ends a Menu press: not cancelled, or cancelled only as Xiaomi's injected short press is. */+ static boolean menuReleased(int action, int flags) {+ if (action != KeyEvent.ACTION_UP) return false;+ return (flags & KeyEvent.FLAG_CANCELED) == 0+ || (flags & XIAOMI_SHORT_MENU_FLAGS) == XIAOMI_SHORT_MENU_FLAGS;+ }+/** The app a mapped key opens: its hold entry after HOLD_MS, otherwise its normal one. */static String target(String app, String holdApp, long heldMs) {return heldMs >= HOLD_MS && holdApp != null ? holdApp : app;diff --git a/launcher/app/src/test/java/com/gathin/tvhome/RemoteKeysTest.java b/launcher/app/src/test/java/com/gathin/tvhome/RemoteKeysTest.javaindex 81fd1b202..42e822e66 100644--- a/launcher/app/src/test/java/com/gathin/tvhome/RemoteKeysTest.java+++ b/launcher/app/src/test/java/com/gathin/tvhome/RemoteKeysTest.java@@ -241,4 +241,17 @@ public class RemoteKeysTest {remote.up("1:191:0", 1700, 1000, "tap", "hold");assertEquals(Arrays.asList("tap", "hold"), remote.opened);}++ @Test public void menuReleasedTakesXiaomisInjectedShortPress() {+ // ACTION_DOWN 0, ACTION_UP 1; FLAG_CANCELED 0x20, FLAG_CANCELED_LONG_PRESS 0x100, FLAG_FROM_SYSTEM 0x8.+ assertTrue(RemoteKeys.menuReleased(1, 0));+ assertTrue(RemoteKeys.menuReleased(1, 0x8));+ assertTrue(RemoteKeys.menuReleased(1, RemoteKeys.XIAOMI_SHORT_MENU_FLAGS));+ assertFalse(RemoteKeys.menuReleased(0, 0));+ assertFalse(RemoteKeys.menuReleased(0, RemoteKeys.XIAOMI_SHORT_MENU_FLAGS));+ // A cancelled press elsewhere, long press or not, still opens nothing.+ assertFalse(RemoteKeys.menuReleased(1, 0x20));+ assertFalse(RemoteKeys.menuReleased(1, 0x20 | 0x100 | 0x8));+ assertFalse(RemoteKeys.menuReleased(1, RemoteKeys.XIAOMI_SHORT_MENU_FLAGS & ~0x4000));+ }}