Model native file failures and wake lock ownership on host
This commit is contained in:
1 parent
529237dfc8
commit
f60390c99c
3 files changed
+22
-2
No files matched your search
@@ -2,18 +2,22 @@ package android.os
|
||||
|
||||
/** Host wake lock: тест различает отказ до acquire, после побочного эффекта и освобождение по timeout. */
|
||||
class PowerManager {
|
||||
companion object { const val SCREEN_BRIGHT_WAKE_LOCK = 10; const val ACQUIRE_CAUSES_WAKEUP = 0x10000000; const val ON_AFTER_RELEASE = 0x20000000 }
|
||||
companion object {
|
||||
const val PARTIAL_WAKE_LOCK = 1; const val SCREEN_BRIGHT_WAKE_LOCK = 10
|
||||
const val ACQUIRE_CAUSES_WAKEUP = 0x10000000; const val ON_AFTER_RELEASE = 0x20000000
|
||||
}
|
||||
var failures = emptySet<String>()
|
||||
val locks = mutableListOf<WakeLock>()
|
||||
fun newWakeLock(flags: Int, tag: String): WakeLock {
|
||||
check("create" !in failures) { "wake lock creation unavailable" }
|
||||
return WakeLock(flags, tag, failures).also { locks.add(it) }
|
||||
}
|
||||
class WakeLock(val flags: Int, val tag: String, private val failures: Set<String>) {
|
||||
class WakeLock(val flags: Int, val tag: String, var failures: Set<String>) {
|
||||
var timeout = 0L
|
||||
var releaseCalls = 0
|
||||
var held = false
|
||||
val isHeld: Boolean get() { check("query" !in failures) { "wake lock query unavailable" }; return held }
|
||||
fun acquire() = acquire(0)
|
||||
fun acquire(timeout: Long) {
|
||||
this.timeout = timeout
|
||||
held = true
|
||||
|
||||
@@ -16,5 +16,7 @@ object R {
|
||||
const val incoming_calls = 101; const val incoming_call_notification = 102; const val radio_call_incoming = 103
|
||||
const val incoming_call = 104; const val decline = 105; const val hang_up = 106; const val accept = 107
|
||||
const val media_audio_fallback = 108; const val media_audio_failed = 109
|
||||
const val files_preparing = 201; const val files_transferring = 202; const val files_completed = 203
|
||||
const val files_cancelled = 204; const val files_failed = 205; const val files_replace_title = 206; const val files_saving = 207
|
||||
}
|
||||
}
|
||||
+14
@@ -34,6 +34,20 @@ object LogManager {
|
||||
|
||||
/** Только host-тест: считает уведомления standby, не загружает JNI и не запускает ядро. */
|
||||
object NativeLib {
|
||||
data class FileTransfer(val id: Long, val group: Long, val server: Long, val owner: Long,
|
||||
val remote: String, val local: String, val upload: Boolean, val version: ByteArray)
|
||||
var fileRequest: (Long, Long, ByteArray) -> Boolean = { _, _, _ -> true }
|
||||
var acceptFileTransfer = true
|
||||
val fileTransfers = mutableListOf<FileTransfer>()
|
||||
val fileCancels = mutableListOf<Long>()
|
||||
fun getMyNodeId() = 1L
|
||||
fun fileRequest(group: Long, server: Long, wire: ByteArray) = fileRequest.invoke(group, server, wire)
|
||||
fun fileTransfer(id: Long, group: Long, server: Long, owner: Long, remote: String, local: String,
|
||||
upload: Boolean, version: ByteArray): Boolean {
|
||||
fileTransfers.add(FileTransfer(id, group, server, owner, remote, local, upload, version.copyOf()))
|
||||
return acceptFileTransfer
|
||||
}
|
||||
fun fileCancel(id: Long): Boolean { fileCancels.add(id); return true }
|
||||
val networkNotifications = AtomicInteger()
|
||||
var ready = true
|
||||
var acceptSocketUpdate = true
|
||||
|
||||
Reference in new issue
Block a user