# Testing Quick Reference - P0 Production-Grade Features ## Current Version Features ✅ **P0 Priority 1**: Channel Management (ChannelManager) ✅ **P0 Priority 2**: PendingIntent & Exact Alarms (PendingIntentManager) ✅ **P0 Priority 3**: JIT Freshness Re-check (Soft TTL) ✅ **P0 Priority 4**: Recovery Coexistence (RecoveryManager) ## Quick Test Commands ### 1. Basic Functionality Test ```bash # Launch app adb shell am start -n com.timesafari.dailynotification/.MainActivity # Check channel status adb shell "dumpsys notification | grep -A5 daily_default" # Check alarms adb shell "dumpsys alarm | grep timesafari" # Check exact alarm permission adb shell "dumpsys alarm | grep SCHEDULE_EXACT_ALARM" ``` ### 2. Channel Management Test ```bash # Check channel exists and is enabled adb shell "dumpsys notification | grep daily_default" # Check channel importance (should be 3 = IMPORTANCE_HIGH) adb shell "dumpsys notification | grep -A5 daily_default | grep importance" # Open channel settings adb shell "am start -a android.settings.CHANNEL_NOTIFICATION_SETTINGS -e android.provider.extra.APP_PACKAGE com.timesafari.dailynotification -e android.provider.extra.CHANNEL_ID daily_default" ``` ### 3. PendingIntent & Exact Alarms Test ```bash # Check PendingIntent flags in alarms adb shell "dumpsys alarm | grep -A10 -B5 timesafari" # Check exact alarm permission adb shell "dumpsys alarm | grep SCHEDULE_EXACT_ALARM" # Open exact alarm settings adb shell "am start -a android.settings.REQUEST_SCHEDULE_EXACT_ALARM -d package:com.timesafari.dailynotification" ``` ### 4. JIT Freshness Re-check Test ```bash # Clear logs adb logcat -c # Schedule notification in app UI, then monitor logs adb logcat | grep -i "jit\|freshness\|stale" # Look for: # - "Content is fresh (age: X minutes), skipping JIT refresh" # - "Content is stale (age: X minutes), attempting JIT refresh" # - "JIT refresh succeeded" or "JIT refresh failed, using original content" ``` ### 5. Recovery Coexistence Test ```bash # Clear logs adb logcat -c # Launch app multiple times to test cooldown adb shell am start -n com.timesafari.dailynotification/.MainActivity sleep 2 adb shell am start -n com.timesafari.dailynotification/.MainActivity sleep 2 adb shell am start -n com.timesafari.dailynotification/.MainActivity # Check recovery logs adb logcat -d | grep -i "recovery.*requested.*app_startup" adb logcat -d | grep -i "recovery.*performed.*recently.*skipping" ``` ### 6. Reboot Recovery Test ```bash # Schedule notification in app UI first # Then reboot adb reboot # Wait for boot adb wait-for-device sleep 30 # Check recovery logs adb logcat -d | grep -i "recovery.*requested.*boot_completed" # Check alarms restored adb shell "dumpsys alarm | grep timesafari" ``` ## Automated Test Scripts ### Comprehensive Test Suite ```bash # Run comprehensive test suite ./scripts/comprehensive-test-v2.sh ``` ### Reboot Test Suite ```bash # Run reboot test suite ./scripts/reboot-test-v2.sh ``` ### Python Test Suite ```bash # Run Python test suite python3 scripts/daily-notification-test.py ``` ## Expected Log Patterns ### Channel Management ``` ChannelManager: Creating new notification channel: daily_default ChannelManager: Notification channel created with IMPORTANCE_HIGH ``` ### PendingIntent & Exact Alarms ``` PendingIntentManager: Scheduled exact alarm with setExactAndAllowWhileIdle PendingIntentManager: AlarmStatus{exactAlarmsSupported=true, exactAlarmsGranted=true} ``` ### JIT Freshness Re-check ``` DailyNotificationReceiver: Content is fresh (age: 5 minutes), skipping JIT refresh DailyNotificationReceiver: Content is stale (age: 7 hours), attempting JIT refresh DailyNotificationReceiver: JIT refresh succeeded, using fresh content ``` ### Recovery Coexistence ``` RecoveryManager: Recovery requested from: APP_STARTUP RecoveryManager: Recovery performed recently (2s ago), skipping RecoveryManager: Recovery requested from: BOOT_COMPLETED RecoveryManager: Recovery completed from BOOT_COMPLETED: 3/5 recovered, 2 skipped ``` ## Success Criteria ### ✅ All Tests Pass When: 1. **Channel Management**: - Channel exists with ID `daily_default` - Channel importance is `IMPORTANCE_HIGH` (3) - Channel blocking detection works - Settings deep linking works 2. **PendingIntent & Exact Alarms**: - PendingIntent uses `FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE` - Exact alarm permission detection works - Settings deep linking works - Alarms schedule correctly 3. **JIT Freshness Re-check**: - Fresh content (< 6 hours) skips refresh - Stale content (> 6 hours) attempts refresh - Graceful fallback on refresh failure - Original content preserved on failure 4. **Recovery Coexistence**: - App startup recovery works - Boot recovery works - 5-minute cooldown prevents duplicate recovery - Recovery statistics tracked correctly - State persisted in SharedPreferences ### ❌ Tests Fail When: - Channel not created or blocked - PendingIntent flags incorrect - JIT refresh not working - Recovery operations conflict - Boot recovery not triggered - Alarms not restored after reboot ## Troubleshooting Commands ### Debug Channel Issues ```bash # Check channel status adb shell "dumpsys notification | grep -A10 daily_default" # Check channel importance adb shell "dumpsys notification | grep -A5 daily_default | grep importance" ``` ### Debug Alarm Issues ```bash # Check scheduled alarms adb shell "dumpsys alarm | grep timesafari" # Check exact alarm permission adb shell "dumpsys alarm | grep SCHEDULE_EXACT_ALARM" # Check alarm manager state adb shell "dumpsys alarm | head -20" ``` ### Debug Recovery Issues ```bash # Check recovery logs adb logcat -d | grep -i "recovery.*requested" # Check recovery state adb shell "run-as com.timesafari.dailynotification ls -la /data/data/com.timesafari.dailynotification/shared_prefs/" # Check boot receiver registration adb shell "dumpsys package com.timesafari.dailynotification | grep -A5 -B5 receiver" ``` ### Debug JIT Freshness Issues ```bash # Check JIT refresh logs adb logcat -d | grep -i "jit\|freshness\|stale" # Check content age calculation adb logcat -d | grep -i "age.*minutes" ``` ## Manual Testing Checklist ### Pre-Test Setup - [ ] Device/emulator connected via ADB - [ ] App installed and permissions granted - [ ] Notification permissions enabled - [ ] Exact alarm permissions granted (Android 12+) ### Basic Tests - [ ] App launches successfully - [ ] Plugin loads without errors - [ ] Channel created with correct settings - [ ] Notifications schedule correctly - [ ] Notifications appear at scheduled time ### P0 Feature Tests - [ ] Channel management works - [ ] PendingIntent flags correct - [ ] Exact alarm permission detection - [ ] JIT freshness re-check works - [ ] Recovery coexistence works - [ ] Boot recovery works ### Edge Case Tests - [ ] App background notification - [ ] App closed notification - [ ] Force stop (expected failure) - [ ] Reboot recovery - [ ] Multiple notifications - [ ] Network connectivity issues ### Performance Tests - [ ] Memory usage stable - [ ] CPU usage reasonable - [ ] No memory leaks - [ ] Efficient recovery operations ## Quick Status Check ```bash # One-liner to check all systems echo "=== Channel Status ===" && adb shell "dumpsys notification | grep -A3 daily_default" && echo "=== Alarm Status ===" && adb shell "dumpsys alarm | grep timesafari" && echo "=== Recovery Status ===" && adb logcat -d | grep -i "recovery.*requested" | tail -3 ``` This quick reference covers all the essential testing procedures for the current P0 production-grade version of the DailyNotification plugin.