Search in sources :

Example 51 with AccessPoint

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

the class WifiConfigControllerTest method securitySpinnerTestHelper.

private void securitySpinnerTestHelper(boolean saeVisible, boolean suitebVisible, boolean oweVisible) {
    WifiManager wifiManager = mock(WifiManager.class);
    when(wifiManager.isWpa3SaeSupported()).thenReturn(saeVisible);
    when(wifiManager.isWpa3SuiteBSupported()).thenReturn(suitebVisible);
    when(wifiManager.isEnhancedOpenSupported()).thenReturn(oweVisible);
    mController = new TestWifiConfigController(mConfigUiBase, mView, null, /* accessPoint */
    WifiConfigUiBase.MODE_MODIFY, wifiManager);
    final Spinner securitySpinner = mView.findViewById(R.id.security);
    final ArrayAdapter<String> adapter = (ArrayAdapter) securitySpinner.getAdapter();
    boolean saeFound = false;
    boolean suitebFound = false;
    boolean oweFound = false;
    for (int i = 0; i < adapter.getCount(); i++) {
        String val = adapter.getItem(i);
        if (val.compareTo(mContext.getString(R.string.wifi_security_sae)) == 0) {
            saeFound = true;
        }
        if (val.compareTo(mContext.getString(R.string.wifi_security_eap_suiteb)) == 0) {
            suitebFound = true;
        }
        if (val.compareTo(mContext.getString(R.string.wifi_security_owe)) == 0) {
            oweFound = true;
        }
    }
    if (saeVisible) {
        assertThat(saeFound).isTrue();
    } else {
        assertThat(saeFound).isFalse();
    }
    if (suitebVisible) {
        assertThat(suitebFound).isTrue();
    } else {
        assertThat(suitebFound).isFalse();
    }
    if (oweVisible) {
        assertThat(oweFound).isTrue();
    } else {
        assertThat(oweFound).isFalse();
    }
}
Also used : WifiManager(android.net.wifi.WifiManager) Spinner(android.widget.Spinner) Mockito.anyString(org.mockito.Mockito.anyString) ArrayAdapter(android.widget.ArrayAdapter) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 52 with AccessPoint

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

the class WifiUtilsTest method getWifiConfigByAccessPoint_shouldReturnCorrectConfig.

@Test
public void getWifiConfigByAccessPoint_shouldReturnCorrectConfig() {
    String testSSID = "WifiUtilsTest";
    Bundle bundle = new Bundle();
    bundle.putString("key_ssid", testSSID);
    Context context = spy(RuntimeEnvironment.application);
    AccessPoint accessPoint = new AccessPoint(context, bundle);
    WifiConfiguration config = WifiUtils.getWifiConfig(accessPoint, null, null);
    assertThat(config).isNotNull();
    assertThat(config.SSID).isEqualTo(AccessPoint.convertToQuotedString(testSSID));
}
Also used : Context(android.content.Context) WifiConfiguration(android.net.wifi.WifiConfiguration) Bundle(android.os.Bundle) AccessPoint(com.android.settingslib.wifi.AccessPoint) Test(org.junit.Test)

Example 53 with AccessPoint

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

the class NetworkRequestDialogFragmentTest method onMatch_shouldUpdatedList.

@Test
public void onMatch_shouldUpdatedList() {
    // Assert.
    when(networkRequestDialogFragment.getContext()).thenReturn(mContext);
    Context applicationContext = spy(RuntimeEnvironment.application.getApplicationContext());
    when(mContext.getApplicationContext()).thenReturn(applicationContext);
    WifiManager wifiManager = mock(WifiManager.class);
    when(applicationContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(wifiManager);
    networkRequestDialogFragment.onResume();
    List<AccessPoint> accessPointList = createAccessPointList();
    when(mWifiTracker.getAccessPoints()).thenReturn(accessPointList);
    final String SSID_AP1 = "Test AP 1";
    final String SSID_AP2 = "Test AP 2";
    List<ScanResult> scanResults = new ArrayList<>();
    ScanResult scanResult = new ScanResult();
    scanResult.SSID = SSID_AP1;
    scanResult.capabilities = "WEP";
    scanResults.add(scanResult);
    scanResult = new ScanResult();
    scanResult.SSID = SSID_AP2;
    scanResult.capabilities = "WEP";
    scanResults.add(scanResult);
    // Act.
    networkRequestDialogFragment.onMatch(scanResults);
    // Check.
    List<AccessPoint> returnList = networkRequestDialogFragment.getAccessPointList();
    assertThat(returnList).isNotEmpty();
    assertThat(returnList.size()).isEqualTo(2);
    assertThat(returnList.get(0).getSsid()).isEqualTo(SSID_AP1);
    assertThat(returnList.get(1).getSsid()).isEqualTo(SSID_AP2);
}
Also used : Context(android.content.Context) WifiManager(android.net.wifi.WifiManager) ScanResult(android.net.wifi.ScanResult) AccessPoint(com.android.settingslib.wifi.AccessPoint) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 54 with AccessPoint

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

the class WifiSettings method onCreateDialog.

@Override
public Dialog onCreateDialog(int dialogId) {
    switch(dialogId) {
        case WIFI_DIALOG_ID:
            // modify network
            if (mDlgAccessPoint == null && mAccessPointSavedState != null) {
                // restore AP from save state
                mDlgAccessPoint = new AccessPoint(getActivity(), mAccessPointSavedState);
                // Reset the saved access point data
                mAccessPointSavedState = null;
            }
            mDialog = WifiDialog.createModal(getActivity(), this, mDlgAccessPoint, mDialogMode);
            mSelectedAccessPoint = mDlgAccessPoint;
            return mDialog;
    }
    return super.onCreateDialog(dialogId);
}
Also used : AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 55 with AccessPoint

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

the class WifiSettings method getSavedNetworkSettingsSummaryText.

private String getSavedNetworkSettingsSummaryText(List<AccessPoint> savedNetworks, int numSavedNetworks) {
    int numSavedPasspointNetworks = 0;
    for (AccessPoint savedNetwork : savedNetworks) {
        if (savedNetwork.isPasspointConfig() || savedNetwork.isPasspoint()) {
            numSavedPasspointNetworks++;
        }
    }
    final int numSavedNormalNetworks = numSavedNetworks - numSavedPasspointNetworks;
    if (numSavedNetworks == numSavedNormalNetworks) {
        return getResources().getQuantityString(R.plurals.wifi_saved_access_points_summary, numSavedNormalNetworks, numSavedNormalNetworks);
    } else if (numSavedNetworks == numSavedPasspointNetworks) {
        return getResources().getQuantityString(R.plurals.wifi_saved_passpoint_access_points_summary, numSavedPasspointNetworks, numSavedPasspointNetworks);
    } else {
        return getResources().getQuantityString(R.plurals.wifi_saved_all_access_points_summary, numSavedNetworks, numSavedNetworks);
    }
}
Also used : AccessPoint(com.android.settingslib.wifi.AccessPoint) AccessPoint(com.android.settingslib.wifi.AccessPoint)

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