Model partial wake lock and notification cleanup failures

This commit is contained in:
evgeny committed 2026-10-28 14:43:27 +01:00
1 parent 3a6ef25ca6
commit f4cfe5ba30
2 files changed
+10 -1

No files matched your search

@@ -59,11 +59,13 @@ class NotificationManager {
if ("security" in failures) throw SecurityException("notify denied")
active[id] = notification
posted.add(notification)
check("notify_after" !in failures) { "notification publish failed after effect" }
}
fun cancel(id: Int) {
cancellations.add(id)
check("cancel" !in failures) { "notification cancel unavailable" }
active.remove(id)
check("cancel_after" !in failures) { "notification cancel failed after effect" }
}
}
@@ -95,6 +97,7 @@ class PendingIntent private constructor(val kind: String, val requestCode: Int,
}
private var intent = Intent(intent)
var failCancel = false
var failCancelAfter = false
var cancelled = false
private set
var cancelCalls = 0
@@ -104,5 +107,6 @@ class PendingIntent private constructor(val kind: String, val requestCode: Int,
cancelCalls++
check(!failCancel) { "pending intent cancel unavailable" }
cancelled = true
check(!failCancelAfter) { "pending intent cancel failed after effect" }
}
}
@@ -26,10 +26,14 @@ class PowerManager {
var releaseCalls = 0
var held = false
val isHeld: Boolean get() { check("query" !in failures) { "wake lock query unavailable" }; return held }
fun setReferenceCounted(value: Boolean) { counted = value }
fun setReferenceCounted(value: Boolean) {
check("configure" !in failures) { "wake lock configure unavailable" }
counted = value
}
fun acquire() = acquire(0)
fun acquire(timeout: Long) {
this.timeout = timeout
check("acquire_before" !in failures) { "wake lock acquire before effect" }
held = true
check("acquire" !in failures) { "wake lock acquire unavailable" }
}
@@ -37,6 +41,7 @@ class PowerManager {
releaseCalls++
check("release" !in failures) { "wake lock release unavailable" }
held = false
check("release_after" !in failures) { "wake lock release failed after effect" }
}
}
}