Merge "Add a reevaluate command to ConnectivityService"
This commit is contained in:
@@ -9639,6 +9639,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
try {
|
try {
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case "airplane-mode":
|
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();
|
final String action = getNextArg();
|
||||||
if ("enable".equals(action)) {
|
if ("enable".equals(action)) {
|
||||||
setAirplaneMode(true);
|
setAirplaneMode(true);
|
||||||
@@ -9656,6 +9658,27 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
onHelp();
|
onHelp();
|
||||||
return -1;
|
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:
|
default:
|
||||||
return handleDefaultCommands(cmd);
|
return handleDefaultCommands(cmd);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user