summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Wasilczyk <twasilczyk@google.com>2020-12-14 08:44:05 -0800
committerTomasz Wasilczyk <twasilczyk@google.com>2020-12-15 10:19:55 -0800
commite0410f77eef89599b0c5a603c5b931c36ac88549 (patch)
tree19f5631ce12096896d15eb508bef50fb8aaedb14
parent475acd3f2b03dc2d560e1a530992320667ace444 (diff)
Don't throw RuntimeException on supplicant start/stop failure
In the start case, throw NoSuchElementException instead. Stop case doesn't throw (since there is no recovery path anyway). Bug: 175425346 Test: start/stop Wi-Fi with Supplicant disabled Change-Id: I350887acbb4f20f9835619d40128fb382bd94c4f
-rw-r--r--services/wifi/java/com/android/server/wifi/SupplicantManager.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/services/wifi/java/com/android/server/wifi/SupplicantManager.java b/services/wifi/java/com/android/server/wifi/SupplicantManager.java
index 5ed1ab3198e2..e2e5b2b3ac2d 100644
--- a/services/wifi/java/com/android/server/wifi/SupplicantManager.java
+++ b/services/wifi/java/com/android/server/wifi/SupplicantManager.java
@@ -18,6 +18,9 @@ package com.android.server.wifi;
import android.annotation.SystemApi;
import android.os.SystemService;
+import android.util.Log;
+
+import java.util.NoSuchElementException;
/**
* Wrapper to start/stop supplicant daemon using init system.
@@ -25,6 +28,8 @@ import android.os.SystemService;
*/
@SystemApi(client = SystemApi.Client.SYSTEM_SERVER)
public class SupplicantManager {
+ private static final String TAG = "SupplicantManager";
+
private static final String WPA_SUPPLICANT_DAEMON_NAME = "wpa_supplicant";
private SupplicantManager() {}
@@ -32,9 +37,16 @@ public class SupplicantManager {
/**
* Start the wpa_supplicant daemon.
* Note: This uses the init system to start the "wpa_supplicant" service.
+ *
+ * @throws NoSuchElementException if supplicant daemon failed to start
*/
public static void start() {
- SystemService.start(WPA_SUPPLICANT_DAEMON_NAME);
+ try {
+ SystemService.start(WPA_SUPPLICANT_DAEMON_NAME);
+ } catch (RuntimeException e) {
+ // likely a "failed to set system property" runtime exception
+ throw new NoSuchElementException("Failed to start Supplicant");
+ }
}
/**
@@ -42,6 +54,11 @@ public class SupplicantManager {
* Note: This uses the init system to stop the "wpa_supplicant" service.
*/
public static void stop() {
- SystemService.stop(WPA_SUPPLICANT_DAEMON_NAME);
+ try {
+ SystemService.stop(WPA_SUPPLICANT_DAEMON_NAME);
+ } catch (RuntimeException e) {
+ // likely a "failed to set system property" runtime exception
+ Log.w(TAG, "Failed to stop Supplicant", e);
+ }
}
}