diff options
author | Jason Monk <jmonk@google.com> | 2015-02-05 10:34:20 -0500 |
---|---|---|
committer | Jason Monk <jmonk@google.com> | 2015-02-10 13:58:40 +0000 |
commit | 6572eae9d278e7199440aeae9a91f9418e8ab4af (patch) | |
tree | 0c03e6f8e5786f8c835d556241bcd254b0482274 /packages/SettingsLib/tests | |
parent | efee230fe16e5ca69c75a7385ed6fe07063620a5 (diff) | |
download | frameworks_base-6572eae9d278e7199440aeae9a91f9418e8ab4af.zip frameworks_base-6572eae9d278e7199440aeae9a91f9418e8ab4af.tar.gz frameworks_base-6572eae9d278e7199440aeae9a91f9418e8ab4af.tar.bz2 |
Fix crash in Wifi QS Panel
When open QS wifi panel while wifi was off was causing a crash from
wifi enabling while the WifiTracker was not in a scanning state.
Fix plus a test enclosed.
Bug: 19322090
Change-Id: Id863cdcbf4aa8d50822de3a200355dbaee74b488
Diffstat (limited to 'packages/SettingsLib/tests')
-rw-r--r-- | packages/SettingsLib/tests/src/com/android/settingslib/wifi/WifiTrackerTest.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/SettingsLib/tests/src/com/android/settingslib/wifi/WifiTrackerTest.java b/packages/SettingsLib/tests/src/com/android/settingslib/wifi/WifiTrackerTest.java index 73d4938..8eb1ca4 100644 --- a/packages/SettingsLib/tests/src/com/android/settingslib/wifi/WifiTrackerTest.java +++ b/packages/SettingsLib/tests/src/com/android/settingslib/wifi/WifiTrackerTest.java @@ -201,6 +201,29 @@ public class WifiTrackerTest extends BaseTest { assertTrue("Connected to wifi", accessPoints.get(0).isActive()); } + public void testEnableResumeScanning() { + mWifiTracker.mScanner = null; + + Intent i = new Intent(WifiManager.WIFI_STATE_CHANGED_ACTION); + // Make sure disable/enable cycle works with no scanner (no crashing). + i.putExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED); + mWifiTracker.mReceiver.onReceive(mContext, i); + i.putExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_ENABLED); + mWifiTracker.mReceiver.onReceive(mContext, i); + + Mockito.when(mWifiManager.isWifiEnabled()).thenReturn(false); + i.putExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED); + mWifiTracker.mReceiver.onReceive(mContext, i); + // Now enable scanning while wifi is off, it shouldn't start. + mWifiTracker.resumeScanning(); + assertFalse(mWifiTracker.mScanner.isScanning()); + + // Turn on wifi and make sure scanning starts. + i.putExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_ENABLED); + mWifiTracker.mReceiver.onReceive(mContext, i); + assertTrue(mWifiTracker.mScanner.isScanning()); + } + private String[] generateTestNetworks(List<WifiConfiguration> wifiConfigs, List<ScanResult> scanResults, boolean connectedIsEphemeral) { String[] expectedSsids = new String[NUM_NETWORKS]; |