mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-05 19:08:23 +00:00
If the app was updated try to start the service again
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user