Merge "Add a reevaluate command to ConnectivityService"
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index 9322172..93265e5 100755
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -9639,6 +9639,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);
@@ -9656,6 +9658,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);
}