diff options
author | Roshan Pius <rpius@google.com> | 2018-08-24 14:16:36 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2018-09-05 17:41:22 +0000 |
commit | b7d5cdad5f876ce8f9556cde1714c6cb84b06604 (patch) | |
tree | 794da4c11fc28693520013cd25006f7df2eba994 | |
parent | ceafd95ecce73d175fde04ee1010fb91f1b29c4e (diff) |
supplicant/hostapd: Remove logspam when starting daemons
The lazy start HAL mechanism relies on the first call to
ISupplicant/IHostapd.getService() bring up the daemon. This first call
would expectedly return a NoSuchElementException. Silently ignore this
exception in this case instead of spewing out a scary looking stacktrace
in the logs.
Bug: 113121684
Test: Unit tests
Test: Manually verified that the logspam no longer exists.
Change-Id: I8bbffed931fa2ab7082c3bf82d17af49c6c63241
-rw-r--r-- | service/java/com/android/server/wifi/HostapdHal.java | 13 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/SupplicantStaIfaceHal.java | 44 |
2 files changed, 35 insertions, 22 deletions
diff --git a/service/java/com/android/server/wifi/HostapdHal.java b/service/java/com/android/server/wifi/HostapdHal.java index 5fb828ba0..57d99e6f5 100644 --- a/service/java/com/android/server/wifi/HostapdHal.java +++ b/service/java/com/android/server/wifi/HostapdHal.java @@ -250,6 +250,9 @@ public class HostapdHal { } catch (RemoteException e) { Log.e(TAG, "IHostapd.getService exception: " + e); return false; + } catch (NoSuchElementException e) { + Log.e(TAG, "IHostapd.getService exception: " + e); + return false; } if (mIHostapd == null) { Log.e(TAG, "Got null IHostapd service. Stopping hostapd HIDL startup"); @@ -432,6 +435,9 @@ public class HostapdHal { + e); hostapdServiceDiedHandler(); return false; + } catch (NoSuchElementException e) { + // We're starting the daemon, so expect |NoSuchElementException|. + Log.d(TAG, "Successfully triggered start of hostapd using HIDL"); } return true; } @@ -465,12 +471,7 @@ public class HostapdHal { @VisibleForTesting protected IHostapd getHostapdMockable() throws RemoteException { synchronized (mLock) { - try { - return IHostapd.getService(); - } catch (NoSuchElementException e) { - Log.e(TAG, "Failed to get IHostapd", e); - return null; - } + return IHostapd.getService(); } } diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java index 2e94ae11d..a03b1a738 100644 --- a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java +++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java @@ -257,6 +257,9 @@ public class SupplicantStaIfaceHal { } catch (RemoteException e) { Log.e(TAG, "ISupplicant.getService exception: " + e); return false; + } catch (NoSuchElementException e) { + Log.e(TAG, "ISupplicant.getService exception: " + e); + return false; } if (mISupplicant == null) { Log.e(TAG, "Got null ISupplicant service. Stopping supplicant HIDL startup"); @@ -401,6 +404,10 @@ public class SupplicantStaIfaceHal { Log.e(TAG, "ISupplicant.addInterface exception: " + e); handleRemoteException(e, "addInterface"); return null; + } catch (NoSuchElementException e) { + Log.e(TAG, "ISupplicant.addInterface exception: " + e); + handleNoSuchElementException(e, "addInterface"); + return null; } return supplicantIface.value; } @@ -452,6 +459,10 @@ public class SupplicantStaIfaceHal { Log.e(TAG, "ISupplicant.removeInterface exception: " + e); handleRemoteException(e, "removeInterface"); return false; + } catch (NoSuchElementException e) { + Log.e(TAG, "ISupplicant.removeInterface exception: " + e); + handleNoSuchElementException(e, "removeInterface"); + return false; } return true; } @@ -531,12 +542,15 @@ public class SupplicantStaIfaceHal { synchronized (mLock) { try { // This should startup supplicant daemon using the lazy start HAL mechanism. - getSupplicantMockable(); + getSupplicantMockableV1_1(); } catch (RemoteException e) { Log.e(TAG, "Exception while trying to start supplicant: " + e); supplicantServiceDiedHandler(); return false; + } catch (NoSuchElementException e) { + // We're starting the daemon, so expect |NoSuchElementException|. + Log.d(TAG, "Successfully triggered start of supplicant using HIDL"); } return true; } @@ -571,6 +585,8 @@ public class SupplicantStaIfaceHal { getSupplicantMockableV1_1().terminate(); } catch (RemoteException e) { handleRemoteException(e, methodStr); + } catch (NoSuchElementException e) { + handleNoSuchElementException(e, methodStr); } } } @@ -599,27 +615,17 @@ public class SupplicantStaIfaceHal { } } - protected ISupplicant getSupplicantMockable() throws RemoteException { + protected ISupplicant getSupplicantMockable() throws RemoteException, NoSuchElementException { synchronized (mLock) { - try { - return ISupplicant.getService(); - } catch (NoSuchElementException e) { - Log.e(TAG, "Failed to get ISupplicant", e); - return null; - } + return ISupplicant.getService(); } } protected android.hardware.wifi.supplicant.V1_1.ISupplicant getSupplicantMockableV1_1() - throws RemoteException { + throws RemoteException, NoSuchElementException { synchronized (mLock) { - try { - return android.hardware.wifi.supplicant.V1_1.ISupplicant.castFrom( - ISupplicant.getService()); - } catch (NoSuchElementException e) { - Log.e(TAG, "Failed to get ISupplicant", e); - return null; - } + return android.hardware.wifi.supplicant.V1_1.ISupplicant.castFrom( + ISupplicant.getService()); } } @@ -2275,6 +2281,12 @@ public class SupplicantStaIfaceHal { } } + private void handleNoSuchElementException(NoSuchElementException e, String methodStr) { + synchronized (mLock) { + clearState(); + Log.e(TAG, "ISupplicantStaIface." + methodStr + " failed with exception", e); + } + } private void handleRemoteException(RemoteException e, String methodStr) { synchronized (mLock) { |