Clarify blocked camera suite and trace native calls with default preview baseline

This commit is contained in:
zenord
2026-10-13 19:55:23 +08:00
parent 8cf7d7316c
commit c3fe22b8bf
12 changed files with 366 additions and 118 deletions
+6 -4
View File
@@ -20,16 +20,18 @@ object CameraClock {
@Volatile var now=0L
private data class Task(val h: Handler,val r: Runnable,val due: Long,val order: Long)
private val tasks=java.util.PriorityQueue<Task>(compareBy<Task> {it.due}.thenBy {it.order})
var paused=mutableSetOf<Handler>()
var pausedLoopers=mutableSetOf<Looper>()
private var serial=0L
@Synchronized fun add(h: Handler,r: Runnable,ms: Long) {tasks.add(Task(h,r,now+ms,serial++))}
@Synchronized fun remove(h: Handler,r: Runnable) {tasks.removeIf {it.h===h && it.r===r}}
@Synchronized fun reset() {tasks.clear();now=0;serial=0}
@Synchronized fun reset() {tasks.clear();paused.clear();pausedLoopers.clear();now=0;serial=0}
fun advance(ms: Long=0) {
val end=now+ms
while(true) {
val task=synchronized(this) {if(tasks.peek()?.due?.let {it<=end}==true) tasks.poll() else null} ?: break
now=task.due;task.r.run()
};now=end
val task=synchronized(this) {tasks.filter {it.due<=end && it.h !in paused && it.h.looper !in pausedLoopers}.minWithOrNull(compareBy<Task> {it.due}.thenBy {it.order})?.also {tasks.remove(it)}} ?: break
now=maxOf(now,task.due);task.r.run()
};now=maxOf(now,end)
}
fun await(condition: ()->Boolean) {
val deadline=System.nanoTime()+3_000_000_000