Loading packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java +4 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,10 @@ public class WifiTracker { throw new IllegalArgumentException("Must include either saved or scans"); } mContext = context; if (currentLooper == null) { // When we aren't on a looper thread, default to the main. currentLooper = Looper.getMainLooper(); } mMainHandler = new MainHandler(currentLooper); mWorkHandler = new WorkHandler( workerLooper != null ? workerLooper : currentLooper); Loading packages/SettingsLib/tests/src/com/android/settingslib/wifi/WifiTrackerTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,30 @@ public class WifiTrackerTest extends BaseTest { assertEquals(TEST_SSIDS[0], accessPoints.get(1).getSsid()); } /** * This tests the case where Settings runs this on a non-looper thread for indexing. */ public void testSavedOnlyNoLooper() { mWifiTracker = new WifiTracker(mContext, mWifiListener, mLooper, true, false, true, mWifiManager, null); mWifiTracker.mScanner = mWifiTracker.new Scanner(); List<WifiConfiguration> wifiConfigs = new ArrayList<WifiConfiguration>(); List<ScanResult> scanResults = new ArrayList<ScanResult>(); generateTestNetworks(wifiConfigs, scanResults, true); // Send all of the configs and scan results to the tracker. Mockito.when(mWifiManager.getConfiguredNetworks()).thenReturn(wifiConfigs); Mockito.when(mWifiManager.getScanResults()).thenReturn(scanResults); mWifiTracker.forceUpdate(); List<AccessPoint> accessPoints = mWifiTracker.getAccessPoints(); // Only expect the first two to come back in the results. assertEquals("Expected number of results", 2, accessPoints.size()); assertEquals(TEST_SSIDS[1], accessPoints.get(0).getSsid()); assertEquals(TEST_SSIDS[0], accessPoints.get(1).getSsid()); } public void testAvailableOnly() { mWifiTracker = new WifiTracker(mContext, mWifiListener, mLooper, false, true, true, mWifiManager, mMainLooper); Loading Loading
packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java +4 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,10 @@ public class WifiTracker { throw new IllegalArgumentException("Must include either saved or scans"); } mContext = context; if (currentLooper == null) { // When we aren't on a looper thread, default to the main. currentLooper = Looper.getMainLooper(); } mMainHandler = new MainHandler(currentLooper); mWorkHandler = new WorkHandler( workerLooper != null ? workerLooper : currentLooper); Loading
packages/SettingsLib/tests/src/com/android/settingslib/wifi/WifiTrackerTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,30 @@ public class WifiTrackerTest extends BaseTest { assertEquals(TEST_SSIDS[0], accessPoints.get(1).getSsid()); } /** * This tests the case where Settings runs this on a non-looper thread for indexing. */ public void testSavedOnlyNoLooper() { mWifiTracker = new WifiTracker(mContext, mWifiListener, mLooper, true, false, true, mWifiManager, null); mWifiTracker.mScanner = mWifiTracker.new Scanner(); List<WifiConfiguration> wifiConfigs = new ArrayList<WifiConfiguration>(); List<ScanResult> scanResults = new ArrayList<ScanResult>(); generateTestNetworks(wifiConfigs, scanResults, true); // Send all of the configs and scan results to the tracker. Mockito.when(mWifiManager.getConfiguredNetworks()).thenReturn(wifiConfigs); Mockito.when(mWifiManager.getScanResults()).thenReturn(scanResults); mWifiTracker.forceUpdate(); List<AccessPoint> accessPoints = mWifiTracker.getAccessPoints(); // Only expect the first two to come back in the results. assertEquals("Expected number of results", 2, accessPoints.size()); assertEquals(TEST_SSIDS[1], accessPoints.get(0).getSsid()); assertEquals(TEST_SSIDS[0], accessPoints.get(1).getSsid()); } public void testAvailableOnly() { mWifiTracker = new WifiTracker(mContext, mWifiListener, mLooper, false, true, true, mWifiManager, mMainLooper); Loading