[WPA3] Filter unsupported networks from Add network spinner
Filter unsupported networks from Add network spinner. Removed entries from wifi_dialog.xml, adding them dynamically based on device capabilities. Adding position-to-security table, that decouples spinner positions from security values. Bug: 112195778 Test: atest WifiConfigControllerTest + device functional test Change-Id: I6a814c4d69fbd8d8076db5dbaa5da807b4da4c32
This commit is contained in:
@@ -22,16 +22,19 @@ import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyBoolean;
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.anyString;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.ServiceSpecificException;
|
||||
import android.security.KeyStore;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -298,6 +301,74 @@ public class WifiConfigControllerTest {
|
||||
assertThat(hiddenField.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void securitySpinner_saeSuitebAndOweNotVisible() {
|
||||
securitySpinnerTestHelper(false, false, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void securitySpinner_saeSuitebAndOweVisible() {
|
||||
securitySpinnerTestHelper(true, true, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void securitySpinner_saeVisible_suitebAndOweNotVisible() {
|
||||
securitySpinnerTestHelper(true, false, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void securitySpinner_oweVisible_suitebAndSaeNotVisible() {
|
||||
securitySpinnerTestHelper(false, false, true);
|
||||
}
|
||||
|
||||
private void securitySpinnerTestHelper(boolean saeVisible, boolean suitebVisible,
|
||||
boolean oweVisible) {
|
||||
WifiManager wifiManager = mock(WifiManager.class);
|
||||
when(wifiManager.isWpa3SaeSupported()).thenReturn(saeVisible ? true : false);
|
||||
when(wifiManager.isWpa3SuiteBSupported()).thenReturn(suitebVisible ? true : false);
|
||||
when(wifiManager.isOweSupported()).thenReturn(oweVisible ? true : false);
|
||||
|
||||
mController = new TestWifiConfigController(mConfigUiBase, mView, null /* accessPoint */,
|
||||
WifiConfigUiBase.MODE_MODIFY, wifiManager);
|
||||
|
||||
final Spinner securitySpinner = ((Spinner) 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();
|
||||
}
|
||||
}
|
||||
|
||||
public class TestWifiConfigController extends WifiConfigController {
|
||||
|
||||
private TestWifiConfigController(
|
||||
@@ -305,6 +376,12 @@ public class WifiConfigControllerTest {
|
||||
super(parent, view, accessPoint, mode);
|
||||
}
|
||||
|
||||
private TestWifiConfigController(
|
||||
WifiConfigUiBase parent, View view, AccessPoint accessPoint, int mode,
|
||||
WifiManager wifiManager) {
|
||||
super(parent, view, accessPoint, mode, wifiManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isSplitSystemUser() {
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user