Remove duplicated metered & privacy spinner
From Wi-Fi dialog when there are already same settings in the Wi-Fi detail page. This makes simpler for the user and help fix the inconsistent issue. Fix: 297036035 Test: manual - open Wi-Fi dialog from Wi-Fi detail page Test: robo test Change-Id: Ic02658d91938db78b91e867a923260aa2610ae49
This commit is contained in:
@@ -413,7 +413,8 @@
|
|||||||
<LinearLayout android:id="@+id/metered_settings_fields"
|
<LinearLayout android:id="@+id/metered_settings_fields"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="@style/wifi_item">
|
style="@style/wifi_item"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<TextView android:id="@+id/metered_settings_title"
|
<TextView android:id="@+id/metered_settings_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@@ -64,6 +64,7 @@ import android.widget.ImageButton;
|
|||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.net.module.util.NetUtils;
|
import com.android.net.module.util.NetUtils;
|
||||||
@@ -200,8 +201,10 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
private TextView mDns2View;
|
private TextView mDns2View;
|
||||||
|
|
||||||
private Spinner mProxySettingsSpinner;
|
private Spinner mProxySettingsSpinner;
|
||||||
|
@Nullable
|
||||||
private Spinner mMeteredSettingsSpinner;
|
private Spinner mMeteredSettingsSpinner;
|
||||||
private Spinner mHiddenSettingsSpinner;
|
private Spinner mHiddenSettingsSpinner;
|
||||||
|
@Nullable
|
||||||
private Spinner mPrivacySettingsSpinner;
|
private Spinner mPrivacySettingsSpinner;
|
||||||
private TextView mHiddenWarningView;
|
private TextView mHiddenWarningView;
|
||||||
private TextView mProxyHostView;
|
private TextView mProxyHostView;
|
||||||
@@ -216,48 +219,51 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
private StaticIpConfiguration mStaticIpConfiguration = null;
|
private StaticIpConfiguration mStaticIpConfiguration = null;
|
||||||
|
|
||||||
private String[] mLevels;
|
private String[] mLevels;
|
||||||
private int mMode;
|
private final int mMode;
|
||||||
|
private final boolean mHideMeteredAndPrivacy;
|
||||||
|
private final WifiManager mWifiManager;
|
||||||
|
private final AndroidKeystoreAliasLoader mAndroidKeystoreAliasLoader;
|
||||||
private TextView mSsidView;
|
private TextView mSsidView;
|
||||||
|
|
||||||
private Context mContext;
|
private final Context mContext;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Integer[] mSecurityInPosition;
|
Integer[] mSecurityInPosition;
|
||||||
|
|
||||||
private final WifiManager mWifiManager;
|
|
||||||
private boolean mIsTrustOnFirstUseSupported;
|
private boolean mIsTrustOnFirstUseSupported;
|
||||||
|
|
||||||
private final ArrayMap<Integer, SubscriptionInfo> mActiveSubscriptionInfos = new ArrayMap<>();
|
private final ArrayMap<Integer, SubscriptionInfo> mActiveSubscriptionInfos = new ArrayMap<>();
|
||||||
|
|
||||||
public WifiConfigController2(WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry,
|
public WifiConfigController2(WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry,
|
||||||
int mode) {
|
int mode) {
|
||||||
mConfigUi = parent;
|
this(parent, view, wifiEntry, mode, false);
|
||||||
mView = view;
|
}
|
||||||
mWifiEntry = wifiEntry;
|
|
||||||
mContext = mConfigUi.getContext();
|
|
||||||
|
|
||||||
// Init Wi-Fi manager
|
public WifiConfigController2(WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry,
|
||||||
mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
int mode, boolean hideMeteredAndPrivacy) {
|
||||||
initWifiConfigController2(wifiEntry, mode);
|
this(parent, view, wifiEntry, mode, hideMeteredAndPrivacy,
|
||||||
|
parent.getContext().getSystemService(WifiManager.class),
|
||||||
|
new AndroidKeystoreAliasLoader(KeyProperties.NAMESPACE_WIFI));
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public WifiConfigController2(WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry,
|
public WifiConfigController2(WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry,
|
||||||
int mode, WifiManager wifiManager) {
|
int mode, boolean hideMeteredAndPrivacy, WifiManager wifiManager,
|
||||||
|
AndroidKeystoreAliasLoader androidKeystoreAliasLoader) {
|
||||||
mConfigUi = parent;
|
mConfigUi = parent;
|
||||||
|
|
||||||
mView = view;
|
mView = view;
|
||||||
mWifiEntry = wifiEntry;
|
mWifiEntry = wifiEntry;
|
||||||
|
mMode = mode;
|
||||||
|
mHideMeteredAndPrivacy = hideMeteredAndPrivacy;
|
||||||
mContext = mConfigUi.getContext();
|
mContext = mConfigUi.getContext();
|
||||||
mWifiManager = wifiManager;
|
mWifiManager = wifiManager;
|
||||||
initWifiConfigController2(wifiEntry, mode);
|
mAndroidKeystoreAliasLoader = androidKeystoreAliasLoader;
|
||||||
|
initWifiConfigController2(wifiEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initWifiConfigController2(WifiEntry wifiEntry, int mode) {
|
private void initWifiConfigController2(WifiEntry wifiEntry) {
|
||||||
|
|
||||||
mWifiEntrySecurity = (wifiEntry == null) ? WifiEntry.SECURITY_NONE :
|
mWifiEntrySecurity = (wifiEntry == null) ? WifiEntry.SECURITY_NONE :
|
||||||
wifiEntry.getSecurity();
|
wifiEntry.getSecurity();
|
||||||
mMode = mode;
|
|
||||||
mIsTrustOnFirstUseSupported = mWifiManager.isTrustOnFirstUseSupported();
|
mIsTrustOnFirstUseSupported = mWifiManager.isTrustOnFirstUseSupported();
|
||||||
|
|
||||||
final Resources res = mContext.getResources();
|
final Resources res = mContext.getResources();
|
||||||
@@ -287,12 +293,14 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
mProxySettingsSpinner = (Spinner) mView.findViewById(R.id.proxy_settings);
|
mProxySettingsSpinner = (Spinner) mView.findViewById(R.id.proxy_settings);
|
||||||
mProxySettingsSpinner.setOnItemSelectedListener(this);
|
mProxySettingsSpinner.setOnItemSelectedListener(this);
|
||||||
mSharedCheckBox = (CheckBox) mView.findViewById(R.id.shared);
|
mSharedCheckBox = (CheckBox) mView.findViewById(R.id.shared);
|
||||||
mMeteredSettingsSpinner = mView.findViewById(R.id.metered_settings);
|
if (!mHideMeteredAndPrivacy) {
|
||||||
|
mMeteredSettingsSpinner = mView.findViewById(R.id.metered_settings);
|
||||||
|
mView.findViewById(R.id.metered_settings_fields).setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
mHiddenSettingsSpinner = mView.findViewById(R.id.hidden_settings);
|
mHiddenSettingsSpinner = mView.findViewById(R.id.hidden_settings);
|
||||||
mPrivacySettingsSpinner = mView.findViewById(R.id.privacy_settings);
|
if (!mHideMeteredAndPrivacy && mWifiManager.isConnectedMacRandomizationSupported()) {
|
||||||
if (mWifiManager.isConnectedMacRandomizationSupported()) {
|
mPrivacySettingsSpinner = mView.findViewById(R.id.privacy_settings);
|
||||||
View privacySettingsLayout = mView.findViewById(R.id.privacy_settings_fields);
|
mView.findViewById(R.id.privacy_settings_fields).setVisibility(View.VISIBLE);
|
||||||
privacySettingsLayout.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
mHiddenSettingsSpinner.setOnItemSelectedListener(this);
|
mHiddenSettingsSpinner.setOnItemSelectedListener(this);
|
||||||
mHiddenWarningView = mView.findViewById(R.id.hidden_settings_warning);
|
mHiddenWarningView = mView.findViewById(R.id.hidden_settings_warning);
|
||||||
@@ -313,14 +321,18 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
boolean showAdvancedFields = false;
|
boolean showAdvancedFields = false;
|
||||||
if (mWifiEntry.isSaved()) {
|
if (mWifiEntry.isSaved()) {
|
||||||
WifiConfiguration config = mWifiEntry.getWifiConfiguration();
|
WifiConfiguration config = mWifiEntry.getWifiConfiguration();
|
||||||
mMeteredSettingsSpinner.setSelection(config.meteredOverride);
|
if (mMeteredSettingsSpinner != null) {
|
||||||
|
mMeteredSettingsSpinner.setSelection(config.meteredOverride);
|
||||||
|
}
|
||||||
mHiddenSettingsSpinner.setSelection(config.hiddenSSID
|
mHiddenSettingsSpinner.setSelection(config.hiddenSSID
|
||||||
? HIDDEN_NETWORK
|
? HIDDEN_NETWORK
|
||||||
: NOT_HIDDEN_NETWORK);
|
: NOT_HIDDEN_NETWORK);
|
||||||
|
|
||||||
final int prefMacValue = WifiPrivacyPreferenceController2
|
if (mPrivacySettingsSpinner != null) {
|
||||||
.translateMacRandomizedValueToPrefValue(config.macRandomizationSetting);
|
final int prefMacValue = WifiPrivacyPreferenceController2
|
||||||
mPrivacySettingsSpinner.setSelection(prefMacValue);
|
.translateMacRandomizedValueToPrefValue(config.macRandomizationSetting);
|
||||||
|
mPrivacySettingsSpinner.setSelection(prefMacValue);
|
||||||
|
}
|
||||||
|
|
||||||
if (config.getIpConfiguration().getIpAssignment() == IpAssignment.STATIC) {
|
if (config.getIpConfiguration().getIpAssignment() == IpAssignment.STATIC) {
|
||||||
mIpSettingsSpinner.setSelection(STATIC_IP);
|
mIpSettingsSpinner.setSelection(STATIC_IP);
|
||||||
@@ -1063,17 +1075,15 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
if (refreshCertificates) {
|
if (refreshCertificates) {
|
||||||
loadSims();
|
loadSims();
|
||||||
|
|
||||||
final AndroidKeystoreAliasLoader androidKeystoreAliasLoader =
|
|
||||||
getAndroidKeystoreAliasLoader();
|
|
||||||
loadCertificates(
|
loadCertificates(
|
||||||
mEapCaCertSpinner,
|
mEapCaCertSpinner,
|
||||||
androidKeystoreAliasLoader.getCaCertAliases(),
|
mAndroidKeystoreAliasLoader.getCaCertAliases(),
|
||||||
null /* noCertificateString */,
|
null /* noCertificateString */,
|
||||||
false /* showMultipleCerts */,
|
false /* showMultipleCerts */,
|
||||||
true /* showUsePreinstalledCertOption */);
|
true /* showUsePreinstalledCertOption */);
|
||||||
loadCertificates(
|
loadCertificates(
|
||||||
mEapUserCertSpinner,
|
mEapUserCertSpinner,
|
||||||
androidKeystoreAliasLoader.getKeyCertAliases(),
|
mAndroidKeystoreAliasLoader.getKeyCertAliases(),
|
||||||
mDoNotProvideEapUserCertString,
|
mDoNotProvideEapUserCertString,
|
||||||
false /* showMultipleCerts */,
|
false /* showMultipleCerts */,
|
||||||
false /* showUsePreinstalledCertOption */);
|
false /* showUsePreinstalledCertOption */);
|
||||||
@@ -1158,11 +1168,9 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
setSelection(mEapCaCertSpinner, caCerts[0]);
|
setSelection(mEapCaCertSpinner, caCerts[0]);
|
||||||
} else {
|
} else {
|
||||||
// Reload the cert spinner with an extra "multiple certificates added" item.
|
// Reload the cert spinner with an extra "multiple certificates added" item.
|
||||||
final AndroidKeystoreAliasLoader androidKeystoreAliasLoader =
|
|
||||||
getAndroidKeystoreAliasLoader();
|
|
||||||
loadCertificates(
|
loadCertificates(
|
||||||
mEapCaCertSpinner,
|
mEapCaCertSpinner,
|
||||||
androidKeystoreAliasLoader.getCaCertAliases(),
|
mAndroidKeystoreAliasLoader.getCaCertAliases(),
|
||||||
null /* noCertificateString */,
|
null /* noCertificateString */,
|
||||||
true /* showMultipleCerts */,
|
true /* showMultipleCerts */,
|
||||||
true /* showUsePreinstalledCertOption */);
|
true /* showUsePreinstalledCertOption */);
|
||||||
@@ -1501,11 +1509,6 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
AndroidKeystoreAliasLoader getAndroidKeystoreAliasLoader() {
|
|
||||||
return new AndroidKeystoreAliasLoader(KeyProperties.NAMESPACE_WIFI);
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void loadSims() {
|
void loadSims() {
|
||||||
List<SubscriptionInfo> activeSubscriptionInfos = mContext
|
List<SubscriptionInfo> activeSubscriptionInfos = mContext
|
||||||
|
@@ -41,6 +41,7 @@ class WifiDialog2 @JvmOverloads constructor(
|
|||||||
private val mode: Int,
|
private val mode: Int,
|
||||||
@StyleRes style: Int = 0,
|
@StyleRes style: Int = 0,
|
||||||
private val hideSubmitButton: Boolean = mode == WifiConfigUiBase2.MODE_VIEW,
|
private val hideSubmitButton: Boolean = mode == WifiConfigUiBase2.MODE_VIEW,
|
||||||
|
private val hideMeteredAndPrivacy: Boolean = false,
|
||||||
) : AlertDialog(context, style), WifiConfigUiBase2, DialogInterface.OnClickListener {
|
) : AlertDialog(context, style), WifiConfigUiBase2, DialogInterface.OnClickListener {
|
||||||
/**
|
/**
|
||||||
* Host UI component of WifiDialog2 can receive callbacks by this interface.
|
* Host UI component of WifiDialog2 can receive callbacks by this interface.
|
||||||
@@ -71,7 +72,7 @@ class WifiDialog2 @JvmOverloads constructor(
|
|||||||
setWindowsOverlay()
|
setWindowsOverlay()
|
||||||
view = layoutInflater.inflate(R.layout.wifi_dialog, null)
|
view = layoutInflater.inflate(R.layout.wifi_dialog, null)
|
||||||
setView(view)
|
setView(view)
|
||||||
controller = WifiConfigController2(this, view, wifiEntry, mode)
|
controller = WifiConfigController2(this, view, wifiEntry, mode, hideMeteredAndPrivacy)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
if (hideSubmitButton) {
|
if (hideSubmitButton) {
|
||||||
controller.hideSubmitButton()
|
controller.hideSubmitButton()
|
||||||
|
@@ -42,6 +42,7 @@ import android.view.Menu;
|
|||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
@@ -180,8 +181,14 @@ public class WifiNetworkDetailsFragment extends RestrictedDashboardFragment impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
final WifiEntry wifiEntry = mNetworkDetailsTracker.getWifiEntry();
|
final WifiEntry wifiEntry = mNetworkDetailsTracker.getWifiEntry();
|
||||||
return new WifiDialog2(getActivity(), this, wifiEntry,
|
return new WifiDialog2(
|
||||||
WifiConfigUiBase2.MODE_MODIFY);
|
getActivity(),
|
||||||
|
this,
|
||||||
|
wifiEntry,
|
||||||
|
WifiConfigUiBase2.MODE_MODIFY,
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -276,14 +283,12 @@ public class WifiNetworkDetailsFragment extends RestrictedDashboardFragment impl
|
|||||||
|
|
||||||
// Sets callback listener for wifi dialog.
|
// Sets callback listener for wifi dialog.
|
||||||
mWifiDialogListeners.add(mWifiDetailPreferenceController2);
|
mWifiDialogListeners.add(mWifiDetailPreferenceController2);
|
||||||
mWifiDialogListeners.add(privacyController2);
|
|
||||||
mWifiDialogListeners.add(meteredPreferenceController2);
|
|
||||||
|
|
||||||
return mControllers;
|
return mControllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSubmit(WifiDialog2 dialog) {
|
public void onSubmit(@NonNull WifiDialog2 dialog) {
|
||||||
for (WifiDialog2.WifiDialog2Listener listener : mWifiDialogListeners) {
|
for (WifiDialog2.WifiDialog2Listener listener : mWifiDialogListeners) {
|
||||||
listener.onSubmit(dialog);
|
listener.onSubmit(dialog);
|
||||||
}
|
}
|
||||||
|
@@ -18,26 +18,23 @@ package com.android.settings.wifi.details2;
|
|||||||
|
|
||||||
import android.app.backup.BackupManager;
|
import android.app.backup.BackupManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.wifi.WifiConfiguration;
|
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.wifi.WifiDialog2;
|
|
||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A controller that controls whether the Wi-Fi network is metered or not.
|
* A controller that controls whether the Wi-Fi network is metered or not.
|
||||||
*/
|
*/
|
||||||
public class WifiMeteredPreferenceController2 extends BasePreferenceController implements
|
public class WifiMeteredPreferenceController2 extends BasePreferenceController implements
|
||||||
Preference.OnPreferenceChangeListener, WifiDialog2.WifiDialog2Listener {
|
Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
private static final String KEY_WIFI_METERED = "metered";
|
private static final String KEY_WIFI_METERED = "metered";
|
||||||
private final WifiEntry mWifiEntry;
|
private final WifiEntry mWifiEntry;
|
||||||
private Preference mPreference;
|
|
||||||
|
|
||||||
public WifiMeteredPreferenceController2(Context context, WifiEntry wifiEntry) {
|
public WifiMeteredPreferenceController2(Context context, WifiEntry wifiEntry) {
|
||||||
super(context, KEY_WIFI_METERED);
|
super(context, KEY_WIFI_METERED);
|
||||||
@@ -59,7 +56,7 @@ public class WifiMeteredPreferenceController2 extends BasePreferenceController i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
|
||||||
if (mWifiEntry.isSaved() || mWifiEntry.isSubscription()) {
|
if (mWifiEntry.isSaved() || mWifiEntry.isSubscription()) {
|
||||||
mWifiEntry.setMeteredChoice(Integer.parseInt((String) newValue));
|
mWifiEntry.setMeteredChoice(Integer.parseInt((String) newValue));
|
||||||
}
|
}
|
||||||
@@ -82,36 +79,4 @@ public class WifiMeteredPreferenceController2 extends BasePreferenceController i
|
|||||||
private void updateSummary(ListPreference preference, int meteredOverride) {
|
private void updateSummary(ListPreference preference, int meteredOverride) {
|
||||||
preference.setSummary(preference.getEntries()[meteredOverride]);
|
preference.setSummary(preference.getEntries()[meteredOverride]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
|
||||||
super.displayPreference(screen);
|
|
||||||
mPreference = screen.findPreference(getPreferenceKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSubmit(WifiDialog2 dialog) {
|
|
||||||
if (dialog.getController() != null && mWifiEntry.canSetMeteredChoice()) {
|
|
||||||
final WifiConfiguration newConfig = dialog.getController().getConfig();
|
|
||||||
if (newConfig == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getWifiEntryMeteredChoice(newConfig) != mWifiEntry.getMeteredChoice()) {
|
|
||||||
mWifiEntry.setMeteredChoice(getWifiEntryMeteredChoice(newConfig));
|
|
||||||
onPreferenceChange(mPreference, String.valueOf(newConfig.meteredOverride));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getWifiEntryMeteredChoice(WifiConfiguration wifiConfiguration) {
|
|
||||||
switch (wifiConfiguration.meteredOverride) {
|
|
||||||
case WifiConfiguration.METERED_OVERRIDE_METERED:
|
|
||||||
return WifiEntry.METERED_CHOICE_METERED;
|
|
||||||
case WifiConfiguration.METERED_OVERRIDE_NOT_METERED:
|
|
||||||
return WifiEntry.METERED_CHOICE_UNMETERED;
|
|
||||||
default:
|
|
||||||
return WifiEntry.METERED_CHOICE_AUTO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -17,29 +17,26 @@
|
|||||||
package com.android.settings.wifi.details2;
|
package com.android.settings.wifi.details2;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.wifi.WifiConfiguration;
|
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.wifi.WifiDialog2;
|
|
||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A controller that controls whether the Wi-Fi network is mac randomized or not.
|
* A controller that controls whether the Wi-Fi network is mac randomized or not.
|
||||||
*/
|
*/
|
||||||
public class WifiPrivacyPreferenceController2 extends BasePreferenceController implements
|
public class WifiPrivacyPreferenceController2 extends BasePreferenceController implements
|
||||||
Preference.OnPreferenceChangeListener, WifiDialog2.WifiDialog2Listener {
|
Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
private static final String KEY_WIFI_PRIVACY = "privacy";
|
private static final String KEY_WIFI_PRIVACY = "privacy";
|
||||||
private final WifiManager mWifiManager;
|
private final WifiManager mWifiManager;
|
||||||
private WifiEntry mWifiEntry;
|
private WifiEntry mWifiEntry;
|
||||||
private Preference mPreference;
|
|
||||||
|
|
||||||
public WifiPrivacyPreferenceController2(Context context) {
|
public WifiPrivacyPreferenceController2(Context context) {
|
||||||
super(context, KEY_WIFI_PRIVACY);
|
super(context, KEY_WIFI_PRIVACY);
|
||||||
@@ -57,12 +54,6 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
|
|||||||
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
|
||||||
super.displayPreference(screen);
|
|
||||||
mPreference = screen.findPreference(getPreferenceKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
final ListPreference listPreference = (ListPreference) preference;
|
final ListPreference listPreference = (ListPreference) preference;
|
||||||
@@ -79,7 +70,7 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
|
||||||
final int privacy = Integer.parseInt((String) newValue);
|
final int privacy = Integer.parseInt((String) newValue);
|
||||||
mWifiEntry.setPrivacy(privacy);
|
mWifiEntry.setPrivacy(privacy);
|
||||||
|
|
||||||
@@ -128,30 +119,4 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
|
|||||||
final int prefMacRandomized = translateMacRandomizedValueToPrefValue(macRandomized);
|
final int prefMacRandomized = translateMacRandomizedValueToPrefValue(macRandomized);
|
||||||
preference.setSummary(preference.getEntries()[prefMacRandomized]);
|
preference.setSummary(preference.getEntries()[prefMacRandomized]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSubmit(WifiDialog2 dialog) {
|
|
||||||
if (dialog.getController() != null) {
|
|
||||||
final WifiConfiguration newConfig = dialog.getController().getConfig();
|
|
||||||
if (newConfig == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getWifiEntryPrivacy(newConfig) != mWifiEntry.getPrivacy()) {
|
|
||||||
mWifiEntry.setPrivacy(getWifiEntryPrivacy(newConfig));
|
|
||||||
onPreferenceChange(mPreference, String.valueOf(newConfig.macRandomizationSetting));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getWifiEntryPrivacy(WifiConfiguration wifiConfiguration) {
|
|
||||||
switch (wifiConfiguration.macRandomizationSetting) {
|
|
||||||
case WifiConfiguration.RANDOMIZATION_NONE:
|
|
||||||
return WifiEntry.PRIVACY_DEVICE_MAC;
|
|
||||||
case WifiConfiguration.RANDOMIZATION_PERSISTENT:
|
|
||||||
return WifiEntry.PRIVACY_RANDOMIZED_MAC;
|
|
||||||
default:
|
|
||||||
return WifiEntry.PRIVACY_UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -53,7 +53,6 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.network.SubscriptionUtil;
|
import com.android.settings.network.SubscriptionUtil;
|
||||||
import com.android.settings.testutils.shadow.ShadowConnectivityManager;
|
|
||||||
import com.android.settings.utils.AndroidKeystoreAliasLoader;
|
import com.android.settings.utils.AndroidKeystoreAliasLoader;
|
||||||
import com.android.settings.wifi.details2.WifiPrivacyPreferenceController2;
|
import com.android.settings.wifi.details2.WifiPrivacyPreferenceController2;
|
||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
@@ -69,7 +68,6 @@ import org.mockito.MockitoAnnotations;
|
|||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.Shadows;
|
import org.robolectric.Shadows;
|
||||||
import org.robolectric.annotation.Config;
|
|
||||||
import org.robolectric.shadows.ShadowInputMethodManager;
|
import org.robolectric.shadows.ShadowInputMethodManager;
|
||||||
import org.robolectric.shadows.ShadowSubscriptionManager;
|
import org.robolectric.shadows.ShadowSubscriptionManager;
|
||||||
|
|
||||||
@@ -79,7 +77,6 @@ import java.util.stream.Collectors;
|
|||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = ShadowConnectivityManager.class)
|
|
||||||
public class WifiConfigController2Test {
|
public class WifiConfigController2Test {
|
||||||
|
|
||||||
static final String WIFI_EAP_TLS_V1_3 = "TLS v1.3";
|
static final String WIFI_EAP_TLS_V1_3 = "TLS v1.3";
|
||||||
@@ -138,6 +135,7 @@ public class WifiConfigController2Test {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
when(mContext.getSystemService(eq(WifiManager.class))).thenReturn(mWifiManager);
|
when(mContext.getSystemService(eq(WifiManager.class))).thenReturn(mWifiManager);
|
||||||
|
when(mWifiManager.isConnectedMacRandomizationSupported()).thenReturn(true);
|
||||||
when(mConfigUiBase.getContext()).thenReturn(mContext);
|
when(mConfigUiBase.getContext()).thenReturn(mContext);
|
||||||
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_PSK);
|
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_PSK);
|
||||||
mView = LayoutInflater.from(mContext).inflate(R.layout.wifi_dialog, null);
|
mView = LayoutInflater.from(mContext).inflate(R.layout.wifi_dialog, null);
|
||||||
@@ -152,15 +150,17 @@ public class WifiConfigController2Test {
|
|||||||
ipSettingsSpinner.setSelection(DHCP);
|
ipSettingsSpinner.setSelection(DHCP);
|
||||||
mShadowSubscriptionManager = shadowOf(mContext.getSystemService(SubscriptionManager.class));
|
mShadowSubscriptionManager = shadowOf(mContext.getSystemService(SubscriptionManager.class));
|
||||||
when(mEapMethodSimSpinner.getSelectedItemPosition()).thenReturn(WIFI_EAP_METHOD_SIM);
|
when(mEapMethodSimSpinner.getSelectedItemPosition()).thenReturn(WIFI_EAP_METHOD_SIM);
|
||||||
|
}
|
||||||
|
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
private void createController(
|
||||||
WifiConfigUiBase2.MODE_CONNECT);
|
WifiEntry mWifiEntry, int modeConnect, boolean hideMeteredAndPrivacy) {
|
||||||
|
mController = new WifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
||||||
|
modeConnect, hideMeteredAndPrivacy, mWifiManager, mAndroidKeystoreAliasLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ssidExceeds32Bytes_shouldShowSsidTooLongWarning() {
|
public void ssidExceeds32Bytes_shouldShowSsidTooLongWarning() {
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
|
createController(null, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
WifiConfigUiBase2.MODE_CONNECT);
|
|
||||||
final TextView ssid = mView.findViewById(R.id.ssid);
|
final TextView ssid = mView.findViewById(R.id.ssid);
|
||||||
assertThat(ssid).isNotNull();
|
assertThat(ssid).isNotNull();
|
||||||
ssid.setText("☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎");
|
ssid.setText("☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎");
|
||||||
@@ -172,8 +172,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ssidShorterThan32Bytes_shouldNotShowSsidTooLongWarning() {
|
public void ssidShorterThan32Bytes_shouldNotShowSsidTooLongWarning() {
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
|
createController(null, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
WifiConfigUiBase2.MODE_CONNECT);
|
|
||||||
|
|
||||||
final TextView ssid = mView.findViewById(R.id.ssid);
|
final TextView ssid = mView.findViewById(R.id.ssid);
|
||||||
assertThat(ssid).isNotNull();
|
assertThat(ssid).isNotNull();
|
||||||
@@ -192,6 +191,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSubmittable_noSSID_shouldReturnFalse() {
|
public void isSubmittable_noSSID_shouldReturnFalse() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final TextView ssid = mView.findViewById(R.id.ssid);
|
final TextView ssid = mView.findViewById(R.id.ssid);
|
||||||
assertThat(ssid).isNotNull();
|
assertThat(ssid).isNotNull();
|
||||||
ssid.setText("");
|
ssid.setText("");
|
||||||
@@ -200,6 +200,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSubmittable_longPsk_shouldReturnFalse() {
|
public void isSubmittable_longPsk_shouldReturnFalse() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final TextView password = mView.findViewById(R.id.password);
|
final TextView password = mView.findViewById(R.id.password);
|
||||||
assertThat(password).isNotNull();
|
assertThat(password).isNotNull();
|
||||||
password.setText(LONG_PSK);
|
password.setText(LONG_PSK);
|
||||||
@@ -208,6 +209,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSubmittable_shortPsk_shouldReturnFalse() {
|
public void isSubmittable_shortPsk_shouldReturnFalse() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final TextView password = mView.findViewById(R.id.password);
|
final TextView password = mView.findViewById(R.id.password);
|
||||||
assertThat(password).isNotNull();
|
assertThat(password).isNotNull();
|
||||||
password.setText(SHORT_PSK);
|
password.setText(SHORT_PSK);
|
||||||
@@ -216,6 +218,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSubmittable_goodPsk_shouldReturnTrue() {
|
public void isSubmittable_goodPsk_shouldReturnTrue() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final TextView password = mView.findViewById(R.id.password);
|
final TextView password = mView.findViewById(R.id.password);
|
||||||
assertThat(password).isNotNull();
|
assertThat(password).isNotNull();
|
||||||
password.setText(GOOD_PSK);
|
password.setText(GOOD_PSK);
|
||||||
@@ -224,6 +227,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSubmittable_hexPsk_shouldReturnTrue() {
|
public void isSubmittable_hexPsk_shouldReturnTrue() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final TextView password = mView.findViewById(R.id.password);
|
final TextView password = mView.findViewById(R.id.password);
|
||||||
assertThat(password).isNotNull();
|
assertThat(password).isNotNull();
|
||||||
password.setText(HEX_PSK);
|
password.setText(HEX_PSK);
|
||||||
@@ -232,6 +236,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSubmittable_savedConfigZeroLengthPassword_shouldReturnTrue() {
|
public void isSubmittable_savedConfigZeroLengthPassword_shouldReturnTrue() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final TextView password = mView.findViewById(R.id.password);
|
final TextView password = mView.findViewById(R.id.password);
|
||||||
assertThat(password).isNotNull();
|
assertThat(password).isNotNull();
|
||||||
password.setText("");
|
password.setText("");
|
||||||
@@ -241,15 +246,13 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSubmittable_nullWifiEntry_noException() {
|
public void isSubmittable_nullWifiEntry_noException() {
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null,
|
createController(null, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
WifiConfigUiBase2.MODE_CONNECT);
|
|
||||||
mController.isSubmittable();
|
mController.isSubmittable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSubmittable_EapToPskWithValidPassword_shouldReturnTrue() {
|
public void isSubmittable_EapToPskWithValidPassword_shouldReturnTrue() {
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null,
|
createController(null, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
WifiConfigUiBase2.MODE_CONNECT);
|
|
||||||
final TextView ssid = mView.findViewById(R.id.ssid);
|
final TextView ssid = mView.findViewById(R.id.ssid);
|
||||||
final TextView password = mView.findViewById(R.id.password);
|
final TextView password = mView.findViewById(R.id.password);
|
||||||
final Spinner securitySpinner = mView.findViewById(R.id.security);
|
final Spinner securitySpinner = mView.findViewById(R.id.security);
|
||||||
@@ -268,6 +271,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSubmittable_EapWithAkaMethod_shouldReturnTrue() {
|
public void isSubmittable_EapWithAkaMethod_shouldReturnTrue() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
when(mWifiEntry.isSaved()).thenReturn(true);
|
when(mWifiEntry.isSaved()).thenReturn(true);
|
||||||
mController.mWifiEntrySecurity = WifiEntry.SECURITY_EAP;
|
mController.mWifiEntrySecurity = WifiEntry.SECURITY_EAP;
|
||||||
mView.findViewById(R.id.l_ca_cert).setVisibility(View.GONE);
|
mView.findViewById(R.id.l_ca_cert).setVisibility(View.GONE);
|
||||||
@@ -278,8 +282,7 @@ public class WifiConfigController2Test {
|
|||||||
@Test
|
@Test
|
||||||
public void isSubmittable_caCertWithoutDomain_shouldReturnFalse() {
|
public void isSubmittable_caCertWithoutDomain_shouldReturnFalse() {
|
||||||
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
|
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
WifiConfigUiBase2.MODE_CONNECT);
|
|
||||||
mView.findViewById(R.id.l_ca_cert).setVisibility(View.VISIBLE);
|
mView.findViewById(R.id.l_ca_cert).setVisibility(View.VISIBLE);
|
||||||
final Spinner eapCaCertSpinner = mView.findViewById(R.id.ca_cert);
|
final Spinner eapCaCertSpinner = mView.findViewById(R.id.ca_cert);
|
||||||
eapCaCertSpinner.setAdapter(mController.getSpinnerAdapter(new String[]{"certificate"}));
|
eapCaCertSpinner.setAdapter(mController.getSpinnerAdapter(new String[]{"certificate"}));
|
||||||
@@ -292,8 +295,7 @@ public class WifiConfigController2Test {
|
|||||||
@Test
|
@Test
|
||||||
public void isSubmittable_caCertWithDomain_shouldReturnTrue() {
|
public void isSubmittable_caCertWithDomain_shouldReturnTrue() {
|
||||||
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
|
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
WifiConfigUiBase2.MODE_CONNECT);
|
|
||||||
mView.findViewById(R.id.l_ca_cert).setVisibility(View.VISIBLE);
|
mView.findViewById(R.id.l_ca_cert).setVisibility(View.VISIBLE);
|
||||||
final Spinner eapCaCertSpinner = mView.findViewById(R.id.ca_cert);
|
final Spinner eapCaCertSpinner = mView.findViewById(R.id.ca_cert);
|
||||||
eapCaCertSpinner.setAdapter(mController.getSpinnerAdapter(new String[]{"certificate"}));
|
eapCaCertSpinner.setAdapter(mController.getSpinnerAdapter(new String[]{"certificate"}));
|
||||||
@@ -306,6 +308,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSignalString_notReachable_shouldHaveNoSignalString() {
|
public void getSignalString_notReachable_shouldHaveNoSignalString() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
when(mWifiEntry.getLevel()).thenReturn(WifiEntry.WIFI_LEVEL_UNREACHABLE);
|
when(mWifiEntry.getLevel()).thenReturn(WifiEntry.WIFI_LEVEL_UNREACHABLE);
|
||||||
|
|
||||||
assertThat(mController.getSignalString()).isNull();
|
assertThat(mController.getSignalString()).isNull();
|
||||||
@@ -313,6 +316,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void loadCertificates_undesiredCertificates_shouldNotLoadUndesiredCertificates() {
|
public void loadCertificates_undesiredCertificates_shouldNotLoadUndesiredCertificates() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final Spinner spinner = new Spinner(mContext);
|
final Spinner spinner = new Spinner(mContext);
|
||||||
|
|
||||||
mController.loadCertificates(spinner,
|
mController.loadCertificates(spinner,
|
||||||
@@ -326,8 +330,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ssidGetFocus_addNewNetwork_shouldReturnTrue() {
|
public void ssidGetFocus_addNewNetwork_shouldReturnTrue() {
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
|
createController(null, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
WifiConfigUiBase2.MODE_CONNECT);
|
|
||||||
final TextView ssid = mView.findViewById(R.id.ssid);
|
final TextView ssid = mView.findViewById(R.id.ssid);
|
||||||
// Verify ssid text get focus when add new network (wifiEntry is null)
|
// Verify ssid text get focus when add new network (wifiEntry is null)
|
||||||
assertThat(ssid.isFocused()).isTrue();
|
assertThat(ssid.isFocused()).isTrue();
|
||||||
@@ -335,6 +338,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void passwordGetFocus_connectSecureWifi_shouldReturnTrue() {
|
public void passwordGetFocus_connectSecureWifi_shouldReturnTrue() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final TextView password = mView.findViewById(R.id.password);
|
final TextView password = mView.findViewById(R.id.password);
|
||||||
// Verify password get focus when connect to secure wifi without eap type
|
// Verify password get focus when connect to secure wifi without eap type
|
||||||
assertThat(password.isFocused()).isTrue();
|
assertThat(password.isFocused()).isTrue();
|
||||||
@@ -342,6 +346,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void hiddenWarning_warningVisibilityProperlyUpdated() {
|
public void hiddenWarning_warningVisibilityProperlyUpdated() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
View warningView = mView.findViewById(R.id.hidden_settings_warning);
|
View warningView = mView.findViewById(R.id.hidden_settings_warning);
|
||||||
mController.onItemSelected(mHiddenSettingsSpinner, null, mController.HIDDEN_NETWORK, 0);
|
mController.onItemSelected(mHiddenSettingsSpinner, null, mController.HIDDEN_NETWORK, 0);
|
||||||
assertThat(warningView.getVisibility()).isEqualTo(View.VISIBLE);
|
assertThat(warningView.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
@@ -355,8 +360,7 @@ public class WifiConfigController2Test {
|
|||||||
View hiddenField = mView.findViewById(R.id.hidden_settings_field);
|
View hiddenField = mView.findViewById(R.id.hidden_settings_field);
|
||||||
assertThat(hiddenField.getVisibility()).isEqualTo(View.GONE);
|
assertThat(hiddenField.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
|
createController(null, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
WifiConfigUiBase2.MODE_CONNECT);
|
|
||||||
assertThat(hiddenField.getVisibility()).isEqualTo(View.VISIBLE);
|
assertThat(hiddenField.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,13 +386,11 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
private void securitySpinnerTestHelper(boolean saeVisible, boolean suitebVisible,
|
private void securitySpinnerTestHelper(boolean saeVisible, boolean suitebVisible,
|
||||||
boolean oweVisible) {
|
boolean oweVisible) {
|
||||||
WifiManager wifiManager = mock(WifiManager.class);
|
when(mWifiManager.isWpa3SaeSupported()).thenReturn(saeVisible);
|
||||||
when(wifiManager.isWpa3SaeSupported()).thenReturn(saeVisible);
|
when(mWifiManager.isWpa3SuiteBSupported()).thenReturn(suitebVisible);
|
||||||
when(wifiManager.isWpa3SuiteBSupported()).thenReturn(suitebVisible);
|
when(mWifiManager.isEnhancedOpenSupported()).thenReturn(oweVisible);
|
||||||
when(wifiManager.isEnhancedOpenSupported()).thenReturn(oweVisible);
|
|
||||||
|
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
|
createController(null, WifiConfigUiBase2.MODE_MODIFY, false);
|
||||||
WifiConfigUiBase2.MODE_MODIFY, wifiManager);
|
|
||||||
|
|
||||||
final Spinner securitySpinner = mView.findViewById(R.id.security);
|
final Spinner securitySpinner = mView.findViewById(R.id.security);
|
||||||
final ArrayAdapter<String> adapter = (ArrayAdapter) securitySpinner.getAdapter();
|
final ArrayAdapter<String> adapter = (ArrayAdapter) securitySpinner.getAdapter();
|
||||||
@@ -431,23 +433,22 @@ public class WifiConfigController2Test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TestWifiConfigController2 extends WifiConfigController2 {
|
@Test
|
||||||
|
public void whenHideMeteredAndPrivacy_shouldHideMetered() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, true);
|
||||||
|
|
||||||
private TestWifiConfigController2(
|
View view = mView.findViewById(R.id.metered_settings_fields);
|
||||||
WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry, int mode) {
|
|
||||||
super(parent, view, wifiEntry, mode, mWifiManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TestWifiConfigController2(
|
assertThat(view.getVisibility()).isEqualTo(View.GONE);
|
||||||
WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry, int mode,
|
}
|
||||||
WifiManager wifiManager) {
|
|
||||||
super(parent, view, wifiEntry, mode, wifiManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Test
|
||||||
AndroidKeystoreAliasLoader getAndroidKeystoreAliasLoader() {
|
public void whenHideMeteredAndPrivacy_shouldHidePrivacy() {
|
||||||
return mAndroidKeystoreAliasLoader;
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, true);
|
||||||
}
|
|
||||||
|
View view = mView.findViewById(R.id.privacy_settings_fields);
|
||||||
|
|
||||||
|
assertThat(view.getVisibility()).isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -477,8 +478,7 @@ public class WifiConfigController2Test {
|
|||||||
when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class));
|
when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class));
|
||||||
when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig);
|
when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig);
|
||||||
mockWifiConfig.macRandomizationSetting = macRandomizedValue;
|
mockWifiConfig.macRandomizationSetting = macRandomizedValue;
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
WifiConfigUiBase2.MODE_CONNECT);
|
|
||||||
|
|
||||||
final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
|
final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
|
||||||
final int expectedPrefValue =
|
final int expectedPrefValue =
|
||||||
@@ -491,6 +491,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void saveMacRandomizedValue_noChanged_shouldPersistentAsDefault() {
|
public void saveMacRandomizedValue_noChanged_shouldPersistentAsDefault() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
WifiConfiguration config = mController.getConfig();
|
WifiConfiguration config = mController.getConfig();
|
||||||
assertThat(config.macRandomizationSetting).isEqualTo(
|
assertThat(config.macRandomizationSetting).isEqualTo(
|
||||||
WifiConfiguration.RANDOMIZATION_PERSISTENT);
|
WifiConfiguration.RANDOMIZATION_PERSISTENT);
|
||||||
@@ -498,6 +499,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void saveMacRandomizedValue_ChangedToNone_shouldGetNone() {
|
public void saveMacRandomizedValue_ChangedToNone_shouldGetNone() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
|
final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
|
||||||
final int prefMacNone =
|
final int prefMacNone =
|
||||||
WifiPrivacyPreferenceController2.translateMacRandomizedValueToPrefValue(
|
WifiPrivacyPreferenceController2.translateMacRandomizedValueToPrefValue(
|
||||||
@@ -510,6 +512,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void replaceTtsString_whenTargetMatched_shouldSuccess() {
|
public void replaceTtsString_whenTargetMatched_shouldSuccess() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final CharSequence[] display = {"PEAP", "AKA1", "AKA2'"};
|
final CharSequence[] display = {"PEAP", "AKA1", "AKA2'"};
|
||||||
final CharSequence[] target = {"AKA1", "AKA2'"};
|
final CharSequence[] target = {"AKA1", "AKA2'"};
|
||||||
final CharSequence[] ttsString = {"AKA1_TTS", "AKA2_TTS"};
|
final CharSequence[] ttsString = {"AKA1_TTS", "AKA2_TTS"};
|
||||||
@@ -524,6 +527,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void replaceTtsString_whenNoTargetStringMatched_originalStringShouldNotChanged() {
|
public void replaceTtsString_whenNoTargetStringMatched_originalStringShouldNotChanged() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final CharSequence[] display = {"PEAP", "AKA1", "AKA2"};
|
final CharSequence[] display = {"PEAP", "AKA1", "AKA2"};
|
||||||
final CharSequence[] target = {"WEP1", "WEP2'"};
|
final CharSequence[] target = {"WEP1", "WEP2'"};
|
||||||
final CharSequence[] ttsString = {"WEP1_TTS", "WEP2_TTS"};
|
final CharSequence[] ttsString = {"WEP1_TTS", "WEP2_TTS"};
|
||||||
@@ -549,10 +553,8 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectSecurity_wpa3Eap192bit_eapMethodTls() {
|
public void selectSecurity_wpa3Eap192bit_eapMethodTls() {
|
||||||
final WifiManager wifiManager = mock(WifiManager.class);
|
when(mWifiManager.isWpa3SuiteBSupported()).thenReturn(true);
|
||||||
when(wifiManager.isWpa3SuiteBSupported()).thenReturn(true);
|
createController(null, WifiConfigUiBase2.MODE_MODIFY, false);
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
|
|
||||||
WifiConfigUiBase2.MODE_MODIFY, wifiManager);
|
|
||||||
final Spinner securitySpinner = mView.findViewById(R.id.security);
|
final Spinner securitySpinner = mView.findViewById(R.id.security);
|
||||||
final Spinner eapMethodSpinner = mView.findViewById(R.id.method);
|
final Spinner eapMethodSpinner = mView.findViewById(R.id.method);
|
||||||
int wpa3Eap192bitPosition = -1;
|
int wpa3Eap192bitPosition = -1;
|
||||||
@@ -573,6 +575,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkImeStatus_whenAdvancedToggled_shouldBeHide() {
|
public void checkImeStatus_whenAdvancedToggled_shouldBeHide() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final InputMethodManager inputMethodManager = mContext
|
final InputMethodManager inputMethodManager = mContext
|
||||||
.getSystemService(InputMethodManager.class);
|
.getSystemService(InputMethodManager.class);
|
||||||
final ShadowInputMethodManager shadowImm = Shadows.shadowOf(inputMethodManager);
|
final ShadowInputMethodManager shadowImm = Shadows.shadowOf(inputMethodManager);
|
||||||
@@ -586,6 +589,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectEapMethod_savedWifiEntry_shouldGetCorrectPosition() {
|
public void selectEapMethod_savedWifiEntry_shouldGetCorrectPosition() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
setUpModifyingSavedPeapConfigController();
|
setUpModifyingSavedPeapConfigController();
|
||||||
final Spinner eapMethodSpinner = mView.findViewById(R.id.method);
|
final Spinner eapMethodSpinner = mView.findViewById(R.id.method);
|
||||||
final Spinner phase2Spinner = mView.findViewById(R.id.phase2);
|
final Spinner phase2Spinner = mView.findViewById(R.id.phase2);
|
||||||
@@ -630,6 +634,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getWepConfig_withNumberAndCharacterKey_shouldContainTheSameKey() {
|
public void getWepConfig_withNumberAndCharacterKey_shouldContainTheSameKey() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final TextView password = mView.findViewById(R.id.password);
|
final TextView password = mView.findViewById(R.id.password);
|
||||||
password.setText(NUMBER_AND_CHARACTER_KEY);
|
password.setText(NUMBER_AND_CHARACTER_KEY);
|
||||||
mController.mWifiEntrySecurity = WifiEntry.SECURITY_WEP;
|
mController.mWifiEntrySecurity = WifiEntry.SECURITY_WEP;
|
||||||
@@ -641,6 +646,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getWepConfig_withPartialNumberAndCharacterKey_shouldContainDifferentKey() {
|
public void getWepConfig_withPartialNumberAndCharacterKey_shouldContainDifferentKey() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final TextView password = mView.findViewById(R.id.password);
|
final TextView password = mView.findViewById(R.id.password);
|
||||||
password.setText(PARTIAL_NUMBER_AND_CHARACTER_KEY);
|
password.setText(PARTIAL_NUMBER_AND_CHARACTER_KEY);
|
||||||
mController.mWifiEntrySecurity = WifiEntry.SECURITY_WEP;
|
mController.mWifiEntrySecurity = WifiEntry.SECURITY_WEP;
|
||||||
@@ -652,6 +658,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getPskConfig_withValidHexKey_shouldContainTheSameKey() {
|
public void getPskConfig_withValidHexKey_shouldContainTheSameKey() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final TextView password = mView.findViewById(R.id.password);
|
final TextView password = mView.findViewById(R.id.password);
|
||||||
password.setText(VALID_HEX_PSK);
|
password.setText(VALID_HEX_PSK);
|
||||||
mController.mWifiEntrySecurity = WifiEntry.SECURITY_PSK;
|
mController.mWifiEntrySecurity = WifiEntry.SECURITY_PSK;
|
||||||
@@ -663,6 +670,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getPskConfig_withInvalidHexKey_shouldContainDifferentKey() {
|
public void getPskConfig_withInvalidHexKey_shouldContainDifferentKey() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
final TextView password = mView.findViewById(R.id.password);
|
final TextView password = mView.findViewById(R.id.password);
|
||||||
password.setText(INVALID_HEX_PSK);
|
password.setText(INVALID_HEX_PSK);
|
||||||
mController.mWifiEntrySecurity = WifiEntry.SECURITY_PSK;
|
mController.mWifiEntrySecurity = WifiEntry.SECURITY_PSK;
|
||||||
@@ -674,6 +682,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEapConfig_withPhase2Gtc_shouldContainGtcMethod() {
|
public void getEapConfig_withPhase2Gtc_shouldContainGtcMethod() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
setUpModifyingSavedPeapConfigController();
|
setUpModifyingSavedPeapConfigController();
|
||||||
|
|
||||||
// Test EAP method PEAP
|
// Test EAP method PEAP
|
||||||
@@ -691,6 +700,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEapConfig_withPhase2Sim_shouldContainSimMethod() {
|
public void getEapConfig_withPhase2Sim_shouldContainSimMethod() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
setUpModifyingSavedPeapConfigController();
|
setUpModifyingSavedPeapConfigController();
|
||||||
|
|
||||||
// Test EAP method PEAP
|
// Test EAP method PEAP
|
||||||
@@ -708,6 +718,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEapConfig_withPhase2Aka_shouldContainAkaMethod() {
|
public void getEapConfig_withPhase2Aka_shouldContainAkaMethod() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
setUpModifyingSavedPeapConfigController();
|
setUpModifyingSavedPeapConfigController();
|
||||||
|
|
||||||
// Test EAP method PEAP
|
// Test EAP method PEAP
|
||||||
@@ -725,6 +736,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEapConfig_withPhase2AkaPrime_shouldContainAkaPrimeMethod() {
|
public void getEapConfig_withPhase2AkaPrime_shouldContainAkaPrimeMethod() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
setUpModifyingSavedPeapConfigController();
|
setUpModifyingSavedPeapConfigController();
|
||||||
|
|
||||||
// Test EAP method PEAP
|
// Test EAP method PEAP
|
||||||
@@ -743,6 +755,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEapConfig_withPeapPhase2Unknown_shouldContainNoneMethod() {
|
public void getEapConfig_withPeapPhase2Unknown_shouldContainNoneMethod() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
setUpModifyingSavedPeapConfigController();
|
setUpModifyingSavedPeapConfigController();
|
||||||
|
|
||||||
// Test EAP method PEAP
|
// Test EAP method PEAP
|
||||||
@@ -760,6 +773,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEapConfig_withTTLSPhase2Pap_shouldContainPapMethod() {
|
public void getEapConfig_withTTLSPhase2Pap_shouldContainPapMethod() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
setUpModifyingSavedPeapConfigController();
|
setUpModifyingSavedPeapConfigController();
|
||||||
|
|
||||||
// Test EAP method TTLS
|
// Test EAP method TTLS
|
||||||
@@ -777,6 +791,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEapConfig_withTTLSPhase2Mschap_shouldContainMschapMethod() {
|
public void getEapConfig_withTTLSPhase2Mschap_shouldContainMschapMethod() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
setUpModifyingSavedPeapConfigController();
|
setUpModifyingSavedPeapConfigController();
|
||||||
|
|
||||||
// Test EAP method TTLS
|
// Test EAP method TTLS
|
||||||
@@ -794,6 +809,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEapConfig_withTTLSPhase2Gtc_shouldContainGtcMethod() {
|
public void getEapConfig_withTTLSPhase2Gtc_shouldContainGtcMethod() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
setUpModifyingSavedPeapConfigController();
|
setUpModifyingSavedPeapConfigController();
|
||||||
|
|
||||||
// Test EAP method TTLS
|
// Test EAP method TTLS
|
||||||
@@ -819,15 +835,13 @@ public class WifiConfigController2Test {
|
|||||||
when(mockWifiEnterpriseConfig.getEapMethod()).thenReturn(Eap.PEAP);
|
when(mockWifiEnterpriseConfig.getEapMethod()).thenReturn(Eap.PEAP);
|
||||||
mockWifiConfig.enterpriseConfig = mockWifiEnterpriseConfig;
|
mockWifiConfig.enterpriseConfig = mockWifiEnterpriseConfig;
|
||||||
when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig);
|
when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig);
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_MODIFY, false);
|
||||||
WifiConfigUiBase2.MODE_MODIFY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void loadSims_noSim_simSpinnerDefaultNoSim() {
|
public void loadSims_noSim_simSpinnerDefaultNoSim() {
|
||||||
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
|
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
WifiConfigUiBase2.MODE_CONNECT);
|
|
||||||
mController.mEapMethodSpinner = mEapMethodSimSpinner;
|
mController.mEapMethodSpinner = mEapMethodSimSpinner;
|
||||||
|
|
||||||
mController.loadSims();
|
mController.loadSims();
|
||||||
@@ -847,8 +861,7 @@ public class WifiConfigController2Test {
|
|||||||
when(subscriptionInfo.getCarrierName()).thenReturn("FAKE-CARRIER");
|
when(subscriptionInfo.getCarrierName()).thenReturn("FAKE-CARRIER");
|
||||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(subscriptionInfo));
|
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(subscriptionInfo));
|
||||||
mShadowSubscriptionManager.setActiveSubscriptionInfoList(Arrays.asList(subscriptionInfo));
|
mShadowSubscriptionManager.setActiveSubscriptionInfoList(Arrays.asList(subscriptionInfo));
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
WifiConfigUiBase2.MODE_CONNECT);
|
|
||||||
mController.mEapMethodSpinner = mEapMethodSimSpinner;
|
mController.mEapMethodSpinner = mEapMethodSimSpinner;
|
||||||
|
|
||||||
mController.loadSims();
|
mController.loadSims();
|
||||||
@@ -864,8 +877,7 @@ public class WifiConfigController2Test {
|
|||||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
||||||
mShadowSubscriptionManager.setActiveSubscriptionInfoList(Arrays.asList(sub1, sub2));
|
mShadowSubscriptionManager.setActiveSubscriptionInfoList(Arrays.asList(sub1, sub2));
|
||||||
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
|
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
WifiConfigUiBase2.MODE_CONNECT);
|
|
||||||
mController.mEapMethodSpinner = mEapMethodSimSpinner;
|
mController.mEapMethodSpinner = mEapMethodSimSpinner;
|
||||||
ShadowSubscriptionManager.setDefaultDataSubscriptionId(1);
|
ShadowSubscriptionManager.setDefaultDataSubscriptionId(1);
|
||||||
|
|
||||||
@@ -881,8 +893,7 @@ public class WifiConfigController2Test {
|
|||||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
||||||
mShadowSubscriptionManager.setActiveSubscriptionInfoList(Arrays.asList(sub1, sub2));
|
mShadowSubscriptionManager.setActiveSubscriptionInfoList(Arrays.asList(sub1, sub2));
|
||||||
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
|
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
WifiConfigUiBase2.MODE_CONNECT);
|
|
||||||
mController.mEapMethodSpinner = mEapMethodSimSpinner;
|
mController.mEapMethodSpinner = mEapMethodSimSpinner;
|
||||||
ShadowSubscriptionManager.setDefaultDataSubscriptionId(1);
|
ShadowSubscriptionManager.setDefaultDataSubscriptionId(1);
|
||||||
|
|
||||||
@@ -909,6 +920,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onItemSelected_shouldPersistentInstallCertsAndStartInstallActivity() {
|
public void onItemSelected_shouldPersistentInstallCertsAndStartInstallActivity() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
String installCertsString = "install_certs";
|
String installCertsString = "install_certs";
|
||||||
Spinner eapCaCertSpinner = mock(Spinner.class);
|
Spinner eapCaCertSpinner = mock(Spinner.class);
|
||||||
AdapterView view = mock(AdapterView.class);
|
AdapterView view = mock(AdapterView.class);
|
||||||
@@ -950,6 +962,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEapMinTlsVerSpinner_isTlsV13Supported_containsTlsV13() {
|
public void getEapMinTlsVerSpinner_isTlsV13Supported_containsTlsV13() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
Spinner spinner = mController.getEapMinTlsVerSpinner(true /* isTlsV13Supported */);
|
Spinner spinner = mController.getEapMinTlsVerSpinner(true /* isTlsV13Supported */);
|
||||||
|
|
||||||
List<Object> list = IntStream.range(0, spinner.getAdapter().getCount())
|
List<Object> list = IntStream.range(0, spinner.getAdapter().getCount())
|
||||||
@@ -960,6 +973,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEapMinTlsVerSpinner_isNotTlsV13Supported_doesNotContainTlsV13() {
|
public void getEapMinTlsVerSpinner_isNotTlsV13Supported_doesNotContainTlsV13() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
Spinner spinner = mController.getEapMinTlsVerSpinner(false /* isTlsV13Supported */);
|
Spinner spinner = mController.getEapMinTlsVerSpinner(false /* isTlsV13Supported */);
|
||||||
|
|
||||||
List<Object> list = IntStream.range(0, spinner.getAdapter().getCount())
|
List<Object> list = IntStream.range(0, spinner.getAdapter().getCount())
|
||||||
@@ -970,6 +984,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setAnonymousIdVisible_showAnonymousIdAndSetDefaultId() {
|
public void setAnonymousIdVisible_showAnonymousIdAndSetDefaultId() {
|
||||||
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);
|
||||||
View anonymousLayout = mView.findViewById(R.id.l_anonymous);
|
View anonymousLayout = mView.findViewById(R.id.l_anonymous);
|
||||||
TextView anonymousId = mView.findViewById(R.id.anonymous);
|
TextView anonymousId = mView.findViewById(R.id.anonymous);
|
||||||
mController.mEapAnonymousView = anonymousId;
|
mController.mEapAnonymousView = anonymousId;
|
||||||
@@ -1008,8 +1023,7 @@ public class WifiConfigController2Test {
|
|||||||
.thenReturn(ImmutableList.of(savedUserCertificate));
|
.thenReturn(ImmutableList.of(savedUserCertificate));
|
||||||
}
|
}
|
||||||
|
|
||||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
createController(mWifiEntry, WifiConfigUiBase2.MODE_MODIFY, false);
|
||||||
WifiConfigUiBase2.MODE_MODIFY);
|
|
||||||
|
|
||||||
// Because Robolectric has a different behavior from normal flow.
|
// Because Robolectric has a different behavior from normal flow.
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user