Merge "Import translations. DO NOT MERGE ANYWHERE" into tm-qpr-dev
diff --git a/res/values-pt-rPT/arrays.xml b/res/values-pt-rPT/arrays.xml
index b7e7632..1504336 100644
--- a/res/values-pt-rPT/arrays.xml
+++ b/res/values-pt-rPT/arrays.xml
@@ -286,7 +286,7 @@
<item msgid="8321845997769724385">"ler estado do telemóvel"</item>
<item msgid="8319500905789302082">"adicionar correio de voz"</item>
<item msgid="1745447762712473288">"utilizar SIP"</item>
- <item msgid="2986821801246709737">"processar chamada efetuada"</item>
+ <item msgid="2986821801246709737">"processar chamada feita"</item>
<item msgid="2702338156976571452">"impressão digital"</item>
<item msgid="7925495329948404955">"sensores de corpo"</item>
<item msgid="8163066895749904470">"ler difusões celulares"</item>
@@ -353,7 +353,7 @@
<item msgid="973363520315356844">"Ler estado do telemóvel"</item>
<item msgid="1203157739257425062">"Adicionar correio de voz"</item>
<item msgid="9143978647977300187">"Utilizar SIP"</item>
- <item msgid="3053060162752878562">"Processar chamada efetuada"</item>
+ <item msgid="3053060162752878562">"Processar chamada feita"</item>
<item msgid="4480721672278100858">"Impressão digital"</item>
<item msgid="7883743426029759112">"Sensores de corpo"</item>
<item msgid="2546206711741159825">"Ler difusões celulares"</item>
diff --git a/res/values-ro/arrays.xml b/res/values-ro/arrays.xml
index 0e27777..93427b7 100644
--- a/res/values-ro/arrays.xml
+++ b/res/values-ro/arrays.xml
@@ -106,7 +106,7 @@
<!-- no translation found for wifi_tether_security:3 (5512131148045414341) -->
<string-array name="eap_ocsp_type">
<item msgid="8568170800958331461">"Nu verifica"</item>
- <item msgid="5703177653586269306">"Solicitați starea certificatelor"</item>
+ <item msgid="5703177653586269306">"Solicită starea certificatelor"</item>
<item msgid="326388247868439528">"Solicită obligatoriu starea certificatelor"</item>
</string-array>
<string-array name="wifi_p2p_wps_setup">
@@ -272,7 +272,7 @@
<item msgid="5272927168355895681">"volumul alarmei"</item>
<item msgid="4422070755065530548">"volum notificări"</item>
<item msgid="3250654589277825306">"volumul Bluetooth"</item>
- <item msgid="4212187233638382465">"mențineți activ"</item>
+ <item msgid="4212187233638382465">"menține activ"</item>
<item msgid="5099026183238335900">"monitorizarea locației"</item>
<item msgid="2297727967385895059">"monitorizarea localizării cu consum ridicat de energie"</item>
<item msgid="8700593962030471569">"obțineți statistici de utilizare"</item>
@@ -321,7 +321,7 @@
<item msgid="1030342664910454057">"Primește mesaje SMS/MMS"</item>
<item msgid="9189359977063200554">"Trimite mesaje SMS/MMS"</item>
<item msgid="6954817837534799424">"Citește mesaje SMS/MMS"</item>
- <item msgid="7921014514153395846">"Scrieți mesaje SMS/MMS"</item>
+ <item msgid="7921014514153395846">"Scrie mesaje SMS/MMS"</item>
<item msgid="8997371825401751421">"Modifică setările"</item>
<item msgid="7005755175240764443">"Desenează deasupra"</item>
<item msgid="8267704990417682222">"Accesează notificări"</item>
@@ -509,7 +509,7 @@
<item msgid="2047166446768045816">"Tratează ca fiind necontorizată"</item>
</string-array>
<string-array name="wifi_privacy_entries">
- <item msgid="3485945604919292489">"Folosiți o adresă MAC aleatorie (prestabilit)"</item>
+ <item msgid="3485945604919292489">"Folosește o adresă MAC aleatorie (prestabilit)"</item>
<item msgid="741680937828608749">"Folosește adresa MAC a dispozitivului"</item>
</string-array>
<string-array name="wifi_hidden_entries">
diff --git a/res/xml/bluetooth_device_details_fragment.xml b/res/xml/bluetooth_device_details_fragment.xml
index efb2bf7..0528973 100644
--- a/res/xml/bluetooth_device_details_fragment.xml
+++ b/res/xml/bluetooth_device_details_fragment.xml
@@ -46,6 +46,7 @@
android:key="hearing_aid_pair_other_button"
android:gravity="center" />
<com.android.settings.applications.SpacePreference
+ android:key="hearing_aid_space_layout"
android:layout_height="8dp" />
<com.android.settingslib.widget.ActionButtonsPreference
diff --git a/src/com/android/settings/accessibility/TextReadingPreviewController.java b/src/com/android/settings/accessibility/TextReadingPreviewController.java
index 98767d9..dab57ba 100644
--- a/src/com/android/settings/accessibility/TextReadingPreviewController.java
+++ b/src/com/android/settings/accessibility/TextReadingPreviewController.java
@@ -42,6 +42,8 @@
class TextReadingPreviewController extends BasePreferenceController implements
PreviewSizeSeekBarController.ProgressInteractionListener {
private static final String TAG = "TextReadingPreviewCtrl";
+ private static final int LAYER_INITIAL_INDEX = 0;
+ private static final int FRAME_INITIAL_INDEX = 0;
static final int[] PREVIEW_SAMPLE_RES_IDS = new int[]{
R.layout.accessibility_text_reading_preview_app_grid,
R.layout.screen_zoom_preview_1,
@@ -108,25 +110,15 @@
final PreviewPagerAdapter pagerAdapter = new PreviewPagerAdapter(mContext, isLayoutRtl,
PREVIEW_SAMPLE_RES_IDS, createConfig(origConfig));
mPreviewPreference.setPreviewAdapter(pagerAdapter);
- mPreviewPreference.setCurrentItem(isLayoutRtl ? PREVIEW_SAMPLE_RES_IDS.length - 1 : 0);
- pagerAdapter.setPreviewLayer(/* newLayerIndex= */ 0,
- /* currentLayerIndex= */ 0,
- /* currentFrameIndex= */ 0, /* animate= */ false);
+ mPreviewPreference.setCurrentItem(
+ isLayoutRtl ? PREVIEW_SAMPLE_RES_IDS.length - 1 : FRAME_INITIAL_INDEX);
+ pagerAdapter.setPreviewLayer(getPagerIndex(), LAYER_INITIAL_INDEX,
+ FRAME_INITIAL_INDEX, /* animate= */ false);
}
@Override
public void notifyPreferenceChanged() {
- final int displayDataSize = mDisplaySizeData.getValues().size();
- final int fontSizeProgress = mFontSizePreference.getProgress();
- final int displaySizeProgress = mDisplaySizePreference.getProgress();
-
- // To be consistent with the
- // {@link PreviewPagerAdapter#setPreviewLayer(int, int, int, boolean)} behavior,
- // here also needs the same design. In addition, please also refer to
- // the {@link #createConfig(Configuration)}.
- final int pagerIndex = fontSizeProgress * displayDataSize + displaySizeProgress;
-
- mPreviewPreference.notifyPreviewPagerChanged(pagerIndex);
+ mPreviewPreference.notifyPreviewPagerChanged(getPagerIndex());
}
@Override
@@ -174,6 +166,15 @@
choreographer.postFrameCallbackDelayed(mCommit, commitDelayMs);
}
+ private int getPagerIndex() {
+ final int displayDataSize = mDisplaySizeData.getValues().size();
+
+ // To be consistent with the {@link PreviewPagerAdapter#setPreviewLayer(int, int, int,
+ // boolean)} behavior, here also needs the same design. In addition, please also refer to
+ // the {@link #createConfig(Configuration)}.
+ return mLastFontProgress * displayDataSize + mLastDisplayProgress;
+ }
+
private void tryCommitFontSizeConfig() {
final int fontProgress = mFontSizePreference.getProgress();
if (fontProgress != mLastFontProgress) {
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index 64a08d3..be38f27 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -31,6 +31,7 @@
import android.content.Intent;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
+import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Animatable2;
@@ -63,6 +64,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
+import com.android.settings.SetupWizardUtils;
import com.android.settings.biometrics.BiometricEnrollSidecar;
import com.android.settings.biometrics.BiometricUtils;
import com.android.settings.biometrics.BiometricsEnrollEnrolling;
@@ -213,6 +215,13 @@
}
@Override
+ protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
+ final int newResid = SetupWizardUtils.getTheme(this, getIntent());
+ theme.applyStyle(R.style.SetupWizardPartnerResource, true);
+ super.onApplyThemeResource(theme, newResid, first);
+ }
+
+ @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
index 5c32dff..bb03ee4 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
@@ -18,6 +18,7 @@
import android.app.settings.SettingsEnums;
import android.content.Intent;
+import android.content.res.Resources;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.os.Bundle;
@@ -31,6 +32,7 @@
import androidx.annotation.Nullable;
import com.android.settings.R;
+import com.android.settings.SetupWizardUtils;
import com.android.settings.Utils;
import com.android.settings.biometrics.BiometricEnrollBase;
import com.android.settings.biometrics.BiometricEnrollSidecar;
@@ -211,6 +213,13 @@
super.onBackPressed();
}
+ @Override
+ protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
+ final int newResid = SetupWizardUtils.getTheme(this, getIntent());
+ theme.applyStyle(R.style.SetupWizardPartnerResource, true);
+ super.onApplyThemeResource(theme, newResid, first);
+ }
+
protected int getContentView() {
if (mCanAssumeUdfps) {
return R.layout.udfps_enroll_find_sensor_layout;
diff --git a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
index 1ae5dae..f6b947a 100644
--- a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
@@ -77,7 +77,7 @@
@NonNull
public AlertDialog.Builder onCreateDialogBuilder() {
- return new AlertDialog.Builder(getActivity(), R.style.GlifV2ThemeAlertDialog)
+ return new AlertDialog.Builder(getActivity())
.setTitle(R.string.setup_fingerprint_enroll_skip_title)
.setPositiveButton(R.string.skip_anyway_button_label, this)
.setNegativeButton(R.string.go_back_button_label, this)
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsPairOtherController.java b/src/com/android/settings/bluetooth/BluetoothDetailsPairOtherController.java
index d14a9b1..6710044 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsPairOtherController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsPairOtherController.java
@@ -22,19 +22,25 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.applications.SpacePreference;
import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.HearingAidProfile;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.widget.ButtonPreference;
+import com.google.common.annotations.VisibleForTesting;
+
/**
* This class handles button preference logic to display for hearing aid device.
*/
public class BluetoothDetailsPairOtherController extends BluetoothDetailsController {
private static final String KEY_PAIR_OTHER = "hearing_aid_pair_other_button";
+ @VisibleForTesting
+ static final String KEY_SPACE = "hearing_aid_space_layout";
private ButtonPreference mPreference;
+ private SpacePreference mSpacePreference;
public BluetoothDetailsPairOtherController(Context context,
PreferenceFragmentCompat fragment,
@@ -62,13 +68,20 @@
: R.string.bluetooth_pair_left_ear_button;
mPreference = screen.findPreference(getPreferenceKey());
+ mSpacePreference = screen.findPreference(KEY_SPACE);
mPreference.setTitle(stringRes);
+ setPreferencesVisibility(getButtonPreferenceVisibility(mCachedDevice));
mPreference.setOnClickListener(v -> launchPairingDetail());
}
@Override
protected void refresh() {
- mPreference.setVisible(getButtonPreferenceVisibility(mCachedDevice));
+ setPreferencesVisibility(getButtonPreferenceVisibility(mCachedDevice));
+ }
+
+ private void setPreferencesVisibility(boolean visible) {
+ mPreference.setVisible(visible);
+ mSpacePreference.setVisible(visible);
}
private boolean getButtonPreferenceVisibility(CachedBluetoothDevice cachedDevice) {
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
index 2c864d6..2dfcee2 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
@@ -17,6 +17,7 @@
package com.android.settings.biometrics.fingerprint;
import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_POWER_BUTTON;
+import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_OPTICAL;
import static com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling.KEY_STATE_PREVIOUS_ROTATION;
import static com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling.SFPS_STAGE_NO_ANIMATION;
@@ -37,6 +38,7 @@
import android.content.Context;
import android.content.res.ColorStateList;
+import android.content.res.Resources;
import android.hardware.biometrics.ComponentInfoInternal;
import android.hardware.biometrics.SensorProperties;
import android.hardware.fingerprint.FingerprintManager;
@@ -84,6 +86,8 @@
@Mock private Display mMockDisplay;
+ @Mock private Resources.Theme mTheme;
+
private final int[] mSfpsStageThresholds = new int[]{0, 9, 13, 19, 25};
private FingerprintEnrollEnrolling mActivity;
@@ -110,7 +114,7 @@
@Test
public void fingerprintUdfpsEnrollSuccessProgress_shouldNotVibrate() {
- initializeActivityFor(FingerprintSensorProperties.TYPE_UDFPS_OPTICAL);
+ initializeActivityFor(TYPE_UDFPS_OPTICAL);
mActivity.onEnrollmentProgressChange(1, 1);
@@ -128,7 +132,7 @@
@Test
public void fingerprintUdfpsOverlayEnrollment_gainFocus_shouldNotCancel() {
- initializeActivityFor(FingerprintSensorProperties.TYPE_UDFPS_OPTICAL);
+ initializeActivityFor(TYPE_UDFPS_OPTICAL);
mActivity.onEnrollmentProgressChange(1, 1);
mActivity.onWindowFocusChanged(true);
@@ -138,7 +142,7 @@
@Test
public void fingerprintUdfpsOverlayEnrollment_loseFocus_shouldCancel() {
- initializeActivityFor(FingerprintSensorProperties.TYPE_UDFPS_OPTICAL);
+ initializeActivityFor(TYPE_UDFPS_OPTICAL);
mActivity.onEnrollmentProgressChange(1, 1);
mActivity.onWindowFocusChanged(false);
@@ -232,6 +236,24 @@
verify(mActivity, never()).onCancelEnrollment(anyInt());
}
+ @Test
+ public void fingerprintUdfpsEnroll_activityApplyDarkLightStyle() {
+ initializeActivityFor(TYPE_UDFPS_OPTICAL);
+
+ mActivity.onApplyThemeResource(mTheme, R.style.GlifTheme, true /* first */);
+
+ verify(mTheme).applyStyle(R.style.SetupWizardPartnerResource, true);
+ }
+
+ @Test
+ public void fingerprintSfpsEnroll_activityApplyDarkLightStyle() {
+ initializeActivityFor(TYPE_POWER_BUTTON);
+
+ mActivity.onApplyThemeResource(mTheme, R.style.GlifTheme, true /* first */);
+
+ verify(mTheme).applyStyle(R.style.SetupWizardPartnerResource, true);
+ }
+
private void initializeActivityFor(int sensorType) {
final List<ComponentInfoInternal> componentInfo = new ArrayList<>();
final FingerprintSensorPropertiesInternal prop =
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java
index fad3abf..b6fcc47 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java
@@ -16,6 +16,7 @@
package com.android.settings.biometrics.fingerprint;
+import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_POWER_BUTTON;
import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_REAR;
import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_OPTICAL;
@@ -38,6 +39,7 @@
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
+import android.content.res.Resources;
import android.hardware.biometrics.ComponentInfoInternal;
import android.hardware.biometrics.SensorProperties;
import android.hardware.fingerprint.FingerprintManager;
@@ -87,6 +89,9 @@
@Mock
private FingerprintManager mFingerprintManager;
+ @Mock
+ private Resources.Theme mTheme;
+
private ActivityController<FingerprintEnrollFindSensor> mActivityController;
private FingerprintEnrollFindSensor mActivity;
@@ -125,6 +130,14 @@
mActivityController.setup();
}
+ private void setupActivity_onSfpsDevice() {
+ final ArrayList<FingerprintSensorPropertiesInternal> props = new ArrayList<>();
+ props.add(newFingerprintSensorPropertiesInternal(TYPE_POWER_BUTTON));
+ doReturn(props).when(mFingerprintManager).getSensorPropertiesInternal();
+
+ mActivityController.setup();
+ }
+
private FingerprintSensorPropertiesInternal newFingerprintSensorPropertiesInternal(
@FingerprintSensorProperties.SensorType int sensorType) {
return new FingerprintSensorPropertiesInternal(
@@ -542,6 +555,16 @@
gotEnrollingResult_recreateActivityAndVerifyResultThenForward(RESULT_TIMEOUT, bundle);
}
+ @Test
+ public void fingerprintEnrollFindSensor_activityApplyDarkLightStyle() {
+ setupActivity_onSfpsDevice();
+ verifySidecar_onRearOrSfpsDevice();
+
+ mActivity.onApplyThemeResource(mActivity.getTheme(), R.style.GlifTheme, true /* first */);
+
+ verify(mTheme).applyStyle(R.style.SetupWizardPartnerResource, true);
+ }
+
private void triggerEnrollProgressAndError_onRearDevice() {
EnrollmentCallback enrollmentCallback = verifyAndCaptureEnrollmentCallback();
enrollmentCallback.onEnrollmentProgress(123);
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensorTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensorTest.java
index 54a7fb1..71cecc0 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensorTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensorTest.java
@@ -18,9 +18,11 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.verify;
import static org.robolectric.RuntimeEnvironment.application;
import android.content.Intent;
+import android.content.res.Resources.Theme;
import android.hardware.fingerprint.FingerprintManager;
import androidx.appcompat.app.AlertDialog;
@@ -48,14 +50,23 @@
@Config(shadows = {ShadowUtils.class, ShadowAlertDialogCompat.class})
public class SetupFingerprintEnrollFindSensorTest {
- @Mock
- private FingerprintManager mFingerprintManager;
+ @Mock private FingerprintManager mFingerprintManager;
+
+ @Mock private Theme mTheme;
+
+ private SetupFingerprintEnrollFindSensor mActivity;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
ShadowUtils.setFingerprintManager(mFingerprintManager);
FakeFeatureFactory.setupForTest();
+
+ final Intent intent = new Intent()
+ // Set the challenge token so the confirm screen will not be shown
+ .putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, new byte[0]);
+ mActivity = Robolectric.buildActivity(SetupFingerprintEnrollFindSensor.class,
+ intent).setup().get();
}
@After
@@ -74,23 +85,14 @@
}
@Test
- public void fingerprintEnroll_showsAlert_setSudTheme() {
- final AlertDialog alertDialog = setupAlertDialog();
+ public void fingerprintEnroll_activityApplyDarkLightStyle() {
+ mActivity.onApplyThemeResource(mTheme, R.style.GlifTheme, true /* first */);
- assertThat(alertDialog.getContext().getThemeResId()).isEqualTo(
- R.style.GlifV2ThemeAlertDialog);
+ verify(mTheme).applyStyle(R.style.SetupWizardPartnerResource, true);
}
private AlertDialog setupAlertDialog() {
- final Intent intent = new Intent()
- // Set the challenge token so the confirm screen will not be shown
- .putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, new byte[0]);
-
- final SetupFingerprintEnrollFindSensor activity =
- Robolectric.buildActivity(SetupFingerprintEnrollFindSensor.class,
- intent).setup().get();
-
- PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
+ PartnerCustomizationLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
layout.getMixin(FooterBarMixin.class).getSecondaryButtonView().performClick();
final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsPairOtherControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsPairOtherControllerTest.java
index cfa6d41..4b77637 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsPairOtherControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsPairOtherControllerTest.java
@@ -21,6 +21,7 @@
import static org.mockito.Mockito.when;
import com.android.settings.R;
+import com.android.settings.applications.SpacePreference;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.HearingAidProfile;
import com.android.settingslib.widget.ButtonPreference;
@@ -43,6 +44,7 @@
private CachedBluetoothDevice mSubCachedDevice;
private BluetoothDetailsPairOtherController mController;
private ButtonPreference mPreference;
+ private SpacePreference mSpacePreference;
@Override
public void setUp() {
@@ -51,8 +53,11 @@
mController = new BluetoothDetailsPairOtherController(mContext, mFragment, mCachedDevice,
mLifecycle);
mPreference = new ButtonPreference(mContext);
+ mSpacePreference = new SpacePreference(mContext, null);
mPreference.setKey(mController.getPreferenceKey());
+ mSpacePreference.setKey(BluetoothDetailsPairOtherController.KEY_SPACE);
mScreen.addPreference(mPreference);
+ mScreen.addPreference(mSpacePreference);
}
@Test
@@ -76,7 +81,17 @@
}
@Test
- public void isAvailable_isConnectedHearingAidDevice_available() {
+ public void init_isNotConnectedHearingAidDevice_notVisiblePreference() {
+ when(mCachedDevice.isConnectedHearingAidDevice()).thenReturn(false);
+
+ mController.init(mScreen);
+
+ assertThat(mPreference.isVisible()).isFalse();
+ assertThat(mSpacePreference.isVisible()).isFalse();
+ }
+
+ @Test
+ public void isAvailable_isNotConnectedHearingAidDevice_notAvailable() {
when(mCachedDevice.isConnectedHearingAidDevice()).thenReturn(false);
assertThat(mController.isAvailable()).isFalse();
@@ -118,4 +133,15 @@
assertThat(mController.isAvailable()).isTrue();
}
+
+ @Test
+ public void refresh_isNotConnectedHearingAidDevice_notVisiblePreference() {
+ when(mCachedDevice.isConnectedHearingAidDevice()).thenReturn(false);
+ mController.init(mScreen);
+
+ mController.refresh();
+
+ assertThat(mPreference.isVisible()).isFalse();
+ assertThat(mSpacePreference.isVisible()).isFalse();
+ }
}