summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/scanner/SupplicantWifiScannerImpl.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/SupplicantPnoScannerTest.java38
2 files changed, 39 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/scanner/SupplicantWifiScannerImpl.java b/service/java/com/android/server/wifi/scanner/SupplicantWifiScannerImpl.java
index 3f93c9074..eb4862b22 100644
--- a/service/java/com/android/server/wifi/scanner/SupplicantWifiScannerImpl.java
+++ b/service/java/com/android/server/wifi/scanner/SupplicantWifiScannerImpl.java
@@ -1041,7 +1041,6 @@ public class SupplicantWifiScannerImpl extends WifiScannerImpl implements Handle
if (DBG) Log.d(TAG, "PNO state is already " + enable);
return true;
}
-
mLastPnoChangeTimeStamp = mClock.elapsedRealtime();
if (mWifiNative.setPnoScan(enable)) {
Log.d(TAG, "Changed PNO state from " + mCurrentPnoState + " to " + enable);
@@ -1049,6 +1048,7 @@ public class SupplicantWifiScannerImpl extends WifiScannerImpl implements Handle
return true;
} else {
Log.e(TAG, "PNO state change to " + enable + " failed");
+ mCurrentPnoState = false;
return false;
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/SupplicantPnoScannerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/SupplicantPnoScannerTest.java
index 39709f84d..ada882d7f 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/SupplicantPnoScannerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/SupplicantPnoScannerTest.java
@@ -214,6 +214,43 @@ public class SupplicantPnoScannerTest {
verifyNoMoreInteractions(pnoEventHandler);
}
+ /**
+ * Verify that the HW PNO scan stop failure still resets the PNO scan state.
+ * 1. Start Hw PNO.
+ * 2. Stop Hw PNO scan which raises a stop command to WifiNative which is failed.
+ * 3. Now restart a new PNO scan to ensure that the failure was cleanly handled.
+ */
+ @Test
+ public void ignoreHwDisconnectedPnoScanStopFailure() {
+ createScannerWithHwPnoScanSupport();
+
+ WifiNative.PnoEventHandler pnoEventHandler = mock(WifiNative.PnoEventHandler.class);
+ WifiNative.PnoSettings pnoSettings = createDummyPnoSettings(false);
+
+ // Start PNO scan
+ startSuccessfulPnoScan(null, pnoSettings, null, pnoEventHandler);
+
+ // Fail the PNO stop.
+ when(mWifiNative.setPnoScan(false)).thenReturn(false);
+ assertTrue(mScanner.resetHwPnoList());
+ assertTrue("dispatch pno monitor alarm",
+ mAlarmManager.dispatch(
+ SupplicantWifiScannerImpl.HwPnoDebouncer.PNO_DEBOUNCER_ALARM_TAG));
+ mLooper.dispatchAll();
+ verify(mWifiNative).setPnoScan(false);
+
+ // Add a new PNO scan request and ensure it runs successfully.
+ startSuccessfulPnoScan(null, pnoSettings, null, pnoEventHandler);
+ assertTrue("dispatch pno monitor alarm",
+ mAlarmManager.dispatch(
+ SupplicantWifiScannerImpl.HwPnoDebouncer.PNO_DEBOUNCER_ALARM_TAG));
+ mLooper.dispatchAll();
+ InOrder order = inOrder(pnoEventHandler, mWifiNative);
+ ScanResults scanResults = createDummyScanResults();
+ expectSuccessfulHwDisconnectedPnoScan(order, pnoSettings, pnoEventHandler, scanResults);
+ verifyNoMoreInteractions(pnoEventHandler);
+ }
+
private void doSuccessfulSwPnoScanTest(boolean isConnectedPno) {
WifiNative.PnoEventHandler pnoEventHandler = mock(WifiNative.PnoEventHandler.class);
WifiNative.PnoSettings pnoSettings = createDummyPnoSettings(isConnectedPno);
@@ -275,6 +312,7 @@ public class SupplicantPnoScannerTest {
private void startSuccessfulPnoScan(WifiNative.ScanSettings scanSettings,
WifiNative.PnoSettings pnoSettings, WifiNative.ScanEventHandler scanEventHandler,
WifiNative.PnoEventHandler pnoEventHandler) {
+ reset(mWifiNative);
when(mWifiNative.setNetworkVariable(anyInt(), anyString(), anyString())).thenReturn(true);
when(mWifiNative.enableNetworkWithoutConnect(anyInt())).thenReturn(true);
// Scans succeed