Add a reevaluate command to ConnectivityService
This is useful for debugging occasionally.
Test: manual
Change-Id: Ic29f81cb993d7e75916d3bacfaed7d0d6d07af07
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index 8ec979a..55369f9 100755
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -9627,6 +9627,8 @@
try {
switch (cmd) {
case "airplane-mode":
+ // Usage : adb shell cmd connectivity airplane-mode [enable|disable]
+ // If no argument, get and display the current status
final String action = getNextArg();
if ("enable".equals(action)) {
setAirplaneMode(true);
@@ -9644,6 +9646,27 @@
onHelp();
return -1;
}
+ case "reevaluate":
+ // Usage : adb shell cmd connectivity reevaluate <netId>
+ // If netId is omitted, then reevaluate the default network
+ final String netId = getNextArg();
+ final NetworkAgentInfo nai;
+ if (null == netId) {
+ // Note that the command is running on the wrong thread to call this,
+ // so this could in principle return stale data. But it can't crash.
+ nai = getDefaultNetwork();
+ } else {
+ // If netId can't be parsed, this throws NumberFormatException, which
+ // is passed back to adb who prints it.
+ nai = getNetworkAgentInfoForNetId(Integer.parseInt(netId));
+ }
+ if (null == nai) {
+ pw.println("Unknown network (net ID not found or no default network)");
+ return 0;
+ }
+ Log.d(TAG, "Reevaluating network " + nai.network);
+ reportNetworkConnectivity(nai.network, !nai.isValidated());
+ return 0;
default:
return handleDefaultCommands(cmd);
}