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