Don't bother validating networks that don't satisfy the default request.

The only immediate change in behavior is not validating untrusted networks.

bug:18299572
bug:18394654

Change-Id: I8d626baf37db0bd0f55ddf3af8a0abf094a12369
This commit is contained in:
Paul Jensen
2014-11-17 12:34:51 -05:00
parent c52ae42e2f
commit ce90ecbaf7
2 changed files with 6 additions and 3 deletions

View File

@@ -3615,6 +3615,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
private final HashMap<Messenger, NetworkAgentInfo> mNetworkAgentInfos =
new HashMap<Messenger, NetworkAgentInfo>();
// Note: if mDefaultRequest is changed, NetworkMonitor needs to be updated.
private final NetworkRequest mDefaultRequest;
private boolean isDefaultNetwork(NetworkAgentInfo nai) {
@@ -3626,10 +3627,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
int currentScore, NetworkMisc networkMisc) {
enforceConnectivityInternalPermission();
// TODO: Instead of passing mDefaultRequest, provide an API to determine whether a Network
// satisfies mDefaultRequest.
NetworkAgentInfo nai = new NetworkAgentInfo(messenger, new AsyncChannel(),
new NetworkInfo(networkInfo), new LinkProperties(linkProperties),
new NetworkCapabilities(networkCapabilities), currentScore, mContext, mTrackerHandler,
new NetworkMisc(networkMisc));
new NetworkMisc(networkMisc), mDefaultRequest);
synchronized (this) {
nai.networkMonitor.systemReady = mSystemReady;
}

View File

@@ -68,7 +68,7 @@ public class NetworkAgentInfo {
public NetworkAgentInfo(Messenger messenger, AsyncChannel ac, NetworkInfo info,
LinkProperties lp, NetworkCapabilities nc, int score, Context context, Handler handler,
NetworkMisc misc) {
NetworkMisc misc, NetworkRequest defaultRequest) {
this.messenger = messenger;
asyncChannel = ac;
network = null;
@@ -76,7 +76,7 @@ public class NetworkAgentInfo {
linkProperties = lp;
networkCapabilities = nc;
currentScore = score;
networkMonitor = new NetworkMonitor(context, handler, this);
networkMonitor = new NetworkMonitor(context, handler, this, defaultRequest);
networkMisc = misc;
created = false;
validated = false;