Loading src/com/android/settings/wifi/WifiConfigController2.java +21 −12 Original line number Diff line number Diff line Loading @@ -232,6 +232,8 @@ public class WifiConfigController2 implements TextWatcher, private final boolean mHideMeteredAndPrivacy; private final WifiManager mWifiManager; private final AndroidKeystoreAliasLoader mAndroidKeystoreAliasLoader; private final boolean mIsMultiUser; private boolean mIsNetworkEditable = true; private TextInputValidator mValidator = new TextInputValidator(); private TextInputGroup mSsidInputGroup; Loading Loading @@ -272,6 +274,10 @@ public class WifiConfigController2 implements TextWatcher, mContext = mConfigUi.getContext(); mWifiManager = wifiManager; mAndroidKeystoreAliasLoader = androidKeystoreAliasLoader; mIsMultiUser = mContext.getSystemService(UserManager.class).getUserCount() > 1; if (mWifiEntry != null) { mIsNetworkEditable = WifiUtils.isNetworkEditable(mWifiEntry, mContext); } initWifiConfigController2(wifiEntry); } Loading @@ -281,8 +287,6 @@ public class WifiConfigController2 implements TextWatcher, wifiEntry.getSecurity(); mIsTrustOnFirstUseSupported = mWifiManager.isTrustOnFirstUseSupported(); UserManager mUserManager = mContext.getSystemService(UserManager.class); final Resources res = mContext.getResources(); mLevels = res.getStringArray(R.array.wifi_signal); Loading Loading @@ -354,12 +358,10 @@ public class WifiConfigController2 implements TextWatcher, (LinearLayout) mView.findViewById(R.id.shared_network_login_screen_warning); if (com.android.settings.connectivity.Flags.wifiMultiuser()) { int userCount = mUserManager.getUserCount(); mView.findViewById(R.id.sharing_toggle_fields) .setVisibility(userCount > 1 ? View.VISIBLE : View.GONE); mEditConfigurationSwitch.setEnabled(false); .setVisibility(mIsMultiUser ? View.VISIBLE : View.GONE); mView.findViewById(R.id.edit_wifi_network_configuration_fields) .setVisibility(userCount > 1 ? View.VISIBLE : View.GONE); .setVisibility(mIsMultiUser ? View.VISIBLE : View.GONE); boolean sharedDefault = mContext.getResources().getBoolean(R.bool.config_share_network_by_default); Loading @@ -368,7 +370,8 @@ public class WifiConfigController2 implements TextWatcher, .getBoolean(R.bool.config_allow_edit_network_configuration_by_default); mSharedSwitch.setChecked(sharedDefault); mEditConfigurationSwitch.setEnabled(sharedDefault); mSharedSwitch.setEnabled(mIsNetworkEditable); mEditConfigurationSwitch.setEnabled(sharedDefault && mIsNetworkEditable); mEditConfigurationSwitch.setChecked(editConfigDefault); mSharedSwitch.setOnCheckedChangeListener(this); Loading Loading @@ -418,11 +421,9 @@ public class WifiConfigController2 implements TextWatcher, } else { mIpSettingsSpinner.setSelection(DHCP); } mIpSettingsSpinner.setEnabled(mIsNetworkEditable); mSharedCheckBox.setEnabled(config.shared); if (!config.shared) { showAdvancedFields = true; } ProxySettings proxySettings = config.getIpConfiguration().getProxySettings(); if (proxySettings == ProxySettings.STATIC) { Loading @@ -434,6 +435,7 @@ public class WifiConfigController2 implements TextWatcher, } else { mProxySettingsSpinner.setSelection(PROXY_NONE); } mProxySettingsSpinner.setEnabled(mIsNetworkEditable); if (config != null && config.isPasspoint()) { addRow(group, R.string.passpoint_label, String.format(mContext.getString(R.string.passpoint_content), Loading Loading @@ -1450,7 +1452,6 @@ public class WifiConfigController2 implements TextWatcher, WifiConfiguration config = null; mView.findViewById(R.id.ip_fields).setVisibility(View.VISIBLE); if (mWifiEntry != null && mWifiEntry.isSaved()) { config = mWifiEntry.getWifiConfiguration(); } Loading @@ -1460,16 +1461,21 @@ public class WifiConfigController2 implements TextWatcher, if (mIpAddressView == null) { mIpAddressView = (TextView) mView.findViewById(R.id.ipaddress); mIpAddressView.addTextChangedListener(this); mIpAddressView.setEnabled(mIsNetworkEditable); mGatewayView = (TextView) mView.findViewById(R.id.gateway); mGatewayView.addTextChangedListener(getIpConfigFieldsTextWatcher(mGatewayView)); mGatewayView.setEnabled(mIsNetworkEditable); mNetworkPrefixLengthView = (TextView) mView.findViewById( R.id.network_prefix_length); mNetworkPrefixLengthView.addTextChangedListener( getIpConfigFieldsTextWatcher(mNetworkPrefixLengthView)); mNetworkPrefixLengthView.setEnabled(mIsNetworkEditable); mDns1View = (TextView) mView.findViewById(R.id.dns1); mDns1View.addTextChangedListener(getIpConfigFieldsTextWatcher(mDns1View)); mDns1View.setEnabled(mIsNetworkEditable); mDns2View = (TextView) mView.findViewById(R.id.dns2); mDns2View.addTextChangedListener(this); mDns2View.setEnabled(mIsNetworkEditable); } if (config != null) { StaticIpConfiguration staticConfig = config.getIpConfiguration() Loading Loading @@ -1504,7 +1510,6 @@ public class WifiConfigController2 implements TextWatcher, WifiConfiguration config = null; mView.findViewById(R.id.proxy_settings_fields).setVisibility(View.VISIBLE); if (mWifiEntry != null && mWifiEntry.isSaved()) { config = mWifiEntry.getWifiConfiguration(); } Loading @@ -1516,10 +1521,13 @@ public class WifiConfigController2 implements TextWatcher, if (mProxyHostView == null) { mProxyHostView = (TextView) mView.findViewById(R.id.proxy_hostname); mProxyHostView.addTextChangedListener(this); mProxyHostView.setEnabled(mIsNetworkEditable); mProxyPortView = (TextView) mView.findViewById(R.id.proxy_port); mProxyPortView.addTextChangedListener(this); mProxyPortView.setEnabled(mIsNetworkEditable); mProxyExclusionListView = (TextView) mView.findViewById(R.id.proxy_exclusionlist); mProxyExclusionListView.addTextChangedListener(this); mProxyExclusionListView.setEnabled(mIsNetworkEditable); } if (config != null) { ProxyInfo proxyProperties = config.getHttpProxy(); Loading @@ -1538,6 +1546,7 @@ public class WifiConfigController2 implements TextWatcher, if (mProxyPacView == null) { mProxyPacView = (TextView) mView.findViewById(R.id.proxy_pac); mProxyPacView.addTextChangedListener(this); mProxyPacView.setEnabled(mIsNetworkEditable); } if (config != null) { ProxyInfo proxyInfo = config.getHttpProxy(); Loading tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java +100 −2 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.net.wifi.WifiManager; import android.os.Looper; import android.os.UserManager; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading @@ -68,11 +69,13 @@ import com.android.wifitrackerlib.WifiEntry; import com.google.common.collect.ImmutableList; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.Shadows; Loading @@ -89,6 +92,11 @@ public class WifiConfigController2Test { static final String WIFI_EAP_TLS_V1_3 = "TLS v1.3"; @Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule(); @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Mock private WifiConfigUiBase2 mConfigUiBase; @Mock Loading Loading @@ -130,6 +138,7 @@ public class WifiConfigController2Test { private static final String NUMBER_AND_CHARACTER_KEY = "123456abcd"; private static final String PARTIAL_NUMBER_AND_CHARACTER_KEY = "123456abc?"; private static final int DHCP = 0; private static final int STATIC_IP = 1; // Saved certificates private static final String SAVED_CA_CERT = "saved CA cert"; private static final String SAVED_USER_CERT = "saved user cert"; Loading @@ -142,7 +151,6 @@ public class WifiConfigController2Test { @Before public void setUp() { MockitoAnnotations.initMocks(this); mContext = spy(RuntimeEnvironment.application); when(mContext.getSystemService(eq(WifiManager.class))).thenReturn(mWifiManager); when(mContext.getSystemService(eq(UserManager.class))).thenReturn(mUserManager); Loading Loading @@ -269,6 +277,96 @@ public class WifiConfigController2Test { assertThat(editConfigFields.getVisibility()).isEqualTo(View.GONE); } @Test @EnableFlags(Flags.FLAG_WIFI_MULTIUSER) public void checkIpSpinnerState_networkNotOwned_multipleUsers() { when(mUserManager.getUserCount()).thenReturn(2); when(mWifiEntry.isSaved()).thenReturn(true); final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration()); when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class)); when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); mockWifiConfig.creatorUid = Integer.MAX_VALUE; createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false); final View ipSettingsSpinner = mView.findViewById(R.id.ip_settings); assertThat(ipSettingsSpinner.isEnabled()).isEqualTo(false); } @Test @EnableFlags(Flags.FLAG_WIFI_MULTIUSER) public void checkIpSpinnerState_networkNotOwned_singleUser() { when(mUserManager.getUserCount()).thenReturn(1); when(mWifiEntry.isSaved()).thenReturn(true); final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration()); when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class)); when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); mockWifiConfig.creatorUid = Integer.MAX_VALUE; createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false); final View ipSettingsSpinner = mView.findViewById(R.id.ip_settings); assertThat(ipSettingsSpinner.isEnabled()).isEqualTo(true); } @Test @EnableFlags(Flags.FLAG_WIFI_MULTIUSER) public void checkIpSpinnerState_networkOwned_multipleUsers() { when(mUserManager.getUserCount()).thenReturn(2); when(mWifiEntry.isSaved()).thenReturn(true); final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration()); when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class)); when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); mockWifiConfig.creatorUid = 1; createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false); final View ipSettingsSpinner = mView.findViewById(R.id.ip_settings); assertThat(ipSettingsSpinner.isEnabled()).isEqualTo(true); } @Test @EnableFlags(Flags.FLAG_WIFI_MULTIUSER) public void checkProxySpinnerState_networkNotOwned_multipleUsers() { when(mUserManager.getUserCount()).thenReturn(2); when(mWifiEntry.isSaved()).thenReturn(true); final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration()); when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class)); when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); mockWifiConfig.creatorUid = Integer.MAX_VALUE; createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false); final View proxySettingsSpinner = mView.findViewById(R.id.proxy_settings); assertThat(proxySettingsSpinner.isEnabled()).isEqualTo(false); } @Test @EnableFlags(Flags.FLAG_WIFI_MULTIUSER) public void checkProxySpinnerState_networkNotOwned_singleUser() { when(mUserManager.getUserCount()).thenReturn(1); when(mWifiEntry.isSaved()).thenReturn(true); final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration()); when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class)); when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); mockWifiConfig.creatorUid = Integer.MAX_VALUE; createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false); final View proxySettingsSpinner = mView.findViewById(R.id.proxy_settings); assertThat(proxySettingsSpinner.isEnabled()).isEqualTo(true); } @Test @EnableFlags(Flags.FLAG_WIFI_MULTIUSER) public void checkProxySpinnerState_networkOwned_multipleUsers() { when(mUserManager.getUserCount()).thenReturn(2); when(mWifiEntry.isSaved()).thenReturn(true); final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration()); when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class)); when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); mockWifiConfig.creatorUid = 1; createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false); final View proxySettingsSpinner = mView.findViewById(R.id.proxy_settings); assertThat(proxySettingsSpinner.isEnabled()).isEqualTo(true); } @Test public void isSubmittable_EapWithAkaMethod_shouldReturnTrue() { createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false); Loading Loading
src/com/android/settings/wifi/WifiConfigController2.java +21 −12 Original line number Diff line number Diff line Loading @@ -232,6 +232,8 @@ public class WifiConfigController2 implements TextWatcher, private final boolean mHideMeteredAndPrivacy; private final WifiManager mWifiManager; private final AndroidKeystoreAliasLoader mAndroidKeystoreAliasLoader; private final boolean mIsMultiUser; private boolean mIsNetworkEditable = true; private TextInputValidator mValidator = new TextInputValidator(); private TextInputGroup mSsidInputGroup; Loading Loading @@ -272,6 +274,10 @@ public class WifiConfigController2 implements TextWatcher, mContext = mConfigUi.getContext(); mWifiManager = wifiManager; mAndroidKeystoreAliasLoader = androidKeystoreAliasLoader; mIsMultiUser = mContext.getSystemService(UserManager.class).getUserCount() > 1; if (mWifiEntry != null) { mIsNetworkEditable = WifiUtils.isNetworkEditable(mWifiEntry, mContext); } initWifiConfigController2(wifiEntry); } Loading @@ -281,8 +287,6 @@ public class WifiConfigController2 implements TextWatcher, wifiEntry.getSecurity(); mIsTrustOnFirstUseSupported = mWifiManager.isTrustOnFirstUseSupported(); UserManager mUserManager = mContext.getSystemService(UserManager.class); final Resources res = mContext.getResources(); mLevels = res.getStringArray(R.array.wifi_signal); Loading Loading @@ -354,12 +358,10 @@ public class WifiConfigController2 implements TextWatcher, (LinearLayout) mView.findViewById(R.id.shared_network_login_screen_warning); if (com.android.settings.connectivity.Flags.wifiMultiuser()) { int userCount = mUserManager.getUserCount(); mView.findViewById(R.id.sharing_toggle_fields) .setVisibility(userCount > 1 ? View.VISIBLE : View.GONE); mEditConfigurationSwitch.setEnabled(false); .setVisibility(mIsMultiUser ? View.VISIBLE : View.GONE); mView.findViewById(R.id.edit_wifi_network_configuration_fields) .setVisibility(userCount > 1 ? View.VISIBLE : View.GONE); .setVisibility(mIsMultiUser ? View.VISIBLE : View.GONE); boolean sharedDefault = mContext.getResources().getBoolean(R.bool.config_share_network_by_default); Loading @@ -368,7 +370,8 @@ public class WifiConfigController2 implements TextWatcher, .getBoolean(R.bool.config_allow_edit_network_configuration_by_default); mSharedSwitch.setChecked(sharedDefault); mEditConfigurationSwitch.setEnabled(sharedDefault); mSharedSwitch.setEnabled(mIsNetworkEditable); mEditConfigurationSwitch.setEnabled(sharedDefault && mIsNetworkEditable); mEditConfigurationSwitch.setChecked(editConfigDefault); mSharedSwitch.setOnCheckedChangeListener(this); Loading Loading @@ -418,11 +421,9 @@ public class WifiConfigController2 implements TextWatcher, } else { mIpSettingsSpinner.setSelection(DHCP); } mIpSettingsSpinner.setEnabled(mIsNetworkEditable); mSharedCheckBox.setEnabled(config.shared); if (!config.shared) { showAdvancedFields = true; } ProxySettings proxySettings = config.getIpConfiguration().getProxySettings(); if (proxySettings == ProxySettings.STATIC) { Loading @@ -434,6 +435,7 @@ public class WifiConfigController2 implements TextWatcher, } else { mProxySettingsSpinner.setSelection(PROXY_NONE); } mProxySettingsSpinner.setEnabled(mIsNetworkEditable); if (config != null && config.isPasspoint()) { addRow(group, R.string.passpoint_label, String.format(mContext.getString(R.string.passpoint_content), Loading Loading @@ -1450,7 +1452,6 @@ public class WifiConfigController2 implements TextWatcher, WifiConfiguration config = null; mView.findViewById(R.id.ip_fields).setVisibility(View.VISIBLE); if (mWifiEntry != null && mWifiEntry.isSaved()) { config = mWifiEntry.getWifiConfiguration(); } Loading @@ -1460,16 +1461,21 @@ public class WifiConfigController2 implements TextWatcher, if (mIpAddressView == null) { mIpAddressView = (TextView) mView.findViewById(R.id.ipaddress); mIpAddressView.addTextChangedListener(this); mIpAddressView.setEnabled(mIsNetworkEditable); mGatewayView = (TextView) mView.findViewById(R.id.gateway); mGatewayView.addTextChangedListener(getIpConfigFieldsTextWatcher(mGatewayView)); mGatewayView.setEnabled(mIsNetworkEditable); mNetworkPrefixLengthView = (TextView) mView.findViewById( R.id.network_prefix_length); mNetworkPrefixLengthView.addTextChangedListener( getIpConfigFieldsTextWatcher(mNetworkPrefixLengthView)); mNetworkPrefixLengthView.setEnabled(mIsNetworkEditable); mDns1View = (TextView) mView.findViewById(R.id.dns1); mDns1View.addTextChangedListener(getIpConfigFieldsTextWatcher(mDns1View)); mDns1View.setEnabled(mIsNetworkEditable); mDns2View = (TextView) mView.findViewById(R.id.dns2); mDns2View.addTextChangedListener(this); mDns2View.setEnabled(mIsNetworkEditable); } if (config != null) { StaticIpConfiguration staticConfig = config.getIpConfiguration() Loading Loading @@ -1504,7 +1510,6 @@ public class WifiConfigController2 implements TextWatcher, WifiConfiguration config = null; mView.findViewById(R.id.proxy_settings_fields).setVisibility(View.VISIBLE); if (mWifiEntry != null && mWifiEntry.isSaved()) { config = mWifiEntry.getWifiConfiguration(); } Loading @@ -1516,10 +1521,13 @@ public class WifiConfigController2 implements TextWatcher, if (mProxyHostView == null) { mProxyHostView = (TextView) mView.findViewById(R.id.proxy_hostname); mProxyHostView.addTextChangedListener(this); mProxyHostView.setEnabled(mIsNetworkEditable); mProxyPortView = (TextView) mView.findViewById(R.id.proxy_port); mProxyPortView.addTextChangedListener(this); mProxyPortView.setEnabled(mIsNetworkEditable); mProxyExclusionListView = (TextView) mView.findViewById(R.id.proxy_exclusionlist); mProxyExclusionListView.addTextChangedListener(this); mProxyExclusionListView.setEnabled(mIsNetworkEditable); } if (config != null) { ProxyInfo proxyProperties = config.getHttpProxy(); Loading @@ -1538,6 +1546,7 @@ public class WifiConfigController2 implements TextWatcher, if (mProxyPacView == null) { mProxyPacView = (TextView) mView.findViewById(R.id.proxy_pac); mProxyPacView.addTextChangedListener(this); mProxyPacView.setEnabled(mIsNetworkEditable); } if (config != null) { ProxyInfo proxyInfo = config.getHttpProxy(); Loading
tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java +100 −2 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.net.wifi.WifiManager; import android.os.Looper; import android.os.UserManager; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading @@ -68,11 +69,13 @@ import com.android.wifitrackerlib.WifiEntry; import com.google.common.collect.ImmutableList; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.Shadows; Loading @@ -89,6 +92,11 @@ public class WifiConfigController2Test { static final String WIFI_EAP_TLS_V1_3 = "TLS v1.3"; @Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule(); @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Mock private WifiConfigUiBase2 mConfigUiBase; @Mock Loading Loading @@ -130,6 +138,7 @@ public class WifiConfigController2Test { private static final String NUMBER_AND_CHARACTER_KEY = "123456abcd"; private static final String PARTIAL_NUMBER_AND_CHARACTER_KEY = "123456abc?"; private static final int DHCP = 0; private static final int STATIC_IP = 1; // Saved certificates private static final String SAVED_CA_CERT = "saved CA cert"; private static final String SAVED_USER_CERT = "saved user cert"; Loading @@ -142,7 +151,6 @@ public class WifiConfigController2Test { @Before public void setUp() { MockitoAnnotations.initMocks(this); mContext = spy(RuntimeEnvironment.application); when(mContext.getSystemService(eq(WifiManager.class))).thenReturn(mWifiManager); when(mContext.getSystemService(eq(UserManager.class))).thenReturn(mUserManager); Loading Loading @@ -269,6 +277,96 @@ public class WifiConfigController2Test { assertThat(editConfigFields.getVisibility()).isEqualTo(View.GONE); } @Test @EnableFlags(Flags.FLAG_WIFI_MULTIUSER) public void checkIpSpinnerState_networkNotOwned_multipleUsers() { when(mUserManager.getUserCount()).thenReturn(2); when(mWifiEntry.isSaved()).thenReturn(true); final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration()); when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class)); when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); mockWifiConfig.creatorUid = Integer.MAX_VALUE; createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false); final View ipSettingsSpinner = mView.findViewById(R.id.ip_settings); assertThat(ipSettingsSpinner.isEnabled()).isEqualTo(false); } @Test @EnableFlags(Flags.FLAG_WIFI_MULTIUSER) public void checkIpSpinnerState_networkNotOwned_singleUser() { when(mUserManager.getUserCount()).thenReturn(1); when(mWifiEntry.isSaved()).thenReturn(true); final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration()); when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class)); when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); mockWifiConfig.creatorUid = Integer.MAX_VALUE; createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false); final View ipSettingsSpinner = mView.findViewById(R.id.ip_settings); assertThat(ipSettingsSpinner.isEnabled()).isEqualTo(true); } @Test @EnableFlags(Flags.FLAG_WIFI_MULTIUSER) public void checkIpSpinnerState_networkOwned_multipleUsers() { when(mUserManager.getUserCount()).thenReturn(2); when(mWifiEntry.isSaved()).thenReturn(true); final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration()); when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class)); when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); mockWifiConfig.creatorUid = 1; createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false); final View ipSettingsSpinner = mView.findViewById(R.id.ip_settings); assertThat(ipSettingsSpinner.isEnabled()).isEqualTo(true); } @Test @EnableFlags(Flags.FLAG_WIFI_MULTIUSER) public void checkProxySpinnerState_networkNotOwned_multipleUsers() { when(mUserManager.getUserCount()).thenReturn(2); when(mWifiEntry.isSaved()).thenReturn(true); final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration()); when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class)); when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); mockWifiConfig.creatorUid = Integer.MAX_VALUE; createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false); final View proxySettingsSpinner = mView.findViewById(R.id.proxy_settings); assertThat(proxySettingsSpinner.isEnabled()).isEqualTo(false); } @Test @EnableFlags(Flags.FLAG_WIFI_MULTIUSER) public void checkProxySpinnerState_networkNotOwned_singleUser() { when(mUserManager.getUserCount()).thenReturn(1); when(mWifiEntry.isSaved()).thenReturn(true); final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration()); when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class)); when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); mockWifiConfig.creatorUid = Integer.MAX_VALUE; createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false); final View proxySettingsSpinner = mView.findViewById(R.id.proxy_settings); assertThat(proxySettingsSpinner.isEnabled()).isEqualTo(true); } @Test @EnableFlags(Flags.FLAG_WIFI_MULTIUSER) public void checkProxySpinnerState_networkOwned_multipleUsers() { when(mUserManager.getUserCount()).thenReturn(2); when(mWifiEntry.isSaved()).thenReturn(true); final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration()); when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class)); when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); mockWifiConfig.creatorUid = 1; createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false); final View proxySettingsSpinner = mView.findViewById(R.id.proxy_settings); assertThat(proxySettingsSpinner.isEnabled()).isEqualTo(true); } @Test public void isSubmittable_EapWithAkaMethod_shouldReturnTrue() { createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false); Loading