Search in sources :

Example 1 with AccessPointPreference

use of com.android.settingslib.wifi.AccessPointPreference in project android_packages_apps_Settings by crdroidandroid.

the class WifiSettings method configureConnectedAccessPointPreferenceCategory.

/**
 * Configure the ConnectedAccessPointPreferenceCategory and return true if the Category was
 * shown.
 */
private boolean configureConnectedAccessPointPreferenceCategory(List<AccessPoint> accessPoints) {
    if (accessPoints.size() == 0) {
        removeConnectedAccessPointPreference();
        return false;
    }
    AccessPoint connectedAp = accessPoints.get(0);
    if (!connectedAp.isActive()) {
        removeConnectedAccessPointPreference();
        return false;
    }
    // Is the preference category empty?
    if (mConnectedAccessPointPreferenceCategory.getPreferenceCount() == 0) {
        addConnectedAccessPointPreference(connectedAp);
        return true;
    }
    // Is the previous currently connected SSID different from the new one?
    AccessPointPreference preference = (AccessPointPreference) (mConnectedAccessPointPreferenceCategory.getPreference(0));
    // in the UI.
    if (preference.getAccessPoint() != connectedAp) {
        removeConnectedAccessPointPreference();
        addConnectedAccessPointPreference(connectedAp);
        return true;
    }
    // Else same AP is connected, simply refresh the connected access point preference
    // (first and only access point in this category).
    ((LongPressAccessPointPreference) mConnectedAccessPointPreferenceCategory.getPreference(0)).refresh();
    return true;
}
Also used : AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 2 with AccessPointPreference

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

the class WifiConnectionPreferenceControllerTest method onAccessPointsChanged_wifiBecameConnectedToDifferentAP_preferenceReplaced.

@Test
public void onAccessPointsChanged_wifiBecameConnectedToDifferentAP_preferenceReplaced() {
    when(mWifiTracker.isConnected()).thenReturn(true);
    final AccessPoint accessPoint1 = mock(AccessPoint.class);
    when(accessPoint1.isActive()).thenReturn(true);
    when(mWifiTracker.getAccessPoints()).thenReturn(Arrays.asList(accessPoint1));
    mController.displayPreference(mScreen);
    final ArgumentCaptor<AccessPointPreference> captor = ArgumentCaptor.forClass(AccessPointPreference.class);
    final AccessPoint accessPoint2 = mock(AccessPoint.class);
    when(accessPoint1.isActive()).thenReturn(false);
    when(accessPoint2.isActive()).thenReturn(true);
    when(mWifiTracker.getAccessPoints()).thenReturn(Arrays.asList(accessPoint1, accessPoint2));
    final int onUpdatedCountBefore = mOnChildUpdatedCount;
    mController.onAccessPointsChanged();
    verify(mPreferenceCategory, times(2)).addPreference(captor.capture());
    final AccessPointPreference pref1 = captor.getAllValues().get(0);
    final AccessPointPreference pref2 = captor.getAllValues().get(1);
    assertThat(pref1.getAccessPoint()).isEqualTo(accessPoint1);
    assertThat(pref2.getAccessPoint()).isEqualTo(accessPoint2);
    verify(mPreferenceCategory).removePreference(eq(pref1));
    assertThat(mOnChildUpdatedCount).isEqualTo(onUpdatedCountBefore + 1);
}
Also used : AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) AccessPoint(com.android.settingslib.wifi.AccessPoint) AccessPoint(com.android.settingslib.wifi.AccessPoint) Test(org.junit.Test)

Example 3 with AccessPointPreference

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

the class SubscribedAccessPointsPreferenceControllerTest method refreshSubscribedAccessPoints_shouldListSubscribedAPs.

@Test
@Config(shadows = ShadowAccessPoint.class)
public void refreshSubscribedAccessPoints_shouldListSubscribedAPs() {
    mWifiManager.addOrUpdatePasspointConfiguration(createMockPasspointConfiguration());
    mController.displayPreference(mPreferenceScreen);
    mController.refreshSubscribedAccessPoints();
    final ArgumentCaptor<AccessPointPreference> captor = ArgumentCaptor.forClass(AccessPointPreference.class);
    verify(mPreferenceCategory).addPreference(captor.capture());
    final AccessPointPreference pref = captor.getValue();
    assertThat(pref.getTitle()).isEqualTo("TESTPASSPOINT");
}
Also used : AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) Test(org.junit.Test) Config(org.robolectric.annotation.Config) WifiEnterpriseConfig(android.net.wifi.WifiEnterpriseConfig)

