From c4c449023f23d77b6e1b400247f2e369fda4ebb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=8E?= Date: Sat, 22 Jan 2022 11:26:57 +0800 Subject: [PATCH 1/5] add work sheduler ts. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈明 --- api/@ohos.workScheduler.d.ts | 303 +++++++++++++++++++++++++++++++++++ 1 file changed, 303 insertions(+) create mode 100644 api/@ohos.workScheduler.d.ts diff --git a/api/@ohos.workScheduler.d.ts b/api/@ohos.workScheduler.d.ts new file mode 100644 index 0000000000..7e625229ed --- /dev/null +++ b/api/@ohos.workScheduler.d.ts @@ -0,0 +1,303 @@ +/* + * 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 {AsyncCallback} from './basic'; + +/** + * Work scheduler interface. + * + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tv, wearable, tablet, car + */ +declare namespace workScheduler { + /** + * The info of work. + * + * @name WorkInfo + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tv, wearable, tablet, car + */ + export interface WorkInfo { + /** + * The id of the current work. + */ + workId: number; + /** + * The network type of the current work. + */ + networkType?: NetworkType; + /** + * Whether the device deep idle state has been set for triggering the work. + */ + isDeepIdle?: boolean; + /** + * The idle wait time based on which the work is triggered. + */ + idleWaitTime?: number; + /** + * Whether a charging state has been set for triggering the work. + */ + isCharging?: boolean; + /** + * The charger type based on which the work is triggered. + */ + chargerType?: ChargingType; + /** + * The battery level for triggering a work. + */ + batteryLevel?: number; + /** + * The battery status for triggering a work. + */ + batteryStatus?: BatteryStatus; + /** + * Whether a storage state has been set for triggering the work. + */ + storageRequest?: StorageRequest; + /** + * Whether the work has been set to repeat at the specified interval. + */ + isRepeat?: boolean; + /** + * Whether the current work will be saved. + */ + isPersisted?: boolean; + /** + * The interval at which the work is repeated. + */ + repeatCycleTime?: number; + /** + * The repeat of the current work. + */ + repeatCount?: number; + /** + * The bundle name of the current work. + */ + bundleName: string; + /** + * The ability name of the current work. + */ + abilityName: string; + } + + /** + * Class of the work scheduler extension. + * + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tv, wearable, tablet, car + */ + export default class WorkSchedulerExtension { + /** + * Called back when a work is started. + * + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tv, wearable, tablet, car + * @param work The info of work. + */ + onWorkStart(work: WorkInfo): void; + + /** + * Called back when a work is stopped. + * + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tv, wearable, tablet, car + * @param work The info of work. + */ + onWorkStop(work: WorkInfo): void; + } + + /** + * Add a work to the queue. A work can be executed only when it meets the preset triggering condition + * and complies with the rules fo work scheduler manager. + * + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tv, wearable, tablet, car + * @param work The info of work. + * @return true if success, otherwise false. + */ + function startWork(work: WorkInfo): boolean; + + /** + * Stop a work. + * + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tv, wearable, tablet, car + * @param work The info of work. + * @param needCancel Indicates the work that whether need to be canceled. + * @return true if success, otherwise false. + */ + function stopWork(work: WorkInfo, needCancel?: boolean): boolean; + + /** + * Obtains the latest status of a work. + * + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tv, wearable, tablet, car + * @param workId The id of work. + */ + function getWorkStatus(workId: number, callback: AsyncCallback): void; + function getWorkStatus(workId: number): Promise; + + /** + * Get all work status. + * + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tv, wearable, tablet, car + * @param workId The id of work. + * @return the work info list. + */ + function obtainAllWorks(callback: AsyncCallback): Array; + function obtainAllWorks(): Promise>; + + /** + * Stop all and clear work. + * + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tv, wearable, tablet, car + * @return true if success, otherwise false. + */ + function stopAndClearWorks(): boolean; + + /** + * Check last work timeout. + * + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tv, wearable, tablet, car + * @param workId The id of work. + * @return true if last work is timeout, otherwise false. + */ + function isLastWorkTimeOut(workId: number, callback: AsyncCallback): boolean; + function isLastWorkTimeOut(workId: number): Promise; + + /** + * Describes network type. + * + * @name NetworkType + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tablet, tv, wearable, car + */ + export enum NetworkType { + /** + * Describes any network connection. + */ + NETWORK_TYPE_ANY = 0, + /** + * Describes a mobile network connection. + */ + NETWORK_TYPE_MOBILE, + /** + * Describes a wifi network connection. + */ + NETWORK_TYPE_WIFI, + /** + * Describes a bluetooth network connection. + */ + NETWORK_TYPE_BLUETOOTH, + /** + * Describes a wifi p2p network connection. + */ + NETWORK_TYPE_WIFI_P2P, + /** + * Describes a wifi wire network connection. + */ + NETWORK_TYPE_ETHERNET + } + + /** + * Describes charging type. + * + * @name ChargingType + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tablet, tv, wearable, car + */ + export enum ChargingType { + /** + * Describes any charger is connected. + */ + CHARGING_PLUGGED_ANY = 0, + /** + * Describes ac charger is connected. + */ + CHARGING_PLUGGED_AC, + /** + * Describes usb charger is connected. + */ + CHARGING_PLUGGED_USB, + /** + * Describes wireless charger is connected. + */ + CHARGING_PLUGGED_WIRELESS + } + + /** + * Describes the battery status. + * + * @name BatteryStatus + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tablet, tv, wearable, car + */ + export enum BatteryStatus { + /** + * Describes battery status is to low. + */ + BATTERY_STATUS_LOW = 0, + /** + * Describes battery status is to ok. + */ + BATTERY_STATUS_OKAY, + /** + * Describes battery status is to low or ok. + */ + BATTERY_STATUS_LOW_OR_OKAY + } + + /** + * Describes the storage request. + * + * @name StorageRequest + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tablet, tv, wearable, car + */ + export enum StorageRequest { + /** + * Describes storage is to low. + */ + STORAGE_LEVEL_LOW = 0, + /** + * Describes storage is to ok. + */ + STORAGE_LEVEL_OKAY, + /** + * Describes storage is to low or ok. + */ + STORAGE_LEVEL_LOW_OR_OKAY + } +} +export default workScheduler; \ No newline at end of file -- Gitee From 566764753f8fde917d22e79fbfed65ce5d4ccf27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=8E?= Date: Sat, 22 Jan 2022 12:55:01 +0800 Subject: [PATCH 2/5] add work scheudler extension ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈明 --- api/@ohos.workScheduler.d.ts | 29 ----------------- api/@ohos.workSchedulerExtension.d.ts | 45 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 29 deletions(-) create mode 100644 api/@ohos.workSchedulerExtension.d.ts diff --git a/api/@ohos.workScheduler.d.ts b/api/@ohos.workScheduler.d.ts index 7e625229ed..1084775d20 100644 --- a/api/@ohos.workScheduler.d.ts +++ b/api/@ohos.workScheduler.d.ts @@ -94,35 +94,6 @@ declare namespace workScheduler { abilityName: string; } - /** - * Class of the work scheduler extension. - * - * @since 8 - * @sysCap SystemCapability.Ressched.WorkScheduler - * @devices phone, tv, wearable, tablet, car - */ - export default class WorkSchedulerExtension { - /** - * Called back when a work is started. - * - * @since 8 - * @sysCap SystemCapability.Ressched.WorkScheduler - * @devices phone, tv, wearable, tablet, car - * @param work The info of work. - */ - onWorkStart(work: WorkInfo): void; - - /** - * Called back when a work is stopped. - * - * @since 8 - * @sysCap SystemCapability.Ressched.WorkScheduler - * @devices phone, tv, wearable, tablet, car - * @param work The info of work. - */ - onWorkStop(work: WorkInfo): void; - } - /** * Add a work to the queue. A work can be executed only when it meets the preset triggering condition * and complies with the rules fo work scheduler manager. diff --git a/api/@ohos.workSchedulerExtension.d.ts b/api/@ohos.workSchedulerExtension.d.ts new file mode 100644 index 0000000000..6afa3a9ecc --- /dev/null +++ b/api/@ohos.workSchedulerExtension.d.ts @@ -0,0 +1,45 @@ +/* + * 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 workScheduler from "../@ohos.workScheduler"; + +/** + * Class of the work scheduler extension. + * + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tv, wearable, tablet, car + */ +export default class WorkSchedulerExtension { + /** + * Called back when a work is started. + * + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tv, wearable, tablet, car + * @param work The info of work. + */ + onWorkStart(work: workScheduler.WorkInfo): void; + + /** + * Called back when a work is stopped. + * + * @since 8 + * @sysCap SystemCapability.Ressched.WorkScheduler + * @devices phone, tv, wearable, tablet, car + * @param work The info of work. + */ + onWorkStop(work: workScheduler.WorkInfo): void; +} \ No newline at end of file -- Gitee From 00e54cd347f6210fb169aae75b1f3679080319ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=8E?= Date: Sat, 22 Jan 2022 13:02:17 +0800 Subject: [PATCH 3/5] change work scheduler extension ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈明 --- api/@ohos.workSchedulerExtension.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@ohos.workSchedulerExtension.d.ts b/api/@ohos.workSchedulerExtension.d.ts index 6afa3a9ecc..359b9075a6 100644 --- a/api/@ohos.workSchedulerExtension.d.ts +++ b/api/@ohos.workSchedulerExtension.d.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import workScheduler from "../@ohos.workScheduler"; +import workScheduler from "./@ohos.workScheduler"; /** * Class of the work scheduler extension. -- Gitee From 28c37bd20ecb65b7e6ff6affb775fb0eb66229ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=8E?= Date: Sat, 22 Jan 2022 15:46:10 +0800 Subject: [PATCH 4/5] change to api9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈明 --- api/@ohos.workSchedulerExtension.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/@ohos.workSchedulerExtension.d.ts b/api/@ohos.workSchedulerExtension.d.ts index 359b9075a6..7dd6011498 100644 --- a/api/@ohos.workSchedulerExtension.d.ts +++ b/api/@ohos.workSchedulerExtension.d.ts @@ -18,7 +18,7 @@ import workScheduler from "./@ohos.workScheduler"; /** * Class of the work scheduler extension. * - * @since 8 + * @since 9 * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tv, wearable, tablet, car */ @@ -26,7 +26,7 @@ export default class WorkSchedulerExtension { /** * Called back when a work is started. * - * @since 8 + * @since 9 * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tv, wearable, tablet, car * @param work The info of work. @@ -36,7 +36,7 @@ export default class WorkSchedulerExtension { /** * Called back when a work is stopped. * - * @since 8 + * @since 9 * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tv, wearable, tablet, car * @param work The info of work. -- Gitee From f05b1dfbd2a288bab4b841cdae5b0b6b87b5ba7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=8E?= Date: Sun, 23 Jan 2022 17:17:28 +0800 Subject: [PATCH 5/5] change api version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈明 --- api/@ohos.workScheduler.d.ts | 24 ++++++++++++------------ api/@ohos.workSchedulerExtension.d.ts | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/api/@ohos.workScheduler.d.ts b/api/@ohos.workScheduler.d.ts index 1084775d20..91be8d4a04 100644 --- a/api/@ohos.workScheduler.d.ts +++ b/api/@ohos.workScheduler.d.ts @@ -18,7 +18,7 @@ import {AsyncCallback} from './basic'; /** * Work scheduler interface. * - * @since 8 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tv, wearable, tablet, car */ @@ -27,7 +27,7 @@ declare namespace workScheduler { * The info of work. * * @name WorkInfo - * @since 8 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tv, wearable, tablet, car */ @@ -98,7 +98,7 @@ declare namespace workScheduler { * Add a work to the queue. A work can be executed only when it meets the preset triggering condition * and complies with the rules fo work scheduler manager. * - * @since 8 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tv, wearable, tablet, car * @param work The info of work. @@ -109,7 +109,7 @@ declare namespace workScheduler { /** * Stop a work. * - * @since 8 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tv, wearable, tablet, car * @param work The info of work. @@ -121,7 +121,7 @@ declare namespace workScheduler { /** * Obtains the latest status of a work. * - * @since 8 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tv, wearable, tablet, car * @param workId The id of work. @@ -132,7 +132,7 @@ declare namespace workScheduler { /** * Get all work status. * - * @since 8 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tv, wearable, tablet, car * @param workId The id of work. @@ -144,7 +144,7 @@ declare namespace workScheduler { /** * Stop all and clear work. * - * @since 8 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tv, wearable, tablet, car * @return true if success, otherwise false. @@ -154,7 +154,7 @@ declare namespace workScheduler { /** * Check last work timeout. * - * @since 8 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tv, wearable, tablet, car * @param workId The id of work. @@ -167,7 +167,7 @@ declare namespace workScheduler { * Describes network type. * * @name NetworkType - * @since 8 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tablet, tv, wearable, car */ @@ -202,7 +202,7 @@ declare namespace workScheduler { * Describes charging type. * * @name ChargingType - * @since 8 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tablet, tv, wearable, car */ @@ -229,7 +229,7 @@ declare namespace workScheduler { * Describes the battery status. * * @name BatteryStatus - * @since 8 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tablet, tv, wearable, car */ @@ -252,7 +252,7 @@ declare namespace workScheduler { * Describes the storage request. * * @name StorageRequest - * @since 8 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tablet, tv, wearable, car */ diff --git a/api/@ohos.workSchedulerExtension.d.ts b/api/@ohos.workSchedulerExtension.d.ts index 7dd6011498..05499ba10d 100644 --- a/api/@ohos.workSchedulerExtension.d.ts +++ b/api/@ohos.workSchedulerExtension.d.ts @@ -18,7 +18,7 @@ import workScheduler from "./@ohos.workScheduler"; /** * Class of the work scheduler extension. * - * @since 9 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tv, wearable, tablet, car */ @@ -26,7 +26,7 @@ export default class WorkSchedulerExtension { /** * Called back when a work is started. * - * @since 9 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tv, wearable, tablet, car * @param work The info of work. @@ -36,7 +36,7 @@ export default class WorkSchedulerExtension { /** * Called back when a work is stopped. * - * @since 9 + * @since 9 Preview * @sysCap SystemCapability.Ressched.WorkScheduler * @devices phone, tv, wearable, tablet, car * @param work The info of work. -- Gitee