Create a hidden Vibrator API for haptic feedback.
Haptic feedbacks are played on a View (via the performHapticFeedback API
in the View class). This API used to go through the window manager code
space to derive the vibration effect/attribute for a given haptic
feedback ID, and use the vibrator to play the corresponding vibration.
To remove dependency on window manager, we are creating a hidden API in
Vibrator that will handle performing haptic feedback. View can pass a
haptic feedback request directly to this new Vibrator API (after making
sure that the View is attached to a window), and this API will handle
creating the vibration effect/attribute for the haptic feedback and
playing it, all without requiring the VIBRATE permission.
We are guarding View's direct call to the Vibrator API with a new
vibrator flag. Once this implementation has been seen to be stable, we
will remove the haptic feedback code in the window manager code space.
Test: atest VibratorManagerServiceTest
Test: atest HapticFeedbackVibrationProviderTest
Test: sample test app without VIBRATE permission plays haptic feedback
Bug: 295459081
Change-Id: Ic4d226f724bf0591bad9f465a4872a41ddca2c60
diff --git a/AconfigFlags.bp b/AconfigFlags.bp
index 5cfdeb9..e9fcad8 100644
--- a/AconfigFlags.bp
+++ b/AconfigFlags.bp
@@ -19,6 +19,7 @@
// Add java_aconfig_libraries to here to add them to the core framework
srcs: [
":android.os.flags-aconfig-java{.generated_srcjars}",
+ ":android.os.vibrator.flags-aconfig-java{.generated_srcjars}",
":android.security.flags-aconfig-java{.generated_srcjars}",
":camera_platform_flags_core_java_lib{.generated_srcjars}",
":com.android.window.flags.window-aconfig-java{.generated_srcjars}",
@@ -138,3 +139,16 @@
aconfig_declarations: "android.view.inputmethod.flags-aconfig",
defaults: ["framework-minus-apex-aconfig-java-defaults"],
}
+
+// Vibrator
+aconfig_declarations {
+ name: "android.os.vibrator.flags-aconfig",
+ package: "android.os.vibrator",
+ srcs: ["core/java/android/os/vibrator/*.aconfig"],
+}
+
+java_aconfig_library {
+ name: "android.os.vibrator.flags-aconfig-java",
+ aconfig_declarations: "android.os.vibrator.flags-aconfig",
+ defaults: ["framework-minus-apex-aconfig-java-defaults"],
+}