summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Khalil <khalilahmad@google.com>2023-12-07 20:59:38 +0000
committerAhmad Khalil <khalilahmad@google.com>2023-12-07 20:59:38 +0000
commit77fa8239a654f960d24fd86688f9ac16316989f8 (patch)
treeadc6ef616dcef0c932346264f3f45929707824c6
parentb703fffce14954549cfb37d645df3baa0adbafec (diff)
downloadinterfaces-77fa8239a654f960d24fd86688f9ac16316989f8.tar.gz
Introducing IVibratorController and IVibratorControlService
We're adding IVibratorController.aidl and IVibratorControlService.aidl to allow the HAL to set haptic intensity through VibrationParams. Bug: 305961689 Test: run vts --module VtsHalVibratorControlServiceTargetTest Change-Id: I4d06bfdb161cc0342121c2a3359fc6c1168e078c
-rw-r--r--vibrator/OWNERS2
-rw-r--r--vibrator/aidl/Android.bp41
-rw-r--r--vibrator/aidl/TEST_MAPPING7
-rw-r--r--vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/IVibratorControlService.aidl43
-rw-r--r--vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/IVibratorController.aidl39
-rw-r--r--vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/ScaleParam.aidl39
-rw-r--r--vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/VibrationParam.aidl38
-rw-r--r--vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/VibrationTypeMask.aidl42
-rw-r--r--vibrator/aidl/android/frameworks/vibrator/IVibratorControlService.aidl78
-rw-r--r--vibrator/aidl/android/frameworks/vibrator/IVibratorController.aidl41
-rw-r--r--vibrator/aidl/android/frameworks/vibrator/ScaleParam.aidl28
-rw-r--r--vibrator/aidl/android/frameworks/vibrator/VibrationParam.aidl27
-rw-r--r--vibrator/aidl/android/frameworks/vibrator/VibrationTypeMask.aidl27
-rw-r--r--vibrator/aidl/vts/functional/Android.bp44
-rw-r--r--vibrator/aidl/vts/functional/VtsHalVibratorControlServiceTargetTest.cpp153
15 files changed, 649 insertions, 0 deletions
diff --git a/vibrator/OWNERS b/vibrator/OWNERS
new file mode 100644
index 0000000..c4de58a
--- /dev/null
+++ b/vibrator/OWNERS
@@ -0,0 +1,2 @@
+# Bug component: 345036
+include platform/frameworks/base:/services/core/java/com/android/server/vibrator/OWNERS
diff --git a/vibrator/aidl/Android.bp b/vibrator/aidl/Android.bp
new file mode 100644
index 0000000..0451921
--- /dev/null
+++ b/vibrator/aidl/Android.bp
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+aidl_interface {
+ name: "android.frameworks.vibrator",
+ srcs: ["android/frameworks/vibrator/*.aidl"],
+ owner: "google",
+ vendor_available: true,
+ host_supported: true,
+ stability: "vintf",
+ backend: {
+ java: {
+ platform_apis: true,
+ },
+ ndk: {
+ enabled: true,
+ },
+ cpp: {
+ enabled: false,
+ },
+ },
+ frozen: false,
+
+}
diff --git a/vibrator/aidl/TEST_MAPPING b/vibrator/aidl/TEST_MAPPING
new file mode 100644
index 0000000..f7f7b11
--- /dev/null
+++ b/vibrator/aidl/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "postsubmit": [
+ {
+ "name": "VtsHalVibratorControlServiceTargetTest"
+ }
+ ]
+}
diff --git a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/IVibratorControlService.aidl b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/IVibratorControlService.aidl
new file mode 100644
index 0000000..f6a0e11
--- /dev/null
+++ b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/IVibratorControlService.aidl
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.frameworks.vibrator;
+/* @hide */
+@VintfStability
+interface IVibratorControlService {
+ oneway void registerVibratorController(in android.frameworks.vibrator.IVibratorController controller);
+ oneway void unregisterVibratorController(in android.frameworks.vibrator.IVibratorController controller);
+ oneway void setVibrationParams(in android.frameworks.vibrator.VibrationParam[] params, in android.frameworks.vibrator.IVibratorController token);
+ oneway void clearVibrationParams(in android.frameworks.vibrator.VibrationTypeMask types, in android.frameworks.vibrator.IVibratorController token);
+ oneway void onRequestVibrationParamsComplete(in IBinder requestToken, in android.frameworks.vibrator.VibrationParam[] result);
+}
diff --git a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/IVibratorController.aidl b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/IVibratorController.aidl
new file mode 100644
index 0000000..324fb49
--- /dev/null
+++ b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/IVibratorController.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.frameworks.vibrator;
+/* @hide */
+@VintfStability
+interface IVibratorController {
+ oneway void requestVibrationParams(in android.frameworks.vibrator.VibrationTypeMask type, in long deadlineElapsedRealtimeMillis, in IBinder requestToken);
+}
diff --git a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/ScaleParam.aidl b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/ScaleParam.aidl
new file mode 100644
index 0000000..f2b8931
--- /dev/null
+++ b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/ScaleParam.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.frameworks.vibrator;
+@VintfStability
+parcelable ScaleParam {
+ android.frameworks.vibrator.VibrationTypeMask types;
+ float scale;
+}
diff --git a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/VibrationParam.aidl b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/VibrationParam.aidl
new file mode 100644
index 0000000..ddf7d05
--- /dev/null
+++ b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/VibrationParam.aidl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.frameworks.vibrator;
+@VintfStability
+union VibrationParam {
+ android.frameworks.vibrator.ScaleParam scale;
+}
diff --git a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/VibrationTypeMask.aidl b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/VibrationTypeMask.aidl
new file mode 100644
index 0000000..909a513
--- /dev/null
+++ b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/VibrationTypeMask.aidl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.frameworks.vibrator;
+@Backing(type="int") @VintfStability
+enum VibrationTypeMask {
+ ALARM = (1 << 0) /* 1 */,
+ NOTIFICATION = (1 << 1) /* 2 */,
+ RINGTONE = (1 << 2) /* 4 */,
+ INTERACTIVE = (1 << 3) /* 8 */,
+ MEDIA = (1 << 4) /* 16 */,
+}
diff --git a/vibrator/aidl/android/frameworks/vibrator/IVibratorControlService.aidl b/vibrator/aidl/android/frameworks/vibrator/IVibratorControlService.aidl
new file mode 100644
index 0000000..12da57d
--- /dev/null
+++ b/vibrator/aidl/android/frameworks/vibrator/IVibratorControlService.aidl
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+
+package android.frameworks.vibrator;
+
+import android.frameworks.vibrator.IVibratorController;
+import android.frameworks.vibrator.VibrationParam;
+import android.frameworks.vibrator.VibrationTypeMask;
+
+/**
+ * IVibratorControlService is a service that allows clients to register IVibratorControllers to
+ * receive VibrationParams. It also allows the client to set and clear VibrationParams.
+ * @hide
+ */
+@VintfStability
+interface IVibratorControlService {
+ /**
+ * Registers an IVibratorController to allow pushing VibrationParams. These params will be used
+ * to modify vibration characteristics, such as scaling.
+ * <p>Only one controller should be registered at the same time. Registering a new controller
+ * must unregister the old controller before registering the new one.
+ *
+ * @param controller The vibrator controller used for pulling requests.
+ */
+ oneway void registerVibratorController(in IVibratorController controller);
+
+ /**
+ * Unregisters an IVibratorController.
+ * <p>If the provided controller is not the registered one, the request must be ignored.
+ *
+ * @param controller The vibrator controller to be removed.
+ */
+ oneway void unregisterVibratorController(in IVibratorController controller);
+
+ /**
+ * Sets VibrationParams which will be used to modify some vibration characteristics, such as
+ * scaling.
+ * <p>If the provided controller is not the registered one, the request must be ignored.
+ *
+ * @param params The vibration params to be applied to new vibrations.
+ * @param token The token to register a death recipient to expire these params.
+ */
+ oneway void setVibrationParams(in VibrationParam[] params, in IVibratorController token);
+
+ /**
+ * Clears any set VibrationParams and reverts the vibration characteristics to their default
+ * settings.
+ * <p>If the provided controller is not the registered one, the request must be ignored.
+ *
+ * @param type The combined bitfield of VibrationTypeMask to be cleared
+ * @param token The token to register a death recipient to expire these params
+ */
+ oneway void clearVibrationParams(in VibrationTypeMask types, in IVibratorController token);
+
+ /**
+ * Notifies the VibrationControlService of new VibrationParams.
+ * <p>This method must be called by the IVibratorController after processing a
+ * 'requestVibrationParams()' call by the service.
+ *
+ * @param requestToken The token used for this request
+ * @param result The request result
+ */
+ oneway void onRequestVibrationParamsComplete(
+ in IBinder requestToken, in VibrationParam[] result);
+} \ No newline at end of file
diff --git a/vibrator/aidl/android/frameworks/vibrator/IVibratorController.aidl b/vibrator/aidl/android/frameworks/vibrator/IVibratorController.aidl
new file mode 100644
index 0000000..7bcc7d2
--- /dev/null
+++ b/vibrator/aidl/android/frameworks/vibrator/IVibratorController.aidl
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+
+package android.frameworks.vibrator;
+
+import android.frameworks.vibrator.VibrationTypeMask;
+
+/**
+ * IVibratorController is an interface that allows clients to request the VibrationParams for the
+ * specified vibration types. If the request is longer than the specified deadline, the result will
+ * be ignored by the caller.
+ * @hide
+ */
+@VintfStability
+interface IVibratorController {
+ /**
+ * Triggers a request to receive VibrationParams for the specified vibration types. The
+ * received params are used to modify vibration characteristics, such as scaling.
+ * <p> If the request takes longer than the specified deadline, the request must be ignored by
+ * the caller.
+ *
+ * @param type The type of vibration queried
+ * @param deadlineElapsedRealtimeMillis The request deadline, result ignored after this
+ * @param requestToken The token for the async result, used by the service
+ */
+ oneway void requestVibrationParams(in VibrationTypeMask type,
+ in long deadlineElapsedRealtimeMillis, in IBinder requestToken);
+} \ No newline at end of file
diff --git a/vibrator/aidl/android/frameworks/vibrator/ScaleParam.aidl b/vibrator/aidl/android/frameworks/vibrator/ScaleParam.aidl
new file mode 100644
index 0000000..07228ff
--- /dev/null
+++ b/vibrator/aidl/android/frameworks/vibrator/ScaleParam.aidl
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+
+package android.frameworks.vibrator;
+
+import android.frameworks.vibrator.VibrationTypeMask;
+
+/**
+ * Vibration scale for one or more vibration types
+ */
+@VintfStability
+parcelable ScaleParam {
+ VibrationTypeMask types; // combined bitfield of VibrationTypeMask
+ float scale;
+} \ No newline at end of file
diff --git a/vibrator/aidl/android/frameworks/vibrator/VibrationParam.aidl b/vibrator/aidl/android/frameworks/vibrator/VibrationParam.aidl
new file mode 100644
index 0000000..e9bde2a
--- /dev/null
+++ b/vibrator/aidl/android/frameworks/vibrator/VibrationParam.aidl
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+
+package android.frameworks.vibrator;
+
+import android.frameworks.vibrator.ScaleParam;
+
+/**
+ * Consolidated representation of all vibration parameters
+ */
+@VintfStability
+union VibrationParam {
+ ScaleParam scale;
+} \ No newline at end of file
diff --git a/vibrator/aidl/android/frameworks/vibrator/VibrationTypeMask.aidl b/vibrator/aidl/android/frameworks/vibrator/VibrationTypeMask.aidl
new file mode 100644
index 0000000..693acf5
--- /dev/null
+++ b/vibrator/aidl/android/frameworks/vibrator/VibrationTypeMask.aidl
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+
+package android.frameworks.vibrator;
+
+@VintfStability
+@Backing(type="int")
+enum VibrationTypeMask {
+ ALARM = 1 << 0, // Alarm usage
+ NOTIFICATION = 1 << 1, // Notification and communication request usages
+ RINGTONE = 1 << 2, // Ringtone usage
+ INTERACTIVE = 1 << 3, // Touch and hardware feedback usages
+ MEDIA = 1 << 4 // Media and unknown usages
+} \ No newline at end of file
diff --git a/vibrator/aidl/vts/functional/Android.bp b/vibrator/aidl/vts/functional/Android.bp
new file mode 100644
index 0000000..e95eb01
--- /dev/null
+++ b/vibrator/aidl/vts/functional/Android.bp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_test {
+ name: "VtsHalVibratorControlServiceTargetTest",
+ defaults: [
+ "VtsHalTargetTestDefaults",
+ "use_libaidlvintf_gtest_helper_static",
+ ],
+ tidy_timeout_srcs: [
+ "VtsHalVibratorControlServiceTargetTest.cpp",
+ ],
+ srcs: [
+ "VtsHalVibratorControlServiceTargetTest.cpp",
+ ],
+ static_libs: [
+ "android.frameworks.vibrator-V1-ndk",
+ "libgmock",
+ ],
+ shared_libs: [
+ "libbinder_ndk",
+ ],
+ test_suites: [
+ "general-tests",
+ "vts",
+ ],
+}
diff --git a/vibrator/aidl/vts/functional/VtsHalVibratorControlServiceTargetTest.cpp b/vibrator/aidl/vts/functional/VtsHalVibratorControlServiceTargetTest.cpp
new file mode 100644
index 0000000..feb0554
--- /dev/null
+++ b/vibrator/aidl/vts/functional/VtsHalVibratorControlServiceTargetTest.cpp
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+
+#include <aidl/Gtest.h>
+#include <aidl/Vintf.h>
+#include <aidl/android/frameworks/vibrator/BnVibratorControlService.h>
+#include <aidl/android/frameworks/vibrator/BnVibratorController.h>
+#include <aidl/android/frameworks/vibrator/IVibratorControlService.h>
+#include <aidl/android/frameworks/vibrator/IVibratorController.h>
+#include <aidl/android/frameworks/vibrator/ScaleParam.h>
+#include <aidl/android/frameworks/vibrator/VibrationTypeMask.h>
+#include <android-base/logging.h>
+#include <android/binder_auto_utils.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+#include <utils/Condition.h>
+#include <utils/Mutex.h>
+
+namespace android {
+
+using ::aidl::android::frameworks::vibrator::BnVibratorController;
+using ::aidl::android::frameworks::vibrator::BnVibratorControlService;
+using ::aidl::android::frameworks::vibrator::IVibratorController;
+using ::aidl::android::frameworks::vibrator::IVibratorControlService;
+using ::aidl::android::frameworks::vibrator::ScaleParam;
+using ::aidl::android::frameworks::vibrator::VibrationParam;
+using ::aidl::android::frameworks::vibrator::VibrationTypeMask;
+using ::android::getAidlHalInstanceNames;
+using ::android::PrintInstanceNameToString;
+using ndk::SpAIBinder;
+using ::testing::Eq;
+using ::testing::InitGoogleTest;
+using ::testing::TestWithParam;
+using ::testing::ValuesIn;
+
+std::vector<VibrationParam> generateVibrationParams(VibrationTypeMask in_type, float scale) {
+ ScaleParam scaleParam = ScaleParam();
+ scaleParam.types = in_type;
+ scaleParam.scale = scale;
+ VibrationParam vibrationParam = VibrationParam(scaleParam);
+ std::vector<VibrationParam> vibrationParams = {vibrationParam};
+ return vibrationParams;
+}
+
+class VibratorController : public BnVibratorController {
+ public:
+ ~VibratorController() override = default;
+
+ ndk::ScopedAStatus requestVibrationParams(VibrationTypeMask in_type,
+ int64_t in_deadlineElapsedRealtimeMillis,
+ const ::ndk::SpAIBinder& in_requestToken) override {
+ if (in_requestToken == nullptr) {
+ LOG(INFO) << "Vibrator controller failed to process a request for vibration params";
+ return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_ILLEGAL_ARGUMENT));
+ }
+
+ LOG(INFO) << "Vibrator controller received a request for vibration params for type: "
+ << toString(in_type)
+ << ", with a timeout of: " << in_deadlineElapsedRealtimeMillis;
+
+ std::shared_ptr<IVibratorControlService> service =
+ IVibratorControlService::fromBinder(in_requestToken);
+
+ EXPECT_TRUE(service
+ ->onRequestVibrationParamsComplete(
+ in_requestToken, generateVibrationParams(in_type, /* scale= */ 1))
+ .isOk());
+
+ return ndk::ScopedAStatus::ok();
+ }
+};
+
+class VibratorControlServiceTest : public ::testing::TestWithParam<std::string> {
+ public:
+ void SetUp() override {
+ SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
+ service = IVibratorControlService::fromBinder(binder);
+ ASSERT_NE(service, nullptr);
+ }
+
+ std::shared_ptr<IVibratorControlService> service;
+};
+
+TEST_P(VibratorControlServiceTest, RegisterVibrationControllerTest) {
+ std::shared_ptr<IVibratorController> vibratorController =
+ ::ndk::SharedRefBase::make<VibratorController>();
+
+ EXPECT_TRUE(service->registerVibratorController(vibratorController).isOk());
+
+ EXPECT_TRUE(service->unregisterVibratorController(vibratorController).isOk());
+}
+
+TEST_P(VibratorControlServiceTest, RequestVibrationParamsTest) {
+ std::shared_ptr<IVibratorController> vibratorController =
+ ::ndk::SharedRefBase::make<VibratorController>();
+
+ EXPECT_TRUE(service->registerVibratorController(vibratorController).isOk());
+
+ EXPECT_TRUE(vibratorController
+ ->requestVibrationParams(VibrationTypeMask::ALARM,
+ /* deadlineElapsedRealtimeMillis= */ 50,
+ service->asBinder())
+ .isOk());
+ EXPECT_TRUE(service->unregisterVibratorController(vibratorController).isOk());
+}
+
+TEST_P(VibratorControlServiceTest, SetAndClearVibrationParamsTest) {
+ std::shared_ptr<IVibratorController> vibratorController =
+ ::ndk::SharedRefBase::make<VibratorController>();
+
+ EXPECT_TRUE(service->registerVibratorController(vibratorController).isOk());
+
+ EXPECT_TRUE(
+ service
+ ->setVibrationParams(generateVibrationParams(VibrationTypeMask::ALARM, /* scale= */ 1),
+ vibratorController->getDefaultImpl())
+ .isOk());
+
+ EXPECT_TRUE(
+ service
+ ->clearVibrationParams(VibrationTypeMask::ALARM, vibratorController->getDefaultImpl())
+ .isOk());
+
+ EXPECT_TRUE(service->unregisterVibratorController(vibratorController).isOk());
+}
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VibratorControlServiceTest);
+
+INSTANTIATE_TEST_SUITE_P(
+ PerInstance, VibratorControlServiceTest,
+ testing::ValuesIn(getAidlHalInstanceNames(IVibratorControlService::descriptor)),
+ PrintInstanceNameToString);
+
+int main(int argc, char** argv) {
+ InitGoogleTest(&argc, argv);
+ ABinderProcess_setThreadPoolMaxThreadCount(/* numThreads= */ 1);
+ ABinderProcess_startThreadPool();
+ return RUN_ALL_TESTS();
+}
+} // namespace android