Search in sources :

Example 96 with AccessPoint

use of com.android.settingslib.wifi.AccessPoint in project platform_packages_apps_Settings by BlissRoms.

the class WifiSettingsUiTest method changingSecurityStateOnApShouldNotCauseMultipleListItems.

@Test
public void changingSecurityStateOnApShouldNotCauseMultipleListItems() {
    setWifiState(WifiManager.WIFI_STATE_ENABLED);
    TestAccessPointBuilder builder = new TestAccessPointBuilder(mContext).setSsid(TEST_SSID).setSecurity(AccessPoint.SECURITY_NONE).setRssi(TEST_RSSI);
    AccessPoint open = builder.build();
    builder.setSecurity(AccessPoint.SECURITY_EAP);
    AccessPoint eap = builder.build();
    builder.setSecurity(AccessPoint.SECURITY_WEP);
    AccessPoint wep = builder.build();
    // Return a different security state each time getAccessPoints is invoked
    when(mWifiTracker.getAccessPoints()).thenReturn(Lists.newArrayList(open)).thenReturn(Lists.newArrayList(eap)).thenReturn(Lists.newArrayList(wep));
    launchActivity();
    onView(withText(TEST_SSID)).check(matches(isDisplayed()));
    mWifiListener.onAccessPointsChanged();
    onView(withText(TEST_SSID)).check(matches(isDisplayed()));
    mWifiListener.onAccessPointsChanged();
    onView(withText(TEST_SSID)).check(matches(isDisplayed()));
}
Also used : AccessPoint(com.android.settingslib.wifi.AccessPoint) TestAccessPointBuilder(com.android.settingslib.wifi.TestAccessPointBuilder) Test(org.junit.Test)

Example 97 with AccessPoint

use of com.android.settingslib.wifi.AccessPoint in project platform_packages_apps_Settings by BlissRoms.

the class WifiSettingsUiTest method setupConnectedAccessPoint.

private void setupConnectedAccessPoint() {
    WifiConfiguration config = new WifiConfiguration();
    config.SSID = TEST_SSID;
    config.BSSID = TEST_BSSID;
    config.networkId = TEST_NETWORK_ID;
    WifiInfo wifiInfo = new WifiInfo();
    wifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(TEST_UNQUOTED_SSID));
    wifiInfo.setBSSID(TEST_BSSID);
    wifiInfo.setRssi(TEST_RSSI);
    wifiInfo.setNetworkId(TEST_NETWORK_ID);
    NetworkInfo networkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0, null, null);
    networkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED, null, null);
    AccessPoint accessPoint = new AccessPoint(mContext, config);
    accessPoint.update(config, wifiInfo, networkInfo);
    assertThat(accessPoint.getSsidStr()).isEqualTo(TEST_UNQUOTED_SSID);
    assertThat(accessPoint.getBssid()).isEqualTo(TEST_BSSID);
    assertThat(accessPoint.getNetworkInfo()).isNotNull();
    assertThat(accessPoint.isActive()).isTrue();
    assertThat(accessPoint.getSettingsSummary()).isEqualTo(resourceString(WIFI_DISPLAY_STATUS_CONNECTED));
    when(mWifiTracker.getAccessPoints()).thenReturn(Lists.asList(accessPoint, new AccessPoint[] {}));
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) NetworkInfo(android.net.NetworkInfo) AccessPoint(com.android.settingslib.wifi.AccessPoint) WifiInfo(android.net.wifi.WifiInfo)

Example 98 with AccessPoint

use of com.android.settingslib.wifi.AccessPoint in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SavedAccessPointsPreferenceController method refreshSavedAccessPoints.

@VisibleForTesting
void refreshSavedAccessPoints() {
    if (mPreferenceGroup == null) {
        Log.w(TAG, "PreferenceGroup is null, skipping.");
        return;
    }
    final Context prefContext = mPreferenceGroup.getContext();
    final List<AccessPoint> accessPoints = WifiSavedConfigUtils.getAllConfigs(mContext, mWifiManager);
    Collections.sort(accessPoints, SavedNetworkComparator.INSTANCE);
    mChildrenCache.cacheRemoveAllPrefs(mPreferenceGroup);
    final int accessPointsSize = accessPoints.size();
    for (int i = 0; i < accessPointsSize; ++i) {
        AccessPoint ap = accessPoints.get(i);
        if (mHost != null && mHost.isSubscriptionsFeatureEnabled() && ap.isPasspointConfig()) {
            continue;
        }
        String key = ap.getKey();
        AccessPointPreference preference = (AccessPointPreference) mChildrenCache.getCachedPreference(key);
        if (preference == null) {
            preference = new AccessPointPreference(ap, prefContext, mUserBadgeCache, true);
            preference.setKey(key);
            preference.setIcon(null);
            preference.setOnPreferenceClickListener(this);
            mPreferenceGroup.addPreference(preference);
        }
        preference.setOrder(i);
    }
    mChildrenCache.removeCachedPrefs(mPreferenceGroup);
    if (mPreferenceGroup.getPreferenceCount() < 1) {
        Log.w(TAG, "Saved networks activity loaded, but there are no saved networks!");
        mPreferenceGroup.setVisible(false);
    } else {
        mPreferenceGroup.setVisible(true);
    }
    if (mHost != null && !mHost.isSubscriptionsFeatureEnabled()) {
        mPreferenceGroup.setVisible(true);
        mPreferenceGroup.setTitle(null);
        mPreferenceGroup.setLayoutResource(R.layout.preference_category_no_label);
    }
}
Also used : Context(android.content.Context) AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) AccessPoint(com.android.settingslib.wifi.AccessPoint) AccessPoint(com.android.settingslib.wifi.AccessPoint) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 99 with AccessPoint

