diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts old mode 100755 new mode 100644 index e8f1bece16b6cd6c15fc896440b372e2a19a900d..13911f22c23cad4b954a98580c7867da1c188199 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -50,6 +50,17 @@ declare namespace vibrator { function vibrate(effectId: EffectId): Promise; function vibrate(effectId: EffectId, callback?: AsyncCallback): void; + /** + * Trigger vibrator vibration. + * @param effect Describes the effect of vibration. + * @param attribute The attribute of vibration. + * @syscap SystemCapability.Sensors.MiscDevice + * @permission ohos.permission.VIBRATE + * @since 9 + */ + function vibrate(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallback): void; + function vibrate(effect: VibrateEffect, attribute: VibrateAttribute): Promise; + /** * Stop the motor from vibrating. * @param stopMode Indicate the stop mode in which the motor vibrates, {@code VibratorStopMode}. @@ -81,6 +92,52 @@ declare namespace vibrator { /* Indicates the mode of stopping a preset vibration effect.*/ VIBRATOR_STOP_MODE_PRESET = "preset", } + + /** + * The use of vibration. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + type Usage = "unknown" | "alarm" | "ring" | "notification" | "communication" | + "touch" | "media" | "physicalFeedback" | "simulateReality"; + + /** + * The attribute of vibration. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + interface VibrateAttribute { + id?: number, /** Vibrator id, default is 0. */ + usage: Usage, /** The use of vibration. */ + } + + /** + * Describes the effect of vibration. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + type VibrateEffect = VibrateTime | VibratePreset; + + /** + * Specifies the duration of the vibration effect. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + interface VibrateTime { + type: "time"; + duration: number; /** The duration of the vibration, in ms */ + } + + /** + * Preset vibration type vibration effect. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + interface VibratePreset { + type: "preset"; + effectId: string; /** Preset type vibration */ + count: number; /** The number of vibration repetitions */ + } } export default vibrator; \ No newline at end of file