Skip to content

Auto-Reconnect on Network Change#7

Merged
PhenixStar merged 7 commits intomainfrom
auto-claude/007-auto-reconnect-on-network-change
Feb 6, 2026
Merged

Auto-Reconnect on Network Change#7
PhenixStar merged 7 commits intomainfrom
auto-claude/007-auto-reconnect-on-network-change

Conversation

@PhenixStar
Copy link
Owner

Automatically re-enable wireless ADB when the device connects to a new WiFi network or when the network changes. Maintains connection continuity across network transitions.

PhenixStar and others added 7 commits February 7, 2026 04:48
…allback

- Created NetworkChangeReceiver extending BroadcastReceiver
- Follows BootReceiver pattern for code style consistency
- Handles CONNECTIVITY_ACTION and WiFi state change intents
- Checks for active WiFi connection using NetworkCapabilities
- Includes companion methods for modern NetworkCallback registration
- Placeholder for auto-reconnect logic (to be added in subtask-2-2)
- Includes comprehensive logging for debugging

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…hangeReceiver

- Added coroutine imports (CoroutineScope, Dispatchers, launch)
- Check if auto-reconnect is enabled via PrefsManager.isAutoReconnectEnabled()
- Get current ADB status to verify it was previously enabled
- Re-enable ADB on port using AdbManager.enable() in IO coroutine
- Follows BootReceiver pattern for async operations
- Only reconnects if ADB was already enabled before network change

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ted networks

- Add WifiManager import for SSID detection
- Implement getCurrentWifiSsid() to get current WiFi SSID
- Check trusted networks before auto-reconnect
- Skip auto-reconnect if network is not trusted
- Allow all networks if trusted list is empty
- Proper error handling and logging throughout

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4431f3611b

ℹ️ 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".

Comment on lines +62 to +68
<receiver
android:name=".NetworkChangeReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_ACTION" />
</intent-filter>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use a manifest CONNECTIVITY_ACTION receiver won’t fire on API 24+

Because the app targets SDK 34, a manifest-declared receiver for android.net.conn.CONNECTIVITY_ACTION will not receive broadcasts on Android 7.0+; those implicit broadcasts are delivered only to context-registered receivers. That means NetworkChangeReceiver won’t be invoked in normal production scenarios, so auto‑reconnect never triggers. Consider switching to ConnectivityManager.registerNetworkCallback (or dynamically registering a receiver) instead of relying on the manifest entry.

Useful? React with 👍 / 👎.

Comment on lines 98 to +104
}
return START_STICKY
}
ACTION_NETWORK_CHANGED -> {
handleNetworkChange()
return START_STICKY
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Starting the service from a broadcast can crash in background

The network-change path calls AdbService.onNetworkChanged from a manifest receiver, which uses context.startService(...). On Android 8.0+, starting a background service from a broadcast receiver throws IllegalStateException unless it’s a foreground service; additionally, the ACTION_NETWORK_CHANGED branch never calls startForeground, so a newly started service can’t promote itself within the 5‑second window. If the service isn’t already running (e.g., killed while ADB remains enabled), the auto‑reconnect flow will crash instead of updating the notification.

Useful? React with 👍 / 👎.

@PhenixStar PhenixStar merged commit 1484a36 into main Feb 6, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant