fix(android): implement proper boot receiver with Direct Boot support

- Add android:exported="true" for API 31+ compatibility
- Add android:directBootAware="true" for Direct Boot handling
- Add LOCKED_BOOT_COMPLETED action for early boot recovery
- Remove PACKAGE_REPLACED action (not needed for our use case)
- Implement handleLockedBootCompleted() for Direct Boot safety
- Use device protected storage context for Direct Boot operations
- Add comprehensive logging for boot receiver events

This fixes Android 10+ boot receiver restrictions and ensures
notifications are restored after device reboots and app updates.
This commit is contained in:
Matthew Raymer
2025-10-14 06:16:36 +00:00
parent 9b9dc25a8d
commit c42814e60b
2 changed files with 179 additions and 5 deletions

View File

@@ -26,19 +26,26 @@
<!-- Daily Notification Plugin Receivers -->
<receiver
android:name="com.timesafari.dailynotification.NotifyReceiver"
android:name="com.timesafari.dailynotification.DailyNotificationReceiver"
android:enabled="true"
android:exported="false" />
android:exported="false">
<intent-filter>
<action android:name="com.timesafari.daily.NOTIFICATION" />
</intent-filter>
</receiver>
<receiver
android:name="com.timesafari.dailynotification.BootReceiver"
android:enabled="true"
android:exported="true">
android:exported="true"
android:directBootAware="true">
<intent-filter android:priority="1000">
<!-- Delivered very early after reboot (before unlock) -->
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
<!-- Delivered after the user unlocks / credential-encrypted storage is available -->
<action android:name="android.intent.action.BOOT_COMPLETED" />
<!-- Delivered after app update; great for rescheduling alarms without reboot -->
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
</receiver>