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:
James Rich 2026-01-17 19:54:13 -06:00 committed by GitHub
parent cf48d6c1c1
commit a41856319c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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() {