use of com.android.settingslib.wifi.AccessPoint in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SubscribedAccessPointsPreferenceController method refreshSubscribedAccessPoints.

@VisibleForTesting
void refreshSubscribedAccessPoints() {
    if (mPreferenceGroup == null) {
        Log.w(TAG, "PreferenceGroup is null, skipping.");
        return;
    }
    if (mHost != null && !mHost.isSubscriptionsFeatureEnabled()) {
        mPreferenceGroup.setVisible(false);
        return;
    }
    final Context prefContext = mPreferenceGroup.getContext();
    final List<AccessPoint> accessPoints = WifiSavedConfigUtils.getAllConfigs(mContext, mWifiManager);
    Collections.sort(accessPoints, SavedNetworkComparator.INSTANCE);
    mChildrenCache.cacheRemoveAllPrefs(mPreferenceGroup);
    final int accessPointsSize = accessPoints.size();
    for (int i = 0; i < accessPointsSize; ++i) {
        AccessPoint ap = accessPoints.get(i);
        if (!ap.isPasspointConfig()) {
            continue;
        }
        final String key = ap.getKey();
        AccessPointPreference preference = (AccessPointPreference) mChildrenCache.getCachedPreference(key);
        if (preference == null) {
            preference = new AccessPointPreference(ap, prefContext, mUserBadgeCache, true);
            preference.setKey(key);
            preference.setIcon(null);
            preference.setOnPreferenceClickListener(this);
            mPreferenceGroup.addPreference(preference);
        }
        preference.setOrder(i);
    }
    mChildrenCache.removeCachedPrefs(mPreferenceGroup);
    if (mPreferenceGroup.getPreferenceCount() < 1) {
        Log.w(TAG, "Subscribed networks activity loaded," + " but there are no subscribed networks!");
        mPreferenceGroup.setVisible(false);
    } else {
        mPreferenceGroup.setVisible(true);
    }
}
Also used : Context(android.content.Context) AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) AccessPoint(com.android.settingslib.wifi.AccessPoint) AccessPoint(com.android.settingslib.wifi.AccessPoint) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 100 with AccessPoint

use of com.android.settingslib.wifi.AccessPoint in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiScanWorker method onAccessPointsChanged.

@Override
public void onAccessPointsChanged() {
    // in case state has changed
    if (!mWifiTracker.getManager().isWifiEnabled()) {
        updateResults(null);
        return;
    }
    // AccessPoints are sorted by the WifiTracker
    final List<AccessPoint> accessPoints = mWifiTracker.getAccessPoints();
    final List<AccessPoint> resultList = new ArrayList<>();
    for (AccessPoint ap : accessPoints) {
        if (ap.isReachable()) {
            resultList.add(clone(ap));
            if (resultList.size() >= DEFAULT_EXPANDED_ROW_COUNT) {
                break;
            }
        }
    }
    updateResults(resultList);
}
Also used : AccessPoint(com.android.settingslib.wifi.AccessPoint) ArrayList(java.util.ArrayList)

Aggregations

AccessPoint (com.android.settingslib.wifi.AccessPoint)130 WifiConfiguration (android.net.wifi.WifiConfiguration)36 Bundle (android.os.Bundle)29 AccessPointPreference (com.android.settingslib.wifi.AccessPointPreference)27 Test (org.junit.Test)26 Intent (android.content.Intent)22 NetworkInfo (android.net.NetworkInfo)18 WifiManager (android.net.wifi.WifiManager)18 WifiInfo (android.net.wifi.WifiInfo)16 Context (android.content.Context)13 Preference (android.support.v7.preference.Preference)13 PreferenceScreen (android.support.v7.preference.PreferenceScreen)7 TestAccessPointBuilder (com.android.settingslib.wifi.TestAccessPointBuilder)7 ArrayList (java.util.ArrayList)5 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)4 View (android.view.View)3 VisibleForTesting (androidx.annotation.VisibleForTesting)3 ScanResult (android.net.wifi.ScanResult)2 Spinner (android.widget.Spinner)2 AlertDialog (androidx.appcompat.app.AlertDialog)2