summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2018-02-15 15:52:40 -0800
committerRoshan Pius <rpius@google.com>2018-03-07 10:00:22 -0800
commit4d2109e282e5ff427c64788dae814baccb542fae (patch)
tree6404adadad4b3cb2af1cadc137379efdf1b8ffc2
parent271fee2404caf4ef62a0ec17afbab24cfa0a895e (diff)
WificondControl: Always check for existing ifaces
Couple of methods in WificondControl are missing checks to ensure if the iface specified exists or not. Adding them. Bug: 73496702 Test: Unit tests Test: Ran WifiManagerTest & WifiSoftApTest ACTS tests locally. Change-Id: Ib1f49af3ba5bba4d8dc8b9ca07a1a3ee727b529e
-rw-r--r--service/java/com/android/server/wifi/WificondControl.java10
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WificondControlTest.java25
2 files changed, 34 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WificondControl.java b/service/java/com/android/server/wifi/WificondControl.java
index faee2f286..a0953e439 100644
--- a/service/java/com/android/server/wifi/WificondControl.java
+++ b/service/java/com/android/server/wifi/WificondControl.java
@@ -275,7 +275,10 @@ public class WificondControl implements IBinder.DeathRecipient {
* @return Returns true on success.
*/
public boolean tearDownClientInterface(@NonNull String ifaceName) {
- boolean success;
+ if (getClientInterface(ifaceName) == null) {
+ Log.e(TAG, "No valid wificond client interface handler");
+ return false;
+ }
try {
IWifiScannerImpl scannerImpl = mWificondScanners.get(ifaceName);
if (scannerImpl != null) {
@@ -287,6 +290,7 @@ public class WificondControl implements IBinder.DeathRecipient {
return false;
}
+ boolean success;
try {
success = mWificond.tearDownClientInterface(ifaceName);
} catch (RemoteException e1) {
@@ -341,6 +345,10 @@ public class WificondControl implements IBinder.DeathRecipient {
* @return Returns true on success.
*/
public boolean tearDownSoftApInterface(@NonNull String ifaceName) {
+ if (getApInterface(ifaceName) == null) {
+ Log.e(TAG, "No valid wificond ap interface handler");
+ return false;
+ }
boolean success;
try {
success = mWificond.tearDownApInterface(ifaceName);
diff --git a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java
index bcb03b39a..8336c03eb 100644
--- a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java
@@ -251,6 +251,19 @@ public class WificondControlTest {
* Verifies that tearDownClientInterface(TEST_INTERFACE_NAME) calls Wificond.
*/
@Test
+ public void testTeardownClientInterfaceOnInvalidIface() throws Exception {
+ when(mWificond.tearDownClientInterface(TEST_INTERFACE_NAME1)).thenReturn(true);
+
+ assertFalse(mWificondControl.tearDownClientInterface(TEST_INTERFACE_NAME1));
+ verify(mWifiScannerImpl, never()).unsubscribeScanEvents();
+ verify(mWifiScannerImpl, never()).unsubscribePnoScanEvents();
+ verify(mWificond, never()).tearDownClientInterface(any());
+ }
+
+ /**
+ * Verifies that tearDownClientInterface(TEST_INTERFACE_NAME) calls Wificond.
+ */
+ @Test
public void testTeardownClientInterfaceFailDueToExceptionScannerUnsubscribe() throws Exception {
when(mWificond.tearDownClientInterface(TEST_INTERFACE_NAME)).thenReturn(true);
doThrow(new RemoteException()).when(mWifiScannerImpl).unsubscribeScanEvents();
@@ -349,6 +362,18 @@ public class WificondControlTest {
}
/**
+ * Verifies that tearDownSoftapInterface(TEST_INTERFACE_NAME) calls Wificond.
+ */
+ @Test
+ public void testTeardownSoftApInterfaceOnInvalidIface() throws Exception {
+ testSetupInterfaceForSoftApMode();
+ when(mWificond.tearDownApInterface(TEST_INTERFACE_NAME1)).thenReturn(true);
+
+ assertFalse(mWificondControl.tearDownSoftApInterface(TEST_INTERFACE_NAME1));
+ verify(mWificond, never()).tearDownApInterface(any());
+ }
+
+ /**
* Verifies that tearDownClientInterface(TEST_INTERFACE_NAME) calls Wificond.
*/
@Test