Skip to content

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

Fall back to a normal launch for an empty input: value

ahmersdev519a04b2c01f
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/LaunchActions.java b/launcher/app/src/main/java/com/gathin/tvhome/LaunchActions.java
index ab684d4a3..32d1b7d54 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/LaunchActions.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/LaunchActions.java
@@ -17,8 +17,11 @@ final class LaunchActions {
private static final String INPUT_PREFIX = "input:";
- /** The TV input id from an "input:<id>" launch_actions value, or null when the value isn't one. */
+ /** The TV input id from an "input:<id>" launch_actions value, or null when the value isn't one, including
+ * an empty id ("input:" alone), which falls back to a normal launch rather than an empty input switch. */
static String inputId(String action) {
- return action != null && action.startsWith(INPUT_PREFIX) ? action.substring(INPUT_PREFIX.length()).trim() : null;
+ if (action == null || !action.startsWith(INPUT_PREFIX)) return null;
+ String id = action.substring(INPUT_PREFIX.length()).trim();
+ return id.isEmpty() ? null : id;
}
}
diff --git a/launcher/app/src/test/java/com/gathin/tvhome/LaunchActionsTest.java b/launcher/app/src/test/java/com/gathin/tvhome/LaunchActionsTest.java
index 07cb13bb5..a43735fb5 100644
--- a/launcher/app/src/test/java/com/gathin/tvhome/LaunchActionsTest.java
+++ b/launcher/app/src/test/java/com/gathin/tvhome/LaunchActionsTest.java
@@ -38,7 +38,6 @@ public class LaunchActionsTest {
assertEquals("com.mediatek.tvinput/.hdmi.HDMIInputService/HW5",
LaunchActions.inputId("input:com.mediatek.tvinput/.hdmi.HDMIInputService/HW5"));
assertEquals("HW5", LaunchActions.inputId("input: HW5 "));
- assertEquals("", LaunchActions.inputId("input:"));
}
@Test public void inputIdIsNullForEverythingElse() {
@@ -47,4 +46,9 @@ public class LaunchActionsTest {
assertNull(LaunchActions.inputId("INPUT:HW5"));
assertNull(LaunchActions.inputId("not-input:HW5"));
}
+
+ @Test public void emptyInputIdFallsBackToANormalLaunchInsteadOfAnEmptySwitch() {
+ assertNull(LaunchActions.inputId("input:"));
+ assertNull(LaunchActions.inputId("input: "));
+ }
}