From c416fa944bbdf0cd8113dcd034437d9425b4ef51 Mon Sep 17 00:00:00 2001 From: wangtong Date: Mon, 26 Dec 2022 17:52:56 +0800 Subject: [PATCH] modfiy timer d.ts Signed-off-by: wangtong --- api/@ohos.systemTimer.d.ts | 150 +++++++++++++++++++++++++++++++++---- 1 file changed, 136 insertions(+), 14 deletions(-) diff --git a/api/@ohos.systemTimer.d.ts b/api/@ohos.systemTimer.d.ts index 3f7a44dd8e..e4d17cc54d 100644 --- a/api/@ohos.systemTimer.d.ts +++ b/api/@ohos.systemTimer.d.ts @@ -19,93 +19,215 @@ import { WantAgent } from './@ohos.wantAgent'; /** * Provides js api for systemTimer * - * @since 7 * @syscap SystemCapability.MiscServices.Time * @systemapi Hide this for inner system use. + * @since 7 */ declare namespace systemTimer { /** * Indicates the timing policy the timer use, which can be REALTIME or UTC. + * + * @constant + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 */ const TIMER_TYPE_REALTIME: number; /** * Describes whether a timer will wake the device up. + * + * @constant + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 */ const TIMER_TYPE_WAKEUP: number; /** * Describes whether a timer will be delivered precisely at a scheduled time. + * + * @constant + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 */ const TIMER_TYPE_EXACT: number; /** * Indicates whether the timer waking up the system is supported in low-power mode. + * + * @constant + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 */ const TIMER_TYPE_IDLE: number; /** * Creates a timer. + * * @param options Indicates the timer options. - * @returns {void | Promise} timer ID. + * @param { TimerOptions } options - The necessary configuration information. + * @param { AsyncCallback } callback - {number} is the timer ID. + * @throws { BusinessError } 202 - permission denied. + * @throws { BusinessError } 401 - if the parameter type is incorrect. + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 */ function createTimer(options: TimerOptions, callback: AsyncCallback): void; + + /** + * Creates a timer. + * + * @param options Indicates the timer options. + * @param { TimerOptions } options - The necessary configuration information. + * @returns { Promise } the timer ID. + * @throws { BusinessError } 202 - permission denied. + * @throws { BusinessError } 401 - if the parameter type is incorrect. + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 + */ function createTimer(options: TimerOptions): Promise; /** * Starts a timer. * - * @param timer The timer ID. - * @param triggerTime Indicates the time at which the timer is triggered for the first time, in milliseconds. - * The time will be automatically set to 5000 milliseconds after the current time if the passed - * value is smaller than the current time plus 5000 milliseconds. + * @param { number } timer - The timer ID. + * @param { number } triggerTime - Indicates the time at which the timer is triggered for the first time, in milliseconds. + * The time will be automatically set to 5000 milliseconds after the current time if the passed + * value is smaller than the current time plus 5000 milliseconds. + * @param { AsyncCallback } callback - The callback function. + * @throws { BusinessError } 202 - permission denied. + * @throws { BusinessError } 401 - if the parameter type is incorrect. + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 */ function startTimer(timer: number, triggerTime: number, callback: AsyncCallback): void; + + /** + * Starts a timer. + * + * @param { number } timer - The timer ID. + * @param { number } triggerTime - Indicates the time at which the timer is triggered for the first time, in milliseconds. + * The time will be automatically set to 5000 milliseconds after the current time if the passed + * value is smaller than the current time plus 5000 milliseconds. + * @returns { Promise } return a promise object. + * @throws { BusinessError } 202 - permission denied. + * @throws { BusinessError } 401 - if the parameter type is incorrect. + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 + */ function startTimer(timer: number, triggerTime: number): Promise; /** * Stops a timer. - * @param timer The timer ID. + * + * @param { number } timer - The timer ID. + * @param { AsyncCallback } callback - The callback function. + * @throws { BusinessError } 202 - permission denied. + * @throws { BusinessError } 401 - if the parameter type is incorrect. + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 */ function stopTimer(timer: number, callback: AsyncCallback): void; + + /** + * Stops a timer. + * + * @param { number } timer - The timer ID. + * @returns { Promise } return a promise object. + * @throws { BusinessError } 202 - permission denied. + * @throws { BusinessError } 401 - if the parameter type is incorrect. + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 + */ function stopTimer(timer: number): Promise; /** * Destroy a timer. - * @param timer The timer ID. + * + * @param { number } timer - The timer ID. + * @param { AsyncCallback } callback - The callback function. + * @throws { BusinessError } 202 - permission denied. + * @throws { BusinessError } 401 - if the parameter type is incorrect. + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 */ function destroyTimer(timer: number, callback: AsyncCallback): void; + + /** + * Destroy a timer. + * + * @param { number } timer - The timer ID. + * @returns { Promise } return a promise object. + * @throws { BusinessError } 202 - permission denied. + * @throws { BusinessError } 401 - if the parameter type is incorrect. + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 + */ function destroyTimer(timer: number): Promise; - /** - * When the repeat is false,the interval is not needed, choose one of wantAgent and callback. - * When the repeat is true,the interval is required, the wantAgent is required, and the callback can be left blank. - * - */ + /** + * When the repeat is false,the interval is not needed, choose one of wantAgent and callback. + * When the repeat is true,the interval is required, the wantAgent is required, and the callback can be left blank. + * + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 + */ interface TimerOptions { /** - * timer type. + * The timer type. + * + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 */ type: number; /** * Indicates a repeating timer + * + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 */ repeat: boolean; /** * Indicates the interval between two consecutive triggers, in milliseconds. * The interval will be set to 5000 milliseconds automatically if the passed value is smaller than 5000. + * + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 */ interval?: number; /** * Indicates the intent to send when the timer goes off. + * + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 */ wantAgent?: WantAgent; /** * Called back when the timer goes off. + * + * @syscap SystemCapability.MiscServices.Time + * @systemapi Hide this for inner system use. + * @since 7 */ callback?: () => void; } -- Gitee