Merge "Fix broken tests"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7fd390a..3a7cf8e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -11668,11 +11668,9 @@
<!-- Option for prevent ringing setting -->
<string name="prevent_ringing_option_none">Do nothing</string>
<!-- Summary for prevent ringing setting -->
- <string name="prevent_ringing_option_vibrate_summary">On (vibrate)</string>
+ <string name="prevent_ringing_option_vibrate_summary">Vibrate</string>
<!-- Summary for prevent ringing setting -->
- <string name="prevent_ringing_option_mute_summary">On (mute)</string>
- <!-- Summary for prevent ringing setting -->
- <string name="prevent_ringing_option_none_summary">Off</string>
+ <string name="prevent_ringing_option_mute_summary">Mute</string>
<!-- Title for detail page of wifi network [CHAR LIMIT=30] -->
<string name="pref_title_network_details">Network details</string>
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index fc5c3e2..31571f6 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -118,7 +118,7 @@
settings:controller="com.android.settings.sound.MediaControlsParentPreferenceController"
settings:keywords="@string/keywords_media_controls"/>
- <Preference
+ <com.android.settings.widget.PrimarySwitchPreference
android:key="gesture_prevent_ringing_sound"
android:title="@string/gesture_prevent_ringing_sound_title"
android:order="-107"
diff --git a/res/xml/sound_settings_v2.xml b/res/xml/sound_settings_v2.xml
new file mode 100644
index 0000000..9699240
--- /dev/null
+++ b/res/xml/sound_settings_v2.xml
@@ -0,0 +1,251 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:title="@string/sound_settings"
+ android:key="sound_settings"
+ settings:keywords="@string/keywords_sounds"
+ settings:initialExpandedChildrenCount="9">
+
+ <!-- Remote volume group -->
+ <PreferenceCategory
+ android:key="remote_media_group"
+ android:title=""
+ android:order="-185"
+ settings:allowDividerBelow="true"
+ settings:controller="com.android.settings.notification.RemoteVolumeGroupController">
+ </PreferenceCategory>
+
+ <!-- Media volume -->
+ <com.android.settings.notification.VolumeSeekBarPreference
+ android:key="media_volume"
+ android:icon="@drawable/ic_media_stream"
+ android:title="@string/media_volume_option_title"
+ android:order="-180"
+ settings:controller="com.android.settings.notification.MediaVolumePreferenceController"/>
+
+ <!-- Media output switcher -->
+ <Preference
+ android:key="media_output"
+ android:title="@string/media_output_title"
+ android:dialogTitle="@string/media_output_title"
+ android:order="-175"
+ settings:searchable="false"
+ settings:controller="com.android.settings.sound.MediaOutputPreferenceController"/>
+
+ <!-- Call volume -->
+ <com.android.settings.notification.VolumeSeekBarPreference
+ android:key="call_volume"
+ android:icon="@drawable/ic_local_phone_24_lib"
+ android:title="@string/call_volume_option_title"
+ android:order="-170"
+ settings:controller="com.android.settings.notification.CallVolumePreferenceController"/>
+
+ <!-- Hands free profile output switcher -->
+ <ListPreference
+ android:key="take_call_on_output"
+ android:title="@string/take_call_on_title"
+ android:dialogTitle="@string/take_call_on_title"
+ android:order="-165"
+ settings:searchable="false"
+ settings:controller="com.android.settings.sound.HandsFreeProfileOutputPreferenceController"/>
+
+ <!-- Ring volume -->
+ <com.android.settings.notification.VolumeSeekBarPreference
+ android:key="ring_volume"
+ android:icon="@drawable/ic_notifications"
+ android:title="@string/ring_volume_option_title"
+ android:order="-160"
+ settings:controller="com.android.settings.notification.RingVolumePreferenceController"/>
+
+
+ <!-- Alarm volume -->
+ <com.android.settings.notification.VolumeSeekBarPreference
+ android:key="alarm_volume"
+ android:icon="@*android:drawable/ic_audio_alarm"
+ android:title="@string/alarm_volume_option_title"
+ android:order="-150"
+ settings:controller="com.android.settings.notification.AlarmVolumePreferenceController"/>
+
+ <!-- Notification volume -->
+ <com.android.settings.notification.VolumeSeekBarPreference
+ android:key="notification_volume"
+ android:icon="@drawable/ic_notifications"
+ android:title="@string/notification_volume_option_title"
+ android:order="-140"
+ settings:controller="com.android.settings.notification.NotificationVolumePreferenceController"/>
+
+ <!-- Also vibrate for calls -->
+ <Preference
+ android:fragment="com.android.settings.sound.VibrateForCallsPreferenceFragment"
+ android:key="vibrate_for_calls"
+ android:title="@string/vibrate_when_ringing_title"
+ android:order="-130"
+ settings:controller="com.android.settings.sound.VibrateForCallsPreferenceController"
+ settings:keywords="@string/keywords_vibrate_for_calls"/>
+
+ <!-- Interruptions -->
+ <com.android.settingslib.RestrictedPreference
+ android:key="zen_mode"
+ android:title="@string/zen_mode_settings_title"
+ android:fragment="com.android.settings.notification.zen.ZenModeSettings"
+ android:order="-120"
+ settings:useAdminDisabledSummary="true"
+ settings:keywords="@string/keywords_sounds_and_notifications_interruptions"
+ settings:allowDividerAbove="true"
+ settings:controller="com.android.settings.notification.zen.ZenModePreferenceController"/>
+
+ <Preference
+ android:key="media_controls_summary"
+ android:title="@string/media_controls_title"
+ android:fragment="com.android.settings.sound.MediaControlsSettings"
+ android:order="-110"
+ settings:controller="com.android.settings.sound.MediaControlsParentPreferenceController"
+ settings:keywords="@string/keywords_media_controls"/>
+
+ <com.android.settings.widget.PrimarySwitchPreference
+ android:key="gesture_prevent_ringing_sound"
+ android:title="@string/gesture_prevent_ringing_sound_title"
+ android:order="-107"
+ android:fragment="com.android.settings.gestures.PreventRingingGestureSettings"
+ settings:controller="com.android.settings.gestures.PreventRingingParentPreferenceController"/>
+
+ <!-- Phone ringtone -->
+ <com.android.settings.DefaultRingtonePreference
+ android:key="phone_ringtone"
+ android:title="@string/ringtone_title"
+ android:dialogTitle="@string/ringtone_title"
+ android:summary="@string/summary_placeholder"
+ android:ringtoneType="ringtone"
+ android:order="-100"
+ settings:keywords="@string/sound_settings"/>
+
+ <!-- Default notification ringtone -->
+ <com.android.settings.DefaultRingtonePreference
+ android:key="notification_ringtone"
+ android:title="@string/notification_ringtone_title"
+ android:dialogTitle="@string/notification_ringtone_title"
+ android:summary="@string/summary_placeholder"
+ android:ringtoneType="notification"
+ android:order="-90"/>
+
+ <!-- Default alarm ringtone -->
+ <com.android.settings.DefaultRingtonePreference
+ android:key="alarm_ringtone"
+ android:title="@string/alarm_ringtone_title"
+ android:dialogTitle="@string/alarm_ringtone_title"
+ android:summary="@string/summary_placeholder"
+ android:persistent="false"
+ android:ringtoneType="alarm"
+ android:order="-80"/>
+
+ <!-- Other sounds -->
+ <PreferenceCategory
+ android:key="other_sounds_and_vibrations_category"
+ android:title="@string/other_sound_category_preference_title"
+ android:order="-50">
+
+ <!-- Dial pad tones -->
+ <SwitchPreference
+ android:key="dial_pad_tones"
+ android:title="@string/dial_pad_tones_title"/>
+
+ <!-- Screen locking sounds -->
+ <SwitchPreference
+ android:key="screen_locking_sounds"
+ android:title="@string/screen_locking_sounds_title"/>
+
+ <!-- Charging sounds -->
+ <SwitchPreference
+ android:key="charging_sounds"
+ android:title="@string/charging_sounds_title"/>
+
+ <!-- Docking sounds -->
+ <SwitchPreference
+ android:key="docking_sounds"
+ android:title="@string/docking_sounds_title"/>
+
+ <!-- Touch sounds -->
+ <SwitchPreference
+ android:key="touch_sounds"
+ android:title="@string/touch_sounds_title"/>
+
+ <!-- Vibrate on touch -->
+ <SwitchPreference
+ android:key="vibrate_on_touch"
+ android:title="@string/vibrate_on_touch_title"
+ android:summary="@string/vibrate_on_touch_summary"
+ settings:keywords="@string/keywords_vibrate_on_touch"/>
+
+ <!-- Dock speaker plays -->
+ <DropDownPreference
+ android:key="dock_audio_media"
+ android:title="@string/dock_audio_media_title"
+ android:summary="%s"/>
+
+ <!-- Boot sounds -->
+ <SwitchPreference
+ android:key="boot_sounds"
+ android:title="@string/boot_sounds_title"/>
+
+ <!-- Emergency tone -->
+ <DropDownPreference
+ android:key="emergency_tone"
+ android:title="@string/emergency_tone_title"
+ android:summary="%s"/>
+ </PreferenceCategory>
+
+ <com.android.settings.widget.WorkOnlyCategory
+ android:key="sound_work_settings_section"
+ android:title="@string/sound_work_settings"
+ android:order="100">
+
+ <!-- Use the same sounds of the work profile -->
+ <SwitchPreference
+ android:key="work_use_personal_sounds"
+ android:title="@string/work_use_personal_sounds_title"
+ android:summary="@string/work_use_personal_sounds_summary"
+ android:disableDependentsState="true"/>
+
+ <!-- Work phone ringtone -->
+ <com.android.settings.DefaultRingtonePreference
+ android:key="work_ringtone"
+ android:title="@string/work_ringtone_title"
+ android:dialogTitle="@string/work_alarm_ringtone_title"
+ android:ringtoneType="ringtone"
+ android:dependency="work_use_personal_sounds"/>
+
+ <!-- Default work notification ringtone -->
+ <com.android.settings.DefaultRingtonePreference
+ android:key="work_notification_ringtone"
+ android:title="@string/work_notification_ringtone_title"
+ android:dialogTitle="@string/work_alarm_ringtone_title"
+ android:ringtoneType="notification"
+ android:dependency="work_use_personal_sounds"/>
+
+ <!-- Default work alarm ringtone -->
+ <com.android.settings.DefaultRingtonePreference
+ android:key="work_alarm_ringtone"
+ android:title="@string/work_alarm_ringtone_title"
+ android:dialogTitle="@string/work_alarm_ringtone_title"
+ android:persistent="false"
+ android:ringtoneType="alarm"
+ android:dependency="work_use_personal_sounds"/>
+
+ </com.android.settings.widget.WorkOnlyCategory>
+</PreferenceScreen>
diff --git a/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java b/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java
index 7c7be09..ca1f1c7 100644
--- a/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java
+++ b/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java
@@ -20,21 +20,85 @@
import static android.provider.Settings.Secure.VOLUME_HUSH_MUTE;
import static android.provider.Settings.Secure.VOLUME_HUSH_VIBRATE;
+import android.content.ContentResolver;
import android.content.Context;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.os.Handler;
import android.provider.Settings;
-import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
-public class PreventRingingParentPreferenceController extends BasePreferenceController {
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+import com.android.settings.widget.PrimarySwitchPreference;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
+
+/** The controller manages the behaviour of the Prevent Ringing gesture setting. */
+public class PreventRingingParentPreferenceController extends TogglePreferenceController
+ implements LifecycleObserver, OnStart, OnStop {
final String SECURE_KEY = VOLUME_HUSH_GESTURE;
+ private PrimarySwitchPreference mPreference;
+ private SettingObserver mSettingObserver;
+
public PreventRingingParentPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ mSettingObserver = new SettingObserver(mPreference);
+ }
+
+ @Override
+ public boolean isChecked() {
+ final int preventRinging = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.VOLUME_HUSH_GESTURE,
+ Settings.Secure.VOLUME_HUSH_VIBRATE);
+ return preventRinging != Settings.Secure.VOLUME_HUSH_OFF;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ final int preventRingingSetting = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.VOLUME_HUSH_GESTURE, Settings.Secure.VOLUME_HUSH_VIBRATE);
+ final int newRingingSetting = preventRingingSetting == Settings.Secure.VOLUME_HUSH_OFF
+ ? Settings.Secure.VOLUME_HUSH_VIBRATE
+ : preventRingingSetting;
+
+ return Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.VOLUME_HUSH_GESTURE, isChecked
+ ? newRingingSetting
+ : Settings.Secure.VOLUME_HUSH_OFF);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ final int value = Settings.Secure.getInt(
+ mContext.getContentResolver(), SECURE_KEY, VOLUME_HUSH_VIBRATE);
+ CharSequence summary;
+ switch (value) {
+ case VOLUME_HUSH_VIBRATE:
+ summary = mContext.getText(R.string.prevent_ringing_option_vibrate_summary);
+ break;
+ case VOLUME_HUSH_MUTE:
+ summary = mContext.getText(R.string.prevent_ringing_option_mute_summary);
+ break;
+ default:
+ summary = null;
+ }
+ preference.setSummary(summary);
+ }
+
+ @Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(
com.android.internal.R.bool.config_volumeHushGestureEnabled)
@@ -42,20 +106,45 @@
}
@Override
- public CharSequence getSummary() {
- int value = Settings.Secure.getInt(
- mContext.getContentResolver(), SECURE_KEY, VOLUME_HUSH_VIBRATE);
- int summary;
- switch (value) {
- case VOLUME_HUSH_VIBRATE:
- summary = R.string.prevent_ringing_option_vibrate_summary;
- break;
- case VOLUME_HUSH_MUTE:
- summary = R.string.prevent_ringing_option_mute_summary;
- break;
- default:
- summary = R.string.prevent_ringing_option_none_summary;
+ public void onStart() {
+ if (mSettingObserver != null) {
+ mSettingObserver.register(mContext.getContentResolver());
+ mSettingObserver.onChange(false, null);
}
- return mContext.getText(summary);
+ }
+
+ @Override
+ public void onStop() {
+ if (mSettingObserver != null) {
+ mSettingObserver.unregister(mContext.getContentResolver());
+ }
+ }
+
+ private class SettingObserver extends ContentObserver {
+ private final Uri mVolumeHushGestureUri = Settings.Secure.getUriFor(
+ Settings.Secure.VOLUME_HUSH_GESTURE);
+
+ private final Preference mPreference;
+
+ SettingObserver(Preference preference) {
+ super(new Handler());
+ mPreference = preference;
+ }
+
+ public void register(ContentResolver cr) {
+ cr.registerContentObserver(mVolumeHushGestureUri, false, this);
+ }
+
+ public void unregister(ContentResolver cr) {
+ cr.unregisterContentObserver(this);
+ }
+
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ super.onChange(selfChange, uri);
+ if (uri == null || mVolumeHushGestureUri.equals(uri)) {
+ updateState(mPreference);
+ }
+ }
}
}
diff --git a/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
index 9545939..be67b5a 100644
--- a/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
+++ b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
@@ -16,11 +16,7 @@
package com.android.settings.gestures;
-import android.content.ContentResolver;
import android.content.Context;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.os.Handler;
import android.provider.Settings;
import android.widget.Switch;
@@ -39,7 +35,6 @@
private static final String KEY = "gesture_prevent_ringing_switch";
private final Context mContext;
- private SettingObserver mSettingObserver;
@VisibleForTesting
SwitchBar mSwitch;
@@ -60,7 +55,6 @@
if (isAvailable()) {
LayoutPreference pref = screen.findPreference(getPreferenceKey());
if (pref != null) {
- mSettingObserver = new SettingObserver(pref);
pref.setOnPreferenceClickListener(preference -> {
int preventRinging = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.VOLUME_HUSH_GESTURE,
@@ -113,32 +107,4 @@
? newRingingSetting
: Settings.Secure.VOLUME_HUSH_OFF);
}
-
- private class SettingObserver extends ContentObserver {
- private final Uri VOLUME_HUSH_GESTURE = Settings.Secure.getUriFor(
- Settings.Secure.VOLUME_HUSH_GESTURE);
-
- private final Preference mPreference;
-
- public SettingObserver(Preference preference) {
- super(new Handler());
- mPreference = preference;
- }
-
- public void register(ContentResolver cr) {
- cr.registerContentObserver(VOLUME_HUSH_GESTURE, false, this);
- }
-
- public void unregister(ContentResolver cr) {
- cr.unregisterContentObserver(this);
- }
-
- @Override
- public void onChange(boolean selfChange, Uri uri) {
- super.onChange(selfChange, uri);
- if (uri == null || VOLUME_HUSH_GESTURE.equals(uri)) {
- updateState(mPreference);
- }
- }
- }
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/FaceSetupSlice.java b/src/com/android/settings/homepage/contextualcards/slices/FaceSetupSlice.java
index 0ad241e..1b3ee10 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/FaceSetupSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/FaceSetupSlice.java
@@ -143,8 +143,8 @@
private static RowBuilder buildRowBuilder(CharSequence title, CharSequence subTitle,
IconCompat icon, Context context, Intent intent) {
final SliceAction primarySliceAction = SliceAction.createDeeplink(
- PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED), icon, ListBuilder.ICON_IMAGE,
- title);
+ PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE),
+ icon, ListBuilder.ICON_IMAGE, title);
return new RowBuilder()
.setTitleItem(icon, ListBuilder.ICON_IMAGE)
.setTitle(title)
diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java
index 1ad093f..fc209b8 100644
--- a/src/com/android/settings/notification/SoundSettings.java
+++ b/src/com/android/settings/notification/SoundSettings.java
@@ -26,6 +26,7 @@
import android.os.UserHandle;
import android.preference.SeekBarVolumizer;
import android.text.TextUtils;
+import android.util.FeatureFlagUtils;
import androidx.annotation.VisibleForTesting;
import androidx.preference.ListPreference;
@@ -33,6 +34,7 @@
import com.android.settings.R;
import com.android.settings.RingtonePreference;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.core.OnActivityResultListener;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -152,6 +154,9 @@
@Override
protected int getPreferenceScreenResId() {
+ if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
+ return R.xml.sound_settings_v2;
+ }
return R.xml.sound_settings;
}
diff --git a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
index 15e9bda..dffd7fb 100644
--- a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
+++ b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
@@ -88,14 +88,16 @@
public void setUp() throws RemoteException, NameNotFoundException {
MockitoAnnotations.initMocks(this);
mChanges = new CompatibilityChangeInfo[5];
- mChanges[0] = new CompatibilityChangeInfo(1L, "Default_Enabled", 0, 0, false, false, "");
- mChanges[1] = new CompatibilityChangeInfo(2L, "Default_Disabled", 0, 0, true, false, "");
- mChanges[2] = new CompatibilityChangeInfo(3L, "Enabled_Since_SDK_1_1", -1, 1, false, false,
- "");
- mChanges[3] = new CompatibilityChangeInfo(4L, "Enabled_Since_SDK_1_2", -1, 1, false, false,
- "");
- mChanges[4] = new CompatibilityChangeInfo(5L, "Enabled_Since_SDK_2", -1, 2, false, false,
- "");
+ mChanges[0] = new CompatibilityChangeInfo(
+ 1L, "Default_Enabled", 0, 0, false, false, "", false);
+ mChanges[1] = new CompatibilityChangeInfo(
+ 2L, "Default_Disabled", 0, 0, true, false, "", false);
+ mChanges[2] = new CompatibilityChangeInfo(
+ 3L, "Enabled_Since_SDK_1_1", -1, 1, false, false, "", false);
+ mChanges[3] = new CompatibilityChangeInfo(
+ 4L, "Enabled_Since_SDK_1_2", -1, 1, false, false, "", false);
+ mChanges[4] = new CompatibilityChangeInfo(
+ 5L, "Enabled_Since_SDK_2", -1, 2, false, false, "", false);
when(mPlatformCompat.listUIChanges()).thenReturn(mChanges);
when(mPlatformCompat.getOverrideValidator()).thenReturn(mOverrideValidator);
// By default, allow any change
@@ -208,7 +210,8 @@
for (int i = 0; i < mChanges.length; ++i) {
changesToAdd.add(new CompatibilityChangeInfo(mChanges[i].getId(), mChanges[i].getName(),
-1, mChanges[i].getEnableSinceTargetSdk(), mChanges[i].getDisabled(),
- mChanges[i].getLoggingOnly(), mChanges[i].getDescription()));
+ mChanges[i].getLoggingOnly(), mChanges[i].getDescription(),
+ mChanges[i].getOverridable()));
}
PreferenceCategory category = mDashboard.createChangeCategoryPreference(changesToAdd,
diff --git a/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java
index c752eb9..9e4877c 100644
--- a/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java
@@ -32,6 +32,8 @@
import android.content.res.Resources;
import android.provider.Settings;
+import androidx.preference.Preference;
+
import com.android.settings.R;
import org.junit.Before;
@@ -50,12 +52,14 @@
private Context mContext;
private PreventRingingParentPreferenceController mController;
+ private Preference mPreference;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
mController = new PreventRingingParentPreferenceController(mContext, "test_key");
+ mPreference = new Preference(mContext);
}
@Test
@@ -80,17 +84,43 @@
public void updateState_summaryUpdated() {
Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE,
VOLUME_HUSH_MUTE);
- assertThat(mController.getSummary()).isEqualTo(mContext.getResources().getText(
+ mController.updateState(mPreference);
+ assertThat(mPreference.getSummary()).isEqualTo(mContext.getResources().getText(
R.string.prevent_ringing_option_mute_summary));
Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE,
VOLUME_HUSH_VIBRATE);
- assertThat(mController.getSummary()).isEqualTo(mContext.getResources().getText(
+ mController.updateState(mPreference);
+ assertThat(mPreference.getSummary()).isEqualTo(mContext.getResources().getText(
R.string.prevent_ringing_option_vibrate_summary));
Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE,
VOLUME_HUSH_OFF);
- assertThat(mController.getSummary()).isEqualTo(mContext.getResources().getText(
- R.string.prevent_ringing_option_none_summary));
+ mController.updateState(mPreference);
+ assertThat(mPreference.getSummary()).isEqualTo(null);
+ }
+
+ @Test
+ public void isChecked_vibrate_shouldReturnTrue() {
+ Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE,
+ VOLUME_HUSH_VIBRATE);
+
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void isChecked_mute_shouldReturnTrue() {
+ Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE,
+ VOLUME_HUSH_MUTE);
+
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void isChecked_off_shouldReturnFalse() {
+ Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE,
+ VOLUME_HUSH_OFF);
+
+ assertThat(mController.isChecked()).isFalse();
}
}