Skip to content

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

launcher: answer VIEW_INPUTS with the Inputs menu

johnbenwoo0b4782d44697
diff --git a/launcher/app/src/main/AndroidManifest.xml b/launcher/app/src/main/AndroidManifest.xml
index 7dc9ee681..a3432a6b2 100644
--- a/launcher/app/src/main/AndroidManifest.xml
+++ b/launcher/app/src/main/AndroidManifest.xml
@@ -61,6 +61,15 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
+ <!-- The system input switcher. On some sets the stock launcher was the only handler of this action
+ (Hisense huangshan, Android TV 10: no global_keys.xml and no vendor input picker), so once it is
+ disabled the remote's Input button, which the Live TV app and InputKeyService turn into this
+ action, did nothing. Answered here with the Inputs menu; where a vendor picker exists the TV
+ keeps offering the choice. -->
+ <intent-filter>
+ <action android:name="com.android.tv.action.VIEW_INPUTS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
</activity>
<activity
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 e89977e15..d9be02c4e 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -93,6 +93,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private static final int LAUNCHER_SETTINGS_REQUEST = 42;
/** Sent by QuickSettingsActivity: open Launcher settings from here so Home rebuilds when they close. */
static final String ACTION_LAUNCHER_SETTINGS = "com.gathin.tvhome.action.LAUNCHER_SETTINGS";
+ /** The system input switcher; answered here on TVs where nothing else handles it (see the manifest). */
+ static final String ACTION_VIEW_INPUTS = "com.android.tv.action.VIEW_INPUTS";
/** Tiles per row and dock slots (res/values/config.xml, columns). Set in onCreate. */
static int COLUMNS = 4;
private boolean rtlAppGrid;
@@ -593,7 +595,36 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
.build(), vpnCallback);
}
// Not after recreate(): the launch intent survives it and would open the settings again.
- if (savedInstanceState == null) openLauncherSettingsIfAsked(getIntent());
+ if (savedInstanceState == null && !openLauncherSettingsIfAsked(getIntent())) openInputsIfAsked(getIntent());
+ }
+
+ /**
+ * VIEW_INPUTS, which is what the remote's Input button becomes (InputKeyService, or the TV's Live TV app):
+ * open the Inputs menu once the pill is on screen. The intent is replaced so a later recreate() does not
+ * open it again. Nothing to do when the TV has no inputs to list (the pill is hidden then).
+ */
+ private boolean openInputsIfAsked(Intent intent) {
+ if (intent == null || !ACTION_VIEW_INPUTS.equals(intent.getAction())) return false;
+ setIntent(new Intent(Intent.ACTION_MAIN));
+ if (btnInputs.getVisibility() != View.VISIBLE) return true;
+ if (btnInputs.isLaidOut()) {
+ btnInputs.requestFocus();
+ showInputs();
+ return true;
+ }
+ // Cold start: the popup anchors to the pill, so wait for the first layout.
+ btnInputs.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ btnInputs.getViewTreeObserver().removeOnGlobalLayoutListener(this);
+ btnInputs.post(() -> {
+ if (isFinishing() || btnInputs.getVisibility() != View.VISIBLE) return;
+ btnInputs.requestFocus();
+ showInputs();
+ });
+ }
+ });
+ return true;
}
private boolean openLauncherSettingsIfAsked(Intent intent) {
@@ -612,6 +643,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (openLauncherSettingsIfAsked(intent)) return;
+ if (openInputsIfAsked(intent)) return;
if (intent == null || !intent.hasCategory(Intent.CATEGORY_HOME)) return;
grid.scrollToPosition(0);
lastFocused = 0;