Report unavailable core accurately and include malformed radio event fields
This commit is contained in:
1 parent
16a9bee8f3
commit
6ee4aa99eb
1 file changed
+10
-5
@@ -60,9 +60,11 @@ object RadioCallController {
|
||||
/** На main запросить START с ненулевыми ID канала и участника. Busy снимает первое событие либо reset/отказ очереди. */
|
||||
fun start(channel: String, peer: Long) {
|
||||
checkMain()
|
||||
if (!ready || !NativeLib.isReady() || busy() || CallController.state.value?.ongoing == true) {
|
||||
LogManager.addLog("WARN", "radio", "Call start unavailable core=$ready busy=${busy()}")
|
||||
showOutcome(3); return
|
||||
val nativeReady = NativeLib.isReady()
|
||||
val phoneCall = CallController.state.value?.ongoing == true
|
||||
if (!ready || !nativeReady || busy() || phoneCall) {
|
||||
LogManager.addLog("WARN", "radio", "Call start unavailable core=$ready native=$nativeReady busy=${busy()} phoneCall=$phoneCall")
|
||||
showOutcome(if (ready && nativeReady) 3 else 5); return
|
||||
}
|
||||
val group = channel.toULongOrNull()?.toLong()
|
||||
if (group == null || group == 0L || peer == 0L) {
|
||||
@@ -164,7 +166,9 @@ object RadioCallController {
|
||||
if (type == 13) { reset(); return }
|
||||
if (type != 65 || !ready || !NativeLib.isReady()) return
|
||||
if (data == null || data.size != 27 || data[24].toInt() !in 1..5 || data[25].toInt() !in 0..9 || data[26].toInt() !in 0..1) {
|
||||
LogManager.addLog("ERROR", "radio", "Invalid call event size=${data?.size}"); return
|
||||
LogManager.addLog("ERROR", "radio", "Invalid call event size=${data?.size} phase=${data?.getOrNull(24)?.toUByte()} " +
|
||||
"reason=${data?.getOrNull(25)?.toUByte()} incoming=${data?.getOrNull(26)?.toUByte()}")
|
||||
return
|
||||
}
|
||||
val buf = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN)
|
||||
val id = buf.long; val group = buf.long; val peer = buf.long
|
||||
@@ -290,7 +294,8 @@ object RadioCallController {
|
||||
val text = AppLanguage.text(reasonText(reason))
|
||||
if (visible) { Toast.makeText(ctx, text, Toast.LENGTH_LONG).show(); return }
|
||||
IncomingCallManager.init()
|
||||
requireNotNull(ctx.getSystemService(NotificationManager::class.java)) { "notification manager unavailable" }.notify(RESULT_NOTIFICATION_ID,
|
||||
val manager = requireNotNull(ctx.getSystemService(NotificationManager::class.java)) { "notification manager unavailable" }
|
||||
manager.notify(RESULT_NOTIFICATION_ID,
|
||||
NotificationCompat.Builder(ctx, IncomingCallManager.CHANNEL_CALL)
|
||||
.setSmallIcon(android.R.drawable.ic_dialog_info).setContentTitle(AppLanguage.text(R.string.radio_call))
|
||||
.setContentText(text).setAutoCancel(true).build())
|
||||
|
||||
Reference in new issue
Block a user