Merge "Reinstate much-reduced ConnectivityService logging." into nyc-dev am: facc09d

am: fb1a323

* commit 'fb1a323da6f07a90355efa8de9f3b84842c0ad2f':
  Reinstate much-reduced ConnectivityService logging.

Change-Id: I948e337c16115e27177700af0f9ddc4ac7a77e0a
This commit is contained in:
Lorenzo Colitti
2016-04-11 16:21:50 +00:00
committed by android-build-merger

View File

@@ -165,7 +165,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
implements PendingIntent.OnFinished {
private static final String TAG = "ConnectivityService";
private static final boolean DBG = false;
private static final boolean DBG = true;
private static final boolean VDBG = false;
private static final boolean LOGD_RULES = false;
@@ -450,9 +450,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
*/
private class LegacyTypeTracker {
private static final boolean DBG = false;
private static final boolean DBG = true;
private static final boolean VDBG = false;
private static final String TAG = "CSLegacyTypeTracker";
/**
* Array of lists, one per legacy network type (e.g., TYPE_MOBILE_MMS).
@@ -605,12 +604,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
pw.decreaseIndent();
pw.println();
}
// This class needs its own log method because it has a different TAG.
private void log(String s) {
Slog.d(TAG, s);
}
}
private LegacyTypeTracker mLegacyTypeTracker = new LegacyTypeTracker();
@@ -1532,7 +1525,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
mInitialBroadcast = new Intent(intent);
}
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
if (DBG) {
if (VDBG) {
log("sendStickyBroadcast: action=" + intent.getAction());
}
@@ -1663,7 +1656,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
return;
}
if (LinkProperties.isValidMtu(mtu, newLp.hasGlobalIPv6Address()) == false) {
loge("Unexpected mtu value: " + mtu + ", " + iface);
if (mtu != 0) loge("Unexpected mtu value: " + mtu + ", " + iface);
return;
}
@@ -1674,7 +1667,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
try {
if (DBG) log("Setting MTU size: " + iface + ", " + mtu);
if (VDBG) log("Setting MTU size: " + iface + ", " + mtu);
mNetd.setMtu(iface, mtu);
} catch (Exception e) {
Slog.e(TAG, "exception in setMtu()" + e);
@@ -1710,7 +1703,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (tcpBufferSizes.equals(mCurrentTcpBufferSizes)) return;
try {
if (DBG) Slog.d(TAG, "Setting tx/rx TCP buffers to " + tcpBufferSizes);
if (VDBG) Slog.d(TAG, "Setting tx/rx TCP buffers to " + tcpBufferSizes);
final String prefix = "/sys/kernel/ipv4/tcp_";
FileUtils.stringToFile(prefix + "rmem_min", values[0]);
@@ -2318,7 +2311,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (DBG) log("Attempt to release unowned NetworkRequest " + request);
return;
}
if (DBG) log("releasing NetworkRequest " + request);
if (VDBG || (DBG && nri.isRequest())) log("releasing NetworkRequest " + request);
nri.unlinkDeathRecipient();
mNetworkRequests.remove(request);
mNetworkRequestInfoLogs.log("RELEASE " + nri);
@@ -2331,7 +2324,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
if (nai.networkRequests.get(nri.request.requestId) != null) {
nai.networkRequests.remove(nri.request.requestId);
if (DBG) {
if (VDBG) {
log(" Removing from current network " + nai.name() +
", leaving " + nai.networkRequests.size() +
" requests.");
@@ -2442,14 +2435,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
private void scheduleUnvalidatedPrompt(NetworkAgentInfo nai) {
if (DBG) log("scheduleUnvalidatedPrompt " + nai.network);
if (VDBG) log("scheduleUnvalidatedPrompt " + nai.network);
mHandler.sendMessageDelayed(
mHandler.obtainMessage(EVENT_PROMPT_UNVALIDATED, nai.network),
PROMPT_UNVALIDATED_DELAY_MS);
}
private void handlePromptUnvalidated(Network network) {
if (DBG) log("handlePromptUnvalidated " + network);
if (VDBG) log("handlePromptUnvalidated " + network);
NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
// Only prompt if the network is unvalidated and was explicitly selected by the user, and if
@@ -2492,11 +2485,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
break;
}
}
if (msg.what == EVENT_EXPIRE_NET_TRANSITION_WAKELOCK) {
log("Failed to find a new network - expiring NetTransition Wakelock");
} else {
log("NetTransition Wakelock (" + (causedBy == null ? "unknown" : causedBy) +
" cleared because we found a replacement network");
if (VDBG) {
if (msg.what == EVENT_EXPIRE_NET_TRANSITION_WAKELOCK) {
log("Failed to find a new network - expiring NetTransition Wakelock");
} else {
log("NetTransition Wakelock (" +
(causedBy == null ? "unknown" : causedBy) +
" cleared because we found a replacement network");
}
}
break;
}
@@ -3350,10 +3346,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
private static enum NotificationType { SIGN_IN, NO_INTERNET; };
private void setProvNotificationVisible(boolean visible, int networkType, String action) {
if (DBG) {
log("setProvNotificationVisible: E visible=" + visible + " networkType=" + networkType
+ " action=" + action);
}
Intent intent = new Intent(action);
PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
// Concatenate the range of types onto the range of NetIDs.
@@ -3380,7 +3372,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
private void setProvNotificationVisibleIntent(boolean visible, int id,
NotificationType notifyType, int networkType, String extraInfo, PendingIntent intent,
boolean highPriority) {
if (DBG) {
if (VDBG || (DBG && visible)) {
log("setProvNotificationVisibleIntent " + notifyType + " visible=" + visible
+ " networkType=" + getNetworkTypeName(networkType)
+ " extraInfo=" + extraInfo + " highPriority=" + highPriority);
@@ -3823,8 +3815,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
Bundle thresholds = new Bundle();
thresholds.putIntegerArrayList("thresholds", thresholdsArray);
// TODO: Switch to VDBG.
if (DBG) {
if (VDBG || (DBG && !"CONNECT".equals(reason))) {
String detail;
if (request != null && request.networkCapabilities.hasSignalStrength()) {
detail = reason + " " + request.networkCapabilities.getSignalStrength();
@@ -3989,7 +3980,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
new NetworkCapabilities(networkCapabilities), TYPE_NONE, nextNetworkRequestId());
NetworkRequestInfo nri = new NetworkRequestInfo(messenger, networkRequest, binder,
NetworkRequestType.LISTEN);
if (DBG) log("listenForNetwork for " + nri);
if (VDBG) log("listenForNetwork for " + nri);
mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_LISTENER, nri));
return networkRequest;
@@ -4007,7 +3998,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
new NetworkCapabilities(networkCapabilities), TYPE_NONE, nextNetworkRequestId());
NetworkRequestInfo nri = new NetworkRequestInfo(networkRequest, operation,
NetworkRequestType.LISTEN);
if (DBG) log("pendingListenForNetwork for " + nri);
if (VDBG) log("pendingListenForNetwork for " + nri);
mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_LISTENER, nri));
}
@@ -4212,7 +4203,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// do this twice, adding non-nexthop routes first, then routes they are dependent on
for (RouteInfo route : routeDiff.added) {
if (route.hasGateway()) continue;
if (DBG) log("Adding Route [" + route + "] to network " + netId);
if (VDBG) log("Adding Route [" + route + "] to network " + netId);
try {
mNetd.addRoute(netId, route);
} catch (Exception e) {
@@ -4223,7 +4214,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
for (RouteInfo route : routeDiff.added) {
if (route.hasGateway() == false) continue;
if (DBG) log("Adding Route [" + route + "] to network " + netId);
if (VDBG) log("Adding Route [" + route + "] to network " + netId);
try {
mNetd.addRoute(netId, route);
} catch (Exception e) {
@@ -4234,7 +4225,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
for (RouteInfo route : routeDiff.removed) {
if (DBG) log("Removing Route [" + route + "] from network " + netId);
if (VDBG) log("Removing Route [" + route + "] from network " + netId);
try {
mNetd.removeRoute(netId, route);
} catch (Exception e) {
@@ -4250,7 +4241,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
Collection<InetAddress> dnses = newLp.getDnsServers();
if (DBG) log("Setting Dns servers for network " + netId + " to " + dnses);
if (DBG) log("Setting DNS servers for network " + netId + " to " + dnses);
try {
mNetd.setDnsServersForNetwork(
netId, NetworkUtils.makeStrings(dnses), newLp.getDomains());
@@ -4518,14 +4509,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
if (currentNetwork == null ||
currentNetwork.getCurrentScore() < newNetwork.getCurrentScore()) {
if (DBG) log("rematch for " + newNetwork.name());
if (VDBG) log("rematch for " + newNetwork.name());
if (currentNetwork != null) {
if (DBG) log(" accepting network in place of " + currentNetwork.name());
if (VDBG) log(" accepting network in place of " + currentNetwork.name());
currentNetwork.networkRequests.remove(nri.request.requestId);
currentNetwork.networkLingered.add(nri.request);
affectedNetworks.add(currentNetwork);
} else {
if (DBG) log(" accepting network in place of null");
if (VDBG) log(" accepting network in place of null");
}
unlinger(newNetwork);
mNetworkForRequestId.put(nri.request.requestId, newNetwork);
@@ -4855,7 +4846,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
private void updateNetworkScore(NetworkAgentInfo nai, int score) {
if (DBG) log("updateNetworkScore for " + nai.name() + " to " + score);
if (VDBG) log("updateNetworkScore for " + nai.name() + " to " + score);
if (score < 0) {
loge("updateNetworkScore for " + nai.name() + " got a negative score (" + score +
"). Bumping score to min of 0");
@@ -4933,7 +4924,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
protected void notifyNetworkCallbacks(NetworkAgentInfo networkAgent, int notifyType) {
if (DBG) log("notifyType " + notifyTypeToName(notifyType) + " for " + networkAgent.name());
if (VDBG) log("notifyType " + notifyTypeToName(notifyType) + " for " + networkAgent.name());
for (int i = 0; i < networkAgent.networkRequests.size(); i++) {
NetworkRequest nr = networkAgent.networkRequests.valueAt(i);
NetworkRequestInfo nri = mNetworkRequests.get(nr);