summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Jensen <pauljensen@google.com>2015-07-13 15:09:52 -0400
committerPaul Jensen <pauljensen@google.com>2015-07-28 13:34:47 +0000
commit312c60d9779c200e8250b8a7ae32eaea01b08b42 (patch)
tree74f4b3fce4730fab1f2f240e9d7c699d79c8dedc
parentf33245e1755794a0b6f1b8bfa7376ead57e68b53 (diff)
downloadwifi-312c60d9779c200e8250b8a7ae32eaea01b08b42.tar.gz
Disable WiFi autojoin when user decides via "Stay connected?" dialog
If the user selects "No" in the "Stay connected?" dialog box: 1. Disable autojoining that network in the future, and 2. Disassociate from that network. Also, correct the name of a constant that was misleading. Bug:22187193 Change-Id: I14dc9236c57e3ab7d3ec95edc906787cbfbf3c9f
-rw-r--r--service/java/com/android/server/wifi/WifiAutoJoinController.java1
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java31
2 files changed, 25 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/WifiAutoJoinController.java b/service/java/com/android/server/wifi/WifiAutoJoinController.java
index 07382d6c5..a1a9a8213 100644
--- a/service/java/com/android/server/wifi/WifiAutoJoinController.java
+++ b/service/java/com/android/server/wifi/WifiAutoJoinController.java
@@ -1630,6 +1630,7 @@ public class WifiAutoJoinController {
}
}
}
+ // NOTE: If this condition is updated, update NETWORK_STATUS_UNWANTED_DISABLE_AUTOJOIN.
if (config.numNoInternetAccessReports > 0
&& !isLastSelected
&& !config.validatedInternetAccess) {
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index f4a2e53ef..84d28d74e 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -693,7 +693,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno
/* Remove a packages associated configrations */
static final int CMD_REMOVE_APP_CONFIGURATIONS = BASE + 97;
-
+
/* Disable an ephemeral network */
static final int CMD_DISABLE_EPHEMERAL_NETWORK = BASE + 98;
@@ -744,8 +744,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno
static final int CMD_AUTO_CONNECT = BASE + 143;
- static final int network_status_unwanted_disconnect = 0;
- static final int network_status_unwanted_disable_autojoin = 1;
+ private static final int NETWORK_STATUS_UNWANTED_DISCONNECT = 0;
+ private static final int NETWORK_STATUS_UNWANTED_VALIDATION_FAILED = 1;
+ private static final int NETWORK_STATUS_UNWANTED_DISABLE_AUTOJOIN = 2;
static final int CMD_UNWANTED_NETWORK = BASE + 144;
@@ -7737,7 +7738,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno
if (this != mNetworkAgent) return;
if (DBG) log("WifiNetworkAgent -> Wifi unwanted score "
+ Integer.toString(mWifiInfo.score));
- unwantedNetwork(network_status_unwanted_disconnect);
+ unwantedNetwork(NETWORK_STATUS_UNWANTED_DISCONNECT);
}
@Override
@@ -7746,7 +7747,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno
if (status == NetworkAgent.INVALID_NETWORK) {
if (DBG) log("WifiNetworkAgent -> Wifi networkStatus invalid, score="
+ Integer.toString(mWifiInfo.score));
- unwantedNetwork(network_status_unwanted_disable_autojoin);
+ unwantedNetwork(NETWORK_STATUS_UNWANTED_VALIDATION_FAILED);
} else if (status == NetworkAgent.VALID_NETWORK) {
if (DBG && mWifiInfo != null) log("WifiNetworkAgent -> Wifi networkStatus valid, score= "
+ Integer.toString(mWifiInfo.score));
@@ -7759,6 +7760,12 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno
if (this != mNetworkAgent) return;
WifiStateMachine.this.sendMessage(CMD_ACCEPT_UNVALIDATED, accept ? 1 : 0);
}
+
+ @Override
+ protected void preventAutomaticReconnect() {
+ if (this != mNetworkAgent) return;
+ unwantedNetwork(NETWORK_STATUS_UNWANTED_DISABLE_AUTOJOIN);
+ }
}
void unwantedNetwork(int reason) {
@@ -8673,14 +8680,24 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno
transitionTo(mVerifyingLinkState);
break;
case CMD_UNWANTED_NETWORK:
- if (message.arg1 == network_status_unwanted_disconnect) {
+ if (message.arg1 == NETWORK_STATUS_UNWANTED_DISCONNECT) {
mWifiConfigStore.handleBadNetworkDisconnectReport(mLastNetworkId, mWifiInfo);
mWifiNative.disconnect();
transitionTo(mDisconnectingState);
- } else if (message.arg1 == network_status_unwanted_disable_autojoin) {
+ } else if (message.arg1 == NETWORK_STATUS_UNWANTED_DISABLE_AUTOJOIN ||
+ message.arg1 == NETWORK_STATUS_UNWANTED_VALIDATION_FAILED) {
config = getCurrentWifiConfiguration();
if (config != null) {
// Disable autojoin
+ if (message.arg1 == NETWORK_STATUS_UNWANTED_DISABLE_AUTOJOIN) {
+ config.validatedInternetAccess = false;
+ // Clear last-selected status, as being last-selected also avoids
+ // disabling auto-join.
+ if (mWifiConfigStore.isLastSelectedConfiguration(config)) {
+ mWifiConfigStore.setLastSelectedConfiguration(
+ WifiConfiguration.INVALID_NETWORK_ID);
+ }
+ }
config.numNoInternetAccessReports += 1;
config.dirty = true;
mWifiConfigStore.writeKnownNetworkHistory(false);