Cleanup logging.
Change-Id: Ie73c6d97ec19b0d27e58c085b60e885d90066056
This commit is contained in:
@@ -257,7 +257,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ConnectivityService(Context context) {
|
private ConnectivityService(Context context) {
|
||||||
if (DBG) Slog.v(TAG, "ConnectivityService starting up");
|
if (DBG) log("ConnectivityService starting up");
|
||||||
|
|
||||||
HandlerThread handlerThread = new HandlerThread("ConnectivityServiceThread");
|
HandlerThread handlerThread = new HandlerThread("ConnectivityServiceThread");
|
||||||
handlerThread.start();
|
handlerThread.start();
|
||||||
@@ -281,7 +281,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
try {
|
try {
|
||||||
mDefaultDns = InetAddress.getByName(dns);
|
mDefaultDns = InetAddress.getByName(dns);
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
Slog.e(TAG, "Error setting defaultDns using " + dns);
|
loge("Error setting defaultDns using " + dns);
|
||||||
}
|
}
|
||||||
|
|
||||||
mContext = context;
|
mContext = context;
|
||||||
@@ -305,11 +305,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
for (String raString : raStrings) {
|
for (String raString : raStrings) {
|
||||||
RadioAttributes r = new RadioAttributes(raString);
|
RadioAttributes r = new RadioAttributes(raString);
|
||||||
if (r.mType > ConnectivityManager.MAX_RADIO_TYPE) {
|
if (r.mType > ConnectivityManager.MAX_RADIO_TYPE) {
|
||||||
Slog.e(TAG, "Error in radioAttributes - ignoring attempt to define type " + r.mType);
|
loge("Error in radioAttributes - ignoring attempt to define type " + r.mType);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (mRadioAttributes[r.mType] != null) {
|
if (mRadioAttributes[r.mType] != null) {
|
||||||
Slog.e(TAG, "Error in radioAttributes - ignoring attempt to redefine type " +
|
loge("Error in radioAttributes - ignoring attempt to redefine type " +
|
||||||
r.mType);
|
r.mType);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -322,17 +322,17 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
try {
|
try {
|
||||||
NetworkAttributes n = new NetworkAttributes(naString);
|
NetworkAttributes n = new NetworkAttributes(naString);
|
||||||
if (n.mType > ConnectivityManager.MAX_NETWORK_TYPE) {
|
if (n.mType > ConnectivityManager.MAX_NETWORK_TYPE) {
|
||||||
Slog.e(TAG, "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 (mNetAttributes[n.mType] != null) {
|
||||||
Slog.e(TAG, "Error in networkAttributes - ignoring attempt to redefine type " +
|
loge("Error in networkAttributes - ignoring attempt to redefine type " +
|
||||||
n.mType);
|
n.mType);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (mRadioAttributes[n.mRadio] == null) {
|
if (mRadioAttributes[n.mRadio] == null) {
|
||||||
Slog.e(TAG, "Error in networkAttributes - ignoring attempt to use undefined " +
|
loge("Error in networkAttributes - ignoring attempt to use undefined " +
|
||||||
"radio " + n.mRadio + " in network type " + n.mType);
|
"radio " + n.mRadio + " in network type " + n.mType);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -388,7 +388,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
for (int netType : mPriorityList) {
|
for (int netType : mPriorityList) {
|
||||||
switch (mNetAttributes[netType].mRadio) {
|
switch (mNetAttributes[netType].mRadio) {
|
||||||
case ConnectivityManager.TYPE_WIFI:
|
case ConnectivityManager.TYPE_WIFI:
|
||||||
if (DBG) Slog.v(TAG, "Starting Wifi Service.");
|
if (DBG) log("Starting Wifi Service.");
|
||||||
WifiStateTracker wst = new WifiStateTracker();
|
WifiStateTracker wst = new WifiStateTracker();
|
||||||
WifiService wifiService = new WifiService(context);
|
WifiService wifiService = new WifiService(context);
|
||||||
ServiceManager.addService(Context.WIFI_SERVICE, wifiService);
|
ServiceManager.addService(Context.WIFI_SERVICE, wifiService);
|
||||||
@@ -405,12 +405,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
mNetAttributes[netType].mName);
|
mNetAttributes[netType].mName);
|
||||||
mNetTrackers[netType].startMonitoring(context, mHandler);
|
mNetTrackers[netType].startMonitoring(context, mHandler);
|
||||||
if (noMobileData) {
|
if (noMobileData) {
|
||||||
if (DBG) Slog.d(TAG, "tearing down Mobile networks due to setting");
|
if (DBG) log("tearing down Mobile networks due to setting");
|
||||||
mNetTrackers[netType].teardown();
|
mNetTrackers[netType].teardown();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Slog.e(TAG, "Trying to create a DataStateTracker for an unknown radio type " +
|
loge("Trying to create a DataStateTracker for an unknown radio type " +
|
||||||
mNetAttributes[netType].mRadio);
|
mNetAttributes[netType].mRadio);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -499,8 +499,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (t != mNetworkPreference && mNetTrackers[t] != null &&
|
if (t != mNetworkPreference && mNetTrackers[t] != null &&
|
||||||
mNetTrackers[t].getNetworkInfo().isConnected()) {
|
mNetTrackers[t].getNetworkInfo().isConnected()) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "tearing down " +
|
log("tearing down " + mNetTrackers[t].getNetworkInfo() +
|
||||||
mNetTrackers[t].getNetworkInfo() +
|
|
||||||
" in enforcePreference");
|
" in enforcePreference");
|
||||||
}
|
}
|
||||||
teardown(mNetTrackers[t]);
|
teardown(mNetTrackers[t]);
|
||||||
@@ -533,9 +532,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
NetworkStateTracker t = mNetTrackers[type];
|
NetworkStateTracker t = mNetTrackers[type];
|
||||||
NetworkInfo info = t.getNetworkInfo();
|
NetworkInfo info = t.getNetworkInfo();
|
||||||
if (info.isConnected()) {
|
if (info.isConnected()) {
|
||||||
if (DBG && type != mActiveDefaultNetwork) Slog.e(TAG,
|
if (DBG && type != mActiveDefaultNetwork) {
|
||||||
"connected default network is not " +
|
loge("connected default network is not mActiveDefaultNetwork!");
|
||||||
"mActiveDefaultNetwork!");
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -648,14 +647,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void binderDied() {
|
public void binderDied() {
|
||||||
Slog.d(TAG, "ConnectivityService FeatureUser binderDied(" +
|
log("ConnectivityService FeatureUser binderDied(" +
|
||||||
mNetworkType + ", " + mFeature + ", " + mBinder + "), created " +
|
mNetworkType + ", " + mFeature + ", " + mBinder + "), created " +
|
||||||
(System.currentTimeMillis() - mCreateTime) + " mSec ago");
|
(System.currentTimeMillis() - mCreateTime) + " mSec ago");
|
||||||
stopUsingNetworkFeature(this, false);
|
stopUsingNetworkFeature(this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void expire() {
|
public void expire() {
|
||||||
Slog.d(TAG, "ConnectivityService FeatureUser expire(" +
|
log("ConnectivityService FeatureUser expire(" +
|
||||||
mNetworkType + ", " + mFeature + ", " + mBinder +"), created " +
|
mNetworkType + ", " + mFeature + ", " + mBinder +"), created " +
|
||||||
(System.currentTimeMillis() - mCreateTime) + " mSec ago");
|
(System.currentTimeMillis() - mCreateTime) + " mSec ago");
|
||||||
stopUsingNetworkFeature(this, false);
|
stopUsingNetworkFeature(this, false);
|
||||||
@@ -671,8 +670,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
public int startUsingNetworkFeature(int networkType, String feature,
|
public int startUsingNetworkFeature(int networkType, String feature,
|
||||||
IBinder binder) {
|
IBinder binder) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "startUsingNetworkFeature for net " + networkType +
|
log("startUsingNetworkFeature for net " + networkType + ": " + feature);
|
||||||
": " + feature);
|
|
||||||
}
|
}
|
||||||
enforceChangePermission();
|
enforceChangePermission();
|
||||||
if (!ConnectivityManager.isNetworkTypeValid(networkType) ||
|
if (!ConnectivityManager.isNetworkTypeValid(networkType) ||
|
||||||
@@ -686,7 +684,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
int usedNetworkType = networkType;
|
int usedNetworkType = networkType;
|
||||||
if(networkType == ConnectivityManager.TYPE_MOBILE) {
|
if(networkType == ConnectivityManager.TYPE_MOBILE) {
|
||||||
if (!getMobileDataEnabled()) {
|
if (!getMobileDataEnabled()) {
|
||||||
if (DBG) Slog.d(TAG, "requested special network with data disabled - rejected");
|
if (DBG) log("requested special network with data disabled - rejected");
|
||||||
return Phone.APN_TYPE_NOT_AVAILABLE;
|
return Phone.APN_TYPE_NOT_AVAILABLE;
|
||||||
}
|
}
|
||||||
if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_MMS)) {
|
if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_MMS)) {
|
||||||
@@ -708,7 +706,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
NetworkInfo ni = network.getNetworkInfo();
|
NetworkInfo ni = network.getNetworkInfo();
|
||||||
|
|
||||||
if (ni.isAvailable() == false) {
|
if (ni.isAvailable() == false) {
|
||||||
if (DBG) Slog.d(TAG, "special network not available");
|
if (DBG) log("special network not available");
|
||||||
return Phone.APN_TYPE_NOT_AVAILABLE;
|
return Phone.APN_TYPE_NOT_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -728,17 +726,17 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (ni.isConnected() == true) {
|
if (ni.isConnected() == true) {
|
||||||
// add the pid-specific dns
|
// add the pid-specific dns
|
||||||
handleDnsConfigurationChange(networkType);
|
handleDnsConfigurationChange(networkType);
|
||||||
if (DBG) Slog.d(TAG, "special network already active");
|
if (DBG) log("special network already active");
|
||||||
return Phone.APN_ALREADY_ACTIVE;
|
return Phone.APN_ALREADY_ACTIVE;
|
||||||
}
|
}
|
||||||
if (DBG) Slog.d(TAG, "special network already connecting");
|
if (DBG) log("special network already connecting");
|
||||||
return Phone.APN_REQUEST_STARTED;
|
return Phone.APN_REQUEST_STARTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the radio in play can make another contact
|
// check if the radio in play can make another contact
|
||||||
// assume if cannot for now
|
// assume if cannot for now
|
||||||
|
|
||||||
if (DBG) Slog.d(TAG, "reconnecting to special network");
|
if (DBG) log("reconnecting to special network");
|
||||||
network.reconnect();
|
network.reconnect();
|
||||||
return Phone.APN_REQUEST_STARTED;
|
return Phone.APN_REQUEST_STARTED;
|
||||||
} else {
|
} else {
|
||||||
@@ -774,7 +772,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
return stopUsingNetworkFeature(u, true);
|
return stopUsingNetworkFeature(u, true);
|
||||||
} else {
|
} else {
|
||||||
// none found!
|
// none found!
|
||||||
if (DBG) Slog.d(TAG, "ignoring stopUsingNetworkFeature - not a live request");
|
if (DBG) log("ignoring stopUsingNetworkFeature - not a live request");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -789,7 +787,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
boolean callTeardown = false; // used to carry our decision outside of sync block
|
boolean callTeardown = false; // used to carry our decision outside of sync block
|
||||||
|
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "stopUsingNetworkFeature for net " + networkType +
|
log("stopUsingNetworkFeature for net " + networkType +
|
||||||
": " + feature);
|
": " + feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -802,7 +800,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
// check if this process still has an outstanding start request
|
// check if this process still has an outstanding start request
|
||||||
if (!mFeatureUsers.contains(u)) {
|
if (!mFeatureUsers.contains(u)) {
|
||||||
if (DBG) Slog.d(TAG, "ignoring - this process has no outstanding requests");
|
if (DBG) log("ignoring - this process has no outstanding requests");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
u.unlinkDeathRecipient();
|
u.unlinkDeathRecipient();
|
||||||
@@ -820,7 +818,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (x.mUid == u.mUid && x.mPid == u.mPid &&
|
if (x.mUid == u.mUid && x.mPid == u.mPid &&
|
||||||
x.mNetworkType == u.mNetworkType &&
|
x.mNetworkType == u.mNetworkType &&
|
||||||
TextUtils.equals(x.mFeature, u.mFeature)) {
|
TextUtils.equals(x.mFeature, u.mFeature)) {
|
||||||
if (DBG) Slog.d(TAG, "ignoring stopUsingNetworkFeature as dup is found");
|
if (DBG) log("ignoring stopUsingNetworkFeature as dup is found");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -841,7 +839,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
tracker = mNetTrackers[usedNetworkType];
|
tracker = mNetTrackers[usedNetworkType];
|
||||||
if (tracker == null) {
|
if (tracker == null) {
|
||||||
if (DBG) Slog.d(TAG, "ignoring - no known tracker for net type " + usedNetworkType);
|
if (DBG) log("ignoring - no known tracker for net type " + usedNetworkType);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (usedNetworkType != networkType) {
|
if (usedNetworkType != networkType) {
|
||||||
@@ -849,14 +847,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
mNetRequestersPids[usedNetworkType].remove(currentPid);
|
mNetRequestersPids[usedNetworkType].remove(currentPid);
|
||||||
reassessPidDns(pid, true);
|
reassessPidDns(pid, true);
|
||||||
if (mNetRequestersPids[usedNetworkType].size() != 0) {
|
if (mNetRequestersPids[usedNetworkType].size() != 0) {
|
||||||
if (DBG) Slog.d(TAG, "not tearing down special network - " +
|
if (DBG) log("not tearing down special network - " +
|
||||||
"others still using it");
|
"others still using it");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
callTeardown = true;
|
callTeardown = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DBG) Slog.d(TAG, "Doing network teardown");
|
if (DBG) log("Doing network teardown");
|
||||||
if (callTeardown) {
|
if (callTeardown) {
|
||||||
tracker.teardown();
|
tracker.teardown();
|
||||||
return 1;
|
return 1;
|
||||||
@@ -905,7 +903,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (tracker == null || !tracker.getNetworkInfo().isConnected() ||
|
if (tracker == null || !tracker.getNetworkInfo().isConnected() ||
|
||||||
tracker.isTeardownRequested()) {
|
tracker.isTeardownRequested()) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "requestRouteToHostAddress on down network " +
|
log("requestRouteToHostAddress on down network " +
|
||||||
"(" + networkType + ") - dropped");
|
"(" + networkType + ") - dropped");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -935,12 +933,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
String interfaceName = p.getInterfaceName();
|
String interfaceName = p.getInterfaceName();
|
||||||
|
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "Requested host route to " + hostAddress + "(" + interfaceName + ")");
|
log("Requested host route to " + hostAddress + "(" + interfaceName + ")");
|
||||||
}
|
}
|
||||||
if (interfaceName != null) {
|
if (interfaceName != null) {
|
||||||
return NetworkUtils.addHostRoute(interfaceName, hostAddress, null);
|
return NetworkUtils.addHostRoute(interfaceName, hostAddress, null);
|
||||||
} else {
|
} else {
|
||||||
if (DBG) Slog.e(TAG, "addHostRoute failed due to null interface name");
|
if (DBG) loge("addHostRoute failed due to null interface name");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -982,7 +980,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
boolean retVal = Settings.Secure.getInt(mContext.getContentResolver(),
|
boolean retVal = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.MOBILE_DATA, 1) == 1;
|
Settings.Secure.MOBILE_DATA, 1) == 1;
|
||||||
if (DBG) Slog.d(TAG, "getMobileDataEnabled returning " + retVal);
|
if (DBG) log("getMobileDataEnabled returning " + retVal);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -991,7 +989,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
*/
|
*/
|
||||||
public void setMobileDataEnabled(boolean enabled) {
|
public void setMobileDataEnabled(boolean enabled) {
|
||||||
enforceChangePermission();
|
enforceChangePermission();
|
||||||
if (DBG) Slog.d(TAG, "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));
|
||||||
@@ -1006,7 +1004,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (enabled) {
|
if (enabled) {
|
||||||
if (mNetTrackers[ConnectivityManager.TYPE_MOBILE] != null) {
|
if (mNetTrackers[ConnectivityManager.TYPE_MOBILE] != null) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "starting up " + mNetTrackers[ConnectivityManager.TYPE_MOBILE]);
|
log("starting up " + mNetTrackers[ConnectivityManager.TYPE_MOBILE]);
|
||||||
}
|
}
|
||||||
mNetTrackers[ConnectivityManager.TYPE_MOBILE].reconnect();
|
mNetTrackers[ConnectivityManager.TYPE_MOBILE].reconnect();
|
||||||
}
|
}
|
||||||
@@ -1015,7 +1013,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (nt == null) continue;
|
if (nt == null) continue;
|
||||||
int netType = nt.getNetworkInfo().getType();
|
int netType = nt.getNetworkInfo().getType();
|
||||||
if (mNetAttributes[netType].mRadio == ConnectivityManager.TYPE_MOBILE) {
|
if (mNetAttributes[netType].mRadio == ConnectivityManager.TYPE_MOBILE) {
|
||||||
if (DBG) Slog.d(TAG, "tearing down " + nt);
|
if (DBG) log("tearing down " + nt);
|
||||||
nt.teardown();
|
nt.teardown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1114,9 +1112,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (newNet != null) {
|
if (newNet != null) {
|
||||||
NetworkInfo switchTo = newNet.getNetworkInfo();
|
NetworkInfo switchTo = newNet.getNetworkInfo();
|
||||||
if (!switchTo.isConnected()) {
|
if (!switchTo.isConnected()) {
|
||||||
// if the other net is connected they've already reset this and perhaps even gotten
|
// if the other net is connected they've already reset this and perhaps even
|
||||||
// a positive report we don't want to overwrite, but if not we need to clear this now
|
// gotten a positive report we don't want to overwrite, but if not we need to
|
||||||
// to turn our cellular sig strength white
|
// clear this now to turn our cellular sig strength white
|
||||||
mDefaultInetConditionPublished = 0;
|
mDefaultInetConditionPublished = 0;
|
||||||
}
|
}
|
||||||
intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo);
|
intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo);
|
||||||
@@ -1159,7 +1157,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (mNetAttributes[checkType] == null) continue;
|
if (mNetAttributes[checkType] == null) continue;
|
||||||
if (mNetAttributes[checkType].mRadio == ConnectivityManager.TYPE_MOBILE &&
|
if (mNetAttributes[checkType].mRadio == ConnectivityManager.TYPE_MOBILE &&
|
||||||
noMobileData) {
|
noMobileData) {
|
||||||
Slog.e(TAG, "not failing over to mobile type " + checkType +
|
loge("not failing over to mobile type " + checkType +
|
||||||
" because Mobile Data Disabled");
|
" because Mobile Data Disabled");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1196,11 +1194,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
if (switchTo.isConnected()) {
|
if (switchTo.isConnected()) {
|
||||||
Slog.v(TAG, "Switching to already connected " +
|
log("Switching to already connected " + switchTo.getTypeName());
|
||||||
switchTo.getTypeName());
|
|
||||||
} else {
|
} else {
|
||||||
Slog.v(TAG, "Attempting to switch to " +
|
log("Attempting to switch to " + switchTo.getTypeName());
|
||||||
switchTo.getTypeName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1209,7 +1205,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
// report no failover
|
// report no failover
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Slog.e(TAG, "Network failover failing.");
|
loge("Network failover failing.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1258,7 +1254,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
} else {
|
} else {
|
||||||
reasonText = " (" + reason + ").";
|
reasonText = " (" + reason + ").";
|
||||||
}
|
}
|
||||||
Slog.e(TAG, "Attempt to connect to " + info.getTypeName() + " failed" + reasonText);
|
loge("Attempt to connect to " + info.getTypeName() + " failed" + reasonText);
|
||||||
|
|
||||||
Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
|
Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||||
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO, info);
|
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO, info);
|
||||||
@@ -1343,19 +1339,22 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
mNetAttributes[type].mPriority) ||
|
mNetAttributes[type].mPriority) ||
|
||||||
mNetworkPreference == mActiveDefaultNetwork) {
|
mNetworkPreference == mActiveDefaultNetwork) {
|
||||||
// don't accept this one
|
// don't accept this one
|
||||||
if (DBG) Slog.v(TAG, "Not broadcasting CONNECT_ACTION " +
|
if (DBG) {
|
||||||
|
log("Not broadcasting CONNECT_ACTION " +
|
||||||
"to torn down network " + info.getTypeName());
|
"to torn down network " + info.getTypeName());
|
||||||
|
}
|
||||||
teardown(thisNet);
|
teardown(thisNet);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// tear down the other
|
// tear down the other
|
||||||
NetworkStateTracker otherNet =
|
NetworkStateTracker otherNet =
|
||||||
mNetTrackers[mActiveDefaultNetwork];
|
mNetTrackers[mActiveDefaultNetwork];
|
||||||
if (DBG) Slog.v(TAG, "Policy requires " +
|
if (DBG) {
|
||||||
otherNet.getNetworkInfo().getTypeName() +
|
log("Policy requires " + otherNet.getNetworkInfo().getTypeName() +
|
||||||
" teardown");
|
" teardown");
|
||||||
|
}
|
||||||
if (!teardown(otherNet)) {
|
if (!teardown(otherNet)) {
|
||||||
Slog.e(TAG, "Network declined teardown request");
|
loge("Network declined teardown request");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1423,13 +1422,13 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
String interfaceName = p.getInterfaceName();
|
String interfaceName = p.getInterfaceName();
|
||||||
|
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "addPrivateDnsRoutes for " + nt +
|
log("addPrivateDnsRoutes for " + nt +
|
||||||
"(" + interfaceName + ") - mPrivateDnsRouteSet = " + privateDnsRouteSet);
|
"(" + interfaceName + ") - mPrivateDnsRouteSet = " + privateDnsRouteSet);
|
||||||
}
|
}
|
||||||
if (interfaceName != null && !privateDnsRouteSet) {
|
if (interfaceName != null && !privateDnsRouteSet) {
|
||||||
Collection<InetAddress> dnsList = p.getDnses();
|
Collection<InetAddress> dnsList = p.getDnses();
|
||||||
for (InetAddress dns : dnsList) {
|
for (InetAddress dns : dnsList) {
|
||||||
if (DBG) Slog.d(TAG, " adding " + dns);
|
if (DBG) log(" adding " + dns);
|
||||||
NetworkUtils.addHostRoute(interfaceName, dns, null);
|
NetworkUtils.addHostRoute(interfaceName, dns, null);
|
||||||
}
|
}
|
||||||
nt.privateDnsRouteSet(true);
|
nt.privateDnsRouteSet(true);
|
||||||
@@ -1445,7 +1444,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
boolean privateDnsRouteSet = nt.isPrivateDnsRouteSet();
|
boolean privateDnsRouteSet = nt.isPrivateDnsRouteSet();
|
||||||
if (interfaceName != null && privateDnsRouteSet) {
|
if (interfaceName != null && privateDnsRouteSet) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "removePrivateDnsRoutes for " + nt.getNetworkInfo().getTypeName() +
|
log("removePrivateDnsRoutes for " + nt.getNetworkInfo().getTypeName() +
|
||||||
" (" + interfaceName + ")");
|
" (" + interfaceName + ")");
|
||||||
}
|
}
|
||||||
NetworkUtils.removeHostRoutes(interfaceName);
|
NetworkUtils.removeHostRoutes(interfaceName);
|
||||||
@@ -1463,7 +1462,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if ((interfaceName != null) && (defaultGatewayAddr != null )) {
|
if ((interfaceName != null) && (defaultGatewayAddr != null )) {
|
||||||
if (!NetworkUtils.addDefaultRoute(interfaceName, defaultGatewayAddr) && DBG) {
|
if (!NetworkUtils.addDefaultRoute(interfaceName, defaultGatewayAddr) && DBG) {
|
||||||
NetworkInfo networkInfo = nt.getNetworkInfo();
|
NetworkInfo networkInfo = nt.getNetworkInfo();
|
||||||
Slog.d(TAG, "addDefaultRoute for " + networkInfo.getTypeName() +
|
log("addDefaultRoute for " + networkInfo.getTypeName() +
|
||||||
" (" + interfaceName + "), GatewayAddr=" + defaultGatewayAddr);
|
" (" + interfaceName + "), GatewayAddr=" + defaultGatewayAddr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1478,7 +1477,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (interfaceName != null) {
|
if (interfaceName != null) {
|
||||||
if ((NetworkUtils.removeDefaultRoute(interfaceName) >= 0) && DBG) {
|
if ((NetworkUtils.removeDefaultRoute(interfaceName) >= 0) && DBG) {
|
||||||
NetworkInfo networkInfo = nt.getNetworkInfo();
|
NetworkInfo networkInfo = nt.getNetworkInfo();
|
||||||
Slog.d(TAG, "removeDefaultRoute for " + networkInfo.getTypeName() + " (" +
|
log("removeDefaultRoute for " + networkInfo.getTypeName() + " (" +
|
||||||
interfaceName + ")");
|
interfaceName + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1494,7 +1493,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
String bufferSizes = SystemProperties.get(key);
|
String bufferSizes = SystemProperties.get(key);
|
||||||
|
|
||||||
if (bufferSizes.length() == 0) {
|
if (bufferSizes.length() == 0) {
|
||||||
Slog.e(TAG, key + " not found in system properties. Using defaults");
|
loge(key + " not found in system properties. Using defaults");
|
||||||
|
|
||||||
// Setting to default values so we won't be stuck to previous values
|
// Setting to default values so we won't be stuck to previous values
|
||||||
key = "net.tcp.buffersize.default";
|
key = "net.tcp.buffersize.default";
|
||||||
@@ -1504,7 +1503,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
// Set values in kernel
|
// Set values in kernel
|
||||||
if (bufferSizes.length() != 0) {
|
if (bufferSizes.length() != 0) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.v(TAG, "Setting TCP values: [" + bufferSizes
|
log("Setting TCP values: [" + bufferSizes
|
||||||
+ "] which comes from [" + key + "]");
|
+ "] which comes from [" + key + "]");
|
||||||
}
|
}
|
||||||
setBufferSize(bufferSizes);
|
setBufferSize(bufferSizes);
|
||||||
@@ -1531,10 +1530,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
stringToFile(prefix + "wmem_def", values[4]);
|
stringToFile(prefix + "wmem_def", values[4]);
|
||||||
stringToFile(prefix + "wmem_max", values[5]);
|
stringToFile(prefix + "wmem_max", values[5]);
|
||||||
} else {
|
} else {
|
||||||
Slog.e(TAG, "Invalid buffersize string: " + bufferSizes);
|
loge("Invalid buffersize string: " + bufferSizes);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slog.e(TAG, "Can't set tcp buffer sizes:" + e);
|
loge("Can't set tcp buffer sizes:" + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1562,7 +1561,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
*/
|
*/
|
||||||
private void reassessPidDns(int myPid, boolean doBump)
|
private void reassessPidDns(int myPid, boolean doBump)
|
||||||
{
|
{
|
||||||
if (DBG) Slog.d(TAG, "reassessPidDns for pid " + myPid);
|
if (DBG) log("reassessPidDns for pid " + myPid);
|
||||||
for(int i : mPriorityList) {
|
for(int i : mPriorityList) {
|
||||||
if (mNetAttributes[i].isDefault()) {
|
if (mNetAttributes[i].isDefault()) {
|
||||||
continue;
|
continue;
|
||||||
@@ -1638,21 +1637,21 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
int j = 1;
|
int j = 1;
|
||||||
if (dnses.size() == 0 && mDefaultDns != null) {
|
if (dnses.size() == 0 && mDefaultDns != null) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "no dns provided - using " + mDefaultDns.getHostAddress());
|
log("no dns provided - using " + mDefaultDns.getHostAddress());
|
||||||
}
|
}
|
||||||
SystemProperties.set("net.dns1", mDefaultDns.getHostAddress());
|
SystemProperties.set("net.dns1", mDefaultDns.getHostAddress());
|
||||||
j++;
|
j++;
|
||||||
} else {
|
} else {
|
||||||
for (InetAddress dns : dnses) {
|
for (InetAddress dns : dnses) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "adding dns " + dns + " for " +
|
log("adding dns " + dns + " for " +
|
||||||
nt.getNetworkInfo().getTypeName());
|
nt.getNetworkInfo().getTypeName());
|
||||||
}
|
}
|
||||||
SystemProperties.set("net.dns" + j++, dns.getHostAddress());
|
SystemProperties.set("net.dns" + j++, dns.getHostAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int k=j ; k<mNumDnsEntries; k++) {
|
for (int k=j ; k<mNumDnsEntries; k++) {
|
||||||
if (DBG) Slog.d(TAG, "erasing net.dns" + k);
|
if (DBG) log("erasing net.dns" + k);
|
||||||
SystemProperties.set("net.dns" + k, "");
|
SystemProperties.set("net.dns" + k, "");
|
||||||
}
|
}
|
||||||
mNumDnsEntries = j;
|
mNumDnsEntries = j;
|
||||||
@@ -1762,7 +1761,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (DBG) {
|
if (DBG) {
|
||||||
// TODO - remove this after we validate the dropping doesn't break
|
// TODO - remove this after we validate the dropping doesn't break
|
||||||
// anything
|
// anything
|
||||||
Slog.d(TAG, "Dropping ConnectivityChange for " +
|
log("Dropping ConnectivityChange for " +
|
||||||
info.getTypeName() + ": " +
|
info.getTypeName() + ": " +
|
||||||
state + "/" + info.getDetailedState());
|
state + "/" + info.getDetailedState());
|
||||||
}
|
}
|
||||||
@@ -1770,7 +1769,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
mNetAttributes[type].mLastState = state;
|
mNetAttributes[type].mLastState = state;
|
||||||
|
|
||||||
if (DBG) Slog.d(TAG, "ConnectivityChange for " +
|
if (DBG) log("ConnectivityChange for " +
|
||||||
info.getTypeName() + ": " +
|
info.getTypeName() + ": " +
|
||||||
state + "/" + info.getDetailedState());
|
state + "/" + info.getDetailedState());
|
||||||
|
|
||||||
@@ -1820,8 +1819,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (causedBy != null) {
|
if (causedBy != null) {
|
||||||
Slog.d(TAG, "NetTransition Wakelock for " +
|
log("NetTransition Wakelock for " + causedBy + " released by timeout");
|
||||||
causedBy + " released by timeout");
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EVENT_RESTORE_DEFAULT_NETWORK:
|
case EVENT_RESTORE_DEFAULT_NETWORK:
|
||||||
@@ -1978,7 +1976,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
// 100 percent is full good, 0 is full bad.
|
// 100 percent is full good, 0 is full bad.
|
||||||
public void reportInetCondition(int networkType, int percentage) {
|
public void reportInetCondition(int networkType, int percentage) {
|
||||||
if (DBG) Slog.d(TAG, "reportNetworkCondition(" + networkType + ", " + percentage + ")");
|
if (DBG) log("reportNetworkCondition(" + networkType + ", " + percentage + ")");
|
||||||
mContext.enforceCallingOrSelfPermission(
|
mContext.enforceCallingOrSelfPermission(
|
||||||
android.Manifest.permission.STATUS_BAR,
|
android.Manifest.permission.STATUS_BAR,
|
||||||
"ConnectivityService");
|
"ConnectivityService");
|
||||||
@@ -2000,22 +1998,22 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
private void handleInetConditionChange(int netType, int condition) {
|
private void handleInetConditionChange(int netType, int condition) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "Inet connectivity change, net=" +
|
log("Inet connectivity change, net=" +
|
||||||
netType + ", condition=" + condition +
|
netType + ", condition=" + condition +
|
||||||
",mActiveDefaultNetwork=" + mActiveDefaultNetwork);
|
",mActiveDefaultNetwork=" + mActiveDefaultNetwork);
|
||||||
}
|
}
|
||||||
if (mActiveDefaultNetwork == -1) {
|
if (mActiveDefaultNetwork == -1) {
|
||||||
if (DBG) Slog.d(TAG, "no active default network - aborting");
|
if (DBG) log("no active default network - aborting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mActiveDefaultNetwork != netType) {
|
if (mActiveDefaultNetwork != netType) {
|
||||||
if (DBG) Slog.d(TAG, "given net not default - aborting");
|
if (DBG) log("given net not default - aborting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mDefaultInetCondition = condition;
|
mDefaultInetCondition = condition;
|
||||||
int delay;
|
int delay;
|
||||||
if (mInetConditionChangeInFlight == false) {
|
if (mInetConditionChangeInFlight == false) {
|
||||||
if (DBG) Slog.d(TAG, "starting a change hold");
|
if (DBG) log("starting a change hold");
|
||||||
// setup a new hold to debounce this
|
// setup a new hold to debounce this
|
||||||
if (mDefaultInetCondition > 50) {
|
if (mDefaultInetCondition > 50) {
|
||||||
delay = Settings.Secure.getInt(mContext.getContentResolver(),
|
delay = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
@@ -2030,33 +2028,33 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
} else {
|
} else {
|
||||||
// we've set the new condition, when this hold ends that will get
|
// we've set the new condition, when this hold ends that will get
|
||||||
// picked up
|
// picked up
|
||||||
if (DBG) Slog.d(TAG, "currently in hold - not setting new end evt");
|
if (DBG) log("currently in hold - not setting new end evt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleInetConditionHoldEnd(int netType, int sequence) {
|
private void handleInetConditionHoldEnd(int netType, int sequence) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "Inet hold end, net=" + netType +
|
log("Inet hold end, net=" + netType +
|
||||||
", condition =" + mDefaultInetCondition +
|
", condition =" + mDefaultInetCondition +
|
||||||
", published condition =" + mDefaultInetConditionPublished);
|
", published condition =" + mDefaultInetConditionPublished);
|
||||||
}
|
}
|
||||||
mInetConditionChangeInFlight = false;
|
mInetConditionChangeInFlight = false;
|
||||||
|
|
||||||
if (mActiveDefaultNetwork == -1) {
|
if (mActiveDefaultNetwork == -1) {
|
||||||
if (DBG) Slog.d(TAG, "no active default network - aborting");
|
if (DBG) log("no active default network - aborting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mDefaultConnectionSequence != sequence) {
|
if (mDefaultConnectionSequence != sequence) {
|
||||||
if (DBG) Slog.d(TAG, "event hold for obsolete network - aborting");
|
if (DBG) log("event hold for obsolete network - aborting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mDefaultInetConditionPublished == mDefaultInetCondition) {
|
if (mDefaultInetConditionPublished == mDefaultInetCondition) {
|
||||||
if (DBG) Slog.d(TAG, "no change in condition - aborting");
|
if (DBG) log("no change in condition - aborting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NetworkInfo networkInfo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
NetworkInfo networkInfo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
||||||
if (networkInfo.isConnected() == false) {
|
if (networkInfo.isConnected() == false) {
|
||||||
if (DBG) Slog.d(TAG, "default network not connected - aborting");
|
if (DBG) log("default network not connected - aborting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mDefaultInetConditionPublished = mDefaultInetCondition;
|
mDefaultInetConditionPublished = mDefaultInetCondition;
|
||||||
@@ -2133,7 +2131,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
mDefaultProxy = null;
|
mDefaultProxy = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DBG) Slog.d(TAG, "changing default proxy to " + proxy);
|
if (DBG) log("changing default proxy to " + proxy);
|
||||||
if ((proxy == null && mGlobalProxy == null) || proxy.equals(mGlobalProxy)) return;
|
if ((proxy == null && mGlobalProxy == null) || proxy.equals(mGlobalProxy)) return;
|
||||||
if (mGlobalProxy != null) return;
|
if (mGlobalProxy != null) return;
|
||||||
sendProxyBroadcast(proxy);
|
sendProxyBroadcast(proxy);
|
||||||
@@ -2159,7 +2157,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendProxyBroadcast(ProxyProperties proxy) {
|
private void sendProxyBroadcast(ProxyProperties proxy) {
|
||||||
Slog.d(TAG, "sending Proxy Broadcast for " + proxy);
|
log("sending Proxy Broadcast for " + proxy);
|
||||||
Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
|
Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
|
||||||
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
|
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
|
||||||
intent.putExtra(Proxy.EXTRA_PROXY_INFO, proxy);
|
intent.putExtra(Proxy.EXTRA_PROXY_INFO, proxy);
|
||||||
@@ -2186,4 +2184,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
mHandler.obtainMessage(mWhat).sendToTarget();
|
mHandler.obtainMessage(mWhat).sendToTarget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void log(String s) {
|
||||||
|
Slog.d(TAG, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loge(String s) {
|
||||||
|
Slog.e(TAG, s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user