Connection Health Monitor#6
Conversation
… status - Created HealthCheckWorker as CoroutineWorker for periodic ADB health checks - Implements doWork() to call AdbManager.getStatus() and verify connection - Detects connection degradation (disabled, port change, IP change) - Returns health status (healthy/degraded/failed) in output data - Includes input/output data keys for state tracking - Battery efficient using WorkManager's optimized scheduling - Follows patterns from AdbManager.kt (coroutines, logging, error handling) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…Manager. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ation channel and show degradation alerts
…oring state - Added healthState LiveData property to AdbViewModel - Exposes ConnectionHealthManager.healthState for UI observation - Follows same pattern as p2pManager integration - Enables ControlFragment to observe and display connection health status
…cator in status card Added health indicator icon to status card that displays connection health state: - Added healthIcon ImageView to fragment_control.xml layout - Added cd_health_indicator string resource for accessibility - Added health state observer in ControlFragment.observeViewModel() - Implemented updateHealthIndicator() function to update icon based on health state - Shows green ic_health for HEALTHY state - Shows orange ic_health_warning for DEGRADED/FAILED states - Hides icon for UNKNOWN state Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
… add health monitoring toggle and frequency setting
…ration Analyzed WorkManager configuration requirements: - Confirmed WorkManager dependency present (work-runtime-ktx:2.9.0) - Verified app uses default auto-initialization - No custom Configuration.Provider implementation - WorkManagerInitializer added automatically via manifest merger - AndroidManifest.xml already properly configured Result: No changes needed - manifest is correct as-is Verification: ./gradlew compileDebugKotlin - BUILD SUCCESSFUL
…d via ConnectionHealthManager Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ng flow - Created comprehensive E2E_VERIFICATION_GUIDE.md with 7-test suite - Built debug APK successfully: app/build/outputs/apk/debug/app-debug.apk - Verified all components properly integrated: * HealthCheckWorker - periodic ADB health checks * ConnectionHealthManager - WorkManager scheduling * AdbViewModel - health monitoring lifecycle * ControlFragment - UI health indicator * AdbService - notification infrastructure * PrefsManager - health preferences - Documented verification procedures and acceptance criteria - Ready for QA acceptance and device testing Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixes: - Add HealthCheckWorkerTest.kt with 8 comprehensive test cases - Add ConnectionHealthManagerTest.kt with 8 comprehensive test cases - Update spec.md to reflect 15-minute interval (WorkManager constraint) - Implement automatic notification trigger on health degradation - Add rate limiting to prevent notification spam (5-minute cooldown) - Add health degradation broadcast handler in AdbService Verified: - All code compiles successfully (assembleDebug passes) - Unit tests created for health monitoring components - Spec deviation documented with technical rationale - Notification trigger wired to ConnectionHealthManager QA Fix Session: 1
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3420857982
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| else -> "Connection health issue detected" | ||
| } | ||
|
|
||
| showHealthDegradationAlert(healthStatus, details) | ||
| return START_NOT_STICKY |
There was a problem hiding this comment.
Avoid starting foreground service without foregrounding
This branch posts a notification and returns without calling startForeground(). Because health alerts are triggered via startForegroundService(...) (see ConnectionHealthManager.triggerHealthNotification), Android O+ will throw ForegroundServiceDidNotStartInTimeException if the service wasn’t already running, causing a crash whenever a health alert fires while ADB service is stopped. Either use startService for this action or call startForeground when handling the health-degradation intent.
Useful? React with 👍 / 👎.
| workDataOf( | ||
| HealthCheckWorker.KEY_LAST_KNOWN_ENABLED to lastKnownEnabled, | ||
| HealthCheckWorker.KEY_LAST_KNOWN_PORT to lastKnownPort, | ||
| HealthCheckWorker.KEY_LAST_KNOWN_IP to (lastKnownIp ?: "") | ||
| ) |
There was a problem hiding this comment.
Periodic health checks never update baseline state
The periodic worker is scheduled with fixed input data, so KEY_LAST_KNOWN_* reflects only the state at scheduling time. WorkManager does not mutate input between runs, meaning any IP/port change will be compared against the original values forever. After a network change, the health state will remain DEGRADED and never return to HEALTHY unless monitoring is cancelled and rescheduled. The baseline should be refreshed (e.g., reschedule work with new input) when the worker reports healthy or when the app updates last-known state.
Useful? React with 👍 / 👎.
Background monitoring that periodically checks if ADB is still accessible and functional. Automatically alerts user if connection degrades or fails without user action.