Skip to content

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

addons: TV Static styles - snow, colour bars with a 1 kHz tone, an old set's blue no-signal, random

Luiz Fernandoa39aada08231
diff --git a/addons/README.md b/addons/README.md
index 002553a11..3359a3dde 100644
--- a/addons/README.md
+++ b/addons/README.md
@@ -15,7 +15,7 @@ the core bigger or change how it behaves. You install an add-on only if you want
| [Photo Prints](photo-prints/) | Your own photos as a screensaver: dated prints dealt in on a time-of-day sky, and a card that starts the slideshow | [@shivamsingh262](https://github.com/shivamsingh262) | Sony BRAVIA KD-65X82L (Google TV 12) | None |
| [Photo screensaver](photo-screensaver/) | Your own pictures and MP4 clips as the TV's screensaver and as a card, slowly zooming and crossfading (20 s each by default); optional time, photo dates, prints on a sky and weather | [JorickGU](https://github.com/JorickGU) | TCL 43P69K (Google TV 12) | `INTERNET` and coarse location, only with the weather option on |
| [Prayer Times](prayer-times/) | Today's prayer times for one city from Aladhan (no key), the next prayer with a countdown, Gregorian and Hijri dates | [@majnioui](https://github.com/majnioui) | Xiaomi TV (MiTV-MOOR2), Google TV 11 | `INTERNET` |
-| [TV Static](tv-static/) | An off-the-air moment each time the screen turns on: the picture opens from a bright line, snow and hiss for 3 to 10 s, then fades into what was on screen; the card sets sound and length | [@luyzfernando08](https://github.com/luyzfernando08) | Xiaomi Mi Box S (Android TV 9), Philco by Skyworth (Android TV 14) | foreground service (screen-on watcher), start at boot, display over other apps |
+| [TV Static](tv-static/) | An off-the-air moment each time the screen turns on: the picture opens from a bright line, snow and hiss, colour bars or an old "no signal" screen for 3 to 10 s, then fades into what was on screen; the card sets style, sound and length | [@luyzfernando08](https://github.com/luyzfernando08) | Xiaomi Mi Box S (Android TV 9), Philco by Skyworth (Android TV 14) | foreground service (screen-on watcher), start at boot, display over other apps |
A widget, an info tile, a storage or smart-home card: if it can live as its own small app, it can live
here. See the rules below.
diff --git a/addons/tv-static/README.md b/addons/tv-static/README.md
index 549262688..0e5b9dd9a 100644
--- a/addons/tv-static/README.md
+++ b/addons/tv-static/README.md
@@ -14,10 +14,16 @@ Open the card (or the app's own tile). OK on a row changes it:
| Setting | Choices |
|---|---|
| Effect on wake | on (default), off |
+| Style | snow (default), colour bars, no signal, random |
| Sound | on (default), muted |
| Length | 3 s (default), 5 s, 10 s |
| Try it now | plays it once |
+The styles: **snow**, hard-edged static with a dark band rolling down and a hiss; **colour bars**, a 75% SMPTE
+test card with a 1 kHz tone; **no signal**, an old set's blue screen with a blocky on-screen display (a green
+"CH 03" in the corner, "NO SIGNAL" blinking in the middle, scan lines and dark tube corners), silent; and
+**random**, one of the three each time.
+
A TV with Android built in shows a picture as soon as it wakes, and 3 seconds is plenty. A box behind HDMI is
different: its screen turns on before the TV has switched itself on and over to that input. On a Mi Box S
the TV only showed a picture about seven seconds after the box woke, so there 10 seconds is the setting that
diff --git a/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/Prefs.java b/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/Prefs.java
index a8c9b8610..6149da576 100644
--- a/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/Prefs.java
+++ b/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/Prefs.java
@@ -10,6 +10,9 @@ final class Prefs {
/** A box behind HDMI can take several seconds to show a picture after waking; 10 s covers that. */
static final int[] SECONDS = {3, 5, 10};
+ static final int STYLE_SNOW = 0, STYLE_BARS = 1, STYLE_NO_SIGNAL = 2, STYLE_RANDOM = 3;
+ static final int STYLES = 4;
+
private static SharedPreferences prefs(Context ctx) {
return ctx.getSharedPreferences("settings", Context.MODE_PRIVATE);
}
@@ -26,6 +29,15 @@ final class Prefs {
return prefs(ctx).getInt("seconds", 3);
}
+ static int style(Context ctx) {
+ int style = prefs(ctx).getInt("style", STYLE_SNOW);
+ return style >= 0 && style < STYLES ? style : STYLE_SNOW;
+ }
+
+ static void setStyle(Context ctx, int value) {
+ prefs(ctx).edit().putInt("style", value).apply();
+ }
+
static void setEnabled(Context ctx, boolean value) {
prefs(ctx).edit().putBoolean("enabled", value).apply();
}
diff --git a/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/SettingsActivity.java b/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/SettingsActivity.java
index 5cb353d74..bf5b17ae4 100644
--- a/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/SettingsActivity.java
+++ b/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/SettingsActivity.java
@@ -16,7 +16,9 @@ import android.widget.TextView;
* without sound, how long it runs, and a button to try it now. Each row changes its value on OK.
*/
public class SettingsActivity extends Activity {
- private TextView enabled, sound, seconds;
+ private TextView enabled, style, sound, seconds;
+ private static final int[] STYLE_NAMES = {R.string.style_snow, R.string.style_bars, R.string.style_no_signal,
+ R.string.style_random};
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -45,6 +47,11 @@ public class SettingsActivity extends Activity {
Prefs.setEnabled(this, !Prefs.enabled(this));
refresh();
});
+ style = row(root);
+ style.setOnClickListener(v -> {
+ Prefs.setStyle(this, (Prefs.style(this) + 1) % Prefs.STYLES);
+ refresh();
+ });
sound = row(root);
sound.setOnClickListener(v -> {
Prefs.setSound(this, !Prefs.sound(this));
@@ -71,6 +78,7 @@ public class SettingsActivity extends Activity {
private void refresh() {
enabled.setText(getString(R.string.enabled_state,
getString(Prefs.enabled(this) ? R.string.on : R.string.off)));
+ style.setText(getString(R.string.style_state, getString(STYLE_NAMES[Prefs.style(this)])));
sound.setText(getString(R.string.sound_state,
getString(Prefs.sound(this) ? R.string.with_sound : R.string.without_sound)));
seconds.setText(getString(R.string.seconds_state, Prefs.seconds(this)));
diff --git a/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/StaticActivity.java b/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/StaticActivity.java
index aebb32d9c..f032b505e 100644
--- a/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/StaticActivity.java
+++ b/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/StaticActivity.java
@@ -16,18 +16,22 @@ public class StaticActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- StaticView view = new StaticView(this, Prefs.seconds(this), this::finish);
+ int style = Prefs.style(this);
+ if (style == Prefs.STYLE_RANDOM) style = new java.util.Random().nextInt(Prefs.STYLE_RANDOM);
+ StaticView view = new StaticView(this, Prefs.seconds(this), style, this::finish);
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
setContentView(view);
- hiss = Prefs.sound(this) ? makeHiss(view.snowMs) : null;
+ // Snow hisses, the bars hold a 1 kHz tone, "no signal" is silent.
+ hiss = Prefs.sound(this) && style != Prefs.STYLE_NO_SIGNAL
+ ? makeSound(view.snowMs, style == Prefs.STYLE_BARS) : null;
if (hiss != null) view.postDelayed(() -> {
if (hiss != null) hiss.play();
}, StaticView.OPEN_MS);
}
- /** White noise for the snow's length, shaped so it starts and dies away with the picture. */
- private static AudioTrack makeHiss(int snowMs) {
+ /** White noise, or a 1 kHz tone, for the picture's length, shaped to start and die away with it. */
+ private static AudioTrack makeSound(int snowMs, boolean tone) {
int samples = RATE * (snowMs + StaticView.FADE_MS) / 1000;
short[] pcm = new short[samples];
int fadeIn = RATE / 20, fadeOut = RATE * StaticView.FADE_MS / 1000;
@@ -36,10 +40,11 @@ public class StaticActivity extends Activity {
seed ^= seed << 13;
seed ^= seed >>> 7;
seed ^= seed << 17;
- float gain = 0.3f;
+ float gain = tone ? 0.2f : 0.3f;
if (i < fadeIn) gain *= i / (float) fadeIn;
if (i > samples - fadeOut) gain *= (samples - i) / (float) fadeOut;
- pcm[i] = (short) ((int) seed * gain / 65536f);
+ pcm[i] = tone ? (short) (32767 * gain * Math.sin(2 * Math.PI * 1000 * i / RATE))
+ : (short) ((int) seed * gain / 65536f);
}
try {
AudioTrack track = new AudioTrack.Builder()
diff --git a/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/StaticView.java b/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/StaticView.java
index fa4411ae8..caaf7bd3d 100644
--- a/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/StaticView.java
+++ b/addons/tv-static/app/src/main/java/io/github/luyzfernando08/tvstatic/StaticView.java
@@ -5,14 +5,18 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
+import android.graphics.RadialGradient;
+import android.graphics.Shader;
+import android.graphics.Typeface;
import android.graphics.Rect;
import android.os.SystemClock;
import android.view.View;
/**
- * Snow drawn into a small bitmap and stretched over the screen without smoothing, so each dot stays a hard
- * block like an analogue set's. Timeline: the tube opens from a bright line, snow with a slow rolling band,
- * then the snow fades and the window, translucent, shows what is underneath.
+ * An off-the-air picture in one of three styles: snow (a small bitmap stretched without smoothing, so each
+ * dot stays a hard block, with a slow rolling band), colour bars, or an old set's blue "no signal" screen.
+ * Timeline: the tube opens from a bright line, the picture holds, then it fades and the window, translucent,
+ * shows what is underneath.
*/
class StaticView extends View {
static final int OPEN_MS = 300;
@@ -21,18 +25,35 @@ class StaticView extends View {
/** Snow time: the chosen length less the opening and the fade. */
final int snowMs;
+ private final int style;
+ private final String noSignal, channel;
private final Runnable done;
private final Bitmap snow = Bitmap.createBitmap(W, H, Bitmap.Config.ARGB_8888);
private final int[] pixels = new int[W * H];
private final Paint paint = new Paint();
private final Paint fill = new Paint();
+ /** The "no signal" on-screen display, drawn small without anti-aliasing and blown up: blocky like a 90s set. */
+ private static final int OSD_W = 320, OSD_H = 180;
+ private Bitmap osdOn, osdOff;
+ private final Paint shade = new Paint();
+ private final Paint scan = new Paint();
private final Rect dst = new Rect();
+ private final Rect full = new Rect();
private long start;
private long seed = System.nanoTime() | 1;
private boolean finished;
- StaticView(Context context, int seconds, Runnable done) {
+ /** 75% colour bars, then the reversed strip and the bottom row of an SMPTE test card. */
+ private static final int[] BARS_TOP = {0xFFC0C0C0, 0xFFC0C000, 0xFF00C0C0, 0xFF00C000, 0xFFC000C0, 0xFFC00000, 0xFF0000C0};
+ private static final int[] BARS_MID = {0xFF0000C0, 0xFF131313, 0xFFC000C0, 0xFF131313, 0xFF00C0C0, 0xFF131313, 0xFFC0C0C0};
+ private static final int[] BARS_LOW = {0xFF00214C, 0xFFFFFFFF, 0xFF32006A, 0xFF131313, 0xFF090909, 0xFF131313, 0xFF1D1D1D};
+
+ StaticView(Context context, int seconds, int style, Runnable done) {
super(context);
+ this.style = style;
+ noSignal = context.getString(R.string.no_signal);
+ channel = context.getString(R.string.osd_channel);
+ scan.setColor(0x38000000);
snowMs = Math.max(500, seconds * 1000 - OPEN_MS - FADE_MS);
this.done = done;
paint.setFilterBitmap(false);
@@ -72,23 +93,93 @@ class StaticView extends View {
}
return;
}
- fillSnow(t);
+ if (style == Prefs.STYLE_SNOW) fillSnow(t);
+ full.set(0, 0, w, h);
if (t < OPEN_MS) {
// The tube opens: black, a bright line across the middle that grows into the picture.
canvas.drawColor(Color.BLACK);
float k = t / (float) OPEN_MS;
int half = Math.max(2, (int) (h / 2f * k * k));
dst.set(0, h / 2 - half, w, h / 2 + half);
- canvas.drawBitmap(snow, null, dst, paint);
+ canvas.save();
+ canvas.clipRect(dst);
+ drawPicture(canvas, 255);
+ canvas.restore();
fill.setColor(Color.argb((int) (220 * (1 - k)), 255, 255, 255));
canvas.drawRect(dst, fill);
} else {
int alpha = 255;
if (t > OPEN_MS + snowMs) alpha = (int) (255 * (1 - (t - OPEN_MS - snowMs) / (float) FADE_MS));
- paint.setAlpha(alpha);
- dst.set(0, 0, w, h);
- canvas.drawBitmap(snow, null, dst, paint);
+ drawPicture(canvas, alpha);
}
postInvalidateOnAnimation();
}
+
+ private void drawPicture(Canvas canvas, int alpha) {
+ int w = full.width(), h = full.height();
+ if (style == Prefs.STYLE_BARS) {
+ int top = h * 67 / 100, mid = h * 75 / 100;
+ drawRow(canvas, BARS_TOP, 0, top, w, alpha);
+ drawRow(canvas, BARS_MID, top, mid, w, alpha);
+ // Bottom row: four wide blocks (each 5/4 of a bar), then the three near-black PLUGE steps.
+ int x = 0, wide = w * 5 / 28;
+ for (int i = 0; i < BARS_LOW.length; i++) {
+ int right = i < 4 ? x + wide : (i == BARS_LOW.length - 1 ? w : x + (w - 4 * wide) / 3);
+ fill.setColor(BARS_LOW[i]);
+ fill.setAlpha(alpha);
+ canvas.drawRect(x, mid, right, h, fill);
+ x = right;
+ }
+ } else if (style == Prefs.STYLE_NO_SIGNAL) {
+ if (osdOn == null) makeOsd(w, h);
+ fill.setColor(0xFF1414A8);
+ fill.setAlpha(alpha);
+ canvas.drawRect(full, fill);
+ // The centre text blinks once a second, as the set's own message did.
+ paint.setAlpha(alpha);
+ canvas.drawBitmap(SystemClock.uptimeMillis() / 600 % 2 == 0 ? osdOn : osdOff, null, full, paint);
+ scan.setAlpha(alpha * 0x38 / 255);
+ for (int y = 0; y < h; y += 4) canvas.drawRect(0, y, w, y + 2, scan);
+ shade.setAlpha(alpha);
+ canvas.drawRect(full, shade);
+ } else {
+ paint.setAlpha(alpha);
+ canvas.drawBitmap(snow, null, full, paint);
+ }
+ }
+
+ private void drawRow(Canvas canvas, int[] colors, int top, int bottom, int w, int alpha) {
+ for (int i = 0; i < colors.length; i++) {
+ fill.setColor(colors[i]);
+ fill.setAlpha(alpha);
+ canvas.drawRect(w * i / colors.length, top, w * (i + 1) / colors.length, bottom, fill);
+ }
+ }
+
+ /** Two OSD frames (with and without the centre text) and the dark corners of a curved tube. */
+ private void makeOsd(int w, int h) {
+ osdOn = Bitmap.createBitmap(OSD_W, OSD_H, Bitmap.Config.ARGB_8888);
+ osdOff = Bitmap.createBitmap(OSD_W, OSD_H, Bitmap.Config.ARGB_8888);
+ Paint p = new Paint(); // no anti-aliasing: hard pixel edges
+ p.setTypeface(Typeface.create(Typeface.MONOSPACE, Typeface.BOLD));
+ for (Bitmap b : new Bitmap[]{osdOn, osdOff}) {
+ Canvas c = new Canvas(b);
+ p.setTextAlign(Paint.Align.LEFT);
+ p.setTextSize(14);
+ p.setColor(0xFF000000);
+ c.drawText(channel, 17, 25, p);
+ p.setColor(0xFF4CFF4C);
+ c.drawText(channel, 16, 24, p);
+ if (b == osdOn) {
+ p.setTextAlign(Paint.Align.CENTER);
+ p.setTextSize(26);
+ p.setColor(0xFF000000);
+ c.drawText(noSignal, OSD_W / 2f + 2, OSD_H / 2f + 11, p);
+ p.setColor(0xFFFFFFFF);
+ c.drawText(noSignal, OSD_W / 2f, OSD_H / 2f + 9, p);
+ }
+ }
+ shade.setShader(new RadialGradient(w / 2f, h / 2f, (float) Math.hypot(w, h) / 2f,
+ new int[]{0x00000000, 0x00000000, 0xB0000000}, new float[]{0f, 0.55f, 1f}, Shader.TileMode.CLAMP));
+ }
}
diff --git a/addons/tv-static/app/src/main/res/values-pt/strings.xml b/addons/tv-static/app/src/main/res/values-pt/strings.xml
index 97fc339ae..250a316d1 100644
--- a/addons/tv-static/app/src/main/res/values-pt/strings.xml
+++ b/addons/tv-static/app/src/main/res/values-pt/strings.xml
@@ -7,6 +7,13 @@
<string name="sound_state">Som: %1$s</string>
<string name="seconds_state">Duração: %1$d segundos</string>
<string name="test">Testar agora</string>
+ <string name="style_state">Estilo: %1$s</string>
+ <string name="style_snow">chiado</string>
+ <string name="style_bars">barras coloridas</string>
+ <string name="style_no_signal">sem sinal</string>
+ <string name="style_random">aleatório</string>
+ <string name="no_signal">SEM SINAL</string>
+ <string name="osd_channel">CANAL 03</string>
<string name="on">ligado</string>
<string name="off">desligado</string>
<string name="with_sound">com som</string>
diff --git a/addons/tv-static/app/src/main/res/values/values.xml b/addons/tv-static/app/src/main/res/values/values.xml
index 434c4ee72..722c9bff3 100644
--- a/addons/tv-static/app/src/main/res/values/values.xml
+++ b/addons/tv-static/app/src/main/res/values/values.xml
@@ -2,11 +2,18 @@
<resources>
<string name="app_name">TV Static</string>
<string name="watching">Static when the TV turns on</string>
- <string name="hint">An off-the-air screen whenever the screen turns on. Any key ends it.</string>
+ <string name="hint">An off-the-air moment whenever the screen turns on. Any key ends it.</string>
<string name="enabled_state">Effect on wake: %1$s</string>
<string name="sound_state">Sound: %1$s</string>
<string name="seconds_state">Length: %1$d seconds</string>
<string name="test">Try it now</string>
+ <string name="style_state">Style: %1$s</string>
+ <string name="style_snow">snow</string>
+ <string name="style_bars">colour bars</string>
+ <string name="style_no_signal">no signal</string>
+ <string name="style_random">random</string>
+ <string name="no_signal">NO SIGNAL</string>
+ <string name="osd_channel">CH 03</string>
<string name="on">on</string>
<string name="off">off</string>
<string name="with_sound">on</string>