Search in sources :

Example 46 with AccessPoint

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);
}
Also used : Bundle(android.os.Bundle) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 47 with AccessPoint

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);
}
Also used : ColorInt(android.annotation.ColorInt) NetworkInfo(android.net.NetworkInfo) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 48 with AccessPoint

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));
    }
}
Also used : Bundle(android.os.Bundle) ConnectivityManager(android.net.ConnectivityManager) Network(android.net.Network) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 49 with AccessPoint

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);
}
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 50 with AccessPoint

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());
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) NetworkRequestUserSelectionCallback(android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback) AccessPoint(com.android.settingslib.wifi.AccessPoint) AccessPoint(com.android.settingslib.wifi.AccessPoint) Test(org.junit.Test)

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