Merge "ConnectivityService: make log configurable" am: 3ec9281fa8 am: a7a96dd623

am: 521d6296e2

Change-Id: Iaa8804ce9721bd47a6a26ca1d87d6d69793ba9c8
This commit is contained in:
Chalard Jean
2018-10-25 23:41:34 -07:00
committed by android-build-merger

View File

@@ -215,7 +215,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
private static final String REQUEST_ARG = "requests"; private static final String REQUEST_ARG = "requests";
private static final boolean DBG = true; private static final boolean DBG = true;
private static final boolean VDBG = false; private static final boolean DDBG = Log.isLoggable(TAG, Log.DEBUG);
private static final boolean VDBG = Log.isLoggable(TAG, Log.VERBOSE);
private static final boolean LOGD_BLOCKED_NETWORKINFO = true; private static final boolean LOGD_BLOCKED_NETWORKINFO = true;
@@ -2056,7 +2057,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
try { try {
if (VDBG) log("Setting MTU size: " + iface + ", " + mtu); if (VDBG || DDBG) log("Setting MTU size: " + iface + ", " + mtu);
mNMS.setMtu(iface, mtu); mNMS.setMtu(iface, mtu);
} catch (Exception e) { } catch (Exception e) {
Slog.e(TAG, "exception in setMtu()" + e); Slog.e(TAG, "exception in setMtu()" + e);
@@ -2092,7 +2093,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (tcpBufferSizes.equals(mCurrentTcpBufferSizes)) return; if (tcpBufferSizes.equals(mCurrentTcpBufferSizes)) return;
try { try {
if (VDBG) Slog.d(TAG, "Setting tx/rx TCP buffers to " + tcpBufferSizes); if (VDBG || DDBG) Slog.d(TAG, "Setting tx/rx TCP buffers to " + tcpBufferSizes);
final String prefix = "/sys/kernel/ipv4/tcp_"; final String prefix = "/sys/kernel/ipv4/tcp_";
FileUtils.stringToFile(prefix + "rmem_min", values[0]); FileUtils.stringToFile(prefix + "rmem_min", values[0]);
@@ -2931,7 +2932,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (nai != null) { if (nai != null) {
boolean wasBackgroundNetwork = nai.isBackgroundNetwork(); boolean wasBackgroundNetwork = nai.isBackgroundNetwork();
nai.removeRequest(nri.request.requestId); nai.removeRequest(nri.request.requestId);
if (VDBG) { if (VDBG || DDBG) {
log(" Removing from current network " + nai.name() + log(" Removing from current network " + nai.name() +
", leaving " + nai.numNetworkRequests() + " requests."); ", leaving " + nai.numNetworkRequests() + " requests.");
} }
@@ -3154,7 +3155,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
private void handlePromptUnvalidated(Network network) { private void handlePromptUnvalidated(Network network) {
if (VDBG) log("handlePromptUnvalidated " + network); if (VDBG || DDBG) log("handlePromptUnvalidated " + network);
NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network); NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
// Only prompt if the network is unvalidated and was explicitly selected by the user, and if // Only prompt if the network is unvalidated and was explicitly selected by the user, and if
@@ -4843,7 +4844,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// do this twice, adding non-next-hop 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) { for (RouteInfo route : routeDiff.added) {
if (route.hasGateway()) continue; if (route.hasGateway()) continue;
if (VDBG) log("Adding Route [" + route + "] to network " + netId); if (VDBG || DDBG) log("Adding Route [" + route + "] to network " + netId);
try { try {
mNMS.addRoute(netId, route); mNMS.addRoute(netId, route);
} catch (Exception e) { } catch (Exception e) {
@@ -4854,7 +4855,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
for (RouteInfo route : routeDiff.added) { for (RouteInfo route : routeDiff.added) {
if (route.hasGateway() == false) continue; if (route.hasGateway() == false) continue;
if (VDBG) log("Adding Route [" + route + "] to network " + netId); if (VDBG || DDBG) log("Adding Route [" + route + "] to network " + netId);
try { try {
mNMS.addRoute(netId, route); mNMS.addRoute(netId, route);
} catch (Exception e) { } catch (Exception e) {
@@ -4865,7 +4866,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
for (RouteInfo route : routeDiff.removed) { for (RouteInfo route : routeDiff.removed) {
if (VDBG) log("Removing Route [" + route + "] from network " + netId); if (VDBG || DDBG) log("Removing Route [" + route + "] from network " + netId);
try { try {
mNMS.removeRoute(netId, route); mNMS.removeRoute(netId, route);
} catch (Exception e) { } catch (Exception e) {
@@ -5066,7 +5067,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
// newLp is already a defensive copy. // newLp is already a defensive copy.
newLp.ensureDirectlyConnectedRoutes(); newLp.ensureDirectlyConnectedRoutes();
if (VDBG) { if (VDBG || DDBG) {
log("Update of LinkProperties for " + nai.name() + log("Update of LinkProperties for " + nai.name() +
"; created=" + nai.created + "; created=" + nai.created +
"; everConnected=" + nai.everConnected); "; everConnected=" + nai.everConnected);
@@ -5090,7 +5091,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
private void sendUpdatedScoreToFactories(NetworkRequest networkRequest, int score) { private void sendUpdatedScoreToFactories(NetworkRequest networkRequest, int score) {
if (VDBG) log("sending new Min Network Score(" + score + "): " + networkRequest.toString()); if (VDBG || DDBG){
log("sending new Min Network Score(" + score + "): " + networkRequest.toString());
}
for (NetworkFactoryInfo nfi : mNetworkFactoryInfos.values()) { for (NetworkFactoryInfo nfi : mNetworkFactoryInfos.values()) {
nfi.asyncChannel.sendMessage(android.net.NetworkFactory.CMD_REQUEST_NETWORK, score, 0, nfi.asyncChannel.sendMessage(android.net.NetworkFactory.CMD_REQUEST_NETWORK, score, 0,
networkRequest); networkRequest);
@@ -5303,7 +5306,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
final boolean wasBackgroundNetwork = newNetwork.isBackgroundNetwork(); final boolean wasBackgroundNetwork = newNetwork.isBackgroundNetwork();
final int score = newNetwork.getCurrentScore(); final int score = newNetwork.getCurrentScore();
if (VDBG) log("rematching " + newNetwork.name()); if (VDBG || DDBG) log("rematching " + newNetwork.name());
// Find and migrate to this Network any NetworkRequests for // Find and migrate to this Network any NetworkRequests for
// which this network is now the best. // which this network is now the best.
@@ -5334,7 +5337,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (satisfies) { if (satisfies) {
// next check if it's better than any current network we're using for // next check if it's better than any current network we're using for
// this request // this request
if (VDBG) { if (VDBG || DDBG) {
log("currentScore = " + log("currentScore = " +
(currentNetwork != null ? currentNetwork.getCurrentScore() : 0) + (currentNetwork != null ? currentNetwork.getCurrentScore() : 0) +
", newScore = " + score); ", newScore = " + score);
@@ -5342,12 +5345,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (currentNetwork == null || currentNetwork.getCurrentScore() < score) { if (currentNetwork == null || currentNetwork.getCurrentScore() < score) {
if (VDBG) log("rematch for " + newNetwork.name()); if (VDBG) log("rematch for " + newNetwork.name());
if (currentNetwork != null) { if (currentNetwork != null) {
if (VDBG) log(" accepting network in place of " + currentNetwork.name()); if (VDBG || DDBG){
log(" accepting network in place of " + currentNetwork.name());
}
currentNetwork.removeRequest(nri.request.requestId); currentNetwork.removeRequest(nri.request.requestId);
currentNetwork.lingerRequest(nri.request, now, mLingerDelayMs); currentNetwork.lingerRequest(nri.request, now, mLingerDelayMs);
affectedNetworks.add(currentNetwork); affectedNetworks.add(currentNetwork);
} else { } else {
if (VDBG) log(" accepting network in place of null"); if (VDBG || DDBG) log(" accepting network in place of null");
} }
newNetwork.unlingerRequest(nri.request); newNetwork.unlingerRequest(nri.request);
setNetworkForRequest(nri.request.requestId, newNetwork); setNetworkForRequest(nri.request.requestId, newNetwork);
@@ -5700,7 +5705,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
private void updateNetworkScore(NetworkAgentInfo nai, int score) { private void updateNetworkScore(NetworkAgentInfo nai, int score) {
if (VDBG) log("updateNetworkScore for " + nai.name() + " to " + score); if (VDBG || DDBG) log("updateNetworkScore for " + nai.name() + " to " + score);
if (score < 0) { if (score < 0) {
loge("updateNetworkScore for " + nai.name() + " got a negative score (" + score + loge("updateNetworkScore for " + nai.name() + " got a negative score (" + score +
"). Bumping score to min of 0"); "). Bumping score to min of 0");
@@ -5846,7 +5851,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
protected void notifyNetworkCallbacks(NetworkAgentInfo networkAgent, int notifyType, int arg1) { protected void notifyNetworkCallbacks(NetworkAgentInfo networkAgent, int notifyType, int arg1) {
if (VDBG) { if (VDBG || DDBG) {
String notification = ConnectivityManager.getCallbackName(notifyType); String notification = ConnectivityManager.getCallbackName(notifyType);
log("notifyType " + notification + " for " + networkAgent.name()); log("notifyType " + notification + " for " + networkAgent.name());
} }