Example 4 with AccessPointPreference

use of com.android.settingslib.wifi.AccessPointPreference in project android_packages_apps_Settings by LineageOS.

the class WifiSettings method configureConnectedAccessPointPreferenceCategory.

/**
 * Configure the ConnectedAccessPointPreferenceCategory and return true if the Category was
 * shown.
 */
private boolean configureConnectedAccessPointPreferenceCategory(List<AccessPoint> accessPoints) {
    if (accessPoints.size() == 0) {
        removeConnectedAccessPointPreference();
        return false;
    }
    AccessPoint connectedAp = accessPoints.get(0);
    if (!connectedAp.isActive()) {
        removeConnectedAccessPointPreference();
        return false;
    }
    // Is the preference category empty?
    if (mConnectedAccessPointPreferenceCategory.getPreferenceCount() == 0) {
        addConnectedAccessPointPreference(connectedAp);
        return true;
    }
    // Is the previous currently connected SSID different from the new one?
    AccessPointPreference preference = (AccessPointPreference) (mConnectedAccessPointPreferenceCategory.getPreference(0));
    // in the UI.
    if (preference.getAccessPoint() != connectedAp) {
        removeConnectedAccessPointPreference();
        addConnectedAccessPointPreference(connectedAp);
        return true;
    }
    // Else same AP is connected, simply refresh the connected access point preference
    // (first and only access point in this category).
    ((LongPressAccessPointPreference) mConnectedAccessPointPreferenceCategory.getPreference(0)).refresh();
    return true;
}
Also used : AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 5 with AccessPointPreference

use of com.android.settingslib.wifi.AccessPointPreference in project android_packages_apps_Settings by omnirom.

the class WifiSettings method configureConnectedAccessPointPreferenceCategory.

/**
 * Configure the ConnectedAccessPointPreferenceCategory and return true if the Category was
 * shown.
 */
private boolean configureConnectedAccessPointPreferenceCategory(List<AccessPoint> accessPoints) {
    if (accessPoints.size() == 0) {
        removeConnectedAccessPointPreference();
        return false;
    }
    AccessPoint connectedAp = accessPoints.get(0);
    if (!connectedAp.isActive()) {
        removeConnectedAccessPointPreference();
        return false;
    }
    // Is the preference category empty?
    if (mConnectedAccessPointPreferenceCategory.getPreferenceCount() == 0) {
        addConnectedAccessPointPreference(connectedAp);
        return true;
    }
    // Is the previous currently connected SSID different from the new one?
    AccessPointPreference preference = (AccessPointPreference) (mConnectedAccessPointPreferenceCategory.getPreference(0));
    // in the UI.
    if (preference.getAccessPoint() != connectedAp) {
        removeConnectedAccessPointPreference();
        addConnectedAccessPointPreference(connectedAp);
        return true;
    }
    // Else same AP is connected, simply refresh the connected access point preference
    // (first and only access point in this category).
    ((LongPressAccessPointPreference) mConnectedAccessPointPreferenceCategory.getPreference(0)).refresh();
    return true;
}
Also used : AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Aggregations

AccessPointPreference (com.android.settingslib.wifi.AccessPointPreference)16 AccessPoint (com.android.settingslib.wifi.AccessPoint)12 Test (org.junit.Test)4 Context (android.content.Context)3 WifiConfiguration (android.net.wifi.WifiConfiguration)3 Bundle (android.os.Bundle)2 View (android.view.View)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)2 Config (org.robolectric.annotation.Config)2 Activity (android.app.Activity)1 SettingsEnums (android.app.settings.SettingsEnums)1 Intent (android.content.Intent)1 WifiEnterpriseConfig (android.net.wifi.WifiEnterpriseConfig)1 WifiManager (android.net.wifi.WifiManager)1 Log (android.util.Log)1 Toast (android.widget.Toast)1 Preference (androidx.preference.Preference)1 PreferenceCategory (androidx.preference.PreferenceCategory)1 R (com.android.settings.R)1