From fe331f1f8fc87de67ca813f1c8682797955d677d Mon Sep 17 00:00:00 2001 From: Valentin Iftime Date: Tue, 12 Dec 2023 15:32:14 +0100 Subject: [PATCH] Move vibrate while unlocked behind a flag Keep this feature disabled for the initial release. Test: atest NotificationAttentionHelperTest Bug: 270456865 Change-Id: Ia80cc0c147bbc94fa5faf8e2f12a339a9355d332 --- .../PoliteNotifVibrateUnlockedToggleController.java | 2 +- .../PoliteNotifVibrateUnlockedToggleControllerTest.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/notification/PoliteNotifVibrateUnlockedToggleController.java b/src/com/android/settings/notification/PoliteNotifVibrateUnlockedToggleController.java index aaa8f8714b0..dfdd64976b1 100644 --- a/src/com/android/settings/notification/PoliteNotifVibrateUnlockedToggleController.java +++ b/src/com/android/settings/notification/PoliteNotifVibrateUnlockedToggleController.java @@ -40,7 +40,7 @@ public class PoliteNotifVibrateUnlockedToggleController extends TogglePreference @Override public int getAvailabilityStatus() { // TODO: b/291897570 - remove this when the feature flag is removed! - if (!Flags.politeNotifications()) { + if (!Flags.politeNotifications() || !Flags.vibrateWhileUnlocked()) { return CONDITIONALLY_UNAVAILABLE; } return mContext.getSystemService(Vibrator.class).hasVibrator() ? AVAILABLE diff --git a/tests/robotests/src/com/android/settings/notification/PoliteNotifVibrateUnlockedToggleControllerTest.java b/tests/robotests/src/com/android/settings/notification/PoliteNotifVibrateUnlockedToggleControllerTest.java index f92ed252116..4d546ec2b40 100644 --- a/tests/robotests/src/com/android/settings/notification/PoliteNotifVibrateUnlockedToggleControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/PoliteNotifVibrateUnlockedToggleControllerTest.java @@ -64,6 +64,7 @@ public class PoliteNotifVibrateUnlockedToggleControllerTest { public void isAvailable_flagEnabled_vibrationSupported_shouldReturnTrue() { // TODO: b/291907312 - remove feature flags mSetFlagsRule.enableFlags(Flags.FLAG_POLITE_NOTIFICATIONS); + mSetFlagsRule.enableFlags(Flags.FLAG_VIBRATE_WHILE_UNLOCKED); when(mVibrator.hasVibrator()).thenReturn(true); assertThat(mController.isAvailable()).isTrue(); assertThat(mController.getAvailabilityStatus()).isEqualTo( @@ -74,6 +75,7 @@ public class PoliteNotifVibrateUnlockedToggleControllerTest { public void isAvailable_flagEnabled_vibrationNotSupported_shouldReturnFalse() { // TODO: b/291907312 - remove feature flags mSetFlagsRule.enableFlags(Flags.FLAG_POLITE_NOTIFICATIONS); + mSetFlagsRule.enableFlags(Flags.FLAG_VIBRATE_WHILE_UNLOCKED); when(mVibrator.hasVibrator()).thenReturn(false); assertThat(mController.isAvailable()).isFalse(); assertThat(mController.getAvailabilityStatus()).isEqualTo( @@ -84,6 +86,7 @@ public class PoliteNotifVibrateUnlockedToggleControllerTest { public void isAvailable_flagDisabled_shouldReturnFalse() { // TODO: b/291907312 - remove feature flags mSetFlagsRule.disableFlags(Flags.FLAG_POLITE_NOTIFICATIONS); + mSetFlagsRule.enableFlags(Flags.FLAG_VIBRATE_WHILE_UNLOCKED); assertThat(mController.isAvailable()).isFalse(); assertThat(mController.getAvailabilityStatus()).isEqualTo( BasePreferenceController.CONDITIONALLY_UNAVAILABLE);