This PR addresses two key issues reported during testing:
- WiFi detection showing "not in range" when networks were actually present - Solved by adding comprehensive diagnostic logging
- "No permissions allowed" in Android Settings - Solved by implementing runtime permission requests
Problem: User reported WiFi networks weren't being detected even when in range, but logs provided minimal diagnostic information.
Solution: Added comprehensive logging throughout WiFi detection pipeline:
- Android version, device model, manufacturer
- WiFi enabled state at startup
- System capabilities check
- Structured start/complete markers for each check cycle
- Configured Home and OBD SSID display
- Transmission mode verification
- Check progress indicators
- Target SSID being searched for
- WiFi enabled state before scanning
- Scan start success/failure with Android version
- Complete list of all detected SSIDs with signal strengths
- Explicit "NOT found" message when target missing
- Detailed permission/security exception handling
Example output:
DEBUG: === WiFi State Check Started ===
DEBUG: Configured Home SSID: 'MyHomeNetwork'
DEBUG: Scanning for WiFi SSID: 'MyHomeNetwork'
DEBUG: WiFi enabled: true
DEBUG: WiFi scan started: true (Android 33)
DEBUG: WiFi scan found 8 networks:
DEBUG: - SSID: 'MyHomeNetwork' Signal: -45 dBm
DEBUG: - SSID: 'NeighborWiFi' Signal: -72 dBm
DEBUG: - SSID: 'OBDII' Signal: -38 dBm
INFO: Target WiFi found in range: 'MyHomeNetwork' (Signal: -45 dBm)
- Step-by-step connection verification
- Network state and type information
- Current SSID vs target comparison
- Clear match/no-match indication
- All state variables at decision time
- Mode-specific condition checks
- Clear SEND/SKIP decisions with rationale
- Network availability details
- Network type (WiFi/Mobile/None)
- Connection state information
Documentation:
- Created
WIFI_DEBUGGING_GUIDE.md- 200+ lines of debugging instructions - Created
LOGGING_IMPLEMENTATION_SUMMARY.md- Technical implementation details - Updated README troubleshooting section
Problem: App showed "No permissions allowed" in Android Settings because permissions weren't being requested at runtime (required on Android 6.0+).
Solution: Implemented comprehensive runtime permission request system:
- Automatic check on SettingsActivity launch
- Explanation dialog before requesting permissions
- Clear rationale for each permission
- Graceful handling of denial with feature impact
-
Location (ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION)
- Required for WiFi scanning on Android 6.0+
- Used for network detection and automatic switching
- Prepares for future GPS location tracking feature
- Not used to track location (explicitly stated)
-
Notifications (POST_NOTIFICATIONS)
- Required on Android 13+ for foreground service
- Shows status indicators and connection updates
Permission Explanation Dialog:
This app requires the following permissions:
Location:
- Scan for WiFi networks (required by Android)
- Detect when home network is in range
- Enable automatic WiFi switching
- Optional: Send vehicle location to Home Assistant
Note: Location is not tracked unless you explicitly enable the location tracking option.
Notifications:
- Display network status indicator
- Show connection/transmission status
On Grant:
All required permissions have been granted. The app can now:
- Scan for WiFi networks
- Detect home network proximity
- Enable automatic WiFi switching
- Display status notifications
- Optional: Track vehicle location (when enabled)
On Denial:
Some permissions were not granted. This will limit functionality:
Location Denied:
- WiFi network scanning disabled
- Cannot detect when home network is in range
- Automatic WiFi switching unavailable
- Location sensor feature unavailable
Notifications Denied:
- Status notifications may not appear
- Network indicator may not display
- Added
androidx.core:core:1.12.0dependency for ActivityCompat - Permission check on Activity onCreate
- Dialog-based explanation before system permission request
- Handles grant/deny/never-ask-again states
- Direct links to Android Settings for manual management
- Android version checks (only request POST_NOTIFICATIONS on Android 13+)
- Added
POST_NOTIFICATIONSpermission - Updated location permission comments to mention future GPS feature
- All permissions properly documented
Documentation:
- Created
PERMISSIONS_GUIDE.md- Complete permission documentation - Updated README requirements section
- Updated README troubleshooting section with permission steps
Users can now diagnose WiFi detection issues by:
- Enabling logging in app settings
- Viewing detailed scan results showing all detected networks
- Comparing configured SSID with actual network names
- Identifying permission issues, scan throttling, or WiFi disabled state
- Understanding why transmission doesn't occur
Users will now:
- See permission request on first app launch
- Understand why each permission is needed
- Have working WiFi scanning (if permission granted)
- Know what features are disabled if permissions denied
- Have easy access to manual permission management
- Location permission structure supports planned GPS feature
- Permission explanation mentions vehicle location tracking
- Framework in place for future permission needs
- Enable logging and configure home WiFi SSID
- Wait for WiFi check cycle (30 seconds)
- View logs to verify networks are detected
- Compare scan results with actual network names
- Check for permission errors or throttling messages
- Fresh install or clear app data
- Open app - should see permission dialog
- Grant permissions - should see confirmation
- Check Android Settings shows permissions granted
- Test WiFi scanning works with permissions
- Revoke permissions - should see limited functionality warning
HomeAssistantPlugin.java- Enhanced logging throughout WiFi detectionSettingsActivity.java- Added runtime permission handlingbuild.gradle.module- Added androidx.core dependencyAndroidManifest.xml- Added POST_NOTIFICATIONS permission
WIFI_DEBUGGING_GUIDE.md- NEW: WiFi detection debugging guideLOGGING_IMPLEMENTATION_SUMMARY.md- NEW: Technical logging detailsPERMISSIONS_GUIDE.md- NEW: Permission handling documentationREADME.md- Updated with troubleshooting and requirements
All changes are additive and backward compatible:
- No API changes
- No behavior changes when logging disabled
- Permission requests are graceful (can be denied)
- Works on Android 4.0.3+ (minSdk 15)
- Runtime permissions only on Android 6.0+ (API 23+)
- POST_NOTIFICATIONS only on Android 13+ (API 33+)
- Lines added: ~550
- New log points: 40+
- New files: 4 documentation files
- Files modified: 4 source/config files
- Commits: 5
- Documentation: 600+ lines of comprehensive guides