Skip to content

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

Launcher: open_on_start_on_wake, to open the Open on start app when the screen comes on

Abu Hasan Rumi7f402323d282
diff --git a/docs/switches.md b/docs/switches.md
index 7ef454e35..3ab95ae93 100644
--- a/docs/switches.md
+++ b/docs/switches.md
@@ -46,6 +46,7 @@ rule sit on its wanted list until a screenshot arrives.
| `clock_glow` | <img src="switches/clock_glow.jpg" width="320" alt="clock_glow on a TV"> |
| `open_on_start_choice` | <img src="switches/open_on_start_choice.jpg" width="320" alt="open_on_start_choice on a TV"> |
| `open_on_start_network_wait` | <img src="switches/open_on_start_network_wait.jpg" width="320" alt="open_on_start_network_wait on a TV"> |
+| `open_on_start_on_wake` | <img src="switches/open_on_start_on_wake.jpg" width="320" alt="open_on_start_on_wake on a TV"> |
| `single_row` | <img src="switches/single_row.jpg" width="320" alt="single_row on a TV"> |
| `dock_band_all` | <img src="switches/single_row.jpg" width="320" alt="dock_band_all on a TV"> |
| `uniform_tiles` | <img src="switches/uniform_tiles.jpg" width="320" alt="uniform_tiles on a TV"> |
diff --git a/docs/switches/open_on_start_on_wake.jpg b/docs/switches/open_on_start_on_wake.jpg
new file mode 100644
index 000000000..9d81ed5fc
Binary files /dev/null and b/docs/switches/open_on_start_on_wake.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 86ccef2e1..732294791 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -110,6 +110,8 @@ final class Config {
final boolean openOnStartChoice;
/** Seconds the boot's app waits for a validated network; 0 opens it at once (open_on_start_network_wait). */
final int openOnStartNetworkWait;
+ /** The Open on start app also opens when the screen comes back on (config.xml, open_on_start_on_wake). */
+ final boolean openOnStartOnWake;
/** The focused dock app's name in large type above the dock (config.xml, dock_title). */
final boolean dockTitle;
/** The dock as its own row: band, no names, parked low (config.xml dock_row). false: one plain grid. */
@@ -286,7 +288,7 @@ 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 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,
- int openOnStartNetworkWait, boolean iconOnlyVpn, String clockFormat, boolean backOpensClock) {
+ int openOnStartNetworkWait, boolean openOnStartOnWake, boolean iconOnlyVpn, String clockFormat, boolean backOpensClock) {
this.handleViewInputs = handleViewInputs;
this.tileMenu = tileMenu;
this.inputKeycodes = inputKeycodes;
@@ -387,6 +389,7 @@ final class Config {
this.powerOnHomeAlways = powerOnHomeAlways;
this.inputsConnectedOnly = inputsConnectedOnly;
this.openOnStartNetworkWait = openOnStartNetworkWait;
+ this.openOnStartOnWake = openOnStartOnWake;
this.clockFormat = clockFormat;
this.wifiStatusWarnings = wifiStatusWarnings;
this.topBarApps = Collections.unmodifiableList(topBarApps);
@@ -453,6 +456,7 @@ final class Config {
boolean bootToLiveTv = res.getBoolean(R.bool.boot_to_live_tv);
boolean openOnStartChoice = res.getBoolean(R.bool.open_on_start_choice);
int openOnStartNetworkWait = res.getInteger(R.integer.open_on_start_network_wait);
+ boolean openOnStartOnWake = res.getBoolean(R.bool.open_on_start_on_wake);
boolean dockTitle = res.getBoolean(R.bool.dock_title);
boolean dockRow = res.getBoolean(R.bool.dock_row);
boolean topMenu = res.getBoolean(R.bool.top_menu);
@@ -564,6 +568,7 @@ final class Config {
bootToLiveTv = bool(json, "boot_to_live_tv", bootToLiveTv);
openOnStartChoice = bool(json, "open_on_start_choice", openOnStartChoice);
openOnStartNetworkWait = integer(json, "open_on_start_network_wait", openOnStartNetworkWait, 0, 600);
+ openOnStartOnWake = bool(json, "open_on_start_on_wake", openOnStartOnWake);
dockTitle = bool(json, "dock_title", dockTitle);
dockRow = bool(json, "dock_row", dockRow);
topMenu = bool(json, "top_menu", topMenu);
@@ -700,7 +705,7 @@ final class Config {
consumeVolumeKeys, 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,
- Math.max(0, Math.min(600, openOnStartNetworkWait)), iconOnlyVpn, clockFormat, backOpensClock);
+ Math.max(0, Math.min(600, openOnStartNetworkWait)), openOnStartOnWake, iconOnlyVpn, clockFormat, backOpensClock);
}
/**
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 c4993b9be..858c12803 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -267,6 +267,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private boolean openOnStartChoice;
/** open_on_start_network_wait, in ms; the boot's app while it waits for the network, and until when. */
private long openOnStartWaitMs;
+ /** open_on_start_on_wake: wakeReceiver is registered for this activity's life. */
+ private boolean openOnStartOnWake;
private volatile Intent startPending;
private long startDeadline;
/** Opens the boot's app once the network is validated (networkCallback posts this) or the wait is over. */
@@ -282,6 +284,12 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
open(i);
}
};
+ private final BroadcastReceiver wakeReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ openStartAppOnWake();
+ }
+ };
/** hidden_apps as the adapter sees them (config.xml or a theme's config.json): a hidden app gets no card either. */
private Set<String> hiddenApps = Collections.emptySet();
/** library_excluded_apps: packages the App library catalogue never offers. */
@@ -463,6 +471,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
bootToLiveTv = cfg.bootToLiveTv;
openOnStartChoice = cfg.openOnStartChoice;
openOnStartWaitMs = cfg.openOnStartNetworkWait * 1000L;
+ openOnStartOnWake = OpenOnStart.onWake(cfg.openOnStartChoice, cfg.openOnStartOnWake);
liveTvAction = cfg.liveTvAction;
liveTvInputId = cfg.liveTvInputId;
appLibraryEnabled = cfg.appLibrary;
@@ -907,6 +916,13 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
} else {
registerReceiver(packageReceiver, packageFilter);
}
+ if (openOnStartOnWake) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ registerReceiver(wakeReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON), Context.RECEIVER_NOT_EXPORTED);
+ } else {
+ registerReceiver(wakeReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
+ }
+ }
ConnectivityManager cm = getSystemService(ConnectivityManager.class);
TvInputManager tim = (TvInputManager) getSystemService(TV_INPUT_SERVICE);
@@ -1310,6 +1326,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
cancelHoldOk();
if (gameDay != null) gameDay.shutdown();
unregisterReceiver(packageReceiver);
+ if (openOnStartOnWake) unregisterReceiver(wakeReceiver);
wallpaperPlayer.close();
ConnectivityManager cm = getSystemService(ConnectivityManager.class);
TvInputManager tim = (TvInputManager) getSystemService(TV_INPUT_SERVICE);
@@ -3112,6 +3129,19 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
if (!prefs.edit().putInt(OpenOnStart.BOOT_KEY, boot).commit()) return false;
Intent i = bootToLiveTv ? liveTvIntent() : OpenOnStart.intent(getPackageManager(), app);
if (i == null) return false;
+ return openWhenReady(i);
+ }
+
+ /** open_on_start_on_wake: the remote's power button is a light sleep on some sets, with no boot for
+ * openLiveTvAfterBoot to catch. */
+ private void openStartAppOnWake() {
+ String app = getSharedPreferences(Config.SETTINGS_NAME, MODE_PRIVATE).getString(OpenOnStart.KEY, "");
+ if (app.isEmpty() || app.equals(getPackageName())) return;
+ Intent i = OpenOnStart.intent(getPackageManager(), app);
+ if (i != null) openWhenReady(i);
+ }
+
+ private boolean openWhenReady(Intent i) {
// open_on_start_network_wait: Home stays on screen until the network is back or the wait is over.
if (openOnStartWaitMs > 0 && !OpenOnStart.online(this)) {
startPending = i;
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/OpenOnStart.java b/launcher/app/src/main/java/com/gathin/tvhome/OpenOnStart.java
index 23cd992da..5bdfead7e 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/OpenOnStart.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/OpenOnStart.java
@@ -25,6 +25,11 @@ final class OpenOnStart {
return boot >= 0 && boot != handledBoot && pkg != null && !pkg.isEmpty() && !pkg.equals(self);
}
+ /** open_on_start_on_wake needs the Open on start row, which is where the app is picked. */
+ static boolean onWake(boolean choice, boolean onWake) {
+ return choice && onWake;
+ }
+
static int boot(Context ctx) {
return Settings.Global.getInt(ctx.getContentResolver(), Settings.Global.BOOT_COUNT, -1);
}
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index 42b73d75f..42925f7c6 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -46,6 +46,10 @@
both are set); Home after that stays Home, and an app that is gone or disabled leaves Home on screen.
Off by default; a theme can set "open_on_start_choice": true. -->
<bool name="open_on_start_choice">false</bool>
+ <!-- With open_on_start_choice: the picked app also opens each time the screen comes back on, for sets whose
+ remote powers them into a light sleep with no boot. It opens over whatever was in front, an HDMI input
+ included. Off by default; a theme can set "open_on_start_on_wake": true. -->
+ <bool name="open_on_start_on_wake">false</bool>
<!-- Seconds the first Home after the TV starts waits for a working internet connection before it opens the
boot_to_live_tv or Open on start app. A streaming app opened before the network is back shows an error,
diff --git a/launcher/app/src/test/java/com/gathin/tvhome/OpenOnStartTest.java b/launcher/app/src/test/java/com/gathin/tvhome/OpenOnStartTest.java
index 9fdb8e965..a810a1f3b 100644
--- a/launcher/app/src/test/java/com/gathin/tvhome/OpenOnStartTest.java
+++ b/launcher/app/src/test/java/com/gathin/tvhome/OpenOnStartTest.java
@@ -38,4 +38,11 @@ public class OpenOnStartTest {
assertFalse(OpenOnStart.opensNow(false, 59_999, 60_000));
assertTrue(OpenOnStart.opensNow(false, 60_000, 60_000));
}
+
+ @Test
+ public void wakeNeedsBothTheRowAndTheSwitch() {
+ assertTrue(OpenOnStart.onWake(true, true));
+ assertFalse(OpenOnStart.onWake(true, false));
+ assertFalse(OpenOnStart.onWake(false, true));
+ }
}
diff --git a/themes/README.md b/themes/README.md
index 36b21bde6..8343797e4 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -119,6 +119,7 @@ A new key needs one there in the same pull request.
| `boot_to_live_tv` | bool | Open the Live TV app (`live_tv_package`) on the first Home after the TV starts, once per boot |
| `open_on_start_choice` | bool | `true` adds an **Open on start** row to Launcher settings: pick an app on the TV, and the first Home after each boot opens it instead (once per boot; `boot_to_live_tv` wins when both are set; an app that is gone or disabled leaves Home on screen). Off by default |
| `open_on_start_network_wait` | 0 to 600 | Seconds the first Home after the TV starts waits for a working internet connection before it opens the `boot_to_live_tv` or Open on start app. A streaming app opened before the network is back shows an error, and after a power cut Wi-Fi can take minutes, as the router starts again too. Home stays on screen meanwhile, and leaving Home cancels the opening. `0`, the default, opens the app at once |
+| `open_on_start_on_wake` | bool | With `open_on_start_choice`, the picked app also opens each time the screen comes back on, for TVs whose remote powers them into a light sleep with no boot. It opens over whatever was in front, an HDMI input included, and `open_on_start_network_wait` applies. Off by default |
| `focus_overshoot` | bool | The highlight and the focused tile swing past their target before settling (`true` by default); `false` glides straight there with smooth scrolling |
| `vpn_app` | string | App the network pill opens when a VPN is configured; also shows a red "VPN off" badge while no VPN is up |
| `vpn_pill` | bool | The VPN as its own pill after the network pill instead of a badge inside it: solid green while a VPN is up, solid red "VPN off" while none is and `vpn_app` is installed, hidden otherwise. Pressing it opens `vpn_app` (without it, the App library, or VPN settings with `app_library` off); it keeps its label with `icon_only_buttons`; the network pill then opens Wi-Fi settings. Ignored with `top_menu`. A VPN app's kill switch holds a VPN up while the app says disconnected, so the pill stays green then (`false` by default) |