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()));
}
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[] {}));
}
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);
}
}
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);
}
}
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);
}
Aggregations