From f707f010a6b0a262506e3d1a0a68222363b71373 Mon Sep 17 00:00:00 2001 From: Lais Andrade Date: Mon, 31 Jul 2023 19:36:22 +0100 Subject: [PATCH] Update VibratorManagerService to allow shell vibrations when running in bg Update VibratorManagerShellCommand to apply USAGE_COMMUNICATION_REQUEST for shell vibrations, which is allowed from background apps. Also update the 'force' shell flag to apply both VibrationAttributes bypass flags. Fix: 292059367 Test: locally run `adb shell cmd vibrate` Change-Id: I41369ac9ddd0109a85e78973b478c512f0f3c5d6 --- .../android/server/vibrator/VibratorManagerService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/vibrator/VibratorManagerService.java b/services/core/java/com/android/server/vibrator/VibratorManagerService.java index 6fdb1dbf2a834..73397972215da 100644 --- a/services/core/java/com/android/server/vibrator/VibratorManagerService.java +++ b/services/core/java/com/android/server/vibrator/VibratorManagerService.java @@ -2170,12 +2170,13 @@ public class VibratorManagerService extends IVibratorManagerService.Stub { } private VibrationAttributes createVibrationAttributes(CommonOptions commonOptions) { - final int flags = - commonOptions.force ? VibrationAttributes.FLAG_BYPASS_INTERRUPTION_POLICY : 0; + // This will bypass user settings, Do Not Disturb and other interruption policies. + final int flags = commonOptions.force ? ATTRIBUTES_ALL_BYPASS_FLAGS : 0; return new VibrationAttributes.Builder() .setFlags(flags) - // Used to apply Settings.System.HAPTIC_FEEDBACK_INTENSITY to scale effects. - .setUsage(VibrationAttributes.USAGE_TOUCH) + // Used to allow vibrations when the adb shell process is running in background. + // This will apply the NOTIFICATION_VIBRATION_INTENSITY setting. + .setUsage(VibrationAttributes.USAGE_COMMUNICATION_REQUEST) .build(); }