Search in sources :

Example 6 with Scanner

use of com.android.settingslib.wifi.WifiTracker.Scanner in project android_frameworks_base by AOSPA.

the class WifiTrackerTest method testSavedOnly.

public void testSavedOnly() {
    mWifiTracker = new WifiTracker(mContext, mWifiListener, mLooper, true, false, true, mWifiManager, mMainLooper);
    mWifiTracker.mScanner = mWifiTracker.new Scanner();
    List<WifiConfiguration> wifiConfigs = new ArrayList<WifiConfiguration>();
    List<ScanResult> scanResults = new ArrayList<ScanResult>();
    generateTestNetworks(wifiConfigs, scanResults, true);
    // Tell WifiTracker we are connected now.
    sendConnected();
    // Send all of the configs and scan results to the tracker.
    Mockito.when(mWifiManager.getConfiguredNetworks()).thenReturn(wifiConfigs);
    Mockito.when(mWifiManager.getScanResults()).thenReturn(scanResults);
    sendScanResultsAndProcess(false);
    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());
}
Also used : Scanner(com.android.settingslib.wifi.WifiTracker.Scanner) ScanResult(android.net.wifi.ScanResult) WifiConfiguration(android.net.wifi.WifiConfiguration) ArrayList(java.util.ArrayList)

Example 7 with Scanner

use of com.android.settingslib.wifi.WifiTracker.Scanner in project android_frameworks_base by AOSPA.

the class WifiTrackerTest method testSavedOnlyNoLooper.

/**
     * 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());
}
Also used : Scanner(com.android.settingslib.wifi.WifiTracker.Scanner) ScanResult(android.net.wifi.ScanResult) WifiConfiguration(android.net.wifi.WifiConfiguration) ArrayList(java.util.ArrayList)

Example 8 with Scanner

use of com.android.settingslib.wifi.WifiTracker.Scanner in project android_frameworks_base by AOSPA.

the class WifiTrackerTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    mWifiManager = Mockito.mock(WifiManager.class);
    mWifiListener = Mockito.mock(WifiListener.class);
    mWorkerThread = new HandlerThread("TestHandlerThread");
    mWorkerThread.start();
    mLooper = mWorkerThread.getLooper();
    mMainThread = new HandlerThread("TestHandlerThread");
    mMainThread.start();
    mMainLooper = mMainThread.getLooper();
    mWifiTracker = new WifiTracker(mContext, mWifiListener, mLooper, true, true, true, mWifiManager, mMainLooper);
    mWifiTracker.mScanner = mWifiTracker.new Scanner();
    Mockito.when(mWifiManager.isWifiEnabled()).thenReturn(true);
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiListener(com.android.settingslib.wifi.WifiTracker.WifiListener) Scanner(com.android.settingslib.wifi.WifiTracker.Scanner) HandlerThread(android.os.HandlerThread)

Example 9 with Scanner

use of com.android.settingslib.wifi.WifiTracker.Scanner in project android_frameworks_base by AOSPA.

the class WifiTrackerTest method testNonEphemeralConnected.

public void testNonEphemeralConnected() {
    mWifiTracker = new WifiTracker(mContext, mWifiListener, mLooper, false, true, true, mWifiManager, mMainLooper);
    mWifiTracker.mScanner = mWifiTracker.new Scanner();
    List<WifiConfiguration> wifiConfigs = new ArrayList<WifiConfiguration>();
    List<ScanResult> scanResults = new ArrayList<ScanResult>();
    generateTestNetworks(wifiConfigs, scanResults, false);
    // Tell WifiTracker we are connected now.
    sendConnected();
    // Send all of the configs and scan results to the tracker.
    Mockito.when(mWifiManager.getConfiguredNetworks()).thenReturn(wifiConfigs);
    Mockito.when(mWifiManager.getScanResults()).thenReturn(scanResults);
    // Do this twice to catch a bug that was happening in the caching, making things ephemeral.
    sendScanResultsAndProcess(true);
    List<AccessPoint> accessPoints = mWifiTracker.getAccessPoints();
    assertEquals("Expected number of results", NUM_NETWORKS - 1, accessPoints.size());
    assertFalse("Connection is not ephemeral", accessPoints.get(0).isEphemeral());
    assertTrue("Connected to wifi", accessPoints.get(0).isActive());
}
Also used : Scanner(com.android.settingslib.wifi.WifiTracker.Scanner) ScanResult(android.net.wifi.ScanResult) WifiConfiguration(android.net.wifi.WifiConfiguration) ArrayList(java.util.ArrayList)

Example 10 with Scanner

use of com.android.settingslib.wifi.WifiTracker.Scanner in project android_frameworks_base by ResurrectionRemix.

the class WifiTrackerTest method testSavedOnlyNoLooper.

/**
     * 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());
}
Also used : Scanner(com.android.settingslib.wifi.WifiTracker.Scanner) ScanResult(android.net.wifi.ScanResult) WifiConfiguration(android.net.wifi.WifiConfiguration) ArrayList(java.util.ArrayList)

Aggregations

Scanner (com.android.settingslib.wifi.WifiTracker.Scanner)25 ScanResult (android.net.wifi.ScanResult)20 WifiConfiguration (android.net.wifi.WifiConfiguration)20 ArrayList (java.util.ArrayList)20 WifiManager (android.net.wifi.WifiManager)5 HandlerThread (android.os.HandlerThread)5 WifiListener (com.android.settingslib.wifi.WifiTracker.WifiListener)5