Clarify Android build modules and handle rejected boot service requests

This commit is contained in:
evgeny committed 2026-10-29 13:34:25 +01:00
1 parent 38e87ecff9
commit 09da244c41
3 files changed
+8 -4

No files matched your search

@@ -10,7 +10,9 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
/** BOOT_COMPLETED приходит после разблокировки, когда настройки и БД уже доступны. */
/** BOOT_COMPLETED после разблокировки: goAsync удерживает broadcast до чтения DataStore и запроса FGS.
* shouldStartOnBoot требует завершённого setup, включённых service/autostart; PendingResult завершается во всех ветках.
*/
class BootReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action != Intent.ACTION_BOOT_COMPLETED) {
@@ -19,17 +21,17 @@ class BootReceiver : BroadcastReceiver() {
}
LogManager.addLog("INFO", "BOOT", "Boot completed broadcast received")
val pending = goAsync()
val appContext = context.applicationContext
CoroutineScope(Dispatchers.IO).launch {
try {
if (!ChatApplication.instance.configProvider.shouldStartOnBoot()) return@launch
val appContext = context.applicationContext
val serviceIntent = Intent(appContext, HeadlessService::class.java).setAction(Intent.ACTION_BOOT_COMPLETED)
ContextCompat.startForegroundService(appContext, serviceIntent)
checkNotNull(ContextCompat.startForegroundService(appContext, serviceIntent)) { "Boot foreground service not found" }
LogManager.addLog("INFO", "BOOT", "Boot service start requested: service=${HeadlessService::class.java.name}")
} catch (e: Exception) {
LogManager.addLog("ERROR", "BOOT", "Boot service start failed: $e")
} finally {
pending.finish()
try { pending.finish() } catch (e: Exception) { LogManager.addLog("ERROR", "BOOT", "Boot broadcast finish failed: $e") }
}
}
}
@@ -1,3 +1,4 @@
// Отдельный Java/AAudio APK для измерений arm64 (API 28+); не линкует основное ядро libutun.
plugins { id("com.android.application") }
android {
+1
View File
@@ -1,3 +1,4 @@
// Общие версии плагинов; app и отдельный audio-probe включают Android plugin в своих модулях, JVM harness — kotlin.jvm.
plugins {
id("com.android.application") version "8.13.2" apply false
id("org.jetbrains.kotlin.android") version "2.2.20" apply false