Move vibrate while unlocked behind a flag

Keep this feature disabled for the initial release.

Test: atest NotificationAttentionHelperTest

Bug: 270456865
Change-Id: Ia80cc0c147bbc94fa5faf8e2f12a339a9355d332
This commit is contained in:
Valentin Iftime
2023-12-12 15:32:14 +01:00
parent e642b4cf2d
commit fe331f1f8f
2 changed files with 4 additions and 1 deletions

View File

@@ -40,7 +40,7 @@ public class PoliteNotifVibrateUnlockedToggleController extends TogglePreference
@Override @Override
public int getAvailabilityStatus() { public int getAvailabilityStatus() {
// TODO: b/291897570 - remove this when the feature flag is removed! // TODO: b/291897570 - remove this when the feature flag is removed!
if (!Flags.politeNotifications()) { if (!Flags.politeNotifications() || !Flags.vibrateWhileUnlocked()) {
return CONDITIONALLY_UNAVAILABLE; return CONDITIONALLY_UNAVAILABLE;
} }
return mContext.getSystemService(Vibrator.class).hasVibrator() ? AVAILABLE return mContext.getSystemService(Vibrator.class).hasVibrator() ? AVAILABLE

View File

@@ -64,6 +64,7 @@ public class PoliteNotifVibrateUnlockedToggleControllerTest {
public void isAvailable_flagEnabled_vibrationSupported_shouldReturnTrue() { public void isAvailable_flagEnabled_vibrationSupported_shouldReturnTrue() {
// TODO: b/291907312 - remove feature flags // TODO: b/291907312 - remove feature flags
mSetFlagsRule.enableFlags(Flags.FLAG_POLITE_NOTIFICATIONS); mSetFlagsRule.enableFlags(Flags.FLAG_POLITE_NOTIFICATIONS);
mSetFlagsRule.enableFlags(Flags.FLAG_VIBRATE_WHILE_UNLOCKED);
when(mVibrator.hasVibrator()).thenReturn(true); when(mVibrator.hasVibrator()).thenReturn(true);
assertThat(mController.isAvailable()).isTrue(); assertThat(mController.isAvailable()).isTrue();
assertThat(mController.getAvailabilityStatus()).isEqualTo( assertThat(mController.getAvailabilityStatus()).isEqualTo(
@@ -74,6 +75,7 @@ public class PoliteNotifVibrateUnlockedToggleControllerTest {
public void isAvailable_flagEnabled_vibrationNotSupported_shouldReturnFalse() { public void isAvailable_flagEnabled_vibrationNotSupported_shouldReturnFalse() {
// TODO: b/291907312 - remove feature flags // TODO: b/291907312 - remove feature flags
mSetFlagsRule.enableFlags(Flags.FLAG_POLITE_NOTIFICATIONS); mSetFlagsRule.enableFlags(Flags.FLAG_POLITE_NOTIFICATIONS);
mSetFlagsRule.enableFlags(Flags.FLAG_VIBRATE_WHILE_UNLOCKED);
when(mVibrator.hasVibrator()).thenReturn(false); when(mVibrator.hasVibrator()).thenReturn(false);
assertThat(mController.isAvailable()).isFalse(); assertThat(mController.isAvailable()).isFalse();
assertThat(mController.getAvailabilityStatus()).isEqualTo( assertThat(mController.getAvailabilityStatus()).isEqualTo(
@@ -84,6 +86,7 @@ public class PoliteNotifVibrateUnlockedToggleControllerTest {
public void isAvailable_flagDisabled_shouldReturnFalse() { public void isAvailable_flagDisabled_shouldReturnFalse() {
// TODO: b/291907312 - remove feature flags // TODO: b/291907312 - remove feature flags
mSetFlagsRule.disableFlags(Flags.FLAG_POLITE_NOTIFICATIONS); mSetFlagsRule.disableFlags(Flags.FLAG_POLITE_NOTIFICATIONS);
mSetFlagsRule.enableFlags(Flags.FLAG_VIBRATE_WHILE_UNLOCKED);
assertThat(mController.isAvailable()).isFalse(); assertThat(mController.isAvailable()).isFalse();
assertThat(mController.getAvailabilityStatus()).isEqualTo( assertThat(mController.getAvailabilityStatus()).isEqualTo(
BasePreferenceController.CONDITIONALLY_UNAVAILABLE); BasePreferenceController.CONDITIONALLY_UNAVAILABLE);