mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-05 19:08:23 +00:00
refactor BootReceiver
This commit is contained in:
@@ -4,7 +4,6 @@ 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
|
||||
|
||||
class BootReceiver : BroadcastReceiver() {
|
||||
@@ -12,9 +11,26 @@ 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")
|
||||
when (intent.action) {
|
||||
Intent.ACTION_PACKAGE_REPLACED -> {
|
||||
if (intent.dataString?.contains("com.greenart7c3.nostrsigner") == true && Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
|
||||
context.startForegroundService(
|
||||
Intent(
|
||||
context,
|
||||
ConnectivityService::class.java,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
Intent.ACTION_MY_PACKAGE_REPLACED -> {
|
||||
context.startForegroundService(
|
||||
Intent(
|
||||
context,
|
||||
ConnectivityService::class.java,
|
||||
),
|
||||
)
|
||||
}
|
||||
Intent.ACTION_BOOT_COMPLETED -> {
|
||||
context.startForegroundService(
|
||||
Intent(
|
||||
context,
|
||||
@@ -23,25 +39,5 @@ class BootReceiver : BroadcastReceiver() {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
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 ACTION_BOOT_COMPLETED")
|
||||
context.startForegroundService(
|
||||
Intent(
|
||||
context,
|
||||
ConnectivityService::class.java,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user