Merge "Add support for carrier wifi in UI." into oc-mr1-dev am: f8f6910d7c

am: a0bc09c27d

Change-Id: I8d84e2f5c35312b089da6d9b5f193c29abbb384a
This commit is contained in:
pkanwar
2017-08-04 22:54:24 +00:00
committed by android-build-merger
2 changed files with 48 additions and 2 deletions

View File

@@ -281,11 +281,17 @@ public class WifiConfigController implements TextWatcher,
showProxyFields();
final CheckBox advancedTogglebox =
(CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox);
mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(
mAccessPoint.isCarrierAp() ? View.GONE : View.VISIBLE);
advancedTogglebox.setOnCheckedChangeListener(this);
advancedTogglebox.setChecked(showAdvancedFields);
mView.findViewById(R.id.wifi_advanced_fields)
.setVisibility(showAdvancedFields ? View.VISIBLE : View.GONE);
if (mAccessPoint.isCarrierAp()) {
addRow(group, R.string.wifi_carrier_connect,
String.format(mContext.getString(R.string.wifi_carrier_content),
mAccessPoint.getCarrierName()));
}
}
if (mMode == WifiConfigUiBase.MODE_MODIFY) {
@@ -845,6 +851,10 @@ public class WifiConfigController implements TextWatcher,
mEapIdentityView = (TextView) mView.findViewById(R.id.identity);
mEapAnonymousView = (TextView) mView.findViewById(R.id.anonymous);
if (mAccessPoint.isCarrierAp()) {
mEapMethodSpinner.setSelection(mAccessPoint.getCarrierApEapType());
}
loadCertificates(
mEapCaCertSpinner,
Credentials.CA_CERTIFICATE,
@@ -1012,6 +1022,9 @@ public class WifiConfigController implements TextWatcher,
setUserCertInvisible();
setPasswordInvisible();
setIdentityInvisible();
if (mAccessPoint.isCarrierAp()) {
setEapMethodInvisible();
}
break;
}
@@ -1077,6 +1090,10 @@ public class WifiConfigController implements TextWatcher,
mView.findViewById(R.id.show_password_layout).setVisibility(View.GONE);
}
private void setEapMethodInvisible() {
mView.findViewById(R.id.eap).setVisibility(View.GONE);
}
private void showIpConfigFields() {
WifiConfiguration config = null;

View File

@@ -19,6 +19,7 @@ package com.android.settings.wifi;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Spinner;
import android.widget.TextView;
@@ -37,7 +38,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
@@ -161,6 +162,34 @@ public class WifiConfigControllerTest {
assertThat(mController.getSignalString()).isNull();
}
@Test
public void showForCarrierAp() {
// Setup the mock view for wifi dialog.
View view = mock(View.class);
TextView nameText = mock(TextView.class);
TextView valueText = mock(TextView.class);
when(view.findViewById(R.id.name)).thenReturn(nameText);
when(view.findViewById(R.id.value)).thenReturn(valueText);
LayoutInflater inflater = mock(LayoutInflater.class);
when(inflater.inflate(anyInt(), any(ViewGroup.class), anyBoolean())).thenReturn(view);
when(mConfigUiBase.getLayoutInflater()).thenReturn(inflater);
String carrierName = "Test Carrier";
when(mAccessPoint.isCarrierAp()).thenReturn(true);
when(mAccessPoint.getCarrierName()).thenReturn(carrierName);
mController = new TestWifiConfigController(mConfigUiBase, mView, mAccessPoint,
WifiConfigUiBase.MODE_CONNECT);
// Verify the content of the text fields.
verify(nameText).setText(R.string.wifi_carrier_connect);
verify(valueText).setText(
String.format(mContext.getString(R.string.wifi_carrier_content), carrierName));
// Verify that the advance toggle is not visible.
assertThat(mView.findViewById(R.id.wifi_advanced_toggle).getVisibility())
.isEqualTo(View.GONE);
// Verify that the EAP method menu is not visible.
assertThat(mView.findViewById(R.id.eap).getVisibility()).isEqualTo(View.GONE);
}
public class TestWifiConfigController extends WifiConfigController {
public TestWifiConfigController(WifiConfigUiBase parent, View view,