Restore Android core activity after internal restart

This commit is contained in:
evgeny committed 2026-10-25 17:20:42 +01:00
1 parent c26b626c35
commit f276fda411
2 files changed
+11 -1

No files matched your search

@@ -32,7 +32,10 @@ object AppEventHandler : ChatEventCallback {
val events: SharedFlow<Pair<Int, ByteArray?>> = _events
override fun onEvent(type: Int, data: ByteArray?) {
if (type == 12) mainHandler.post { com.utun.chat.data.PhoneStateMonitor.refresh() }
if (type == 12) mainHandler.post {
com.utun.chat.data.CoreActivity.onCoreStarted()
com.utun.chat.data.PhoneStateMonitor.refresh()
}
if (type == 12 || type == 13 || type == 65)
mainHandler.post { com.utun.chat.data.RadioCallController.onEvent(type, data) }
if (type == 13 || type in 61..64) mainHandler.post { com.utun.chat.data.LocalDiscovery.onEvent(type, data) }
@@ -14,6 +14,13 @@ object CoreActivity {
fun radioCall(value: Boolean) { radioCall = value; sync() }
fun transfer(value: Boolean) { transfer = value; sync() }
fun reset() { applied = null }
/** Новый экземпляр ядра ещё не получал состояние владельцев активности. */
fun onCoreStarted() {
check(Looper.myLooper() == Looper.getMainLooper())
applied = null
LogManager.addLog("INFO", "Activity", "core started; resynchronizing activity")
sync()
}
fun sync() {
check(Looper.myLooper() == Looper.getMainLooper())
if (!NativeLib.isReady()) { applied = null; return }