diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cb1638d3..06fcc033 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -46,7 +46,6 @@ - diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/service/BootReceiver.kt b/app/src/main/java/com/greenart7c3/nostrsigner/service/BootReceiver.kt index b0c5e338..6242229a 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/service/BootReceiver.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/service/BootReceiver.kt @@ -3,11 +3,10 @@ package com.greenart7c3.nostrsigner.service import android.content.BroadcastReceiver import android.content.Context import android.content.Intent -import android.os.Build import android.util.Log import com.greenart7c3.nostrsigner.Amber import com.greenart7c3.nostrsigner.BuildFlavorChecker -import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch class BootReceiver : BroadcastReceiver() { @@ -16,32 +15,11 @@ class BootReceiver : BroadcastReceiver() { Log.d(Amber.TAG, "Received intent: ${intent.action}") when (intent.action) { - Intent.ACTION_PACKAGE_REPLACED -> { - Log.d(Amber.TAG, "Received ACTION_PACKAGE_REPLACED") - if (intent.dataString?.contains("com.greenart7c3.nostrsigner") == true && Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { - Amber.instance.applicationIOScope.launch { - while (Amber.instance.isStartingAppState.value) { - delay(1000) - } - Amber.instance.startService() - } - } - } - Intent.ACTION_MY_PACKAGE_REPLACED -> { - Log.d(Amber.TAG, "Received ACTION_MY_PACKAGE_REPLACED") - Amber.instance.applicationIOScope.launch { - while (Amber.instance.isStartingAppState.value) { - delay(1000) - } - Amber.instance.startService() - } - } + Intent.ACTION_MY_PACKAGE_REPLACED, Intent.ACTION_BOOT_COMPLETED -> { - Log.d(Amber.TAG, "Received ACTION_BOOT_COMPLETED") + Log.d(Amber.TAG, "Received ${intent.action}") Amber.instance.applicationIOScope.launch { - while (Amber.instance.isStartingAppState.value) { - delay(1000) - } + Amber.instance.isStartingAppState.first { !it } Amber.instance.startService() } }