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;
}
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);
}
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");
}
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;
}
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;
}
Aggregations