package com.sptmobile.link import android.content.BroadcastReceiver import android.content.Context import android.content.Intent // [impl->REQ-HAZARD-RECEIVER-DOWN] /** * Re-arms the device link + webhook receiver after a reboot. The foreground * service ([LinkService]) is what hosts the localhost webhook receiver; a * reboot tears it down and — without this — nothing restarts it until the * user next opens the app, so a Pebble dictation posted post-reboot hits * ECONNREFUSED and is lost (field-observed 2026-07-07, Motorola razr+). * * START_STICKY (LinkService.onStartCommand) already covers OS-reclaim * restarts; this closes the *reboot* hole specifically. Starting an FGS from * a boot receiver is legal because `dataSync` is a permitted post-boot FGS * type. */ class BootReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent?) { if (shouldStart(intent?.action)) { LinkService.start(context) } } companion object { /** OEM fast-boot (Moto/HTC) skips the standard BOOT_COMPLETED. */ const val ACTION_QUICKBOOT_POWERON = "android.intent.action.QUICKBOOT_POWERON" /** * Boot-broadcast filter, factored out of [onReceive] so the trigger * set is JVM-testable without a live [Context] (Android framework * classes are stubbed under unit test). */ fun shouldStart(action: String?): Boolean = action == Intent.ACTION_BOOT_COMPLETED || action == ACTION_QUICKBOOT_POWERON } }