summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Lorenzo Colitti <lorenzo@google.com> 2019-06-05 01:14:56 -0700
committer android-build-merger <android-build-merger@google.com> 2019-06-05 01:14:56 -0700
commit1ee4d86be776f1c69a3079d47f23924f3ca474ae (patch)
tree78394a6d0d780f12cc219d30b871eda41dee1d5d
parent0952103ef87635051552e199989cf37ec040c188 (diff)
parent79e58ad90120166ca81b9717f2a4abe915b2a647 (diff)
Merge "Allow passing in acceptUnvalidated without explicitlySelected"
am: 79e58ad901 Change-Id: I95ce5c2064e3a1cbe616343ed51523620df3faf1
-rw-r--r--core/java/android/net/NetworkAgent.java19
-rw-r--r--services/core/java/com/android/server/ConnectivityService.java10
2 files changed, 23 insertions, 6 deletions
diff --git a/core/java/android/net/NetworkAgent.java b/core/java/android/net/NetworkAgent.java
index aeb464b8d6a8..ed088d0a6756 100644
--- a/core/java/android/net/NetworkAgent.java
+++ b/core/java/android/net/NetworkAgent.java
@@ -433,7 +433,24 @@ public abstract class NetworkAgent extends Handler {
* {@link #saveAcceptUnvalidated} to respect the user's choice.
*/
public void explicitlySelected(boolean acceptUnvalidated) {
- queueOrSendMessage(EVENT_SET_EXPLICITLY_SELECTED, acceptUnvalidated ? 1 : 0, 0);
+ explicitlySelected(true /* explicitlySelected */, acceptUnvalidated);
+ }
+
+ /**
+ * Called by the bearer to indicate this network was manually selected by the user.
+ * This should be called before the NetworkInfo is marked CONNECTED so that this
+ * Network can be given special treatment at that time. If {@code acceptUnvalidated} is
+ * {@code true}, then the system will switch to this network. If it is {@code false} and the
+ * network cannot be validated, the system will ask the user whether to switch to this network.
+ * If the user confirms and selects "don't ask again", then the system will call
+ * {@link #saveAcceptUnvalidated} to persist the user's choice. Thus, if the transport ever
+ * calls this method with {@code acceptUnvalidated} set to {@code false}, it must also implement
+ * {@link #saveAcceptUnvalidated} to respect the user's choice.
+ */
+ public void explicitlySelected(boolean explicitlySelected, boolean acceptUnvalidated) {
+ queueOrSendMessage(EVENT_SET_EXPLICITLY_SELECTED,
+ explicitlySelected ? 1 : 0,
+ acceptUnvalidated ? 1 : 0);
}
/**
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index c64c2783da51..8e56c6962d97 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -2575,11 +2575,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
break;
}
case NetworkAgent.EVENT_SET_EXPLICITLY_SELECTED: {
- if (nai.everConnected && !nai.networkMisc.explicitlySelected) {
- loge("ERROR: already-connected network explicitly selected.");
+ if (nai.everConnected) {
+ loge("ERROR: cannot call explicitlySelected on already-connected network");
}
- nai.networkMisc.explicitlySelected = true;
- nai.networkMisc.acceptUnvalidated = msg.arg1 == 1;
+ nai.networkMisc.explicitlySelected = (msg.arg1 == 1);
+ nai.networkMisc.acceptUnvalidated = (msg.arg1 == 1) && (msg.arg2 == 1);
// Mark the network as temporarily accepting partial connectivity so that it
// will be validated (and possibly become default) even if it only provides
// partial internet access. Note that if user connects to partial connectivity
@@ -2587,7 +2587,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// out of wifi coverage) and if the same wifi is available again, the device
// will auto connect to this wifi even though the wifi has "no internet".
// TODO: Evaluate using a separate setting in IpMemoryStore.
- nai.networkMisc.acceptPartialConnectivity = msg.arg1 == 1;
+ nai.networkMisc.acceptPartialConnectivity = (msg.arg2 == 1);
break;
}
case NetworkAgent.EVENT_SOCKET_KEEPALIVE: {