Merge changes Ifd7d73ad,Id79096fa
am: abf2a3f652
Change-Id: I263f51ba2aafdf8e19e020b2a4f6ff1b8238fa3c
This commit is contained in:
@@ -125,8 +125,8 @@ public class ConnectivityManager {
|
|||||||
/**
|
/**
|
||||||
* A temporary hack until SUPL system can get off the legacy APIS.
|
* A temporary hack until SUPL system can get off the legacy APIS.
|
||||||
* They do too many network requests and the long list of apps listening
|
* They do too many network requests and the long list of apps listening
|
||||||
* and waking due to the CONNECTIVITY_ACTION bcast makes it expensive.
|
* and waking due to the CONNECTIVITY_ACTION broadcast makes it expensive.
|
||||||
* Use this bcast intent instead for SUPL requests.
|
* Use this broadcast intent instead for SUPL requests.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final String CONNECTIVITY_ACTION_SUPL =
|
public static final String CONNECTIVITY_ACTION_SUPL =
|
||||||
@@ -260,7 +260,8 @@ public class ConnectivityManager {
|
|||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
||||||
public static final String ACTION_DATA_ACTIVITY_CHANGE = "android.net.conn.DATA_ACTIVITY_CHANGE";
|
public static final String ACTION_DATA_ACTIVITY_CHANGE =
|
||||||
|
"android.net.conn.DATA_ACTIVITY_CHANGE";
|
||||||
/**
|
/**
|
||||||
* The lookup key for an enum that indicates the network device type on which this data activity
|
* The lookup key for an enum that indicates the network device type on which this data activity
|
||||||
* change happens.
|
* change happens.
|
||||||
@@ -391,14 +392,14 @@ public class ConnectivityManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalid tethering type.
|
* Invalid tethering type.
|
||||||
* @see #startTethering(int, OnStartTetheringCallback, boolean)
|
* @see #startTethering(int, boolean, OnStartTetheringCallback)
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final int TETHERING_INVALID = -1;
|
public static final int TETHERING_INVALID = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wifi tethering type.
|
* Wifi tethering type.
|
||||||
* @see #startTethering(int, OnStartTetheringCallback, boolean)
|
* @see #startTethering(int, boolean, OnStartTetheringCallback)
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
@@ -406,7 +407,7 @@ public class ConnectivityManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* USB tethering type.
|
* USB tethering type.
|
||||||
* @see #startTethering(int, OnStartTetheringCallback, boolean)
|
* @see #startTethering(int, boolean, OnStartTetheringCallback)
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
@@ -414,7 +415,7 @@ public class ConnectivityManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Bluetooth tethering type.
|
* Bluetooth tethering type.
|
||||||
* @see #startTethering(int, OnStartTetheringCallback, boolean)
|
* @see #startTethering(int, boolean, OnStartTetheringCallback)
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
@@ -664,7 +665,7 @@ public class ConnectivityManager {
|
|||||||
/**
|
/**
|
||||||
* Static unique request used as a tombstone for NetworkCallbacks that have been unregistered.
|
* Static unique request used as a tombstone for NetworkCallbacks that have been unregistered.
|
||||||
* This allows to distinguish when unregistering NetworkCallbacks those that were never
|
* This allows to distinguish when unregistering NetworkCallbacks those that were never
|
||||||
* registered and those that were already unregistered.
|
* registered from those that were already unregistered.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
private static final NetworkRequest ALREADY_UNREGISTERED =
|
private static final NetworkRequest ALREADY_UNREGISTERED =
|
||||||
@@ -1494,8 +1495,8 @@ public class ConnectivityManager {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HashMap<NetworkCapabilities, LegacyRequest> sLegacyRequests =
|
private static final HashMap<NetworkCapabilities, LegacyRequest> sLegacyRequests =
|
||||||
new HashMap<NetworkCapabilities, LegacyRequest>();
|
new HashMap<>();
|
||||||
|
|
||||||
private NetworkRequest findRequestForFeature(NetworkCapabilities netCap) {
|
private NetworkRequest findRequestForFeature(NetworkCapabilities netCap) {
|
||||||
synchronized (sLegacyRequests) {
|
synchronized (sLegacyRequests) {
|
||||||
@@ -1635,8 +1636,9 @@ public class ConnectivityManager {
|
|||||||
* {@code onStarted} method will be called. If an error occurs, {@code onError} will be called,
|
* {@code onStarted} method will be called. If an error occurs, {@code onError} will be called,
|
||||||
* specifying one of the {@code ERROR_*} constants in this class.
|
* specifying one of the {@code ERROR_*} constants in this class.
|
||||||
*
|
*
|
||||||
* To stop an existing keepalive, call {@link stop}. The system will call {@code onStopped} if
|
* To stop an existing keepalive, call {@link PacketKeepalive#stop}. The system will call
|
||||||
* the operation was successfull or {@code onError} if an error occurred.
|
* {@link PacketKeepaliveCallback#onStopped} if the operation was successful or
|
||||||
|
* {@link PacketKeepaliveCallback#onError} if an error occurred.
|
||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@@ -1897,7 +1899,7 @@ public class ConnectivityManager {
|
|||||||
* to initiate network traffic), you can retrieve its instantaneous state with
|
* to initiate network traffic), you can retrieve its instantaneous state with
|
||||||
* {@link ConnectivityManager#isDefaultNetworkActive}.
|
* {@link ConnectivityManager#isDefaultNetworkActive}.
|
||||||
*/
|
*/
|
||||||
public void onNetworkActive();
|
void onNetworkActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
private INetworkManagementService getNetworkManagementService() {
|
private INetworkManagementService getNetworkManagementService() {
|
||||||
@@ -1912,8 +1914,7 @@ public class ConnectivityManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final ArrayMap<OnNetworkActiveListener, INetworkActivityListener>
|
private final ArrayMap<OnNetworkActiveListener, INetworkActivityListener>
|
||||||
mNetworkActivityListeners
|
mNetworkActivityListeners = new ArrayMap<>();
|
||||||
= new ArrayMap<OnNetworkActiveListener, INetworkActivityListener>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start listening to reports when the system's default data network is active, meaning it is
|
* Start listening to reports when the system's default data network is active, meaning it is
|
||||||
@@ -2216,12 +2217,12 @@ public class ConnectivityManager {
|
|||||||
/**
|
/**
|
||||||
* Called when tethering has been successfully started.
|
* Called when tethering has been successfully started.
|
||||||
*/
|
*/
|
||||||
public void onTetheringStarted() {};
|
public void onTetheringStarted() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when starting tethering failed.
|
* Called when starting tethering failed.
|
||||||
*/
|
*/
|
||||||
public void onTetheringFailed() {};
|
public void onTetheringFailed() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2658,9 +2659,6 @@ public class ConnectivityManager {
|
|||||||
/**
|
/**
|
||||||
* Set sign in error notification to visible or in visible
|
* Set sign in error notification to visible or in visible
|
||||||
*
|
*
|
||||||
* @param visible
|
|
||||||
* @param networkType
|
|
||||||
*
|
|
||||||
* {@hide}
|
* {@hide}
|
||||||
* @deprecated Doesn't properly deal with multiple connected networks of the same type.
|
* @deprecated Doesn't properly deal with multiple connected networks of the same type.
|
||||||
*/
|
*/
|
||||||
@@ -2869,7 +2867,7 @@ public class ConnectivityManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public interface Errors {
|
public interface Errors {
|
||||||
static int TOO_MANY_REQUESTS = 1;
|
int TOO_MANY_REQUESTS = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -3126,7 +3124,7 @@ public class ConnectivityManager {
|
|||||||
* as these {@code NetworkCapabilities} represent states that a particular
|
* as these {@code NetworkCapabilities} represent states that a particular
|
||||||
* network may never attain, and whether a network will attain these states
|
* network may never attain, and whether a network will attain these states
|
||||||
* is unknown prior to bringing up the network so the framework does not
|
* is unknown prior to bringing up the network so the framework does not
|
||||||
* know how to go about satisfing a request with these capabilities.
|
* know how to go about satisfying a request with these capabilities.
|
||||||
*
|
*
|
||||||
* <p>This method requires the caller to hold either the
|
* <p>This method requires the caller to hold either the
|
||||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
||||||
@@ -3186,7 +3184,7 @@ public class ConnectivityManager {
|
|||||||
* Request a network to satisfy a set of {@link android.net.NetworkCapabilities}, limited
|
* Request a network to satisfy a set of {@link android.net.NetworkCapabilities}, limited
|
||||||
* by a timeout.
|
* by a timeout.
|
||||||
*
|
*
|
||||||
* This function behaves identically to the non-timedout version, but if a suitable
|
* This function behaves identically to the version without timeout, but if a suitable
|
||||||
* network is not found within the given time (in milliseconds) the
|
* network is not found within the given time (in milliseconds) the
|
||||||
* {@link NetworkCallback#onUnavailable} callback is called. The request can still be
|
* {@link NetworkCallback#onUnavailable} callback is called. The request can still be
|
||||||
* released normally by calling {@link #unregisterNetworkCallback(NetworkCallback)} but does
|
* released normally by calling {@link #unregisterNetworkCallback(NetworkCallback)} but does
|
||||||
@@ -3267,7 +3265,7 @@ public class ConnectivityManager {
|
|||||||
* as these {@code NetworkCapabilities} represent states that a particular
|
* as these {@code NetworkCapabilities} represent states that a particular
|
||||||
* network may never attain, and whether a network will attain these states
|
* network may never attain, and whether a network will attain these states
|
||||||
* is unknown prior to bringing up the network so the framework does not
|
* is unknown prior to bringing up the network so the framework does not
|
||||||
* know how to go about satisfing a request with these capabilities.
|
* know how to go about satisfying a request with these capabilities.
|
||||||
*
|
*
|
||||||
* <p>This method requires the caller to hold either the
|
* <p>This method requires the caller to hold either the
|
||||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
||||||
@@ -3432,9 +3430,9 @@ public class ConnectivityManager {
|
|||||||
// capabilities, this request is guaranteed, at all times, to be
|
// capabilities, this request is guaranteed, at all times, to be
|
||||||
// satisfied by the same network, if any, that satisfies the default
|
// satisfied by the same network, if any, that satisfies the default
|
||||||
// request, i.e., the system default network.
|
// request, i.e., the system default network.
|
||||||
NetworkCapabilities nullCapabilities = null;
|
|
||||||
CallbackHandler cbHandler = new CallbackHandler(handler);
|
CallbackHandler cbHandler = new CallbackHandler(handler);
|
||||||
sendRequestForNetwork(nullCapabilities, networkCallback, 0, REQUEST, TYPE_NONE, cbHandler);
|
sendRequestForNetwork(null /* NetworkCapabilities need */, networkCallback, 0,
|
||||||
|
REQUEST, TYPE_NONE, cbHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3669,7 +3667,7 @@ public class ConnectivityManager {
|
|||||||
* @return {@code true} on success, {@code false} if the {@link Network} is no longer valid.
|
* @return {@code true} on success, {@code false} if the {@link Network} is no longer valid.
|
||||||
*/
|
*/
|
||||||
public boolean bindProcessToNetwork(Network network) {
|
public boolean bindProcessToNetwork(Network network) {
|
||||||
// Forcing callers to call thru non-static function ensures ConnectivityManager
|
// Forcing callers to call through non-static function ensures ConnectivityManager
|
||||||
// instantiated.
|
// instantiated.
|
||||||
return setProcessDefaultNetwork(network);
|
return setProcessDefaultNetwork(network);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -774,7 +774,7 @@ public final class LinkProperties implements Parcelable {
|
|||||||
String usePrivateDns = "UsePrivateDns: " + mUsePrivateDns + " ";
|
String usePrivateDns = "UsePrivateDns: " + mUsePrivateDns + " ";
|
||||||
|
|
||||||
String privateDnsServerName = "";
|
String privateDnsServerName = "";
|
||||||
if (privateDnsServerName != null) {
|
if (mPrivateDnsServerName != null) {
|
||||||
privateDnsServerName = "PrivateDnsServerName: " + mPrivateDnsServerName + " ";
|
privateDnsServerName = "PrivateDnsServerName: " + mPrivateDnsServerName + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -810,7 +810,7 @@ public final class LinkProperties implements Parcelable {
|
|||||||
stacked += "] ";
|
stacked += "] ";
|
||||||
}
|
}
|
||||||
return "{" + ifaceName + linkAddresses + routes + dns + usePrivateDns
|
return "{" + ifaceName + linkAddresses + routes + dns + usePrivateDns
|
||||||
+ privateDnsServerName + domainName + mtu + tcpBuffSizes + proxy
|
+ privateDnsServerName + validatedPrivateDns + domainName + mtu + tcpBuffSizes + proxy
|
||||||
+ stacked + "}";
|
+ stacked + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1867,7 +1867,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the network specific MTU size from reources.
|
* Reads the network specific MTU size from resources.
|
||||||
* and set it on it's iface.
|
* and set it on it's iface.
|
||||||
*/
|
*/
|
||||||
private void updateMtu(LinkProperties newLp, LinkProperties oldLp) {
|
private void updateMtu(LinkProperties newLp, LinkProperties oldLp) {
|
||||||
@@ -2813,7 +2813,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
if (!accept) {
|
if (!accept) {
|
||||||
// Tell the NetworkAgent to not automatically reconnect to the network.
|
// Tell the NetworkAgent to not automatically reconnect to the network.
|
||||||
nai.asyncChannel.sendMessage(NetworkAgent.CMD_PREVENT_AUTOMATIC_RECONNECT);
|
nai.asyncChannel.sendMessage(NetworkAgent.CMD_PREVENT_AUTOMATIC_RECONNECT);
|
||||||
// Teardown the nework.
|
// Teardown the network.
|
||||||
teardownUnneededNetwork(nai);
|
teardownUnneededNetwork(nai);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3327,7 +3327,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
private ProxyInfo getDefaultProxy() {
|
private ProxyInfo getDefaultProxy() {
|
||||||
// this information is already available as a world read/writable jvm property
|
// this information is already available as a world read/writable jvm property
|
||||||
// so this API change wouldn't have a benifit. It also breaks the passing
|
// so this API change wouldn't have a benefit. It also breaks the passing
|
||||||
// of proxy info to all the JVMs.
|
// of proxy info to all the JVMs.
|
||||||
// enforceAccessPermission();
|
// enforceAccessPermission();
|
||||||
synchronized (mProxyLock) {
|
synchronized (mProxyLock) {
|
||||||
@@ -3457,7 +3457,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
public ProxyInfo getGlobalProxy() {
|
public ProxyInfo getGlobalProxy() {
|
||||||
// this information is already available as a world read/writable jvm property
|
// this information is already available as a world read/writable jvm property
|
||||||
// so this API change wouldn't have a benifit. It also breaks the passing
|
// so this API change wouldn't have a benefit. It also breaks the passing
|
||||||
// of proxy info to all the JVMs.
|
// of proxy info to all the JVMs.
|
||||||
// enforceAccessPermission();
|
// enforceAccessPermission();
|
||||||
synchronized (mProxyLock) {
|
synchronized (mProxyLock) {
|
||||||
@@ -4029,7 +4029,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
url = String.format(url,
|
url = String.format(url,
|
||||||
mTelephonyManager.getSimSerialNumber() /* ICCID */,
|
mTelephonyManager.getSimSerialNumber() /* ICCID */,
|
||||||
mTelephonyManager.getDeviceId() /* IMEI */,
|
mTelephonyManager.getDeviceId() /* IMEI */,
|
||||||
phoneNumber /* Phone numer */);
|
phoneNumber /* Phone number */);
|
||||||
}
|
}
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
@@ -4702,7 +4702,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void wakeupModifyInterface(String iface, NetworkCapabilities caps, boolean add) {
|
private void wakeupModifyInterface(String iface, NetworkCapabilities caps, boolean add) {
|
||||||
// Marks are only available on WiFi interaces. Checking for
|
// Marks are only available on WiFi interfaces. Checking for
|
||||||
// marks on unsupported interfaces is harmless.
|
// marks on unsupported interfaces is harmless.
|
||||||
if (!caps.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
|
if (!caps.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
|
||||||
return;
|
return;
|
||||||
@@ -4769,7 +4769,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
// add routes before removing old in case it helps with continuous connectivity
|
// add routes before removing old in case it helps with continuous connectivity
|
||||||
|
|
||||||
// do this twice, adding non-nexthop routes first, then routes they are dependent on
|
// do this twice, adding non-next-hop routes first, then routes they are dependent on
|
||||||
for (RouteInfo route : routeDiff.added) {
|
for (RouteInfo route : routeDiff.added) {
|
||||||
if (route.hasGateway()) continue;
|
if (route.hasGateway()) continue;
|
||||||
if (VDBG) log("Adding Route [" + route + "] to network " + netId);
|
if (VDBG) log("Adding Route [" + route + "] to network " + netId);
|
||||||
@@ -5394,7 +5394,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
// This has to happen after the notifyNetworkCallbacks as that tickles each
|
// This has to happen after the notifyNetworkCallbacks as that tickles each
|
||||||
// ConnectivityManager instance so that legacy requests correctly bind dns
|
// ConnectivityManager instance so that legacy requests correctly bind dns
|
||||||
// requests to this network. The legacy users are listening for this bcast
|
// requests to this network. The legacy users are listening for this broadcast
|
||||||
// and will generally do a dns request so they can ensureRouteToHost and if
|
// and will generally do a dns request so they can ensureRouteToHost and if
|
||||||
// they do that before the callbacks happen they'll use the default network.
|
// they do that before the callbacks happen they'll use the default network.
|
||||||
//
|
//
|
||||||
@@ -5459,7 +5459,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// TODO: This may get slow. The "changed" parameter is provided for future optimization
|
// TODO: This may get slow. The "changed" parameter is provided for future optimization
|
||||||
// to avoid the slowness. It is not simply enough to process just "changed", for
|
// to avoid the slowness. It is not simply enough to process just "changed", for
|
||||||
// example in the case where "changed"'s score decreases and another network should begin
|
// example in the case where "changed"'s score decreases and another network should begin
|
||||||
// satifying a NetworkRequest that "changed" currently satisfies.
|
// satisfying a NetworkRequest that "changed" currently satisfies.
|
||||||
|
|
||||||
// Optimization: Only reprocess "changed" if its score improved. This is safe because it
|
// Optimization: Only reprocess "changed" if its score improved. This is safe because it
|
||||||
// can only add more NetworkRequests satisfied by "changed", and this is exactly what
|
// can only add more NetworkRequests satisfied by "changed", and this is exactly what
|
||||||
@@ -5612,7 +5612,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
disconnectAndDestroyNetwork(networkAgent);
|
disconnectAndDestroyNetwork(networkAgent);
|
||||||
} else if ((oldInfo != null && oldInfo.getState() == NetworkInfo.State.SUSPENDED) ||
|
} else if ((oldInfo != null && oldInfo.getState() == NetworkInfo.State.SUSPENDED) ||
|
||||||
state == NetworkInfo.State.SUSPENDED) {
|
state == NetworkInfo.State.SUSPENDED) {
|
||||||
// going into or coming out of SUSPEND: rescore and notify
|
// going into or coming out of SUSPEND: re-score and notify
|
||||||
if (networkAgent.getCurrentScore() != oldScore) {
|
if (networkAgent.getCurrentScore() != oldScore) {
|
||||||
rematchAllNetworksAndRequests(networkAgent, oldScore);
|
rematchAllNetworksAndRequests(networkAgent, oldScore);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user