diff --git a/vibrator/bundle.json b/vibrator/bundle.json
index 47a3a9c3f59284ea724b162ebfca510c6fcc84be..2ab688ff3af9f28f4926b9a5d763e869f1c1fe44 100644
--- a/vibrator/bundle.json
+++ b/vibrator/bundle.json
@@ -23,13 +23,13 @@
},
"build": {
"sub_component": [
- "//drivers/interface/vibrator/v1_0:libvibrator_proxy_1.0"
+ "//drivers/interface/vibrator/v1_1:libvibrator_proxy_1.1"
],
"test": [
],
"inner_kits": [
{
- "name": "//drivers/interface/vibrator/v1_0:libvibrator_proxy_1.0",
+ "name": "//drivers/interface/vibrator/v1_1:libvibrator_proxy_1.1",
"header": {
"header_files": [
],
diff --git a/vibrator/v1_0/VibratorTypes.idl b/vibrator/v1_0/VibratorTypes.idl
index 629ddb80f1285c447e82a8e6566b14d9ba15a317..15925ac77374ecc9cf1c9e7010d718fbfc65dfdc 100644
--- a/vibrator/v1_0/VibratorTypes.idl
+++ b/vibrator/v1_0/VibratorTypes.idl
@@ -21,8 +21,10 @@ package ohos.hdi.vibrator.v1_0;
* @since 2.2
*/
enum HdfVibratorMode {
- HDF_VIBRATOR_MODE_ONCE, /**< Indicates the one-shot vibration with the given duration. */
- HDF_VIBRATOR_MODE_PRESET, /**< Indicates the periodic vibration with the preset effect. */
- HDF_VIBRATOR_MODE_BUTT, /**< Indicates invalid the effect mode. */
+ /**< Indicates the one-shot vibration with the given duration. */
+ HDF_VIBRATOR_MODE_ONCE,
+ /**< Indicates the periodic vibration with the preset effect. */
+ HDF_VIBRATOR_MODE_PRESET,
+ /**< Indicates invalid the effect mode. */
+ HDF_VIBRATOR_MODE_BUTT,
};
-
diff --git a/vibrator/v1_1/BUILD.gn b/vibrator/v1_1/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..0df9d9670f3a321f734e866b6d56bc28d54eabc0
--- /dev/null
+++ b/vibrator/v1_1/BUILD.gn
@@ -0,0 +1,33 @@
+# Copyright (c) 2022 Huawei Device Co., Ltd.
+# 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.
+
+import("//drivers/adapter/uhdf2/hdi.gni")
+if (defined(ohos_lite)) {
+ group("libvibrator_proxy_1.1") {
+ deps = []
+ public_configs = []
+ }
+} else {
+ hdi("vibrator") {
+ module_name = "vibrator_service"
+
+ sources = [
+ "IVibratorInterface.idl",
+ "VibratorTypes.idl",
+ ]
+
+ language = "cpp"
+ subsystem_name = "hdf"
+ part_name = "vibrator_device_driver"
+ }
+}
diff --git a/vibrator/v1_1/IVibratorInterface.idl b/vibrator/v1_1/IVibratorInterface.idl
new file mode 100644
index 0000000000000000000000000000000000000000..163043e1900ea95f64b8713c2cb1b661e0eed78c
--- /dev/null
+++ b/vibrator/v1_1/IVibratorInterface.idl
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * 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.
+ */
+
+/**
+ * @addtogroup Vibrator
+ * @{
+ *
+ * @brief Provides a driver for upper-layer vibrator services.
+ *
+ * After obtaining a driver object or agent, a vibrator service get vibrator ability or
+ * set the vibrator effect using the functions provided by the driver object or agent.
+ *
+ * @since 3.2
+ */
+
+/**
+ * @file VibratorTypes.idl
+ *
+ * @brief Declares common APIs in the vibrator module. The APIs canObtains information about all the vibrator
+ * that support setting intensity and Start the vibrator according to the incoming vibration effect.
+ *
+ * @since 3.2
+ * @version 1.1
+ */
+
+package ohos.hdi.vibrator.v1_1;
+
+import ohos.hdi.vibrator.v1_1.VibratorTypes;
+
+interface IVibratorInterface {
+ /**
+ * @brief Controls the vibrator to perform a one-shot vibration that lasts for a given duration.
+ *
+ * One-shot vibration is mutually exclusive with periodic vibration. Before using one-shot vibration,
+ * exit periodic vibration.
+ *
+ * @param duration Indicates the duration that the one-shot vibration lasts, in milliseconds.
+ * @return Returns 0 if the operation is successful; returns a negative value otherwise.
+ *
+ * @since 2.2
+ * @version 1.0
+ */
+ StartOnce([in] unsigned int duration);
+ /**
+ * @brief Controls the vibrator to perform a periodic vibration with the preset effect.
+ *
+ * One-shot vibration is mutually exclusive with periodic vibration. Before using periodic vibration,
+ * exit one-shot vibration.
+ *
+ * @param effectType Indicates the pointer to the preset effect type. It is recommended that the
+ * maximum length be 64 bytes.
+ * @return Returns 0 if the operation is successful; returns a negative value otherwise.
+ *
+ * @since 2.2
+ * @version 1.0
+ */
+ Start([in] String effectType);
+ /**
+ * @brief Stops the vibration.
+ *
+ * Before the vibrator starts, it must stop vibrating in any mode. This function can be used during
+ * and after the vibrating process.
+ *
+ * @param mode Indicates the vibration mode, which can be one-shot or periodic. For details,
+ * see {@link HdfVibratorMode}.
+ * @return Returns 0 if the operation is successful; returns a negative value otherwise.
+ *
+ * @since 2.2
+ * @version 1.0
+ */
+ Stop([in] enum HdfVibratorMode mode);
+ /**
+ * @brief Obtains information about all the vibrator that support setting intensity and frequency in the system.
+ *
+ * @param vibratorInfo Indicates the pointer to the vibration effect, For details, see {@link HdfVibratorInfo}.
+ *
+ * @return Returns 0 if the operation is successful.
+ * @return Returns negative value if the get failed.
+ *
+ * @since 3.2
+ * @version 1.1
+ */
+ GetVibratorInfo([out] struct HdfVibratorInfo[] vibratorInfo);
+ /**
+ * @brief Start the vibrator according to the incoming vibration effect.
+ *
+ * @param vibrationPeriod Indicates vibration period (in ms).
+ *
+ * @param intensity Indicates vibrator intensity in a vibration period.
+ *
+ * @param frequency Indicates vibrator frequency in a vibration period.
+ *
+ * @return Returns 0 if the operation is successful.
+ * @return Returns -1 if the vibrationPeriod setting is not supported.
+ * @return Returns -2 if the intensity setting is not supported.
+ * @return Returns -3 if the frequency setting is not supported.
+ *
+ * @since 3.2
+ * @version 1.1
+ */
+ SetModulationParameter([in] unsigned int vibrationPeriod, [in] int intensity, [in] int frequency);
+}
\ No newline at end of file
diff --git a/vibrator/v1_1/VibratorTypes.idl b/vibrator/v1_1/VibratorTypes.idl
new file mode 100644
index 0000000000000000000000000000000000000000..5bc107e4f0ee18092ddef722262fc4f3b9c0c966
--- /dev/null
+++ b/vibrator/v1_1/VibratorTypes.idl
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * 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 ohos.hdi.vibrator.v1_1;
+
+/**
+ * @brief Enumerates the vibration modes of this vibrator.
+ *
+ * @since 2.2
+ */
+enum HdfVibratorMode {
+ /**< Indicates the one-shot vibration with the given duration. */
+ HDF_VIBRATOR_MODE_ONCE,
+ /**< Indicates the periodic vibration with the preset effect. */
+ HDF_VIBRATOR_MODE_PRESET,
+ /**< Indicates invalid the effect mode. */
+ HDF_VIBRATOR_MODE_BUTT,
+};
+
+/**
+ * @brief Defines the vibration parameters.
+ *
+ * The parameters include the setting intensity and frequency capability the on and intensity and frequency range.
+ *
+ * @since 3.2
+ */
+struct HdfVibratorInfo {
+ /**< setting intensity capability. 1 indicates support, 0 indicates not support. */
+ int isSupportIntensity;
+ /**< setting frequency capability. 1 indicates support, 0 indicates not support. */
+ int isSupportFrequency;
+ /**< Max intensity */
+ int intensityMaxValue;
+ /**< Min intensity */
+ int intensityMinValue;
+ /**< Max frequency */
+ int frequencyMaxValue;
+ /**< Min frequency */
+ int frequencyMinValue;
+};