# Reboot Testing Steps for DailyNotification Plugin ## ๐ŸŽฏ **Objective** Test that scheduled notifications survive device reboots and are properly restored by the BootReceiver. ## โฐ **Extended Testing Time** - **Notification Delay**: 5 minutes (instead of 1 minute) - **More Realistic**: Allows time for proper testing and verification - **Better for Reboot Testing**: Gives time to reboot and verify recovery ## ๐Ÿ”„ **Complete Reboot Testing Procedure** ### **Step 1: Schedule Notification** ```bash # Launch app adb shell am start -n com.timesafari.dailynotification/.MainActivity ``` - Tap **"Test Notification"** button - Verify message: **"Notification scheduled for [time]! Check your notification bar in 5 minutes."** - **Note the scheduled time** (5 minutes from now) ### **Step 2: Verify Initial Scheduling** ```bash # Check scheduled alarms adb shell "dumpsys alarm | grep timesafari" ``` - Should show scheduled alarm with correct timestamp - Note the alarm details ### **Step 3: Reboot Device** ```bash # Reboot device adb reboot ``` - **Wait 2-3 minutes** for device to fully boot - Wait for boot animation to complete - Wait for home screen to appear ### **Step 4: Verify Boot Recovery** ```bash # Check recovery logs adb logcat -d | grep -i "bootreceiver\|recovery" ``` **Look for these log messages:** - `"Device boot completed - restoring notifications"` - `"Found X notifications to recover"` - `"Notification recovery completed: X/X recovered"` ### **Step 5: Verify Alarm Restoration** ```bash # Check if alarm was restored adb shell "dumpsys alarm | grep timesafari" ``` - Should show the same scheduled alarm as before reboot - Alarm timestamp should match original schedule ### **Step 6: Wait for Notification** - **Wait for the originally scheduled time** (5 minutes from when you scheduled it) - **Check notification panel** for the test notification - **Verify notification appears** with correct content ## ๐Ÿงช **Automated Reboot Test** ### **Run the Reboot Test Script:** ```bash # Run automated reboot test ./scripts/reboot-test.sh ``` **What the script does:** 1. โœ… Checks boot receiver registration 2. ๐Ÿ“… Prompts you to schedule notification 3. ๐Ÿ” Verifies initial scheduling 4. ๐Ÿ”„ Reboots device automatically 5. โณ Waits for boot completion 6. ๐Ÿ” Checks recovery logs 7. โฐ Verifies alarm restoration 8. ๐ŸŽ‰ Reports success/failure ## ๐Ÿ” **Key Log Messages to Look For** ### **Successful Recovery:** ``` BootReceiver: Device boot completed - restoring notifications BootReceiver: Found X notifications to recover BootReceiver: Recovered notification: [notification-id] BootReceiver: Notification recovery completed: X/X recovered ``` ### **Recovery Issues:** ``` BootReceiver: No notifications to recover BootReceiver: Failed to recover notification: [notification-id] BootReceiver: Error during boot recovery ``` ## ๐Ÿšจ **Troubleshooting Reboot Recovery** ### **Issue 1: Boot Receiver Not Triggered** **Symptoms**: No recovery logs after reboot **Solutions**: ```bash # Check boot receiver registration adb shell "dumpsys package com.timesafari.dailynotification | grep -A10 -B10 receiver" # Check BOOT_COMPLETED permission adb shell "dumpsys package com.timesafari.dailynotification | grep permission" ``` ### **Issue 2: Recovery Fails** **Symptoms**: Recovery logs show errors **Solutions**: ```bash # Check notification storage adb shell "run-as com.timesafari.dailynotification ls -la /data/data/com.timesafari.dailynotification/shared_prefs/" # Check alarm permissions adb shell "dumpsys alarm | grep SCHEDULE_EXACT_ALARM" ``` ### **Issue 3: Alarms Not Restored** **Symptoms**: No alarms after recovery **Solutions**: ```bash # Check exact alarm permissions adb shell "dumpsys alarm | grep SCHEDULE_EXACT_ALARM" # Check battery optimization adb shell "dumpsys deviceidle | grep timesafari" ``` ## ๐Ÿ“Š **Success Criteria** ### โœ… **Test Passes When:** - Boot receiver is triggered after reboot - Recovery logs show successful restoration - Alarms are rescheduled correctly - Notification appears at the originally scheduled time - All recovery log messages are present ### โŒ **Test Fails When:** - Boot receiver is not triggered - Recovery fails with errors - Alarms are not restored - Notification doesn't appear - Recovery logs show failures ## ๐ŸŽฏ **Quick Test Commands** ### **One-Line Reboot Test:** ```bash # Schedule notification, reboot, and verify adb shell am start -n com.timesafari.dailynotification/.MainActivity && echo "Schedule notification, then:" && read -p "Press Enter to reboot..." && adb reboot && sleep 120 && adb logcat -d | grep -i "bootreceiver\|recovery" ``` ### **Check Recovery Status:** ```bash # Quick recovery check adb logcat -d | grep -i "bootreceiver" | tail -10 ``` ### **Verify Alarms:** ```bash # Quick alarm check adb shell "dumpsys alarm | grep timesafari" ``` ## ๐Ÿ”ง **Advanced Testing** ### **Test Multiple Reboots:** ```bash # Test multiple reboot cycles for i in {1..3}; do echo "Reboot test $i/3" ./scripts/reboot-test.sh sleep 60 done ``` ### **Test with Different Notification Types:** - Test with sound enabled/disabled - Test with different priorities - Test with different content - Test with multiple notifications ### **Test Edge Cases:** - Test with low battery - Test with airplane mode - Test with timezone changes - Test with system updates ## ๐Ÿ“ฑ **Production Considerations** ### **Real-World Scenarios:** - Users rarely force-stop apps - Device reboots are common (updates, crashes, etc.) - App updates should preserve notifications - Battery optimization can affect recovery ### **Best Practices:** - Test on multiple Android versions - Test on different OEMs - Test with various battery optimization settings - Test under different network conditions ## ๐ŸŽ‰ **Expected Results** After implementing the reboot recovery system: 1. **Notifications survive reboots** โœ… 2. **Boot receiver activates automatically** โœ… 3. **Recovery logs show success** โœ… 4. **Alarms are properly restored** โœ… 5. **Notifications appear at scheduled times** โœ… **The system is now robust and production-ready!** ๐Ÿš€