Add external dependency API.
An APN will not be connected to if some external dependency is not met. bug:3486704 Change-Id: I7d94df343b260013efd11faa978deb13f07f1389
This commit is contained in:
@@ -690,4 +690,16 @@ public class ConnectivityManager
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param networkType The network who's dependence has changed
|
||||||
|
* @param met Boolean - true if network use is ok, false if not
|
||||||
|
* {@hide}
|
||||||
|
*/
|
||||||
|
public void setDataDependency(int networkType, boolean met) {
|
||||||
|
try {
|
||||||
|
mService.setDataDependency(networkType, met);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,4 +92,6 @@ interface IConnectivityManager
|
|||||||
void setGlobalProxy(in ProxyProperties p);
|
void setGlobalProxy(in ProxyProperties p);
|
||||||
|
|
||||||
ProxyProperties getProxy();
|
ProxyProperties getProxy();
|
||||||
|
|
||||||
|
void setDataDependency(int networkType, boolean met);
|
||||||
}
|
}
|
||||||
|
|||||||
76
core/java/android/net/NetworkConfig.java
Normal file
76
core/java/android/net/NetworkConfig.java
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.net;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes the buildtime configuration of a network.
|
||||||
|
* Holds settings read from resources.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public class NetworkConfig {
|
||||||
|
/**
|
||||||
|
* Human readable string
|
||||||
|
*/
|
||||||
|
public String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type from ConnectivityManager
|
||||||
|
*/
|
||||||
|
public int type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the radio number from radio attributes config
|
||||||
|
*/
|
||||||
|
public int radio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* higher number == higher priority when turning off connections
|
||||||
|
*/
|
||||||
|
public int priority;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* indicates the boot time dependencyMet setting
|
||||||
|
*/
|
||||||
|
public boolean dependencyMet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* input string from config.xml resource. Uses the form:
|
||||||
|
* [Connection name],[ConnectivityManager connection type],
|
||||||
|
* [associated radio-type],[priority],[dependencyMet]
|
||||||
|
*/
|
||||||
|
public NetworkConfig(String init) {
|
||||||
|
String fragments[] = init.split(",");
|
||||||
|
name = fragments[0].trim().toLowerCase();
|
||||||
|
type = Integer.parseInt(fragments[1]);
|
||||||
|
radio = Integer.parseInt(fragments[2]);
|
||||||
|
priority = Integer.parseInt(fragments[3]);
|
||||||
|
if (fragments.length > 4) {
|
||||||
|
dependencyMet = Boolean.parseBoolean(fragments[4]);
|
||||||
|
} else {
|
||||||
|
dependencyMet = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if this network is supposed to be default-routable
|
||||||
|
*/
|
||||||
|
public boolean isDefault() {
|
||||||
|
return (type == radio);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ import android.net.DummyDataStateTracker;
|
|||||||
import android.net.IConnectivityManager;
|
import android.net.IConnectivityManager;
|
||||||
import android.net.LinkProperties;
|
import android.net.LinkProperties;
|
||||||
import android.net.MobileDataStateTracker;
|
import android.net.MobileDataStateTracker;
|
||||||
|
import android.net.NetworkConfig;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.NetworkStateTracker;
|
import android.net.NetworkStateTracker;
|
||||||
import android.net.NetworkUtils;
|
import android.net.NetworkUtils;
|
||||||
@@ -188,6 +189,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
private static final int EVENT_APPLY_GLOBAL_HTTP_PROXY =
|
private static final int EVENT_APPLY_GLOBAL_HTTP_PROXY =
|
||||||
MAX_NETWORK_STATE_TRACKER_EVENT + 9;
|
MAX_NETWORK_STATE_TRACKER_EVENT + 9;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* used internally to set external dependency met/unmet
|
||||||
|
* arg1 = ENABLED (met) or DISABLED (unmet)
|
||||||
|
* arg2 = NetworkType
|
||||||
|
*/
|
||||||
|
private static final int EVENT_SET_DEPENDENCY_MET =
|
||||||
|
MAX_NETWORK_STATE_TRACKER_EVENT + 10;
|
||||||
|
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
|
|
||||||
// list of DeathRecipients used to make sure features are turned off when
|
// list of DeathRecipients used to make sure features are turned off when
|
||||||
@@ -216,28 +225,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
private SettingsObserver mSettingsObserver;
|
private SettingsObserver mSettingsObserver;
|
||||||
|
|
||||||
private static class NetworkAttributes {
|
NetworkConfig[] mNetConfigs;
|
||||||
/**
|
|
||||||
* Class for holding settings read from resources.
|
|
||||||
*/
|
|
||||||
public String mName;
|
|
||||||
public int mType;
|
|
||||||
public int mRadio;
|
|
||||||
public int mPriority;
|
|
||||||
public NetworkInfo.State mLastState;
|
|
||||||
public NetworkAttributes(String init) {
|
|
||||||
String fragments[] = init.split(",");
|
|
||||||
mName = fragments[0].toLowerCase();
|
|
||||||
mType = Integer.parseInt(fragments[1]);
|
|
||||||
mRadio = Integer.parseInt(fragments[2]);
|
|
||||||
mPriority = Integer.parseInt(fragments[3]);
|
|
||||||
mLastState = NetworkInfo.State.UNKNOWN;
|
|
||||||
}
|
|
||||||
public boolean isDefault() {
|
|
||||||
return (mType == mRadio);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NetworkAttributes[] mNetAttributes;
|
|
||||||
int mNetworksDefined;
|
int mNetworksDefined;
|
||||||
|
|
||||||
private static class RadioAttributes {
|
private static class RadioAttributes {
|
||||||
@@ -304,7 +292,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
mNetworkPreference = getPersistedNetworkPreference();
|
mNetworkPreference = getPersistedNetworkPreference();
|
||||||
|
|
||||||
mRadioAttributes = new RadioAttributes[ConnectivityManager.MAX_RADIO_TYPE+1];
|
mRadioAttributes = new RadioAttributes[ConnectivityManager.MAX_RADIO_TYPE+1];
|
||||||
mNetAttributes = new NetworkAttributes[ConnectivityManager.MAX_NETWORK_TYPE+1];
|
mNetConfigs = new NetworkConfig[ConnectivityManager.MAX_NETWORK_TYPE+1];
|
||||||
|
|
||||||
// Load device network attributes from resources
|
// Load device network attributes from resources
|
||||||
String[] raStrings = context.getResources().getStringArray(
|
String[] raStrings = context.getResources().getStringArray(
|
||||||
@@ -327,13 +315,13 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
com.android.internal.R.array.networkAttributes);
|
com.android.internal.R.array.networkAttributes);
|
||||||
for (String naString : naStrings) {
|
for (String naString : naStrings) {
|
||||||
try {
|
try {
|
||||||
NetworkAttributes n = new NetworkAttributes(naString);
|
NetworkConfig n = new NetworkConfig(naString);
|
||||||
if (n.mType > ConnectivityManager.MAX_NETWORK_TYPE) {
|
if (n.mType > ConnectivityManager.MAX_NETWORK_TYPE) {
|
||||||
loge("Error in networkAttributes - ignoring attempt to define type " +
|
loge("Error in networkAttributes - ignoring attempt to define type " +
|
||||||
n.mType);
|
n.mType);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (mNetAttributes[n.mType] != null) {
|
if (mNetConfigs[n.mType] != null) {
|
||||||
loge("Error in networkAttributes - ignoring attempt to redefine type " +
|
loge("Error in networkAttributes - ignoring attempt to redefine type " +
|
||||||
n.mType);
|
n.mType);
|
||||||
continue;
|
continue;
|
||||||
@@ -343,7 +331,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
"radio " + n.mRadio + " in network type " + n.mType);
|
"radio " + n.mRadio + " in network type " + n.mType);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mNetAttributes[n.mType] = n;
|
mNetConfigs[n.mType] = n;
|
||||||
mNetworksDefined++;
|
mNetworksDefined++;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
// ignore it - leave the entry null
|
// ignore it - leave the entry null
|
||||||
@@ -357,7 +345,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
int currentLowest = 0;
|
int currentLowest = 0;
|
||||||
int nextLowest = 0;
|
int nextLowest = 0;
|
||||||
while (insertionPoint > -1) {
|
while (insertionPoint > -1) {
|
||||||
for (NetworkAttributes na : mNetAttributes) {
|
for (NetworkConfig na : mNetConfigs) {
|
||||||
if (na == null) continue;
|
if (na == null) continue;
|
||||||
if (na.mPriority < currentLowest) continue;
|
if (na.mPriority < currentLowest) continue;
|
||||||
if (na.mPriority > currentLowest) {
|
if (na.mPriority > currentLowest) {
|
||||||
@@ -392,7 +380,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
* to change very often.
|
* to change very often.
|
||||||
*/
|
*/
|
||||||
for (int netType : mPriorityList) {
|
for (int netType : mPriorityList) {
|
||||||
switch (mNetAttributes[netType].mRadio) {
|
switch (mNetConfigs[netType].mRadio) {
|
||||||
case ConnectivityManager.TYPE_WIFI:
|
case ConnectivityManager.TYPE_WIFI:
|
||||||
if (DBG) log("Starting Wifi Service.");
|
if (DBG) log("Starting Wifi Service.");
|
||||||
WifiStateTracker wst = new WifiStateTracker();
|
WifiStateTracker wst = new WifiStateTracker();
|
||||||
@@ -408,12 +396,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
break;
|
break;
|
||||||
case ConnectivityManager.TYPE_MOBILE:
|
case ConnectivityManager.TYPE_MOBILE:
|
||||||
mNetTrackers[netType] = new MobileDataStateTracker(netType,
|
mNetTrackers[netType] = new MobileDataStateTracker(netType,
|
||||||
mNetAttributes[netType].mName);
|
mNetConfigs[netType].mName);
|
||||||
mNetTrackers[netType].startMonitoring(context, mHandler);
|
mNetTrackers[netType].startMonitoring(context, mHandler);
|
||||||
break;
|
break;
|
||||||
case ConnectivityManager.TYPE_DUMMY:
|
case ConnectivityManager.TYPE_DUMMY:
|
||||||
mNetTrackers[netType] = new DummyDataStateTracker(netType,
|
mNetTrackers[netType] = new DummyDataStateTracker(netType,
|
||||||
mNetAttributes[netType].mName);
|
mNetConfigs[netType].mName);
|
||||||
mNetTrackers[netType].startMonitoring(context, mHandler);
|
mNetTrackers[netType].startMonitoring(context, mHandler);
|
||||||
break;
|
break;
|
||||||
case ConnectivityManager.TYPE_BLUETOOTH:
|
case ConnectivityManager.TYPE_BLUETOOTH:
|
||||||
@@ -422,7 +410,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
loge("Trying to create a DataStateTracker for an unknown radio type " +
|
loge("Trying to create a DataStateTracker for an unknown radio type " +
|
||||||
mNetAttributes[netType].mRadio);
|
mNetConfigs[netType].mRadio);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -469,8 +457,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
private void handleSetNetworkPreference(int preference) {
|
private void handleSetNetworkPreference(int preference) {
|
||||||
if (ConnectivityManager.isNetworkTypeValid(preference) &&
|
if (ConnectivityManager.isNetworkTypeValid(preference) &&
|
||||||
mNetAttributes[preference] != null &&
|
mNetConfigs[preference] != null &&
|
||||||
mNetAttributes[preference].isDefault()) {
|
mNetConfigs[preference].isDefault()) {
|
||||||
if (mNetworkPreference != preference) {
|
if (mNetworkPreference != preference) {
|
||||||
final ContentResolver cr = mContext.getContentResolver();
|
final ContentResolver cr = mContext.getContentResolver();
|
||||||
Settings.Secure.putInt(cr, Settings.Secure.NETWORK_PREFERENCE, preference);
|
Settings.Secure.putInt(cr, Settings.Secure.NETWORK_PREFERENCE, preference);
|
||||||
@@ -539,7 +527,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
public NetworkInfo getActiveNetworkInfo() {
|
public NetworkInfo getActiveNetworkInfo() {
|
||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
for (int type=0; type <= ConnectivityManager.MAX_NETWORK_TYPE; type++) {
|
for (int type=0; type <= ConnectivityManager.MAX_NETWORK_TYPE; type++) {
|
||||||
if (mNetAttributes[type] == null || !mNetAttributes[type].isDefault()) {
|
if (mNetConfigs[type] == null || !mNetConfigs[type].isDefault()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NetworkStateTracker t = mNetTrackers[type];
|
NetworkStateTracker t = mNetTrackers[type];
|
||||||
@@ -585,7 +573,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
public LinkProperties getActiveLinkProperties() {
|
public LinkProperties getActiveLinkProperties() {
|
||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
for (int type=0; type <= ConnectivityManager.MAX_NETWORK_TYPE; type++) {
|
for (int type=0; type <= ConnectivityManager.MAX_NETWORK_TYPE; type++) {
|
||||||
if (mNetAttributes[type] == null || !mNetAttributes[type].isDefault()) {
|
if (mNetConfigs[type] == null || !mNetConfigs[type].isDefault()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NetworkStateTracker t = mNetTrackers[type];
|
NetworkStateTracker t = mNetTrackers[type];
|
||||||
@@ -687,7 +675,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
enforceChangePermission();
|
enforceChangePermission();
|
||||||
if (!ConnectivityManager.isNetworkTypeValid(networkType) ||
|
if (!ConnectivityManager.isNetworkTypeValid(networkType) ||
|
||||||
mNetAttributes[networkType] == null) {
|
mNetConfigs[networkType] == null) {
|
||||||
return Phone.APN_REQUEST_FAILED;
|
return Phone.APN_REQUEST_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -999,6 +987,24 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDataDependency(int networkType, boolean met) {
|
||||||
|
enforceChangePermission();
|
||||||
|
if (DBG) {
|
||||||
|
log("setDataDependency(" + networkType + ", " + met + ")");
|
||||||
|
}
|
||||||
|
mHandler.sendMessage(mHandler.obtainMessage(EVENT_SET_DEPENDENCY_MET,
|
||||||
|
(met ? ENABLED : DISABLED), networkType));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleSetDependencyMet(int networkType, boolean met) {
|
||||||
|
if (mNetTrackers[networkType] != null) {
|
||||||
|
if (DBG) {
|
||||||
|
log("handleSetDependencyMet(" + networkType + ", " + met + ")");
|
||||||
|
}
|
||||||
|
mNetTrackers[networkType].setDependencyMet(met);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ConnectivityManager#setMobileDataEnabled(boolean)
|
* @see ConnectivityManager#setMobileDataEnabled(boolean)
|
||||||
*/
|
*/
|
||||||
@@ -1007,7 +1013,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (DBG) log("setMobileDataEnabled(" + enabled + ")");
|
if (DBG) log("setMobileDataEnabled(" + enabled + ")");
|
||||||
|
|
||||||
mHandler.sendMessage(mHandler.obtainMessage(EVENT_SET_MOBILE_DATA,
|
mHandler.sendMessage(mHandler.obtainMessage(EVENT_SET_MOBILE_DATA,
|
||||||
(enabled ? ENABLED : DISABLED), 0));
|
(enabled ? ENABLED : DISABLED), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleSetMobileData(boolean enabled) {
|
private void handleSetMobileData(boolean enabled) {
|
||||||
@@ -1068,7 +1074,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
* getting the disconnect for a network that we explicitly disabled
|
* getting the disconnect for a network that we explicitly disabled
|
||||||
* in accordance with network preference policies.
|
* in accordance with network preference policies.
|
||||||
*/
|
*/
|
||||||
if (!mNetAttributes[prevNetType].isDefault()) {
|
if (!mNetConfigs[prevNetType].isDefault()) {
|
||||||
List pids = mNetRequestersPids[prevNetType];
|
List pids = mNetRequestersPids[prevNetType];
|
||||||
for (int i = 0; i<pids.size(); i++) {
|
for (int i = 0; i<pids.size(); i++) {
|
||||||
Integer pid = (Integer)pids.get(i);
|
Integer pid = (Integer)pids.get(i);
|
||||||
@@ -1093,7 +1099,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
info.getExtraInfo());
|
info.getExtraInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mNetAttributes[prevNetType].isDefault()) {
|
if (mNetConfigs[prevNetType].isDefault()) {
|
||||||
tryFailover(prevNetType);
|
tryFailover(prevNetType);
|
||||||
if (mActiveDefaultNetwork != -1) {
|
if (mActiveDefaultNetwork != -1) {
|
||||||
NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
||||||
@@ -1123,7 +1129,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
* Try to reconnect on all available and let them hash it out when
|
* Try to reconnect on all available and let them hash it out when
|
||||||
* more than one connects.
|
* more than one connects.
|
||||||
*/
|
*/
|
||||||
if (mNetAttributes[prevNetType].isDefault()) {
|
if (mNetConfigs[prevNetType].isDefault()) {
|
||||||
if (mActiveDefaultNetwork == prevNetType) {
|
if (mActiveDefaultNetwork == prevNetType) {
|
||||||
mActiveDefaultNetwork = -1;
|
mActiveDefaultNetwork = -1;
|
||||||
}
|
}
|
||||||
@@ -1133,12 +1139,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
// TODO - don't filter by priority now - nice optimization but risky
|
// TODO - don't filter by priority now - nice optimization but risky
|
||||||
// int currentPriority = -1;
|
// int currentPriority = -1;
|
||||||
// if (mActiveDefaultNetwork != -1) {
|
// if (mActiveDefaultNetwork != -1) {
|
||||||
// currentPriority = mNetAttributes[mActiveDefaultNetwork].mPriority;
|
// currentPriority = mNetConfigs[mActiveDefaultNetwork].mPriority;
|
||||||
// }
|
// }
|
||||||
for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) {
|
for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) {
|
||||||
if (checkType == prevNetType) continue;
|
if (checkType == prevNetType) continue;
|
||||||
if (mNetAttributes[checkType] == null) continue;
|
if (mNetConfigs[checkType] == null) continue;
|
||||||
if (!mNetAttributes[checkType].isDefault()) continue;
|
if (!mNetConfigs[checkType].isDefault()) continue;
|
||||||
|
|
||||||
// Enabling the isAvailable() optimization caused mobile to not get
|
// Enabling the isAvailable() optimization caused mobile to not get
|
||||||
// selected if it was in the middle of error handling. Specifically
|
// selected if it was in the middle of error handling. Specifically
|
||||||
@@ -1150,7 +1156,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
// complete before it is really complete.
|
// complete before it is really complete.
|
||||||
// if (!mNetTrackers[checkType].isAvailable()) continue;
|
// if (!mNetTrackers[checkType].isAvailable()) continue;
|
||||||
|
|
||||||
// if (currentPriority >= mNetAttributes[checkType].mPriority) continue;
|
// if (currentPriority >= mNetConfigs[checkType].mPriority) continue;
|
||||||
|
|
||||||
NetworkStateTracker checkTracker = mNetTrackers[checkType];
|
NetworkStateTracker checkTracker = mNetTrackers[checkType];
|
||||||
NetworkInfo checkInfo = checkTracker.getNetworkInfo();
|
NetworkInfo checkInfo = checkTracker.getNetworkInfo();
|
||||||
@@ -1223,7 +1229,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
info.setFailover(false);
|
info.setFailover(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mNetAttributes[info.getType()].isDefault()) {
|
if (mNetConfigs[info.getType()].isDefault()) {
|
||||||
tryFailover(info.getType());
|
tryFailover(info.getType());
|
||||||
if (mActiveDefaultNetwork != -1) {
|
if (mActiveDefaultNetwork != -1) {
|
||||||
NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
||||||
@@ -1276,11 +1282,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
// if this is a default net and other default is running
|
// if this is a default net and other default is running
|
||||||
// kill the one not preferred
|
// kill the one not preferred
|
||||||
if (mNetAttributes[type].isDefault()) {
|
if (mNetConfigs[type].isDefault()) {
|
||||||
if (mActiveDefaultNetwork != -1 && mActiveDefaultNetwork != type) {
|
if (mActiveDefaultNetwork != -1 && mActiveDefaultNetwork != type) {
|
||||||
if ((type != mNetworkPreference &&
|
if ((type != mNetworkPreference &&
|
||||||
mNetAttributes[mActiveDefaultNetwork].mPriority >
|
mNetConfigs[mActiveDefaultNetwork].mPriority >
|
||||||
mNetAttributes[type].mPriority) ||
|
mNetConfigs[type].mPriority) ||
|
||||||
mNetworkPreference == mActiveDefaultNetwork) {
|
mNetworkPreference == mActiveDefaultNetwork) {
|
||||||
// don't accept this one
|
// don't accept this one
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
@@ -1344,14 +1350,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
handleDnsConfigurationChange(netType);
|
handleDnsConfigurationChange(netType);
|
||||||
|
|
||||||
if (mNetTrackers[netType].getNetworkInfo().isConnected()) {
|
if (mNetTrackers[netType].getNetworkInfo().isConnected()) {
|
||||||
if (mNetAttributes[netType].isDefault()) {
|
if (mNetConfigs[netType].isDefault()) {
|
||||||
handleApplyDefaultProxy(netType);
|
handleApplyDefaultProxy(netType);
|
||||||
addDefaultRoute(mNetTrackers[netType]);
|
addDefaultRoute(mNetTrackers[netType]);
|
||||||
} else {
|
} else {
|
||||||
addPrivateDnsRoutes(mNetTrackers[netType]);
|
addPrivateDnsRoutes(mNetTrackers[netType]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mNetAttributes[netType].isDefault()) {
|
if (mNetConfigs[netType].isDefault()) {
|
||||||
removeDefaultRoute(mNetTrackers[netType]);
|
removeDefaultRoute(mNetTrackers[netType]);
|
||||||
} else {
|
} else {
|
||||||
removePrivateDnsRoutes(mNetTrackers[netType]);
|
removePrivateDnsRoutes(mNetTrackers[netType]);
|
||||||
@@ -1512,7 +1518,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
{
|
{
|
||||||
if (DBG) log("reassessPidDns for pid " + myPid);
|
if (DBG) log("reassessPidDns for pid " + myPid);
|
||||||
for(int i : mPriorityList) {
|
for(int i : mPriorityList) {
|
||||||
if (mNetAttributes[i].isDefault()) {
|
if (mNetConfigs[i].isDefault()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NetworkStateTracker nt = mNetTrackers[i];
|
NetworkStateTracker nt = mNetTrackers[i];
|
||||||
@@ -1594,7 +1600,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (p == null) return;
|
if (p == null) return;
|
||||||
Collection<InetAddress> dnses = p.getDnses();
|
Collection<InetAddress> dnses = p.getDnses();
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
if (mNetAttributes[netType].isDefault()) {
|
if (mNetConfigs[netType].isDefault()) {
|
||||||
int j = 1;
|
int j = 1;
|
||||||
if (dnses.size() == 0 && mDefaultDns != null) {
|
if (dnses.size() == 0 && mDefaultDns != null) {
|
||||||
String dnsString = mDefaultDns.getHostAddress();
|
String dnsString = mDefaultDns.getHostAddress();
|
||||||
@@ -1725,23 +1731,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
info = (NetworkInfo) msg.obj;
|
info = (NetworkInfo) msg.obj;
|
||||||
int type = info.getType();
|
int type = info.getType();
|
||||||
NetworkInfo.State state = info.getState();
|
NetworkInfo.State state = info.getState();
|
||||||
// only do this optimization for wifi. It going into scan mode for location
|
|
||||||
// services generates alot of noise. Meanwhile the mms apn won't send out
|
|
||||||
// subsequent notifications when on default cellular because it never
|
|
||||||
// disconnects.. so only do this to wifi notifications. Fixed better when the
|
|
||||||
// APN notifications are standardized.
|
|
||||||
if (mNetAttributes[type].mLastState == state &&
|
|
||||||
mNetAttributes[type].mRadio == ConnectivityManager.TYPE_WIFI) {
|
|
||||||
if (DBG) {
|
|
||||||
// TODO - remove this after we validate the dropping doesn't break
|
|
||||||
// anything
|
|
||||||
log("Dropping ConnectivityChange for " +
|
|
||||||
info.getTypeName() + ": " +
|
|
||||||
state + "/" + info.getDetailedState());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mNetAttributes[type].mLastState = state;
|
|
||||||
|
|
||||||
if (DBG) log("ConnectivityChange for " +
|
if (DBG) log("ConnectivityChange for " +
|
||||||
info.getTypeName() + ": " +
|
info.getTypeName() + ": " +
|
||||||
@@ -1780,8 +1769,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
break;
|
break;
|
||||||
case NetworkStateTracker.EVENT_CONFIGURATION_CHANGED:
|
case NetworkStateTracker.EVENT_CONFIGURATION_CHANGED:
|
||||||
info = (NetworkInfo) msg.obj;
|
info = (NetworkInfo) msg.obj;
|
||||||
type = info.getType();
|
handleConnectivityChange(info.getType());
|
||||||
handleConnectivityChange(type);
|
|
||||||
break;
|
break;
|
||||||
case EVENT_CLEAR_NET_TRANSITION_WAKELOCK:
|
case EVENT_CLEAR_NET_TRANSITION_WAKELOCK:
|
||||||
String causedBy = null;
|
String causedBy = null;
|
||||||
@@ -1835,6 +1823,13 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
case EVENT_APPLY_GLOBAL_HTTP_PROXY:
|
case EVENT_APPLY_GLOBAL_HTTP_PROXY:
|
||||||
{
|
{
|
||||||
handleDeprecatedGlobalHttpProxy();
|
handleDeprecatedGlobalHttpProxy();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EVENT_SET_DEPENDENCY_MET:
|
||||||
|
{
|
||||||
|
boolean met = (msg.arg1 == ENABLED);
|
||||||
|
handleSetDependencyMet(msg.arg2, met);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user