Include network name in validation logs for dumpsys

Previously this was included in the log messages from NetworkMonitor
but that has been removed (ag/944107), making it frequently impossible
to know what network the logs apply to as there may be no way to
correlate NetIDs to WiFi SSIDs or Cellular networks if the log has wrapped.

Bug: 26075613
Change-Id: I2e3cd41fffb616ab9f855cb16790360bd3414793
This commit is contained in:
Paul Jensen
2016-06-03 13:51:21 -04:00
parent 4fb4490dfb
commit 5912c7b350

View File

@@ -433,15 +433,26 @@ public class ConnectivityService extends IConnectivityManager.Stub
// Array of <Network,ReadOnlyLocalLogs> tracking network validation and results // Array of <Network,ReadOnlyLocalLogs> tracking network validation and results
private static final int MAX_VALIDATION_LOGS = 10; private static final int MAX_VALIDATION_LOGS = 10;
private final ArrayDeque<Pair<Network,ReadOnlyLocalLog>> mValidationLogs = private static class ValidationLog {
new ArrayDeque<Pair<Network,ReadOnlyLocalLog>>(MAX_VALIDATION_LOGS); final Network mNetwork;
final String mNetworkExtraInfo;
final ReadOnlyLocalLog mLog;
private void addValidationLogs(ReadOnlyLocalLog log, Network network) { ValidationLog(Network network, String networkExtraInfo, ReadOnlyLocalLog log) {
mNetwork = network;
mNetworkExtraInfo = networkExtraInfo;
mLog = log;
}
}
private final ArrayDeque<ValidationLog> mValidationLogs =
new ArrayDeque<ValidationLog>(MAX_VALIDATION_LOGS);
private void addValidationLogs(ReadOnlyLocalLog log, Network network, String networkExtraInfo) {
synchronized(mValidationLogs) { synchronized(mValidationLogs) {
while (mValidationLogs.size() >= MAX_VALIDATION_LOGS) { while (mValidationLogs.size() >= MAX_VALIDATION_LOGS) {
mValidationLogs.removeLast(); mValidationLogs.removeLast();
} }
mValidationLogs.addFirst(new Pair(network, log)); mValidationLogs.addFirst(new ValidationLog(network, networkExtraInfo, log));
} }
} }
@@ -1950,10 +1961,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
pw.println(); pw.println();
synchronized (mValidationLogs) { synchronized (mValidationLogs) {
pw.println("mValidationLogs (most recent first):"); pw.println("mValidationLogs (most recent first):");
for (Pair<Network,ReadOnlyLocalLog> p : mValidationLogs) { for (ValidationLog p : mValidationLogs) {
pw.println(p.first); pw.println(p.mNetwork + " - " + p.mNetworkExtraInfo);
pw.increaseIndent(); pw.increaseIndent();
p.second.dump(fd, pw, args); p.mLog.dump(fd, pw, args);
pw.decreaseIndent(); pw.decreaseIndent();
} }
} }
@@ -4253,7 +4264,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
synchronized (this) { synchronized (this) {
nai.networkMonitor.systemReady = mSystemReady; nai.networkMonitor.systemReady = mSystemReady;
} }
addValidationLogs(nai.networkMonitor.getValidationLogs(), nai.network); addValidationLogs(nai.networkMonitor.getValidationLogs(), nai.network,
networkInfo.getExtraInfo());
if (DBG) log("registerNetworkAgent " + nai); if (DBG) log("registerNetworkAgent " + nai);
mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_AGENT, nai)); mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_AGENT, nai));
return nai.network.netId; return nai.network.netId;