mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-02-07 06:12:56 -05:00
refactor: Use device address to manage service lifecycle (#4251)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
@@ -134,7 +134,7 @@ class MeshService : Service() {
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
val a = radioInterfaceService.getBondedDeviceAddress()
|
||||
val a = radioInterfaceService.getDeviceAddress()
|
||||
val wantForeground = a != null && a != NO_DEVICE_SELECTED
|
||||
|
||||
val notification = connectionManager.updateStatusNotification()
|
||||
@@ -159,6 +159,7 @@ class MeshService : Service() {
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
return if (!wantForeground) {
|
||||
Logger.i { "Stopping mesh service because no device is selected" }
|
||||
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
|
||||
stopSelf()
|
||||
START_NOT_STICKY
|
||||
@@ -167,6 +168,11 @@ class MeshService : Service() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onTaskRemoved(rootIntent: Intent?) {
|
||||
super.onTaskRemoved(rootIntent)
|
||||
Logger.i { "Mesh service: onTaskRemoved" }
|
||||
}
|
||||
|
||||
override fun onBind(intent: Intent?): IBinder = binder
|
||||
|
||||
override fun onDestroy() {
|
||||
|
||||
Reference in New Issue
Block a user