Merge changes Ifd7d73ad,Id79096fa
* changes: Bugfixes in LinkProperties#toString Cleanup of ConnectivityManager.
This commit is contained in:
@@ -125,8 +125,8 @@ public class ConnectivityManager {
|
||||
/**
|
||||
* 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
|
||||
* and waking due to the CONNECTIVITY_ACTION bcast makes it expensive.
|
||||
* Use this bcast intent instead for SUPL requests.
|
||||
* and waking due to the CONNECTIVITY_ACTION broadcast makes it expensive.
|
||||
* Use this broadcast intent instead for SUPL requests.
|
||||
* @hide
|
||||
*/
|
||||
public static final String CONNECTIVITY_ACTION_SUPL =
|
||||
@@ -152,7 +152,7 @@ public class ConnectivityManager {
|
||||
* call {@link CaptivePortal#reportCaptivePortalDismissed} so the system can
|
||||
* reevaluate the network. If reevaluation finds the network no longer
|
||||
* subject to a captive portal, the network may become the default active
|
||||
* data network. </li>
|
||||
* data network.</li>
|
||||
* <li> When the app handling this action believes the user explicitly wants
|
||||
* to ignore the captive portal and the network, the app should call
|
||||
* {@link CaptivePortal#ignoreNetwork}. </li>
|
||||
@@ -260,7 +260,8 @@ public class ConnectivityManager {
|
||||
* {@hide}
|
||||
*/
|
||||
@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
|
||||
* change happens.
|
||||
@@ -391,14 +392,14 @@ public class ConnectivityManager {
|
||||
|
||||
/**
|
||||
* Invalid tethering type.
|
||||
* @see #startTethering(int, OnStartTetheringCallback, boolean)
|
||||
* @see #startTethering(int, boolean, OnStartTetheringCallback)
|
||||
* @hide
|
||||
*/
|
||||
public static final int TETHERING_INVALID = -1;
|
||||
|
||||
/**
|
||||
* Wifi tethering type.
|
||||
* @see #startTethering(int, OnStartTetheringCallback, boolean)
|
||||
* @see #startTethering(int, boolean, OnStartTetheringCallback)
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@@ -406,7 +407,7 @@ public class ConnectivityManager {
|
||||
|
||||
/**
|
||||
* USB tethering type.
|
||||
* @see #startTethering(int, OnStartTetheringCallback, boolean)
|
||||
* @see #startTethering(int, boolean, OnStartTetheringCallback)
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@@ -414,7 +415,7 @@ public class ConnectivityManager {
|
||||
|
||||
/**
|
||||
* Bluetooth tethering type.
|
||||
* @see #startTethering(int, OnStartTetheringCallback, boolean)
|
||||
* @see #startTethering(int, boolean, OnStartTetheringCallback)
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@@ -664,7 +665,7 @@ public class ConnectivityManager {
|
||||
/**
|
||||
* Static unique request used as a tombstone for NetworkCallbacks that have been unregistered.
|
||||
* 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
|
||||
*/
|
||||
private static final NetworkRequest ALREADY_UNREGISTERED =
|
||||
@@ -1494,8 +1495,8 @@ public class ConnectivityManager {
|
||||
};
|
||||
}
|
||||
|
||||
private static HashMap<NetworkCapabilities, LegacyRequest> sLegacyRequests =
|
||||
new HashMap<NetworkCapabilities, LegacyRequest>();
|
||||
private static final HashMap<NetworkCapabilities, LegacyRequest> sLegacyRequests =
|
||||
new HashMap<>();
|
||||
|
||||
private NetworkRequest findRequestForFeature(NetworkCapabilities netCap) {
|
||||
synchronized (sLegacyRequests) {
|
||||
@@ -1635,8 +1636,9 @@ public class ConnectivityManager {
|
||||
* {@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.
|
||||
*
|
||||
* To stop an existing keepalive, call {@link stop}. The system will call {@code onStopped} if
|
||||
* the operation was successfull or {@code onError} if an error occurred.
|
||||
* To stop an existing keepalive, call {@link PacketKeepalive#stop}. The system will call
|
||||
* {@link PacketKeepaliveCallback#onStopped} if the operation was successful or
|
||||
* {@link PacketKeepaliveCallback#onError} if an error occurred.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@@ -1897,7 +1899,7 @@ public class ConnectivityManager {
|
||||
* to initiate network traffic), you can retrieve its instantaneous state with
|
||||
* {@link ConnectivityManager#isDefaultNetworkActive}.
|
||||
*/
|
||||
public void onNetworkActive();
|
||||
void onNetworkActive();
|
||||
}
|
||||
|
||||
private INetworkManagementService getNetworkManagementService() {
|
||||
@@ -1912,8 +1914,7 @@ public class ConnectivityManager {
|
||||
}
|
||||
|
||||
private final ArrayMap<OnNetworkActiveListener, INetworkActivityListener>
|
||||
mNetworkActivityListeners
|
||||
= new ArrayMap<OnNetworkActiveListener, INetworkActivityListener>();
|
||||
mNetworkActivityListeners = new ArrayMap<>();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public void onTetheringStarted() {};
|
||||
public void onTetheringStarted() {}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @param visible
|
||||
* @param networkType
|
||||
*
|
||||
* {@hide}
|
||||
* @deprecated Doesn't properly deal with multiple connected networks of the same type.
|
||||
*/
|
||||
@@ -2869,7 +2867,7 @@ public class ConnectivityManager {
|
||||
* @hide
|
||||
*/
|
||||
public interface Errors {
|
||||
static int TOO_MANY_REQUESTS = 1;
|
||||
int TOO_MANY_REQUESTS = 1;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@@ -3126,7 +3124,7 @@ public class ConnectivityManager {
|
||||
* as these {@code NetworkCapabilities} represent states that a particular
|
||||
* 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
|
||||
* 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
|
||||
* {@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
|
||||
* 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
|
||||
* {@link NetworkCallback#onUnavailable} callback is called. The request can still be
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* {@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
|
||||
// satisfied by the same network, if any, that satisfies the default
|
||||
// request, i.e., the system default network.
|
||||
NetworkCapabilities nullCapabilities = null;
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
return setProcessDefaultNetwork(network);
|
||||
}
|
||||
|
||||
@@ -774,7 +774,7 @@ public final class LinkProperties implements Parcelable {
|
||||
String usePrivateDns = "UsePrivateDns: " + mUsePrivateDns + " ";
|
||||
|
||||
String privateDnsServerName = "";
|
||||
if (privateDnsServerName != null) {
|
||||
if (mPrivateDnsServerName != null) {
|
||||
privateDnsServerName = "PrivateDnsServerName: " + mPrivateDnsServerName + " ";
|
||||
}
|
||||
|
||||
@@ -810,7 +810,7 @@ public final class LinkProperties implements Parcelable {
|
||||
stacked += "] ";
|
||||
}
|
||||
return "{" + ifaceName + linkAddresses + routes + dns + usePrivateDns
|
||||
+ privateDnsServerName + domainName + mtu + tcpBuffSizes + proxy
|
||||
+ privateDnsServerName + validatedPrivateDns + domainName + mtu + tcpBuffSizes + proxy
|
||||
+ stacked + "}";
|
||||
}
|
||||
|
||||
|
||||
@@ -1828,7 +1828,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
if (iface != null && (caps.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) ||
|
||||
caps.hasTransport(NetworkCapabilities.TRANSPORT_WIFI))) {
|
||||
try {
|
||||
// the call fails silently if no idletimer setup for this interface
|
||||
// the call fails silently if no idle timer setup for this interface
|
||||
mNetd.removeIdleTimer(iface);
|
||||
} catch (Exception e) {
|
||||
loge("Exception in removeDataActivityTracking " + e);
|
||||
@@ -1837,7 +1837,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.
|
||||
*/
|
||||
private void updateMtu(LinkProperties newLp, LinkProperties oldLp) {
|
||||
@@ -2775,7 +2775,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
if (!accept) {
|
||||
// Tell the NetworkAgent to not automatically reconnect to the network.
|
||||
nai.asyncChannel.sendMessage(NetworkAgent.CMD_PREVENT_AUTOMATIC_RECONNECT);
|
||||
// Teardown the nework.
|
||||
// Teardown the network.
|
||||
teardownUnneededNetwork(nai);
|
||||
}
|
||||
|
||||
@@ -3283,7 +3283,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
|
||||
private ProxyInfo getDefaultProxy() {
|
||||
// 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.
|
||||
// enforceAccessPermission();
|
||||
synchronized (mProxyLock) {
|
||||
@@ -3413,7 +3413,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
|
||||
public ProxyInfo getGlobalProxy() {
|
||||
// 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.
|
||||
// enforceAccessPermission();
|
||||
synchronized (mProxyLock) {
|
||||
@@ -3821,7 +3821,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
synchronized (mVpns) {
|
||||
Vpn vpn = mVpns.get(userId);
|
||||
if (vpn == null) {
|
||||
// Shouldn't happen as all codepaths that point here should have checked the Vpn
|
||||
// Shouldn't happen as all code paths that point here should have checked the Vpn
|
||||
// exists already.
|
||||
Slog.wtf(TAG, "User " + userId + " has no Vpn configuration");
|
||||
return false;
|
||||
@@ -3985,7 +3985,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
url = String.format(url,
|
||||
mTelephonyManager.getSimSerialNumber() /* ICCID */,
|
||||
mTelephonyManager.getDeviceId() /* IMEI */,
|
||||
phoneNumber /* Phone numer */);
|
||||
phoneNumber /* Phone number */);
|
||||
}
|
||||
|
||||
return url;
|
||||
@@ -4658,7 +4658,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
|
||||
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.
|
||||
if (!caps.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
|
||||
return;
|
||||
@@ -4725,7 +4725,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
|
||||
// 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) {
|
||||
if (route.hasGateway()) continue;
|
||||
if (VDBG) log("Adding Route [" + route + "] to network " + netId);
|
||||
@@ -5224,7 +5224,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
keep = true;
|
||||
// Tell NetworkFactories about the new score, so they can stop
|
||||
// trying to connect if they know they cannot match it.
|
||||
// TODO - this could get expensive if we have alot of requests for this
|
||||
// TODO - this could get expensive if we have a lot of requests for this
|
||||
// network. Think about if there is a way to reduce this. Push
|
||||
// netid->request mapping to each factory?
|
||||
sendUpdatedScoreToFactories(nri.request, score);
|
||||
@@ -5345,7 +5345,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
|
||||
// This has to happen after the notifyNetworkCallbacks as that tickles each
|
||||
// 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
|
||||
// they do that before the callbacks happen they'll use the default network.
|
||||
//
|
||||
@@ -5410,7 +5410,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
// 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
|
||||
// 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
|
||||
// can only add more NetworkRequests satisfied by "changed", and this is exactly what
|
||||
@@ -5563,7 +5563,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
disconnectAndDestroyNetwork(networkAgent);
|
||||
} else if ((oldInfo != null && oldInfo.getState() == 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) {
|
||||
rematchAllNetworksAndRequests(networkAgent, oldScore);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user