refactor(service): Simplify boot-time service startup (#3730)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2025-11-18 12:42:20 -06:00 committed by GitHub
parent f84747cea6
commit bdf9dc375b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 41 deletions

View file

@ -21,13 +21,18 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
/** This receiver starts the MeshService on boot if a device was previously connected. */
class BootCompleteReceiver : BroadcastReceiver() {
override fun onReceive(mContext: Context, intent: Intent) {
// Verify the intent action
override fun onReceive(context: Context, intent: Intent) {
if (Intent.ACTION_BOOT_COMPLETED != intent.action) {
return
}
// start listening for bluetooth messages from our device
MeshService.startServiceLater(mContext)
val prefs = context.getSharedPreferences("mesh-prefs", Context.MODE_PRIVATE)
if (!prefs.contains("device_address")) {
return
}
MeshService.startService(context)
}
}