From f1dab06d07b415dd29f62d7e83f0c5e924c9d687 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Mon, 1 Jun 2020 13:30:12 -0700 Subject: WifiShellCommand: Return 0 for all handled messages Bug: 152299953 Test: Compiles Change-Id: I342e0cb1861693f311942a0c60c5a572ec181ad6 --- .../com/android/server/wifi/WifiShellCommand.java | 39 +++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/WifiShellCommand.java b/service/java/com/android/server/wifi/WifiShellCommand.java index 842493c6d..41933abf0 100644 --- a/service/java/com/android/server/wifi/WifiShellCommand.java +++ b/service/java/com/android/server/wifi/WifiShellCommand.java @@ -372,10 +372,10 @@ public class WifiShellCommand extends BasicShellCommandHandler { if (ApConfigUtil.isWpa3SaeSupported(mContext)) { pw.println("wifi_softap_wpa3_sae_supported"); } - break; + return 0; case "settings-reset": mWifiService.factoryReset(SHELL_PACKAGE_NAME); - break; + return 0; case "list-scan-results": List scanResults = mWifiService.getScanResults(SHELL_PACKAGE_NAME, null); @@ -385,10 +385,10 @@ public class WifiShellCommand extends BasicShellCommandHandler { ScanResultUtil.dumpScanResults(pw, scanResults, SystemClock.elapsedRealtime()); } - break; + return 0; case "start-scan": mWifiService.startScan(SHELL_PACKAGE_NAME, null); - break; + return 0; case "list-networks": ParceledListSlice networks = mWifiService.getConfiguredNetworks(SHELL_PACKAGE_NAME, null); @@ -414,7 +414,7 @@ public class WifiShellCommand extends BasicShellCommandHandler { securityType)); } } - break; + return 0; case "connect-network": { CountDownLatch countDownLatch = new CountDownLatch(1); IActionListener.Stub actionListener = new IActionListener.Stub() { @@ -436,7 +436,7 @@ public class WifiShellCommand extends BasicShellCommandHandler { // wait for status. countDownLatch.await(500, TimeUnit.MILLISECONDS); setAutoJoin(pw, config.SSID, config.allowAutojoin); - break; + return 0; } case "add-network": { CountDownLatch countDownLatch = new CountDownLatch(1); @@ -459,7 +459,7 @@ public class WifiShellCommand extends BasicShellCommandHandler { // wait for status. countDownLatch.await(500, TimeUnit.MILLISECONDS); setAutoJoin(pw, config.SSID, config.allowAutojoin); - break; + return 0; } case "forget-network": { String networkId = getNextArgRequired(); @@ -482,21 +482,21 @@ public class WifiShellCommand extends BasicShellCommandHandler { actionListener.hashCode()); // wait for status. countDownLatch.await(500, TimeUnit.MILLISECONDS); - break; + return 0; } case "status": printStatus(pw); - break; + return 0; case "set-verbose-logging": { boolean enabled = getNextArgRequiredTrueOrFalse("enabled", "disabled"); mWifiService.enableVerboseLogging(enabled ? 1 : 0); - break; + return 0; } case "add-suggestion": { WifiNetworkSuggestion suggestion = buildSuggestion(pw); mWifiService.addNetworkSuggestions( Arrays.asList(suggestion), SHELL_PACKAGE_NAME, null); - break; + return 0; } case "remove-suggestion": { String ssid = getNextArgRequired(); @@ -512,12 +512,12 @@ public class WifiShellCommand extends BasicShellCommandHandler { } mWifiService.removeNetworkSuggestions( Arrays.asList(suggestion), SHELL_PACKAGE_NAME); - break; + return 0; } case "remove-all-suggestions": mWifiService.removeNetworkSuggestions( Collections.emptyList(), SHELL_PACKAGE_NAME); - break; + return 0; case "list-suggestions": { List suggestions = mWifiService.getNetworkSuggestions(SHELL_PACKAGE_NAME); @@ -548,7 +548,7 @@ public class WifiShellCommand extends BasicShellCommandHandler { securityType)); } } - break; + return 0; } case "add-request": { NetworkRequest networkRequest = buildNetworkRequest(pw); @@ -558,7 +558,7 @@ public class WifiShellCommand extends BasicShellCommandHandler { mConnectivityManager.requestNetwork(networkRequest, networkCallback); String ssid = getAllArgs()[1]; sActiveRequests.put(ssid, Pair.create(networkRequest, networkCallback)); - break; + return 0; } case "remove-request": { String ssid = getNextArgRequired(); @@ -570,7 +570,7 @@ public class WifiShellCommand extends BasicShellCommandHandler { } pw.println("Removing request: " + nrAndNc.first); mConnectivityManager.unregisterNetworkCallback(nrAndNc.second); - break; + return 0; } case "remove-all-requests": if (sActiveRequests.isEmpty()) { @@ -583,7 +583,7 @@ public class WifiShellCommand extends BasicShellCommandHandler { mConnectivityManager.unregisterNetworkCallback(nrAndNc.second); } sActiveRequests.clear(); - break; + return 0; case "list-requests": if (sActiveRequests.isEmpty()) { pw.println("No active requests"); @@ -596,7 +596,7 @@ public class WifiShellCommand extends BasicShellCommandHandler { entry.getKey(), entry.getValue().first)); } } - break; + return 0; case "network-requests-set-user-approved": { String packageName = getNextArgRequired(); boolean approved = getNextArgRequiredTrueOrFalse("yes", "no"); @@ -667,11 +667,12 @@ public class WifiShellCommand extends BasicShellCommandHandler { } } catch (IllegalArgumentException e) { pw.println("Invalid args for " + cmd + ": " + e); + return -1; } catch (Exception e) { pw.println("Exception while executing WifiShellCommand: "); e.printStackTrace(pw); + return -1; } - return -1; } private boolean getNextArgRequiredTrueOrFalse(String trueString, String falseString) -- cgit v1.2.3