From b2847c30763820bf1617cac3e19ed2bcc64298bb Mon Sep 17 00:00:00 2001 From: guduhanyan Date: Sun, 26 Sep 2021 17:07:18 +0800 Subject: [PATCH 1/3] 20210926SDK00 Signed-off-by: guduhanyan --- api/@ohos.systemTime.d.ts | 22 ++++++- api/@ohos.systemTimer.d.ts | 116 +++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 api/@ohos.systemTimer.d.ts diff --git a/api/@ohos.systemTime.d.ts b/api/@ohos.systemTime.d.ts index c6d1039d5f..1d19a79584 100755 --- a/api/@ohos.systemTime.d.ts +++ b/api/@ohos.systemTime.d.ts @@ -21,9 +21,29 @@ import { AsyncCallback, ErrorCallback } from './basic'; * @since 6 */ declare namespace systemTime { - // Sets the system time. + /** + * Sets the system time. + * @permission ohos.permission.SET_TIME + * @since 6 + */ function setTime(time : number, callback : AsyncCallback) : void; function setTime(time : number) : Promise; + + /** + * Sets the system time. + * @permission ohos.permission.SET_TIME + * @since 7 + */ + function setDate(date: Date, callback: AsyncCallback): void; + function setDate(date: Date): Promise; + + /** + * Sets the system time zone. + * @permission ohos.permission.SET_TIME_ZONE + * @since 7 + */ + function setTimezone(timezone: string, callback: AsyncCallback): void; + function setTimezone(timezone: string): Promise; } export default systemTime; diff --git a/api/@ohos.systemTimer.d.ts b/api/@ohos.systemTimer.d.ts new file mode 100644 index 0000000000..4a55a96409 --- /dev/null +++ b/api/@ohos.systemTimer.d.ts @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2021 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 { AsyncCallback, ErrorCallback } from './basic'; +import { WantAgent } from './@ohos.wantAgent'; + +/** + * Provides js api for systemTimer + * + * @since 7 + * @devices phone, tablet, tv, wearable + * @systemapi Hide this for inner system use. + */ +declare namespace systemTimer { + /** + * Indicates the timing policy the timer use, which can be REALTIME or UTC. + */ + const TIMER_TYPE_REALTIME: number; + + /** + * Describes whether a timer will wake the device up. + */ + const TIMER_TYPE_WAKEUP: number; + + /** + * Describes whether a timer will be delivered precisely at a scheduled time. + */ + const TIMER_TYPE_EXACT: number; + + /** + * Indicates whether the timer waking up the system is supported in low-power mode. + */ + const TIMER_TYPE_IDLE: number; + + /** + * Creates a timer. + * @since 7 + * @Param options Indicates the timer options. + * @Return timer ID. + * + * @systemapi Hide this for inner system use. + */ + function createTimer(options: TimerOptions, callback: AsyncCallback): void; + function createTimer(options: TimerOptions): Promise; + + /** + * Starts a timer. + *@since 7 + * @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. + * @systemapi Hide this for inner system use. + */ + function startTimer(timer: number, triggerTime: number, callback: AsyncCallback): void; + function startTimer(timer: number, triggerTime: number): Promise; + + /** + * Stops a timer. + * @since 7 + * @Param timer The timer ID. + * @systemapi Hide this for inner system use. + */ + function stopTimer(timer: number, callback: AsyncCallback): void; + function stopTimer(timer: number): Promise; + + /** + * Clears a timer. + * @since 7 + * @Param timer The timer ID. + * @systemapi Hide this for inner system use. + */ + function destroyTimer(timer: number, callback: AsyncCallback): void; + function destroyTimer(timer: number): Promise; + + interface TimerOptions { + /** + * timer type. + */ + type: number; + + /** + * Indicates a repeating timer + */ + 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. + */ + interval?: number; + + /** + * Indicates the intent to send when the timer goes off. + */ + wantAgent?: WantAgent; + + /** + * Called back when the timer goes off. + */ + callback?: () => void; + } +} + +export default systemTimer; \ No newline at end of file -- Gitee From feb5e5ca930490de9df5655d672457e24bf309ea Mon Sep 17 00:00:00 2001 From: guduhanyan Date: Mon, 27 Sep 2021 11:57:11 +0800 Subject: [PATCH 2/3] 20210927sdk00 Signed-off-by: guduhanyan --- api/@ohos.systemTime.d.ts | 12 ++++++------ api/@ohos.systemTimer.d.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/api/@ohos.systemTime.d.ts b/api/@ohos.systemTime.d.ts index 1d19a79584..eec8180bf9 100755 --- a/api/@ohos.systemTime.d.ts +++ b/api/@ohos.systemTime.d.ts @@ -26,24 +26,24 @@ declare namespace systemTime { * @permission ohos.permission.SET_TIME * @since 6 */ - function setTime(time : number, callback : AsyncCallback) : void; - function setTime(time : number) : Promise; + function setTime(time : number, callback : AsyncCallback) : void; + function setTime(time : number) : Promise; /** * Sets the system time. * @permission ohos.permission.SET_TIME * @since 7 */ - function setDate(date: Date, callback: AsyncCallback): void; - function setDate(date: Date): Promise; + function setDate(date: Date, callback: AsyncCallback): void; + function setDate(date: Date): Promise; /** * Sets the system time zone. * @permission ohos.permission.SET_TIME_ZONE * @since 7 */ - function setTimezone(timezone: string, callback: AsyncCallback): void; - function setTimezone(timezone: string): Promise; + function setTimezone(timezone: string, callback: AsyncCallback): void; + function setTimezone(timezone: string): Promise; } export default systemTime; diff --git a/api/@ohos.systemTimer.d.ts b/api/@ohos.systemTimer.d.ts index 4a55a96409..976db5b80e 100644 --- a/api/@ohos.systemTimer.d.ts +++ b/api/@ohos.systemTimer.d.ts @@ -63,8 +63,8 @@ declare namespace systemTimer { * value is smaller than the current time plus 5000 milliseconds. * @systemapi Hide this for inner system use. */ - function startTimer(timer: number, triggerTime: number, callback: AsyncCallback): void; - function startTimer(timer: number, triggerTime: number): Promise; + function startTimer(timer: number, triggerTime: number, callback: AsyncCallback): void; + function startTimer(timer: number, triggerTime: number): Promise; /** * Stops a timer. @@ -72,8 +72,8 @@ declare namespace systemTimer { * @Param timer The timer ID. * @systemapi Hide this for inner system use. */ - function stopTimer(timer: number, callback: AsyncCallback): void; - function stopTimer(timer: number): Promise; + function stopTimer(timer: number, callback: AsyncCallback): void; + function stopTimer(timer: number): Promise; /** * Clears a timer. @@ -81,8 +81,8 @@ declare namespace systemTimer { * @Param timer The timer ID. * @systemapi Hide this for inner system use. */ - function destroyTimer(timer: number, callback: AsyncCallback): void; - function destroyTimer(timer: number): Promise; + function destroyTimer(timer: number, callback: AsyncCallback): void; + function destroyTimer(timer: number): Promise; interface TimerOptions { /** -- Gitee From 79a3f298b52c53ad2988597271ba1fe23f45dc71 Mon Sep 17 00:00:00 2001 From: guduhanyan Date: Tue, 28 Sep 2021 10:11:45 +0800 Subject: [PATCH 3/3] 20210928sdk00 Signed-off-by: guduhanyan --- api/@ohos.systemTime.d.ts | 11 ++++++++--- api/@ohos.systemTimer.d.ts | 28 +++++++++++++--------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/api/@ohos.systemTime.d.ts b/api/@ohos.systemTime.d.ts index eec8180bf9..d69ec642af 100755 --- a/api/@ohos.systemTime.d.ts +++ b/api/@ohos.systemTime.d.ts @@ -17,14 +17,17 @@ import { AsyncCallback, ErrorCallback } from './basic'; /** * System time and timezone. - * - * @since 6 + * @since 7 + * @sysCap SystemCapability.Miscservices.Time + * @devices phone, tablet, tv, wearable, car + * @import systemTime from '@ohos.systemTime'; */ declare namespace systemTime { /** * Sets the system time. * @permission ohos.permission.SET_TIME - * @since 6 + * @param time Target time stamp (ms) + * @since 7 */ function setTime(time : number, callback : AsyncCallback) : void; function setTime(time : number) : Promise; @@ -32,6 +35,7 @@ declare namespace systemTime { /** * Sets the system time. * @permission ohos.permission.SET_TIME + * @param date The target date * @since 7 */ function setDate(date: Date, callback: AsyncCallback): void; @@ -40,6 +44,7 @@ declare namespace systemTime { /** * Sets the system time zone. * @permission ohos.permission.SET_TIME_ZONE + * @param timezone The system time zone * @since 7 */ function setTimezone(timezone: string, callback: AsyncCallback): void; diff --git a/api/@ohos.systemTimer.d.ts b/api/@ohos.systemTimer.d.ts index 976db5b80e..987f9067a8 100644 --- a/api/@ohos.systemTimer.d.ts +++ b/api/@ohos.systemTimer.d.ts @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { AsyncCallback, ErrorCallback } from './basic'; import { WantAgent } from './@ohos.wantAgent'; @@ -19,7 +20,7 @@ import { WantAgent } from './@ohos.wantAgent'; * Provides js api for systemTimer * * @since 7 - * @devices phone, tablet, tv, wearable + * @devices phone, tablet, tv, wearable, car * @systemapi Hide this for inner system use. */ declare namespace systemTimer { @@ -45,51 +46,48 @@ declare namespace systemTimer { /** * Creates a timer. - * @since 7 * @Param options Indicates the timer options. * @Return timer ID. - * - * @systemapi Hide this for inner system use. */ function createTimer(options: TimerOptions, callback: AsyncCallback): void; function createTimer(options: TimerOptions): Promise; /** * Starts a timer. - *@since 7 + * * @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. - * @systemapi Hide this for inner system use. + * 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. */ function startTimer(timer: number, triggerTime: number, callback: AsyncCallback): void; function startTimer(timer: number, triggerTime: number): Promise; /** * Stops a timer. - * @since 7 * @Param timer The timer ID. - * @systemapi Hide this for inner system use. */ - function stopTimer(timer: number, callback: AsyncCallback): void; + function stopTimer(timer: number, callback: AsyncCallback): void; function stopTimer(timer: number): Promise; /** - * Clears a timer. - * @since 7 + * Destroy a timer. * @Param timer The timer ID. - * @systemapi Hide this for inner system use. */ function destroyTimer(timer: number, callback: AsyncCallback): void; 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. + * + */ interface TimerOptions { /** * timer type. */ type: number; - + /** * Indicates a repeating timer */ -- Gitee