2022-11-21 02:29:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 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.
|
|
|
|
*/
|
|
|
|
|
2023-12-11 09:08:03 +00:00
|
|
|
/**
|
|
|
|
* @file
|
2024-01-08 07:25:39 +00:00
|
|
|
* @kit SensorServiceKit
|
2023-12-11 09:08:03 +00:00
|
|
|
*/
|
|
|
|
|
2022-11-21 02:29:10 +00:00
|
|
|
/**
|
2023-06-08 13:35:57 +00:00
|
|
|
* @interface VibrateOptions
|
2022-11-21 02:29:10 +00:00
|
|
|
* @permission ohos.permission.VIBRATE
|
2023-06-21 10:18:14 +00:00
|
|
|
* @syscap SystemCapability.Sensors.MiscDevice.Lite
|
2022-11-21 02:29:10 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 8
|
2022-11-22 07:41:54 +00:00
|
|
|
* @useinstead ohos.vibrator/vibrator.VibrateTime
|
2022-11-21 02:29:10 +00:00
|
|
|
*/
|
2023-04-21 09:47:24 +00:00
|
|
|
export interface VibrateOptions {
|
2022-11-21 07:28:54 +00:00
|
|
|
/**
|
|
|
|
* Vibration mode. The value long indicates long vibration, and short indicates short vibration.
|
|
|
|
* The default value is long.
|
2023-05-24 03:57:19 +00:00
|
|
|
*
|
2023-06-08 13:35:57 +00:00
|
|
|
* @permission ohos.permission.VIBRATE
|
2024-07-04 13:00:30 +00:00
|
|
|
* @type { ?('long' | 'short') }
|
2023-06-21 10:18:14 +00:00
|
|
|
* @syscap SystemCapability.Sensors.MiscDevice.Lite
|
2022-11-21 07:28:54 +00:00
|
|
|
* @since 3
|
2023-05-24 03:57:19 +00:00
|
|
|
* @deprecated since 8
|
2022-11-21 07:28:54 +00:00
|
|
|
*/
|
2023-05-24 03:57:19 +00:00
|
|
|
mode?: 'long' | 'short';
|
2022-11-21 02:29:10 +00:00
|
|
|
|
2022-11-21 07:28:54 +00:00
|
|
|
/**
|
|
|
|
* Called when success to trigger vibration.
|
2023-05-24 03:57:19 +00:00
|
|
|
*
|
2023-06-08 13:35:57 +00:00
|
|
|
* @permission ohos.permission.VIBRATE
|
2024-07-04 13:00:30 +00:00
|
|
|
* @type { function }
|
2023-06-21 10:18:14 +00:00
|
|
|
* @syscap SystemCapability.Sensors.MiscDevice.Lite
|
2022-11-21 07:28:54 +00:00
|
|
|
* @since 3
|
2023-05-24 03:57:19 +00:00
|
|
|
* @deprecated since 8
|
2022-11-21 07:28:54 +00:00
|
|
|
*/
|
|
|
|
success: () => void;
|
2022-11-21 02:29:10 +00:00
|
|
|
|
2022-11-21 07:28:54 +00:00
|
|
|
/**
|
|
|
|
* Called when fail to trigger vibration.
|
2023-05-24 03:57:19 +00:00
|
|
|
*
|
2023-06-08 13:35:57 +00:00
|
|
|
* @permission ohos.permission.VIBRATE
|
2024-07-04 13:00:30 +00:00
|
|
|
* @type { ?function }
|
2023-06-21 10:18:14 +00:00
|
|
|
* @syscap SystemCapability.Sensors.MiscDevice.Lite
|
2022-11-21 07:28:54 +00:00
|
|
|
* @since 3
|
2023-05-24 03:57:19 +00:00
|
|
|
* @deprecated since 8
|
2022-11-21 07:28:54 +00:00
|
|
|
*/
|
|
|
|
fail?: (data: string, code: number) => void;
|
2022-11-21 02:29:10 +00:00
|
|
|
|
2022-11-21 07:28:54 +00:00
|
|
|
/**
|
|
|
|
* Called when the execution is completed.
|
2023-05-24 03:57:19 +00:00
|
|
|
*
|
2023-06-08 13:35:57 +00:00
|
|
|
* @permission ohos.permission.VIBRATE
|
2024-07-04 13:00:30 +00:00
|
|
|
* @type { ?function }
|
2023-06-21 10:18:14 +00:00
|
|
|
* @syscap SystemCapability.Sensors.MiscDevice.Lite
|
2022-11-21 07:28:54 +00:00
|
|
|
* @since 3
|
2023-05-24 03:57:19 +00:00
|
|
|
* @deprecated since 8
|
2022-11-21 07:28:54 +00:00
|
|
|
*/
|
|
|
|
complete?: () => void;
|
|
|
|
}
|
2022-11-21 02:29:10 +00:00
|
|
|
|
2023-04-21 09:47:24 +00:00
|
|
|
/**
|
|
|
|
* @permission ohos.permission.VIBRATE
|
2023-06-21 10:18:14 +00:00
|
|
|
* @syscap SystemCapability.Sensors.MiscDevice.Lite
|
2023-04-21 09:47:24 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 8
|
|
|
|
* @useinstead ohos.vibrator/vibrator
|
|
|
|
*/
|
|
|
|
export default class Vibrator {
|
2022-11-21 07:28:54 +00:00
|
|
|
/**
|
|
|
|
* Triggers vibration.
|
2023-05-24 03:57:19 +00:00
|
|
|
*
|
2022-11-21 07:28:54 +00:00
|
|
|
* @permission ohos.permission.VIBRATE
|
2023-06-08 13:35:57 +00:00
|
|
|
* @param { VibrateOptions } options Options.
|
2023-06-21 10:18:14 +00:00
|
|
|
* @syscap SystemCapability.Sensors.MiscDevice.Lite
|
2022-11-21 07:28:54 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 8
|
|
|
|
* @useinstead ohos.vibrator/vibrator#startVibration
|
|
|
|
*/
|
|
|
|
static vibrate(options?: VibrateOptions): void;
|
2023-05-24 03:57:19 +00:00
|
|
|
}
|