ConnectivityService: make log configurable
Make log of ConnectivityService configurable by system property.
Two levels:
VERBOSE: whole VDBG log.
DEBUG: selected necessary log for debug purpose.
Relevant log can be enbled in either way:
1. use adb command at run time.
2. config init.xx.rc file at compile time by adding.
on boot && property:ro.build.type=userdebug
setprop log.tag.ConnectivityService DEBUG
Bug: 117632924
Change-Id: I43cc84878c64c5b448853c7393393a02262afd15
This commit is contained in:
committed by
Fen Wang
parent
e70b760e83
commit
a1a397d1d1
@@ -212,7 +212,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;
|
||||||
|
|
||||||
@@ -1974,7 +1975,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);
|
||||||
@@ -2010,7 +2011,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]);
|
||||||
@@ -2827,7 +2828,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.");
|
||||||
}
|
}
|
||||||
@@ -3050,7 +3051,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
|
||||||
@@ -4731,7 +4732,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) {
|
||||||
@@ -4742,7 +4743,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) {
|
||||||
@@ -4753,7 +4754,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) {
|
||||||
@@ -4946,7 +4947,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);
|
||||||
@@ -4970,7 +4971,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);
|
||||||
@@ -5176,7 +5179,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.
|
||||||
@@ -5207,7 +5210,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);
|
||||||
@@ -5215,12 +5218,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);
|
||||||
@@ -5573,7 +5578,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");
|
||||||
@@ -5650,7 +5655,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());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user