use of com.android.settingslib.wifi.AccessPoint in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiScanWorker method clone.
private AccessPoint clone(AccessPoint accessPoint) {
final Bundle savedState = new Bundle();
accessPoint.saveWifiState(savedState);
return new AccessPoint(mContext, savedState);
}
use of com.android.settingslib.wifi.AccessPoint in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiSlice method getAccessPointLevelIcon.
private IconCompat getAccessPointLevelIcon(AccessPoint accessPoint) {
final Drawable d = mContext.getDrawable(com.android.settingslib.Utils.getWifiIconResource(accessPoint.getLevel()));
@ColorInt final int color;
if (accessPoint.isActive()) {
final NetworkInfo.State state = accessPoint.getNetworkInfo().getState();
if (state == NetworkInfo.State.CONNECTED) {
color = Utils.getColorAccentDefaultColor(mContext);
} else {
// connecting
color = Utils.getDisabled(mContext, Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorControlNormal));
}
} else {
color = Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorControlNormal);
}
d.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
return Utils.createIconWithDrawable(d);
}
use of com.android.settingslib.wifi.AccessPoint in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConnectToWifiHandler method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
if (context == null || intent == null) {
return;
}
final Network network = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
final Bundle accessPointState = intent.getBundleExtra(WifiDialogActivity.KEY_ACCESS_POINT_STATE);
if (network != null) {
WifiScanWorker.clearClickedWifi();
final ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
// start captive portal app to sign in to network
cm.startCaptivePortalApp(network);
} else if (accessPointState != null) {
connect(context, new AccessPoint(context, accessPointState));
}
}
use of com.android.settingslib.wifi.AccessPoint 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.AccessPoint in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NetworkRequestDialogFragmentTest method onUserSelectionCallbackRegistration_onClick_shouldCallSelect.
@Test
public void onUserSelectionCallbackRegistration_onClick_shouldCallSelect() {
// Assert.
final int indexClickItem = 3;
List<AccessPoint> accessPointList = createAccessPointList();
AccessPoint clickedAccessPoint = accessPointList.get(indexClickItem);
clickedAccessPoint.generateOpenNetworkConfig();
when(networkRequestDialogFragment.getAccessPointList()).thenReturn(accessPointList);
NetworkRequestUserSelectionCallback selectionCallback = mock(NetworkRequestUserSelectionCallback.class);
AlertDialog dialog = mock(AlertDialog.class);
networkRequestDialogFragment.onUserSelectionCallbackRegistration(selectionCallback);
// Act.
networkRequestDialogFragment.onClick(dialog, indexClickItem);
// Check.
verify(selectionCallback, times(1)).select(clickedAccessPoint.getConfig());
}
Aggregations