summaryrefslogtreecommitdiffstats
path: root/core/java/android/net
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2015-04-15 11:48:12 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-15 11:48:22 +0000
commite9a88a3844d8ea7429aa3a5762a1f345b25ce102 (patch)
treef1705b090e8e1b92b4e70152f6b1fc0b4f064ad1 /core/java/android/net
parentfdddb4eb69e719563e604f7dd27ac6999c7844da (diff)
parent1248dd3c296a94457d5864b7f433335f32490b50 (diff)
downloadframeworks_base-e9a88a3844d8ea7429aa3a5762a1f345b25ce102.zip
frameworks_base-e9a88a3844d8ea7429aa3a5762a1f345b25ce102.tar.gz
frameworks_base-e9a88a3844d8ea7429aa3a5762a1f345b25ce102.tar.bz2
Merge changes from topic 'no_internet'
* changes: Add a noInternetAccessExpected boolean to WifiConfiguration. Prompt if a network without an Internet connection is selected Give SystemUI the OVERRIDE_WIFI_CONFIG permission. Add an UNKNOWN_UID constant to WifiConfiguration.
Diffstat (limited to 'core/java/android/net')
-rw-r--r--core/java/android/net/ConnectivityManager.java31
-rw-r--r--core/java/android/net/IConnectivityManager.aidl2
-rw-r--r--core/java/android/net/NetworkAgent.java39
-rw-r--r--core/java/android/net/NetworkMisc.java10
4 files changed, 78 insertions, 4 deletions
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index da2c5e0..55e39b1 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -286,6 +286,14 @@ public class ConnectivityManager {
public static final String EXTRA_IS_CAPTIVE_PORTAL = "captivePortal";
/**
+ * Action used to display a dialog that asks the user whether to connect to a network that is
+ * not validated. This intent is used to start the dialog in settings via startActivity.
+ *
+ * @hide
+ */
+ public static final String ACTION_PROMPT_UNVALIDATED = "android.net.conn.PROMPT_UNVALIDATED";
+
+ /**
* The absence of a connection type.
* @hide
*/
@@ -2455,6 +2463,29 @@ public class ConnectivityManager {
}
/**
+ * Informs the system whether it should switch to {@code network} regardless of whether it is
+ * validated or not. If {@code accept} is true, and the network was explicitly selected by the
+ * user (e.g., by selecting a Wi-Fi network in the Settings app), then the network will become
+ * the system default network regardless of any other network that's currently connected. If
+ * {@code always} is true, then the choice is remembered, so that the next time the user
+ * connects to this network, the system will switch to it.
+ *
+ * <p>This method requires the caller to hold the permission
+ * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}
+ *
+ * @param network The network to accept.
+ * @param accept Whether to accept the network even if unvalidated.
+ * @param always Whether to remember this choice in the future.
+ *
+ * @hide
+ */
+ public void setAcceptUnvalidated(Network network, boolean accept, boolean always) {
+ try {
+ mService.setAcceptUnvalidated(network, accept, always);
+ } catch (RemoteException e) {}
+ }
+
+ /**
* Resets all connectivity manager settings back to factory defaults.
* @hide
*/
diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl
index 3c09978..1aa9c45 100644
--- a/core/java/android/net/IConnectivityManager.aidl
+++ b/core/java/android/net/IConnectivityManager.aidl
@@ -156,6 +156,8 @@ interface IConnectivityManager
void releaseNetworkRequest(in NetworkRequest networkRequest);
+ void setAcceptUnvalidated(in Network network, boolean accept, boolean always);
+
int getRestoreDefaultNetworkDelay(int networkType);
boolean addVpnAddress(String address, int prefixLength);
diff --git a/core/java/android/net/NetworkAgent.java b/core/java/android/net/NetworkAgent.java
index 24aaf0d..95ceb2a 100644
--- a/core/java/android/net/NetworkAgent.java
+++ b/core/java/android/net/NetworkAgent.java
@@ -104,7 +104,7 @@ public abstract class NetworkAgent extends Handler {
public static final int EVENT_UID_RANGES_REMOVED = BASE + 6;
/**
- * Sent by ConnectivitySerice to the NetworkAgent to inform the agent of the
+ * Sent by ConnectivityService to the NetworkAgent to inform the agent of the
* networks status - whether we could use the network or could not, due to
* either a bad network configuration (no internet link) or captive portal.
*
@@ -119,9 +119,21 @@ public abstract class NetworkAgent extends Handler {
* Sent by the NetworkAgent to ConnectivityService to indicate this network was
* explicitly selected. This should be sent before the NetworkInfo is marked
* CONNECTED so it can be given special treatment at that time.
+ *
+ * obj = boolean indicating whether to use this network even if unvalidated
*/
public static final int EVENT_SET_EXPLICITLY_SELECTED = BASE + 8;
+ /**
+ * Sent by ConnectivityService to the NetworkAgent to inform the agent of
+ * whether the network should in the future be used even if not validated.
+ * This decision is made by the user, but it is the network transport's
+ * responsibility to remember it.
+ *
+ * arg1 = 1 if true, 0 if false
+ */
+ public static final int CMD_SAVE_ACCEPT_UNVALIDATED = BASE + 9;
+
public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni,
NetworkCapabilities nc, LinkProperties lp, int score) {
this(looper, context, logTag, ni, nc, lp, score, null);
@@ -191,6 +203,9 @@ public abstract class NetworkAgent extends Handler {
networkStatus(msg.arg1);
break;
}
+ case CMD_SAVE_ACCEPT_UNVALIDATED: {
+ saveAcceptUnvalidated(msg.arg1 != 0);
+ }
}
}
@@ -258,10 +273,16 @@ public abstract class NetworkAgent extends Handler {
/**
* 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.
+ * 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() {
- queueOrSendMessage(EVENT_SET_EXPLICITLY_SELECTED, 0);
+ public void explicitlySelected(boolean acceptUnvalidated) {
+ queueOrSendMessage(EVENT_SET_EXPLICITLY_SELECTED, acceptUnvalidated);
}
/**
@@ -290,6 +311,16 @@ public abstract class NetworkAgent extends Handler {
protected void networkStatus(int status) {
}
+ /**
+ * Called when the user asks to remember the choice to use this network even if unvalidated.
+ * The transport is responsible for remembering the choice, and the next time the user connects
+ * to the network, should explicitlySelected with {@code acceptUnvalidated} set to {@code true}.
+ * This method will only be called if {@link #explicitlySelected} was called with
+ * {@code acceptUnvalidated} set to {@code false}.
+ */
+ protected void saveAcceptUnvalidated(boolean accept) {
+ }
+
protected void log(String s) {
Log.d(LOG_TAG, "NetworkAgent: " + s);
}
diff --git a/core/java/android/net/NetworkMisc.java b/core/java/android/net/NetworkMisc.java
index b92c9e3..5511a24 100644
--- a/core/java/android/net/NetworkMisc.java
+++ b/core/java/android/net/NetworkMisc.java
@@ -45,6 +45,13 @@ public class NetworkMisc implements Parcelable {
public boolean explicitlySelected;
/**
+ * Set if the user desires to use this network even if it is unvalidated. This field has meaning
+ * only if {#link explicitlySelected} is true. If it is, this field must also be set to the
+ * appropriate value based on previous user choice.
+ */
+ public boolean acceptUnvalidated;
+
+ /**
* For mobile networks, this is the subscriber ID (such as IMSI).
*/
public String subscriberId;
@@ -56,6 +63,7 @@ public class NetworkMisc implements Parcelable {
if (nm != null) {
allowBypass = nm.allowBypass;
explicitlySelected = nm.explicitlySelected;
+ acceptUnvalidated = nm.acceptUnvalidated;
subscriberId = nm.subscriberId;
}
}
@@ -69,6 +77,7 @@ public class NetworkMisc implements Parcelable {
public void writeToParcel(Parcel out, int flags) {
out.writeInt(allowBypass ? 1 : 0);
out.writeInt(explicitlySelected ? 1 : 0);
+ out.writeInt(acceptUnvalidated ? 1 : 0);
out.writeString(subscriberId);
}
@@ -78,6 +87,7 @@ public class NetworkMisc implements Parcelable {
NetworkMisc networkMisc = new NetworkMisc();
networkMisc.allowBypass = in.readInt() != 0;
networkMisc.explicitlySelected = in.readInt() != 0;
+ networkMisc.acceptUnvalidated = in.readInt() != 0;
networkMisc.subscriberId = in.readString();
return networkMisc;
}