diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index da4c9352..5dd11e1f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -35,6 +35,7 @@ + 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 6c39e191..a2dce3d5 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/service/BootReceiver.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/service/BootReceiver.kt @@ -3,6 +3,7 @@ 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.BuildConfig @@ -11,8 +12,30 @@ class BootReceiver : BroadcastReceiver() { @Suppress("KotlinConstantConditions") if (BuildConfig.FLAVOR == "offline") return + if (intent.action == Intent.ACTION_PACKAGE_REPLACED && Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { + if (intent.dataString?.contains("com.greenart7c3.nostrsigner") == true) { + Log.d("BootReceiver", "Starting ConnectivityService ACTION_PACKAGE_REPLACED") + context.startForegroundService( + Intent( + context, + ConnectivityService::class.java, + ), + ) + } + } + + if (intent.action == Intent.ACTION_MY_PACKAGE_REPLACED) { + Log.d("BootReceiver", "Starting ConnectivityService ACTION_MY_PACKAGE_REPLACED") + context.startForegroundService( + Intent( + context, + ConnectivityService::class.java, + ), + ) + } + if (intent.action == Intent.ACTION_BOOT_COMPLETED) { - Log.d("BootReceiver", "Starting ConnectivityService") + Log.d("BootReceiver", "Starting ConnectivityService ACTION_BOOT_COMPLETED") context.startForegroundService( Intent( context,