From 3040b86393a04bc939a5a94cda4169b0293dfac7 Mon Sep 17 00:00:00 2001 From: Mitchell Wills Date: Fri, 10 Jun 2016 13:18:09 -0700 Subject: Fix crash when cleaning up WifiScanner client before Wifi enabled Change-Id: Ia212840fcf781740d5e185d3e3c2e30a477e25f0 Fixes: 29250616 --- .../wifi/scanner/WifiScanningServiceTest.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java index dab38f267..a1bf212c3 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java @@ -262,6 +262,10 @@ public class WifiScanningServiceTest { private static final int MAX_AP_PER_SCAN = 16; private void startServiceAndLoadDriver() { mWifiScanningServiceImpl.startService(); + setupAndLoadDriver(); + } + + private void setupAndLoadDriver() { when(mWifiScannerImpl.getScanCapabilities(any(WifiNative.ScanCapabilities.class))) .thenAnswer(new AnswerWithArguments() { public boolean answer(WifiNative.ScanCapabilities capabilities) { @@ -331,6 +335,17 @@ public class WifiScanningServiceTest { verifyFailedResponse(order, handler, 122, WifiScanner.REASON_UNSPECIFIED, "not available"); } + @Test + public void disconnectClientBeforeWifiEnabled() throws Exception { + mWifiScanningServiceImpl.startService(); + + BidirectionalAsyncChannel controlChannel = connectChannel(mock(Handler.class)); + mLooper.dispatchAll(); + + controlChannel.disconnect(); + mLooper.dispatchAll(); + } + @Test public void loadDriver() throws Exception { startServiceAndLoadDriver(); @@ -348,6 +363,29 @@ public class WifiScanningServiceTest { assertDumpContainsRequestLog("addBackgroundScanRequest", 192); } + @Test + public void disconnectClientAfterStartingWifi() throws Exception { + mWifiScanningServiceImpl.startService(); + + BidirectionalAsyncChannel controlChannel = connectChannel(mock(Handler.class)); + mLooper.dispatchAll(); + + setupAndLoadDriver(); + + controlChannel.disconnect(); + mLooper.dispatchAll(); + } + + @Test + public void connectAndDisconnectClientAfterStartingWifi() throws Exception { + startServiceAndLoadDriver(); + + BidirectionalAsyncChannel controlChannel = connectChannel(mock(Handler.class)); + mLooper.dispatchAll(); + controlChannel.disconnect(); + mLooper.dispatchAll(); + } + @Test public void sendInvalidCommand() throws Exception { startServiceAndLoadDriver(); -- cgit v1.2.3