Skip to content

Commit a06cf95

Browse files
committed
Also start on boot for QUICKBOOT_POWERON
Many cheap MediaTek-based car head units suspend/resume on an ignition cycle rather than doing a full Linux reboot, and fire this legacy broadcast instead of (or alongside) BOOT_COMPLETED.
1 parent 186f516 commit a06cf95

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
android:exported="true">
5151
<intent-filter>
5252
<action android:name="android.intent.action.BOOT_COMPLETED" />
53+
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
5354
</intent-filter>
5455
</receiver>
5556

app/src/main/java/com/sleepbutton/app/BootReceiver.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,23 @@ import android.content.Context
55
import android.content.Intent
66
import android.os.Build
77

8-
/** Auto-starts the floating button after boot, if both permissions are already granted. */
8+
/**
9+
* Auto-starts the floating button after boot, if both permissions are already granted.
10+
*
11+
* Also listens for QUICKBOOT_POWERON: many cheap MediaTek-based car head units don't do a full
12+
* Linux reboot on an ignition cycle, they suspend/resume, and fire this instead of (or in
13+
* addition to) BOOT_COMPLETED.
14+
*/
915
class BootReceiver : BroadcastReceiver() {
1016

17+
companion object {
18+
private const val ACTION_QUICKBOOT_POWERON = "android.intent.action.QUICKBOOT_POWERON"
19+
}
20+
1121
override fun onReceive(context: Context, intent: Intent) {
12-
if (intent.action != Intent.ACTION_BOOT_COMPLETED) return
22+
if (intent.action != Intent.ACTION_BOOT_COMPLETED &&
23+
intent.action != ACTION_QUICKBOOT_POWERON
24+
) return
1325
if (!PermissionUtils.hasAllPermissions(context)) return
1426

1527
val serviceIntent = Intent(context, FloatingButtonService::class.java)

0 commit comments

Comments
 (0)