Skip to content

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

Launcher: power_on_home_always, Home at every power-on whatever is in front

benny11799123f0c47ed
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md
index 5501e41ef..0dcfc29fd 100644
--- a/docs/TROUBLESHOOTING.md
+++ b/docs/TROUBLESHOOTING.md
@@ -555,6 +555,10 @@ Things that bit us or contributors, so they don't bite you. Commands use `tools/
HDMI inputs. Set `power_on_home` (`config.xml` or a theme) with `HOME_KEY_SERVICE=1`: until the first
key press after boot or screen-on, `HomeKeyService` sends that Live TV window back to Home. Ask the
person first; someone who watches broadcast TV may want the opposite, `boot_to_live_tv`.
+- **The TV wakes from standby back on the last HDMI input, and `power_on_home` takes about 5 s or misses it**
+ (Philips 65OLED706, Android TV 11): the firmware only resumes the `org.droidtv.playtv` window it left, which
+ sends its window event once the input has a picture, if at all. Set `power_on_home_always` too: Home comes
+ up about a second after the screen turns on, whatever is in front (an input, Live TV or an app).
## Accessibility helper enabled but the remote button does nothing
diff --git a/docs/switches.md b/docs/switches.md
index 44773bfef..c77c6a42f 100644
--- a/docs/switches.md
+++ b/docs/switches.md
@@ -50,3 +50,4 @@ fits the rules; keys from before the rule sit on its wanted list until a screens
| `library_ok_opens` | <img src="switches/library_ok_opens.jpg" width="320" alt="library_ok_opens on a TV"> |
| `date_below_clock` | <img src="switches/date_below_clock.jpg" width="320" alt="date_below_clock on a TV"> |
| `power_on_home` | <img src="switches/power_on_home.jpg" width="320" alt="power_on_home on a TV"> |
+| `power_on_home_always` | <img src="switches/power_on_home_always.jpg" width="320" alt="power_on_home_always on a TV"> |
diff --git a/docs/switches/power_on_home_always.jpg b/docs/switches/power_on_home_always.jpg
new file mode 100644
index 000000000..48609fdc0
Binary files /dev/null and b/docs/switches/power_on_home_always.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 be67171ae..2c8aa8226 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -162,6 +162,8 @@ final class Config {
final String stockHomeRedirect;
/** A Live TV window the firmware opens by itself at power-on is sent back to Home (power_on_home). */
final boolean powerOnHome;
+ /** Home at every power-on, whatever the firmware put in front: an input, Live TV or an app (power_on_home_always). */
+ final boolean powerOnHomeAlways;
/** The Settings button opens the quick settings panel instead of the TV's Settings (settings_key_panel). */
final boolean settingsKeyPanel;
/** Home puts the remote's accessibility helpers back after a force stop (restore_key_services; ServiceRepair). */
@@ -260,7 +262,7 @@ final class Config {
List<RaceWeekend.Race> raceCalendar, boolean cinematicHome, boolean ambientGlow, boolean appGlow, boolean fadeRows, int homeIdleClockMinutes,
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 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) {
+ Map<String, Set<String>> wallpaperMoods, boolean gamepadPassthrough, boolean consumeVolumeKeys, boolean powerOnHome, 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 powerOnHomeAlways) {
this.handleViewInputs = handleViewInputs;
this.tileMenu = tileMenu;
this.inputKeycodes = inputKeycodes;
@@ -350,6 +352,7 @@ final class Config {
this.gamepadPassthrough = gamepadPassthrough;
this.consumeVolumeKeys = consumeVolumeKeys;
this.powerOnHome = powerOnHome;
+ this.powerOnHomeAlways = powerOnHomeAlways;
this.wifiStatusWarnings = wifiStatusWarnings;
this.topBarApps = Collections.unmodifiableList(topBarApps);
this.showGreeting = showGreeting;
@@ -454,6 +457,7 @@ final class Config {
boolean gamepadPassthrough = res.getBoolean(R.bool.gamepad_passthrough);
boolean consumeVolumeKeys = res.getBoolean(R.bool.consume_volume_keys);
boolean powerOnHome = res.getBoolean(R.bool.power_on_home);
+ boolean powerOnHomeAlways = res.getBoolean(R.bool.power_on_home_always);
boolean dockGlass = res.getBoolean(R.bool.dock_glass);
boolean dockEvenPadding = res.getBoolean(R.bool.dock_even_padding);
boolean dockBand = res.getBoolean(R.bool.dock_band);
@@ -553,6 +557,7 @@ final class Config {
gamepadPassthrough = bool(json, "gamepad_passthrough", gamepadPassthrough);
consumeVolumeKeys = bool(json, "consume_volume_keys", consumeVolumeKeys);
powerOnHome = bool(json, "power_on_home", powerOnHome);
+ powerOnHomeAlways = bool(json, "power_on_home_always", powerOnHomeAlways);
dockGlass = bool(json, "dock_glass", dockGlass);
dockEvenPadding = bool(json, "dock_even_padding", dockEvenPadding);
dockBand = bool(json, "dock_band", dockBand);
@@ -635,7 +640,7 @@ final class Config {
dockBand, cinematicDots, cinematicWhiteFocus, wifiStatusColor, cinematicScrim, cinematicArt, wallpaperMoods, gamepadPassthrough,
consumeVolumeKeys, powerOnHome, wifiStatusWarnings, topBarApps, showGreeting, headerWhite, clockWallpaper,
Math.max(0, Math.min(90, clockWallpaperDim)), clockGlow, glassStyle, singleRow && dockRow, dockBandAll, lunar, lunarOffset,
- dateBelowClock);
+ dateBelowClock, powerOnHomeAlways);
}
/**
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
index 016d41d45..4f2b0d932 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
@@ -38,6 +38,8 @@ import java.util.Set;
*
* With power_on_home set, a Live TV window (live_tv_package) that the firmware opens by itself at power-on is sent
* back here too, until the first key press after boot or after the screen turns on (Changhong / Homwee boards).
+ * With power_on_home_always set, Home comes up at every power-on whatever is in front, for TVs that resume their
+ * last source: a Philips back on an HDMI input sends no window event until the input has a picture.
*
* Enable over adb:
* settings put secure enabled_accessibility_services com.gathin.tvhome/.HomeKeyService
@@ -68,6 +70,8 @@ public class HomeKeyService extends AccessibilityService {
/** power_on_home: the Live TV package to send back to Home, empty when off; armed until this uptime or a key. */
private String powerOnLiveTv = "";
private long powerOnUntil;
+ /** power_on_home_always: Home at every power-on, not only over Live TV. */
+ private boolean powerOnAlways;
/** power_on_home: re-arms after the screen turns on; null unless the key is on. */
private BroadcastReceiver screenOnReceiver;
/** Stops key filtering while a game controller is connected; null unless gamepad_passthrough and key_filter, or before the unlock. */
@@ -194,7 +198,8 @@ public class HomeKeyService extends AccessibilityService {
? getSharedPreferences(Config.SETTINGS_NAME, MODE_PRIVATE).getString(OpenOnStart.KEY, "") : "";
powerOnLiveTv = config.powerOnHome && !config.bootToLiveTv && !config.liveTvPackage.equals(openOnStart)
? config.liveTvPackage : "";
- if (!powerOnLiveTv.isEmpty()) {
+ powerOnAlways = config.powerOnHomeAlways && !config.bootToLiveTv && openOnStart.isEmpty();
+ if (!powerOnLiveTv.isEmpty() || powerOnAlways) {
armPowerOnHome();
} else if (screenOnReceiver != null) {
unregisterReceiver(screenOnReceiver);
@@ -285,17 +290,33 @@ public class HomeKeyService extends AccessibilityService {
/** power_on_home: armed for the boot window (if this bind is part of the boot) and after every screen-on. */
private void armPowerOnHome() {
- if (SystemClock.elapsedRealtime() < BOOT_WINDOW_MS) powerOnUntil = BOOT_WINDOW_MS;
+ if (SystemClock.elapsedRealtime() < BOOT_WINDOW_MS) {
+ powerOnUntil = BOOT_WINDOW_MS;
+ if (powerOnAlways) handler.postDelayed(this::homeAtPowerOn, POWER_ON_ALWAYS_DELAY_MS);
+ }
if (screenOnReceiver != null) return;
screenOnReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
powerOnUntil = SystemClock.elapsedRealtime() + SCREEN_ON_WINDOW_MS;
+ if (powerOnAlways) handler.postDelayed(HomeKeyService.this::homeAtPowerOn, POWER_ON_ALWAYS_DELAY_MS);
}
};
registerReceiver(screenOnReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
}
+ /** power_on_home_always: after the firmware has brought its last source back (Philips: within 0.5 s). */
+ static final long POWER_ON_ALWAYS_DELAY_MS = 800L;
+
+ /** power_on_home_always: Home, unless a key was pressed since the screen came on (the user has the TV). */
+ private void homeAtPowerOn() {
+ if (stillArmed(SystemClock.elapsedRealtime(), powerOnUntil)) openHome();
+ }
+
+ static boolean stillArmed(long now, long armedUntil) {
+ return now < armedUntil;
+ }
+
static boolean powerOnRedirect(String liveTv, CharSequence pkg, long now, long armedUntil) {
return !liveTv.isEmpty() && pkg != null && liveTv.contentEquals(pkg) && now < armedUntil;
}
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index 580e748f8..e06ef55e8 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -205,6 +205,10 @@
to the user, so opening Live TV on purpose is never undone. The opposite of boot_to_live_tv, and ignored
when that is on. A theme's config.json can set it too. Off by default. -->
<bool name="power_on_home">false</bool>
+ <!-- Home at every power-on, whatever the firmware put in front (the last HDMI input, Live TV or an app),
+ for TVs that come back to the last source, like Philips. Needs HOME_KEY_SERVICE=1; a key pressed first
+ wins. Ignored with boot_to_live_tv or an Open on start app. Can also be set with "power_on_home_always". -->
+ <bool name="power_on_home_always">false</bool>
<!-- Show the Solar Hijri (Shamsi) date used in Iran and Afghanistan, e.g. "27 Mehr 1405", above the
Gregorian date. -->
diff --git a/launcher/app/src/test/java/com/gathin/tvhome/HomeKeyServiceTest.java b/launcher/app/src/test/java/com/gathin/tvhome/HomeKeyServiceTest.java
index e5ffc0c76..c1acb3e0e 100644
--- a/launcher/app/src/test/java/com/gathin/tvhome/HomeKeyServiceTest.java
+++ b/launcher/app/src/test/java/com/gathin/tvhome/HomeKeyServiceTest.java
@@ -52,4 +52,9 @@ public class HomeKeyServiceTest {
@Test public void offMeansNothing() {
assertFalse(HomeKeyService.powerOnRedirect("", TV, SOON, HomeKeyService.BOOT_WINDOW_MS));
}
+
+ @Test public void alwaysGoesHomeAfterScreenOnUntilAKey() {
+ assertTrue(HomeKeyService.stillArmed(SOON, SOON + HomeKeyService.SCREEN_ON_WINDOW_MS));
+ assertFalse(HomeKeyService.stillArmed(SOON, 0));
+ }
}
diff --git a/themes/README.md b/themes/README.md
index d080af63c..ad99becca 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -122,6 +122,7 @@ A new key needs one there in the same pull request.
| `consume_volume_keys` | bool | `true` makes the key helpers swallow Volume Up/Down and repeat a held one themselves (after 500 ms, every 60 ms). Use it on firmware that applies a volume key both before the helper and when the helper hands it back, so one tap moves two steps (TCL G03 / BeyondTV4, Android 11, #1100). Needs `key_filter` on. Off by default |
| `stock_home_redirect` | string | Stock launcher package; if the firmware turns it back on (XGIMI), its home screen is sent straight back here (`HOME_KEY_SERVICE=1`) |
| `power_on_home` | bool | For firmware that opens the Live TV app (`live_tv_package`) by itself at every power-on (Changhong / Homwee): until the first key press after boot or screen-on, that Live TV window is sent back to Home (`HOME_KEY_SERVICE=1`). Ignored with `boot_to_live_tv`, or with Live TV as the Open on start app. Off by default |
+| `power_on_home_always` | bool | Home at every power-on, whatever the TV put in front: the last HDMI input, Live TV or an app, for TVs that come back to the last source (Philips). Unlike `power_on_home`, it does not wait for a window to show: the Home screen comes up about a second after the screen turns on (`HOME_KEY_SERVICE=1`). A key pressed before that wins. Ignored with `boot_to_live_tv`, or with an Open on start app. Off by default |
| `race_calendar` | list of races | F1 race-weekend mode: from 12 hours before a weekend's first session until 4 hours after the race starts, a panel under the clock shows the next session with a countdown (or the live one) and the weekend's session times in the TV's time zone. Write it with `tools/race_calendar.py <theme folder>`, which fetches the season from the free Jolpica API; the launcher itself never goes online |
| `home_idle_clock_minutes` | 0 to 1440 | Minutes Home may sit untouched before it shows the clock screensaver (a thin clock and date drifting over a slow glow, as the system "Clock" screensaver does). Any key returns to Home. It starts only from Home, never over Live TV or an app; 0 is off (default) |
| `clock_wallpaper` | bool | The clock screensaver over Home's wallpaper instead of black with a coloured glow; the clock still moves every minute (`false` by default) |