summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-04-12 09:34:06 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-04-12 09:34:07 +0000
commite4a99c6c3d3ce34ac33c7fb63fc4202468580a91 (patch)
tree0884add557829144230e04c96329819535b4b798
parent6232408a5fc660b2d8642d56747e05c15c6255b8 (diff)
parent781fa6d27f15a1e3b8cc3d3cd7aaa63b38c8d56e (diff)
Merge "Fix START_WPS null exception" into oc-dev
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java5
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java16
2 files changed, 21 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 8f62288c8..048c86007 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -5111,6 +5111,11 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
break;
case WifiManager.START_WPS:
WpsInfo wpsInfo = (WpsInfo) message.obj;
+ if (wpsInfo == null) {
+ loge("Cannot start WPS with null WpsInfo object");
+ replyToMessage(message, WifiManager.WPS_FAILED, WifiManager.ERROR);
+ break;
+ }
WpsResult wpsResult = new WpsResult();
// TODO(b/32898136): Not needed when we start deleting networks from supplicant
// on disconnect.
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index d3da2e761..20dd11757 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -1545,4 +1545,20 @@ public class WifiStateMachineTest {
addNetworkAndVerifySuccess(false);
verify(mWifiConnectivityManager, never()).setUserConnectChoice(eq(0));
}
+
+ /**
+ * Test START_WPS with a null wpsInfo object fails gracefully (No NPE)
+ */
+ @Test
+ public void testStartWps_nullWpsInfo() throws Exception {
+ loadComponentsInStaMode();
+ mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE);
+ assertEquals(WifiStateMachine.CONNECT_MODE, mWsm.getOperationalModeForTest());
+ assertEquals("DisconnectedState", getCurrentState().getName());
+ mLooper.startAutoDispatch();
+ Message reply = mWsmAsyncChannel.sendMessageSynchronously(WifiManager.START_WPS, 0, 0,
+ null);
+ mLooper.stopAutoDispatch();
+ assertEquals(WifiManager.WPS_FAILED, reply.what);
+ }
}