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: stock_home_redirect leaves the stock launcher the home process, so the remote's YouTube and Netflix buttons still open their apps (#1274)
Jack Moorhouse741ae6f10480
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.javaindex f4f1e21cf..e4db724f5 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java@@ -8,6 +8,7 @@ import android.content.Context;import android.content.Intent;import android.content.IntentFilter;import android.content.SharedPreferences;+import android.os.Build;import android.os.Handler;import android.os.Looper;import android.os.SystemClock;@@ -58,6 +59,8 @@ public class HomeKeyService extends AccessibilityService {private BroadcastReceiver unlockReceiver;/** The stock launcher's HOME activities (stock_home_redirect), disabled ones included. */private final Set<String> stockHome = new HashSet<>();+ /** stock_home_redirect, the stock launcher's package. */+ private String stockHomePackage = "";/** Stops key filtering while a game controller is connected; null unless gamepad_passthrough and key_filter, or before the unlock. */private GamepadPassthrough gamepads;@@ -116,6 +119,7 @@ public class HomeKeyService extends AccessibilityService {appScancodes = RemoteKeys.parseAppScancodes(config.appKeys);RemoteKeys.applyKeyFilter(this, config.keyFilter);stockHome.clear();+ stockHomePackage = config.stockHomeRedirect;if (!config.stockHomeRedirect.isEmpty()) {Intent home = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).setPackage(config.stockHomeRedirect);for (ResolveInfo ri : getPackageManager().queryIntentActivities(home, PackageManager.MATCH_DISABLED_COMPONENTS)) {@@ -171,13 +175,7 @@ public class HomeKeyService extends AccessibilityService {return false;}if (event.getKeyCode() != KeyEvent.KEYCODE_ALL_APPS) return false;- if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) {- Intent home = new Intent(Intent.ACTION_MAIN)- .addCategory(Intent.CATEGORY_HOME)- .setPackage(getPackageName())- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);- startActivity(home);- }+ if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) openHome();return true;}@@ -240,10 +238,27 @@ public class HomeKeyService extends AccessibilityService {}private void openHome() {- startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).setPackage(getPackageName())+ Intent open = stockHomeStays() ? new Intent(this, MainActivity.class)+ : new Intent(Intent.ACTION_MAIN).setPackage(getPackageName());+ startActivity(open.addCategory(Intent.CATEGORY_HOME).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED));}+ /** stock_home_redirect while Android's Home is still the stock launcher (launcherx on Google TV outranks this+ * one). A Home intent would then put this launcher in the home task and make it the home process, and from+ * Android 10 the stock launcher, no longer exempt from the limits on background activity starts, can't open+ * apps for the remote's YouTube and Netflix buttons (#1274). openHome starts it like an app instead:+ * CATEGORY_HOME without ACTION_MAIN is not a Home intent, but still sends MainActivity back to the first tile.+ * A MainActivity already in the home task, as the install scripts' first start leaves it, is reused as it is+ * until that task goes (a restart or a reinstall). With this launcher or Android's chooser as Home, openHome+ * keeps the Home intent. */+ private boolean stockHomeStays() {+ if (stockHome.isEmpty() || Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return false;+ ResolveInfo home = getPackageManager().resolveActivity(+ new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), PackageManager.MATCH_DEFAULT_ONLY);+ return home != null && stockHomePackage.equals(home.activityInfo.packageName);+ }+@Overridepublic void onInterrupt() {}