Files
daily-notification-plugin/docs/reboot-testing-steps.md
Matthew Raymer 72769a15e6 docs: add comprehensive testing and recovery documentation
- Add app-startup-recovery-solution.md with technical deep dive
- Add boot-receiver-testing-guide.md with Android 10+ fixes
- Add notification-testing-procedures.md with manual testing steps
- Add reboot-testing-procedure.md with automated testing
- Add reboot-testing-steps.md with quick reference guide
- Add testing-quick-reference.md with common scenarios

Documentation covers:
- Boot receiver implementation and Direct Boot handling
- App startup recovery as fallback mechanism
- Comprehensive testing procedures for all scenarios
- Troubleshooting guides for common issues
- Performance metrics and success criteria
- Production deployment best practices

This provides complete documentation for the notification system
including both boot receiver and app startup recovery approaches.
2025-10-14 06:17:03 +00:00

217 lines
6.0 KiB
Markdown

# 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!** 🚀