Snap for 5148923 from 39d97b1387 to qt-release
Change-Id: I66d11a2d74c440beba93f2fe0c18fe02e6c55b57
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@*android:color/accent_device_default_light"/>
|
||||
<background android:drawable="@color/icon_launcher_setting_color"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_settings"/>
|
||||
</adaptive-icon>
|
||||
|
||||
@@ -83,12 +83,13 @@
|
||||
style="@style/wifi_item_label"
|
||||
android:text="@string/wifi_security" />
|
||||
|
||||
<!-- Entries are added dynamically to this spinner -->
|
||||
<!-- See WifiConfigController.configureSecuritySpinner -->
|
||||
<Spinner android:id="@+id/security"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/wifi_item_spinner"
|
||||
android:prompt="@string/wifi_security"
|
||||
android:entries="@array/wifi_security" />
|
||||
android:prompt="@string/wifi_security" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -210,29 +210,6 @@
|
||||
<item>Temporarily avoiding poor connection</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Match this with the constants in AccessPoint. --> <skip />
|
||||
<!-- Wi-Fi security choices used when manually added a Wi-Fi network -->
|
||||
<string-array name="wifi_security">
|
||||
<!-- The Wi-Fi network does not have any security. -->
|
||||
<item>@string/wifi_security_none</item>
|
||||
<item translatable="false">@string/wifi_security_wep</item>
|
||||
<item translatable="false">@string/wifi_security_psk_generic</item>
|
||||
<item translatable="false">@string/wifi_security_eap</item>
|
||||
<item translatable="false">@string/wifi_security_owe</item>
|
||||
<item translatable="false">@string/wifi_security_sae</item>
|
||||
<item translatable="false">@string/wifi_security_eap_suiteb</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Match this with the constants in AccessPoint. --> <skip />
|
||||
<!-- Wi-Fi security types for New User Dialog. EAP is not configurable. -->
|
||||
<string-array name="wifi_security_no_eap">
|
||||
<!-- The Wi-Fi network does not have any security. -->
|
||||
<item>@string/wifi_security_none</item>
|
||||
<item translatable="false">@string/wifi_security_wep</item>
|
||||
<item translatable="false">@string/wifi_security_psk_generic</item>
|
||||
<item translatable="false">@string/wifi_security_sae</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Security types for wireless tether -->
|
||||
<string-array name="wifi_tether_security">
|
||||
<!-- Do not translate. -->
|
||||
|
||||
@@ -149,5 +149,8 @@
|
||||
<color name="face_anim_particle_color_3">#ff4caf50</color> <!-- Material Green 500 -->
|
||||
<color name="face_anim_particle_color_4">#fffdd835</color> <!-- Material Yellow 600 -->
|
||||
<color name="face_anim_particle_error">#ff9e9e9e</color> <!-- Material Gray 500 -->
|
||||
|
||||
<!-- launcher icon color -->
|
||||
<color name="icon_launcher_setting_color">@*android:color/accent_device_default_light</color>
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -5424,9 +5424,9 @@
|
||||
<string name="battery_saver_turn_on_automatically_pct">at <xliff:g id="percent">%1$s</xliff:g> battery</string>
|
||||
|
||||
<!-- [CHAR_LIMIT=40] Battery percentage: Title -->
|
||||
<string name="battery_percentage">Battery percentage</string>
|
||||
<string name="battery_info">Battery Information</string>
|
||||
<!-- [CHAR_LIMIT=NONE] Battery percentage: Description for preference -->
|
||||
<string name="battery_percentage_description">Show battery percentage in status bar</string>
|
||||
<string name="battery_info_description">Show percentage and time left before charge is needed</string>
|
||||
|
||||
<!-- Process Stats strings -->
|
||||
<skip />
|
||||
@@ -10079,6 +10079,9 @@
|
||||
<!-- Title for HFP(hands free profile) output switch button in settings. -->
|
||||
<string name="take_call_on_title">Take call on</string>
|
||||
|
||||
<!-- Toast that appears when users tap an APN for which parameters cannot be viewed. [CHAR LIMIT=NONE] -->
|
||||
<string name="cannot_change_apn_toast">This APN cannot be changed.</string>
|
||||
|
||||
<!-- Title for battery Suggestion. (tablet) [CHAR LIMIT=46] -->
|
||||
<string name="battery_suggestion_title" product="tablet" >Improve tablet\'s battery life</string>
|
||||
<!-- Title for battery Suggestion. (device) [CHAR LIMIT=46] -->
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
android:title="@string/data_usage_app_summary_title">
|
||||
|
||||
<com.android.settings.datausage.SpinnerPreference
|
||||
android:key="cycle" />
|
||||
android:key="cycle"
|
||||
settings:isPreferenceVisible="false" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="app_data_usage_summary_category">
|
||||
|
||||
@@ -50,8 +50,8 @@
|
||||
|
||||
<SwitchPreference
|
||||
android:key="battery_percentage"
|
||||
android:title="@string/battery_percentage"
|
||||
android:summary="@string/battery_percentage_description"
|
||||
android:title="@string/battery_info"
|
||||
android:summary="@string/battery_info_description"
|
||||
settings:controller="com.android.settings.display.BatteryPercentagePreferenceController" />
|
||||
|
||||
|
||||
|
||||
@@ -37,11 +37,6 @@
|
||||
android:title="@string/zen_mode_messages_title"
|
||||
android:fragment="com.android.settings.notification.ZenModeMessagesSettings" />
|
||||
|
||||
<!-- Alarms -->
|
||||
<SwitchPreference
|
||||
android:key="zen_mode_behavior_alarms"
|
||||
android:title="@string/zen_mode_alarms"/>
|
||||
|
||||
<!-- All sounds -->
|
||||
<Preference
|
||||
android:key="zen_sound_vibration_settings"
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
@@ -54,6 +55,7 @@ public class ApnPreference extends Preference implements CompoundButton.OnChecke
|
||||
private static CompoundButton mCurrentChecked = null;
|
||||
private boolean mProtectFromCheckedChange = false;
|
||||
private boolean mSelectable = true;
|
||||
private boolean mHideDetails = false;
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||
@@ -113,6 +115,11 @@ public class ApnPreference extends Preference implements CompoundButton.OnChecke
|
||||
super.onClick();
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
if (mHideDetails) {
|
||||
Toast.makeText(context, context.getString(
|
||||
R.string.cannot_change_apn_toast), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
int pos = Integer.parseInt(getKey());
|
||||
Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
|
||||
Intent editIntent = new Intent(Intent.ACTION_EDIT, url);
|
||||
@@ -132,4 +139,8 @@ public class ApnPreference extends Preference implements CompoundButton.OnChecke
|
||||
public void setSubId(int subId) {
|
||||
mSubId = subId;
|
||||
}
|
||||
|
||||
public void setHideDetails() {
|
||||
mHideDetails = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,12 +78,23 @@ public class ApnSettings extends RestrictedSettingsFragment {
|
||||
public static final String MVNO_TYPE = "mvno_type";
|
||||
public static final String MVNO_MATCH_DATA = "mvno_match_data";
|
||||
|
||||
private static final String[] CARRIERS_PROJECTION = new String[] {
|
||||
Telephony.Carriers._ID,
|
||||
Telephony.Carriers.NAME,
|
||||
Telephony.Carriers.APN,
|
||||
Telephony.Carriers.TYPE,
|
||||
Telephony.Carriers.MVNO_TYPE,
|
||||
Telephony.Carriers.MVNO_MATCH_DATA,
|
||||
Telephony.Carriers.EDITED,
|
||||
};
|
||||
|
||||
private static final int ID_INDEX = 0;
|
||||
private static final int NAME_INDEX = 1;
|
||||
private static final int APN_INDEX = 2;
|
||||
private static final int TYPES_INDEX = 3;
|
||||
private static final int MVNO_TYPE_INDEX = 4;
|
||||
private static final int MVNO_MATCH_DATA_INDEX = 5;
|
||||
private static final int EDITED_INDEX = 6;
|
||||
|
||||
private static final int MENU_NEW = Menu.FIRST;
|
||||
private static final int MENU_RESTORE = Menu.FIRST + 1;
|
||||
@@ -116,6 +127,7 @@ public class ApnSettings extends RestrictedSettingsFragment {
|
||||
|
||||
private boolean mHideImsApn;
|
||||
private boolean mAllowAddingApns;
|
||||
private boolean mHidePresetApnDetails;
|
||||
|
||||
public ApnSettings() {
|
||||
super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
|
||||
@@ -196,6 +208,7 @@ public class ApnSettings extends RestrictedSettingsFragment {
|
||||
mAllowAddingApns = false;
|
||||
}
|
||||
}
|
||||
mHidePresetApnDetails = b.getBoolean(CarrierConfigManager.KEY_HIDE_PRESET_APN_DETAILS_BOOL);
|
||||
mUserManager = UserManager.get(activity);
|
||||
}
|
||||
|
||||
@@ -277,9 +290,8 @@ public class ApnSettings extends RestrictedSettingsFragment {
|
||||
where.append(" AND NOT (type='ims')");
|
||||
}
|
||||
|
||||
Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] {
|
||||
"_id", "name", "apn", "type", "mvno_type", "mvno_match_data"}, where.toString(),
|
||||
null, Telephony.Carriers.DEFAULT_SORT_ORDER);
|
||||
Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI,
|
||||
CARRIERS_PROJECTION, where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER);
|
||||
|
||||
if (cursor != null) {
|
||||
IccRecords r = null;
|
||||
@@ -304,14 +316,19 @@ public class ApnSettings extends RestrictedSettingsFragment {
|
||||
String type = cursor.getString(TYPES_INDEX);
|
||||
String mvnoType = cursor.getString(MVNO_TYPE_INDEX);
|
||||
String mvnoMatchData = cursor.getString(MVNO_MATCH_DATA_INDEX);
|
||||
int edited = cursor.getInt(EDITED_INDEX);
|
||||
|
||||
ApnPreference pref = new ApnPreference(getPrefContext());
|
||||
|
||||
pref.setKey(key);
|
||||
pref.setTitle(name);
|
||||
pref.setSummary(apn);
|
||||
pref.setPersistent(false);
|
||||
pref.setSubId(subId);
|
||||
if (mHidePresetApnDetails && edited == Telephony.Carriers.UNEDITED) {
|
||||
pref.setHideDetails();
|
||||
} else {
|
||||
pref.setSummary(apn);
|
||||
}
|
||||
|
||||
boolean selectable = ((type == null) || !type.equals("mms"));
|
||||
pref.setSelectable(selectable);
|
||||
|
||||
@@ -86,8 +86,6 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
"zen_mode_behavior_calls"));
|
||||
controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle,
|
||||
"zen_mode_behavior_messages"));
|
||||
controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle,
|
||||
"zen_mode_behavior_alarms"));
|
||||
controllers.add(new ZenModeBlockedEffectsPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeDurationPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeAutomationPreferenceController(context));
|
||||
|
||||
@@ -321,7 +321,7 @@ public class EntityHeaderController {
|
||||
}
|
||||
actionBar.setBackgroundDrawable(
|
||||
new ColorDrawable(
|
||||
Utils.getColorAttrDefaultColor(activity, android.R.attr.colorPrimary)));
|
||||
Utils.getColorAttrDefaultColor(activity, android.R.attr.colorPrimaryDark)));
|
||||
actionBar.setElevation(0);
|
||||
if (mRecyclerView != null && mLifecycle != null) {
|
||||
ActionBarShadowController.attachToRecyclerView(mActivity, mLifecycle, mRecyclerView);
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.net.wifi.WifiEnterpriseConfig;
|
||||
import android.net.wifi.WifiEnterpriseConfig.Eap;
|
||||
import android.net.wifi.WifiEnterpriseConfig.Phase2;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.UserManager;
|
||||
import android.security.Credentials;
|
||||
import android.security.KeyStore;
|
||||
@@ -119,9 +120,9 @@ public class WifiConfigController implements TextWatcher,
|
||||
|
||||
|
||||
/* Phase2 methods supported by PEAP are limited */
|
||||
private final ArrayAdapter<String> mPhase2PeapAdapter;
|
||||
private ArrayAdapter<String> mPhase2PeapAdapter;
|
||||
/* Full list of phase2 methods */
|
||||
private final ArrayAdapter<String> mPhase2FullAdapter;
|
||||
private ArrayAdapter<String> mPhase2FullAdapter;
|
||||
|
||||
// e.g. AccessPoint.SECURITY_NONE
|
||||
@VisibleForTesting
|
||||
@@ -174,6 +175,9 @@ public class WifiConfigController implements TextWatcher,
|
||||
private TextView mSsidView;
|
||||
|
||||
private Context mContext;
|
||||
private Integer mSecurityInPosition[];
|
||||
|
||||
private final WifiManager mWifiManager;
|
||||
|
||||
public WifiConfigController(WifiConfigUiBase parent, View view, AccessPoint accessPoint,
|
||||
int mode) {
|
||||
@@ -181,11 +185,31 @@ public class WifiConfigController implements TextWatcher,
|
||||
|
||||
mView = view;
|
||||
mAccessPoint = accessPoint;
|
||||
mContext = mConfigUi.getContext();
|
||||
|
||||
// Init Wi-Fi manager
|
||||
mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
||||
initWifiConfigController(accessPoint, mode);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public WifiConfigController(WifiConfigUiBase parent, View view, AccessPoint accessPoint,
|
||||
int mode, WifiManager wifiManager) {
|
||||
mConfigUi = parent;
|
||||
|
||||
mView = view;
|
||||
mAccessPoint = accessPoint;
|
||||
mContext = mConfigUi.getContext();
|
||||
mWifiManager = wifiManager;
|
||||
initWifiConfigController(accessPoint, mode);
|
||||
}
|
||||
|
||||
private void initWifiConfigController(AccessPoint accessPoint, int mode) {
|
||||
|
||||
mAccessPointSecurity = (accessPoint == null) ? AccessPoint.SECURITY_NONE :
|
||||
accessPoint.getSecurity();
|
||||
mMode = mode;
|
||||
|
||||
mContext = mConfigUi.getContext();
|
||||
final Resources res = mContext.getResources();
|
||||
|
||||
mLevels = res.getStringArray(R.array.wifi_signal);
|
||||
@@ -234,24 +258,10 @@ public class WifiConfigController implements TextWatcher,
|
||||
mHiddenSettingsSpinner.getSelectedItemPosition() == NOT_HIDDEN_NETWORK
|
||||
? View.GONE
|
||||
: View.VISIBLE);
|
||||
mSecurityInPosition = new Integer[AccessPoint.SECURITY_MAX_VAL];
|
||||
|
||||
if (mAccessPoint == null) { // new network
|
||||
mConfigUi.setTitle(R.string.wifi_add_network);
|
||||
|
||||
mSsidView = (TextView) mView.findViewById(R.id.ssid);
|
||||
mSsidView.addTextChangedListener(this);
|
||||
mSecuritySpinner = ((Spinner) mView.findViewById(R.id.security));
|
||||
mSecuritySpinner.setOnItemSelectedListener(this);
|
||||
mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
|
||||
|
||||
showIpConfigFields();
|
||||
showProxyFields();
|
||||
mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
|
||||
// Hidden option can be changed only when the user adds a network manually.
|
||||
mView.findViewById(R.id.hidden_settings_field).setVisibility(View.VISIBLE);
|
||||
((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox))
|
||||
.setOnCheckedChangeListener(this);
|
||||
|
||||
configureSecuritySpinner();
|
||||
mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
|
||||
} else {
|
||||
if (!mAccessPoint.isPasspointConfig()) {
|
||||
@@ -1414,7 +1424,8 @@ public class WifiConfigController implements TextWatcher,
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (parent == mSecuritySpinner) {
|
||||
mAccessPointSecurity = position;
|
||||
// Convert menu position to actual Wi-Fi security type
|
||||
mAccessPointSecurity = mSecurityInPosition[position];
|
||||
showSecurityFields();
|
||||
} else if (parent == mEapMethodSpinner || parent == mEapCaCertSpinner) {
|
||||
showSecurityFields();
|
||||
@@ -1459,4 +1470,53 @@ public class WifiConfigController implements TextWatcher,
|
||||
public AccessPoint getAccessPoint() {
|
||||
return mAccessPoint;
|
||||
}
|
||||
|
||||
private void configureSecuritySpinner() {
|
||||
mConfigUi.setTitle(R.string.wifi_add_network);
|
||||
|
||||
mSsidView = (TextView) mView.findViewById(R.id.ssid);
|
||||
mSsidView.addTextChangedListener(this);
|
||||
mSecuritySpinner = ((Spinner) mView.findViewById(R.id.security));
|
||||
mSecuritySpinner.setOnItemSelectedListener(this);
|
||||
|
||||
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(mContext,
|
||||
android.R.layout.simple_spinner_item, android.R.id.text1);
|
||||
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mSecuritySpinner.setAdapter(spinnerAdapter);
|
||||
int idx = 0;
|
||||
|
||||
// Populate the Wi-Fi security spinner with the various supported key management types
|
||||
spinnerAdapter.add(mContext.getString(R.string.wifi_security_none));
|
||||
mSecurityInPosition[idx++] = AccessPoint.SECURITY_NONE;
|
||||
if (mWifiManager.isOweSupported()) {
|
||||
spinnerAdapter.add(mContext.getString(R.string.wifi_security_owe));
|
||||
mSecurityInPosition[idx++] = AccessPoint.SECURITY_OWE;
|
||||
}
|
||||
spinnerAdapter.add(mContext.getString(R.string.wifi_security_wep));
|
||||
mSecurityInPosition[idx++] = AccessPoint.SECURITY_WEP;
|
||||
spinnerAdapter.add(mContext.getString(R.string.wifi_security_wpa_wpa2));
|
||||
mSecurityInPosition[idx++] = AccessPoint.SECURITY_PSK;
|
||||
if (mWifiManager.isWpa3SaeSupported()) {
|
||||
spinnerAdapter.add(mContext.getString(R.string.wifi_security_sae));
|
||||
mSecurityInPosition[idx++] = AccessPoint.SECURITY_SAE;
|
||||
}
|
||||
spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap));
|
||||
mSecurityInPosition[idx++] = AccessPoint.SECURITY_EAP;
|
||||
if (mWifiManager.isWpa3SuiteBSupported()) {
|
||||
spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap_suiteb));
|
||||
mSecurityInPosition[idx++] = AccessPoint.SECURITY_EAP_SUITE_B;
|
||||
}
|
||||
|
||||
spinnerAdapter.notifyDataSetChanged();
|
||||
|
||||
mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
|
||||
|
||||
showIpConfigFields();
|
||||
showProxyFields();
|
||||
mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
|
||||
// Hidden option can be changed only when the user adds a network manually.
|
||||
mView.findViewById(R.id.hidden_settings_field).setVisibility(View.VISIBLE);
|
||||
((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox))
|
||||
.setOnCheckedChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -66,11 +66,11 @@ public class WifiTetherSecurityPreferenceControllerTest {
|
||||
public void onPreferenceChange_securityValueUpdated() {
|
||||
mController.onPreferenceChange(mPreference, WPA2_PSK);
|
||||
assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
|
||||
assertThat(mPreference.getSummary()).isEqualTo("WPA2-Personal");
|
||||
assertThat(mPreference.getSummary().toString()).isEqualTo("WPA2-Personal");
|
||||
|
||||
mController.onPreferenceChange(mPreference, NONE);
|
||||
assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.NONE);
|
||||
assertThat(mPreference.getSummary()).isEqualTo("None");
|
||||
assertThat(mPreference.getSummary().toString()).isEqualTo("None");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,7 +79,7 @@ public class WifiTetherSecurityPreferenceControllerTest {
|
||||
when(mWifiManager.getWifiApConfiguration()).thenReturn(null);
|
||||
mController.updateDisplay();
|
||||
assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
|
||||
assertThat(mPreference.getSummary()).isEqualTo("WPA2-Personal");
|
||||
assertThat(mPreference.getSummary().toString()).isEqualTo("WPA2-Personal");
|
||||
|
||||
// test open tether network
|
||||
when(mWifiManager.getWifiApConfiguration()).thenReturn(mConfig);
|
||||
@@ -87,13 +87,13 @@ public class WifiTetherSecurityPreferenceControllerTest {
|
||||
mConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
|
||||
mController.updateDisplay();
|
||||
assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.NONE);
|
||||
assertThat(mPreference.getSummary()).isEqualTo("None");
|
||||
assertThat(mPreference.getSummary().toString()).isEqualTo("None");
|
||||
|
||||
// test WPA2-Personal tether network
|
||||
mConfig.allowedKeyManagement.clear();
|
||||
mConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA2_PSK);
|
||||
mController.updateDisplay();
|
||||
assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
|
||||
assertThat(mPreference.getSummary()).isEqualTo("WPA2-Personal");
|
||||
assertThat(mPreference.getSummary().toString()).isEqualTo("WPA2-Personal");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user