Skip to content

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

feat(sleep-timer): define bounded monotonic deadlines for power requests

TeenKodeb5e401a03a1c
diff --git a/addons/sleep-timer/app/src/main/java/io/github/luyzfernando08/sleeptimer/PowerDeadline.java b/addons/sleep-timer/app/src/main/java/io/github/luyzfernando08/sleeptimer/PowerDeadline.java
new file mode 100644
index 000000000..9c614803c
--- /dev/null
+++ b/addons/sleep-timer/app/src/main/java/io/github/luyzfernando08/sleeptimer/PowerDeadline.java
@@ -0,0 +1,14 @@
+package io.github.luyzfernando08.sleeptimer;
+
+/** A client and its Shizuku user service share Android's elapsed-realtime clock. */
+final class PowerDeadline {
+ static final long TIMEOUT_MS = 9_000L;
+
+ private PowerDeadline() { }
+
+ /** Refuse expired or implausibly distant deadlines, including arithmetic overflow. */
+ static boolean active(long deadlineElapsedMs, long nowElapsedMs) {
+ long remaining = deadlineElapsedMs - nowElapsedMs;
+ return remaining > 0 && remaining <= TIMEOUT_MS;
+ }
+}