Merge "Reinstate much-reduced ConnectivityService logging." into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
facc09db55
@@ -165,7 +165,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
implements PendingIntent.OnFinished {
|
implements PendingIntent.OnFinished {
|
||||||
private static final String TAG = "ConnectivityService";
|
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 VDBG = false;
|
||||||
|
|
||||||
private static final boolean LOGD_RULES = false;
|
private static final boolean LOGD_RULES = false;
|
||||||
@@ -450,9 +450,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
*/
|
*/
|
||||||
private class LegacyTypeTracker {
|
private class LegacyTypeTracker {
|
||||||
|
|
||||||
private static final boolean DBG = false;
|
private static final boolean DBG = true;
|
||||||
private static final boolean VDBG = false;
|
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).
|
* 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.decreaseIndent();
|
||||||
pw.println();
|
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();
|
private LegacyTypeTracker mLegacyTypeTracker = new LegacyTypeTracker();
|
||||||
|
|
||||||
@@ -1532,7 +1525,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
mInitialBroadcast = new Intent(intent);
|
mInitialBroadcast = new Intent(intent);
|
||||||
}
|
}
|
||||||
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
||||||
if (DBG) {
|
if (VDBG) {
|
||||||
log("sendStickyBroadcast: action=" + intent.getAction());
|
log("sendStickyBroadcast: action=" + intent.getAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1660,7 +1653,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (LinkProperties.isValidMtu(mtu, newLp.hasGlobalIPv6Address()) == false) {
|
if (LinkProperties.isValidMtu(mtu, newLp.hasGlobalIPv6Address()) == false) {
|
||||||
loge("Unexpected mtu value: " + mtu + ", " + iface);
|
if (mtu != 0) loge("Unexpected mtu value: " + mtu + ", " + iface);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1671,7 +1664,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (DBG) log("Setting MTU size: " + iface + ", " + mtu);
|
if (VDBG) log("Setting MTU size: " + iface + ", " + mtu);
|
||||||
mNetd.setMtu(iface, mtu);
|
mNetd.setMtu(iface, mtu);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Slog.e(TAG, "exception in setMtu()" + e);
|
Slog.e(TAG, "exception in setMtu()" + e);
|
||||||
@@ -1707,7 +1700,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
if (tcpBufferSizes.equals(mCurrentTcpBufferSizes)) return;
|
if (tcpBufferSizes.equals(mCurrentTcpBufferSizes)) return;
|
||||||
|
|
||||||
try {
|
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_";
|
final String prefix = "/sys/kernel/ipv4/tcp_";
|
||||||
FileUtils.stringToFile(prefix + "rmem_min", values[0]);
|
FileUtils.stringToFile(prefix + "rmem_min", values[0]);
|
||||||
@@ -2315,7 +2308,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
if (DBG) log("Attempt to release unowned NetworkRequest " + request);
|
if (DBG) log("Attempt to release unowned NetworkRequest " + request);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (DBG) log("releasing NetworkRequest " + request);
|
if (VDBG || (DBG && nri.isRequest())) log("releasing NetworkRequest " + request);
|
||||||
nri.unlinkDeathRecipient();
|
nri.unlinkDeathRecipient();
|
||||||
mNetworkRequests.remove(request);
|
mNetworkRequests.remove(request);
|
||||||
mNetworkRequestInfoLogs.log("RELEASE " + nri);
|
mNetworkRequestInfoLogs.log("RELEASE " + nri);
|
||||||
@@ -2328,7 +2321,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
|
for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
|
||||||
if (nai.networkRequests.get(nri.request.requestId) != null) {
|
if (nai.networkRequests.get(nri.request.requestId) != null) {
|
||||||
nai.networkRequests.remove(nri.request.requestId);
|
nai.networkRequests.remove(nri.request.requestId);
|
||||||
if (DBG) {
|
if (VDBG) {
|
||||||
log(" Removing from current network " + nai.name() +
|
log(" Removing from current network " + nai.name() +
|
||||||
", leaving " + nai.networkRequests.size() +
|
", leaving " + nai.networkRequests.size() +
|
||||||
" requests.");
|
" requests.");
|
||||||
@@ -2439,14 +2432,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void scheduleUnvalidatedPrompt(NetworkAgentInfo nai) {
|
private void scheduleUnvalidatedPrompt(NetworkAgentInfo nai) {
|
||||||
if (DBG) log("scheduleUnvalidatedPrompt " + nai.network);
|
if (VDBG) log("scheduleUnvalidatedPrompt " + nai.network);
|
||||||
mHandler.sendMessageDelayed(
|
mHandler.sendMessageDelayed(
|
||||||
mHandler.obtainMessage(EVENT_PROMPT_UNVALIDATED, nai.network),
|
mHandler.obtainMessage(EVENT_PROMPT_UNVALIDATED, nai.network),
|
||||||
PROMPT_UNVALIDATED_DELAY_MS);
|
PROMPT_UNVALIDATED_DELAY_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePromptUnvalidated(Network network) {
|
private void handlePromptUnvalidated(Network network) {
|
||||||
if (DBG) log("handlePromptUnvalidated " + network);
|
if (VDBG) 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
|
||||||
@@ -2489,11 +2482,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg.what == EVENT_EXPIRE_NET_TRANSITION_WAKELOCK) {
|
if (VDBG) {
|
||||||
log("Failed to find a new network - expiring NetTransition Wakelock");
|
if (msg.what == EVENT_EXPIRE_NET_TRANSITION_WAKELOCK) {
|
||||||
} else {
|
log("Failed to find a new network - expiring NetTransition Wakelock");
|
||||||
log("NetTransition Wakelock (" + (causedBy == null ? "unknown" : causedBy) +
|
} else {
|
||||||
" cleared because we found a replacement network");
|
log("NetTransition Wakelock (" +
|
||||||
|
(causedBy == null ? "unknown" : causedBy) +
|
||||||
|
" cleared because we found a replacement network");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3347,10 +3343,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
private static enum NotificationType { SIGN_IN, NO_INTERNET; };
|
private static enum NotificationType { SIGN_IN, NO_INTERNET; };
|
||||||
|
|
||||||
private void setProvNotificationVisible(boolean visible, int networkType, String action) {
|
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);
|
Intent intent = new Intent(action);
|
||||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
|
||||||
// Concatenate the range of types onto the range of NetIDs.
|
// Concatenate the range of types onto the range of NetIDs.
|
||||||
@@ -3377,7 +3369,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
private void setProvNotificationVisibleIntent(boolean visible, int id,
|
private void setProvNotificationVisibleIntent(boolean visible, int id,
|
||||||
NotificationType notifyType, int networkType, String extraInfo, PendingIntent intent,
|
NotificationType notifyType, int networkType, String extraInfo, PendingIntent intent,
|
||||||
boolean highPriority) {
|
boolean highPriority) {
|
||||||
if (DBG) {
|
if (VDBG || (DBG && visible)) {
|
||||||
log("setProvNotificationVisibleIntent " + notifyType + " visible=" + visible
|
log("setProvNotificationVisibleIntent " + notifyType + " visible=" + visible
|
||||||
+ " networkType=" + getNetworkTypeName(networkType)
|
+ " networkType=" + getNetworkTypeName(networkType)
|
||||||
+ " extraInfo=" + extraInfo + " highPriority=" + highPriority);
|
+ " extraInfo=" + extraInfo + " highPriority=" + highPriority);
|
||||||
@@ -3820,8 +3812,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
Bundle thresholds = new Bundle();
|
Bundle thresholds = new Bundle();
|
||||||
thresholds.putIntegerArrayList("thresholds", thresholdsArray);
|
thresholds.putIntegerArrayList("thresholds", thresholdsArray);
|
||||||
|
|
||||||
// TODO: Switch to VDBG.
|
if (VDBG || (DBG && !"CONNECT".equals(reason))) {
|
||||||
if (DBG) {
|
|
||||||
String detail;
|
String detail;
|
||||||
if (request != null && request.networkCapabilities.hasSignalStrength()) {
|
if (request != null && request.networkCapabilities.hasSignalStrength()) {
|
||||||
detail = reason + " " + request.networkCapabilities.getSignalStrength();
|
detail = reason + " " + request.networkCapabilities.getSignalStrength();
|
||||||
@@ -3986,7 +3977,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
new NetworkCapabilities(networkCapabilities), TYPE_NONE, nextNetworkRequestId());
|
new NetworkCapabilities(networkCapabilities), TYPE_NONE, nextNetworkRequestId());
|
||||||
NetworkRequestInfo nri = new NetworkRequestInfo(messenger, networkRequest, binder,
|
NetworkRequestInfo nri = new NetworkRequestInfo(messenger, networkRequest, binder,
|
||||||
NetworkRequestType.LISTEN);
|
NetworkRequestType.LISTEN);
|
||||||
if (DBG) log("listenForNetwork for " + nri);
|
if (VDBG) log("listenForNetwork for " + nri);
|
||||||
|
|
||||||
mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_LISTENER, nri));
|
mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_LISTENER, nri));
|
||||||
return networkRequest;
|
return networkRequest;
|
||||||
@@ -4004,7 +3995,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
new NetworkCapabilities(networkCapabilities), TYPE_NONE, nextNetworkRequestId());
|
new NetworkCapabilities(networkCapabilities), TYPE_NONE, nextNetworkRequestId());
|
||||||
NetworkRequestInfo nri = new NetworkRequestInfo(networkRequest, operation,
|
NetworkRequestInfo nri = new NetworkRequestInfo(networkRequest, operation,
|
||||||
NetworkRequestType.LISTEN);
|
NetworkRequestType.LISTEN);
|
||||||
if (DBG) log("pendingListenForNetwork for " + nri);
|
if (VDBG) log("pendingListenForNetwork for " + nri);
|
||||||
|
|
||||||
mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_LISTENER, nri));
|
mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_LISTENER, nri));
|
||||||
}
|
}
|
||||||
@@ -4209,7 +4200,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// do this twice, adding non-nexthop routes first, then routes they are dependent on
|
// do this twice, adding non-nexthop 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 (DBG) log("Adding Route [" + route + "] to network " + netId);
|
if (VDBG) log("Adding Route [" + route + "] to network " + netId);
|
||||||
try {
|
try {
|
||||||
mNetd.addRoute(netId, route);
|
mNetd.addRoute(netId, route);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -4220,7 +4211,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 (DBG) log("Adding Route [" + route + "] to network " + netId);
|
if (VDBG) log("Adding Route [" + route + "] to network " + netId);
|
||||||
try {
|
try {
|
||||||
mNetd.addRoute(netId, route);
|
mNetd.addRoute(netId, route);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -4231,7 +4222,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (RouteInfo route : routeDiff.removed) {
|
for (RouteInfo route : routeDiff.removed) {
|
||||||
if (DBG) log("Removing Route [" + route + "] from network " + netId);
|
if (VDBG) log("Removing Route [" + route + "] from network " + netId);
|
||||||
try {
|
try {
|
||||||
mNetd.removeRoute(netId, route);
|
mNetd.removeRoute(netId, route);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -4247,7 +4238,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
Collection<InetAddress> dnses = newLp.getDnsServers();
|
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 {
|
try {
|
||||||
mNetd.setDnsServersForNetwork(
|
mNetd.setDnsServersForNetwork(
|
||||||
netId, NetworkUtils.makeStrings(dnses), newLp.getDomains());
|
netId, NetworkUtils.makeStrings(dnses), newLp.getDomains());
|
||||||
@@ -4515,14 +4506,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
if (currentNetwork == null ||
|
if (currentNetwork == null ||
|
||||||
currentNetwork.getCurrentScore() < newNetwork.getCurrentScore()) {
|
currentNetwork.getCurrentScore() < newNetwork.getCurrentScore()) {
|
||||||
if (DBG) log("rematch for " + newNetwork.name());
|
if (VDBG) log("rematch for " + newNetwork.name());
|
||||||
if (currentNetwork != null) {
|
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.networkRequests.remove(nri.request.requestId);
|
||||||
currentNetwork.networkLingered.add(nri.request);
|
currentNetwork.networkLingered.add(nri.request);
|
||||||
affectedNetworks.add(currentNetwork);
|
affectedNetworks.add(currentNetwork);
|
||||||
} else {
|
} else {
|
||||||
if (DBG) log(" accepting network in place of null");
|
if (VDBG) log(" accepting network in place of null");
|
||||||
}
|
}
|
||||||
unlinger(newNetwork);
|
unlinger(newNetwork);
|
||||||
mNetworkForRequestId.put(nri.request.requestId, newNetwork);
|
mNetworkForRequestId.put(nri.request.requestId, newNetwork);
|
||||||
@@ -4852,7 +4843,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateNetworkScore(NetworkAgentInfo nai, int score) {
|
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) {
|
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");
|
||||||
@@ -4930,7 +4921,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void notifyNetworkCallbacks(NetworkAgentInfo networkAgent, int notifyType) {
|
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++) {
|
for (int i = 0; i < networkAgent.networkRequests.size(); i++) {
|
||||||
NetworkRequest nr = networkAgent.networkRequests.valueAt(i);
|
NetworkRequest nr = networkAgent.networkRequests.valueAt(i);
|
||||||
NetworkRequestInfo nri = mNetworkRequests.get(nr);
|
NetworkRequestInfo nri = mNetworkRequests.get(nr);
|
||||||
|
|||||||
Reference in New Issue
Block a user