wear proxy behind portal

Do not avoid captive portal on wear proxy network; keep network agent
after detecting portal.

Bug: 291112432
Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.ConnectivityServiceTest
Change-Id: I8f6669da62ebd76b6a46d2aec9b3ea563a08cb5e
This commit is contained in:
Andriy Naborskyy 2023-09-26 02:03:18 +00:00
commit d032dd42ea

View file

@ -4405,7 +4405,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
updateCapabilitiesForNetwork(nai);
} else if (portalChanged) {
if (portal && ConnectivitySettingsManager.CAPTIVE_PORTAL_MODE_AVOID
== getCaptivePortalMode()) {
== getCaptivePortalMode(nai)) {
if (DBG) log("Avoiding captive portal network: " + nai.toShortString());
nai.onPreventAutomaticReconnect();
teardownUnneededNetwork(nai);
@ -4441,7 +4441,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
}
private int getCaptivePortalMode() {
private int getCaptivePortalMode(@NonNull NetworkAgentInfo nai) {
if (nai.networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH) &&
mContext.getPackageManager().hasSystemFeature(FEATURE_WATCH)) {
// Do not avoid captive portal when network is wear proxy.
return ConnectivitySettingsManager.CAPTIVE_PORTAL_MODE_PROMPT;
}
return Settings.Global.getInt(mContext.getContentResolver(),
ConnectivitySettingsManager.CAPTIVE_PORTAL_MODE,
ConnectivitySettingsManager.CAPTIVE_PORTAL_MODE_PROMPT);