Skip to content

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

launcher: hide the clock until the system time is set

VincentYe12322fd5459fea6
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 c38133eec..e8f2b4d45 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -96,6 +96,11 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private boolean rtlAppGrid;
private static final long MINUTE_MS = 60_000L;
private static final long STATS_MS = 10_000L;
+ /**
+ * 2025-01-01. TVs without a clock battery boot at the epoch (08:00 in China) and keep it until network
+ * time arrives; the clock, date and greeting stay hidden before then.
+ */
+ private static final long TIME_VALID_AFTER_MS = 1_735_689_600_000L;
private String liveTvPkg;
private String liveTvAction;
private String inputAction;
@@ -129,6 +134,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private boolean animations;
private boolean advancedEffects;
private TextView greeting;
+ private View clockBlock;
private View btnInputs;
private TextView btnWifi;
private TextView shamsiDate;
@@ -256,6 +262,14 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
if (appLibrary != null) appLibrary.refresh();
}
};
+ // Right after boot the clock is often wrong until network time arrives; don't wait a minute to catch up.
+ private final IntentFilter timeFilter = new IntentFilter(Intent.ACTION_TIME_CHANGED);
+ private final BroadcastReceiver timeReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ updateClockVisibility();
+ }
+ };
private final Runnable minuteTick = new Runnable() {
@Override
public void run() {
@@ -315,6 +329,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
// still follows the dock.
if (!cfg.dockTitle) hero.setVisibility(View.GONE);
greeting = findViewById(R.id.greeting);
+ clockBlock = findViewById(R.id.leftBlock);
greetingColor = greeting.getCurrentTextColor();
btnWifi = findViewById(R.id.btnWifi);
shamsiDate = findViewById(R.id.shamsiDate);
@@ -527,6 +542,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
packageFilter.addDataScheme("package");
+ timeFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
ConnectivityManager cm = getSystemService(ConnectivityManager.class);
TvInputManager tim = (TvInputManager) getSystemService(TV_INPUT_SERVICE);
@@ -570,9 +586,12 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
super.onStart();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
registerReceiver(packageReceiver, packageFilter, Context.RECEIVER_NOT_EXPORTED);
+ registerReceiver(timeReceiver, timeFilter, Context.RECEIVER_NOT_EXPORTED);
} else {
registerReceiver(packageReceiver, packageFilter);
+ registerReceiver(timeReceiver, timeFilter);
}
+ updateClockVisibility();
}
@Override
@@ -712,6 +731,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
protected void onStop() {
super.onStop();
unregisterReceiver(packageReceiver);
+ unregisterReceiver(timeReceiver);
+ handler.removeCallbacks(clockCheck);
rebuildOnResume = true;
}
@@ -1759,6 +1780,20 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
// ---- top bar ---------------------------------------------------------------------------------
+ /** Some TVs (Coocaa OS) set the network time without ACTION_TIME_CHANGED, so keep checking until it is valid. */
+ private final Runnable clockCheck = this::updateClockVisibility;
+
+ private void updateClockVisibility() {
+ boolean valid = System.currentTimeMillis() >= TIME_VALID_AFTER_MS;
+ clockBlock.setVisibility(valid ? View.VISIBLE : View.INVISIBLE);
+ handler.removeCallbacks(clockCheck);
+ if (valid) {
+ updateGreeting();
+ } else {
+ handler.postDelayed(clockCheck, 1_000L);
+ }
+ }
+
private void updateGreeting() {
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
int res;