Fixed auto start setting disabled not working when foreground service setting is enabled
This commit is contained in:
parent
cf97a83651
commit
0620ef82d0
1 changed files with 11 additions and 0 deletions
|
@ -23,6 +23,7 @@ import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
|
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
import org.linphone.compatibility.Compatibility
|
import org.linphone.compatibility.Compatibility
|
||||||
|
@ -35,12 +36,16 @@ class BootReceiver : BroadcastReceiver() {
|
||||||
Log.i("[Boot Receiver] Device is starting, autoStart is $autoStart")
|
Log.i("[Boot Receiver] Device is starting, autoStart is $autoStart")
|
||||||
if (autoStart) {
|
if (autoStart) {
|
||||||
startService(context)
|
startService(context)
|
||||||
|
} else {
|
||||||
|
stopService()
|
||||||
}
|
}
|
||||||
} else if (intent.action.equals(Intent.ACTION_MY_PACKAGE_REPLACED, ignoreCase = true)) {
|
} else if (intent.action.equals(Intent.ACTION_MY_PACKAGE_REPLACED, ignoreCase = true)) {
|
||||||
val autoStart = corePreferences.autoStart
|
val autoStart = corePreferences.autoStart
|
||||||
Log.i("[Boot Receiver] App has been updated, autoStart is $autoStart")
|
Log.i("[Boot Receiver] App has been updated, autoStart is $autoStart")
|
||||||
if (autoStart) {
|
if (autoStart) {
|
||||||
startService(context)
|
startService(context)
|
||||||
|
} else {
|
||||||
|
stopService()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,4 +62,10 @@ class BootReceiver : BroadcastReceiver() {
|
||||||
serviceIntent.putExtra("StartForeground", true)
|
serviceIntent.putExtra("StartForeground", true)
|
||||||
Compatibility.startForegroundService(context, serviceIntent)
|
Compatibility.startForegroundService(context, serviceIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun stopService() {
|
||||||
|
Log.i("[Boot Receiver] Auto start setting is disabled, stopping foreground service")
|
||||||
|
coreContext.notificationsManager.stopForegroundNotification()
|
||||||
|
coreContext.stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue