From 40f861caae717f0c3405d3ef9548987acc83dc27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=A4=A9=E6=80=A1?= Date: Sat, 26 Nov 2022 07:26:30 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A7=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 朱天怡 --- api/@ohos.backgroundTaskManager.d.ts | 111 ------- api/@ohos.batteryStatistics.d.ts | 312 ++++++++++++------ ...esourceschedule.backgroundTaskManager.d.ts | 42 +-- 3 files changed, 240 insertions(+), 225 deletions(-) diff --git a/api/@ohos.backgroundTaskManager.d.ts b/api/@ohos.backgroundTaskManager.d.ts index 36bd393014..f707324f0e 100644 --- a/api/@ohos.backgroundTaskManager.d.ts +++ b/api/@ohos.backgroundTaskManager.d.ts @@ -111,29 +111,6 @@ declare namespace backgroundTaskManager { function stopBackgroundRunning(context: Context, callback: AsyncCallback): void; function stopBackgroundRunning(context: Context): Promise; - /** - * Apply or unapply efficiency resources. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply - * @return True if efficiency resources apply success, else false. - * @systemapi Hide this for inner system use. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.backgroundTaskManager.applyEfficiencyResources - */ - function applyEfficiencyResources(request: EfficiencyResourcesRequest): boolean; - - /** - * Reset all efficiency resources apply. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply - * @systemapi Hide this for inner system use. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.backgroundTaskManager.resetAllEfficiencyResources - */ - function resetAllEfficiencyResources(): void; - /** * Supported background mode. * @@ -218,94 +195,6 @@ declare namespace backgroundTaskManager { */ TASK_KEEPING = 9, } - - /** - * The type of resource. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply - * @systemapi Hide this for inner system use. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.backgroundTaskManager.ResourceType - */ - export enum ResourceType { - /** - * The cpu resource for not being suspended. - */ - CPU = 1, - - /** - * The resource for not being proxyed common_event. - */ - COMMON_EVENT = 1 << 1, - - /** - * The resource for not being proxyed timer. - */ - TIMER = 1 << 2, - - /** - * The resource for not being proxyed workscheduler. - */ - WORK_SCHEDULER = 1 << 3, - - /** - * The resource for not being proxyed bluetooth. - */ - BLUETOOTH = 1 << 4, - - /** - * The resource for not being proxyed gps. - */ - GPS = 1 << 5, - - /** - * The resource for not being proxyed audio. - */ - AUDIO = 1 << 6 - } - - /** - * The request of efficiency resources. - * - * @name EfficiencyResourcesRequest - * @since 9 - * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply - * @systemapi Hide this for inner system use. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.backgroundTaskManager.EfficiencyResourcesRequest - */ - export interface EfficiencyResourcesRequest { - /** - * The set of resource types that app wants to apply. - */ - resourceTypes: number; - - /** - * True if the app begin to use, else false. - */ - isApply: boolean; - - /** - * The duration that the resource can be used most. - */ - timeOut: number; - - /** - * True if the apply action is persist, else false. Default value is false. - */ - isPersist?: boolean; - - /** - * True if apply action is for process, false is for package. Default value is false. - */ - isProcess?: boolean; - - /** - * The apply reason. - */ - reason: string; - } } export default backgroundTaskManager; diff --git a/api/@ohos.batteryStatistics.d.ts b/api/@ohos.batteryStatistics.d.ts index 45289ecc6a..b2539343d2 100755 --- a/api/@ohos.batteryStatistics.d.ts +++ b/api/@ohos.batteryStatistics.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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 @@ -13,133 +13,259 @@ * limitations under the License. */ -import {AsyncCallback, BusinessError} from "./basic"; +import { AsyncCallback , Callback} from './basic'; /** - * Provides methods to get power consumption information. + * Provides methods for managing bundle usage statistics, + * including the methods for querying bundle usage information and state data. * - * @syscap SystemCapability.PowerManager.BatteryStatistics - * @systemapi - * @since 8 + *

You can use the methods defined in this class to query + * the usage history and states of bundles in a specified period. + * The system stores the query result in a {@link BundleStateInfo} or {@link BundleActiveState} instance and + * then returns it to you. + * + * @since 7 + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics */ -declare namespace batteryStats { +declare namespace bundleState { + /** - * Describes the consumption type. - * - * @systemapi - * @since 8 + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.BundleStatsInfo */ - export enum ConsumptionType { - /** Indicates an invalid consumption type */ - CONSUMPTION_TYPE_INVALID = -17, - - /** Indicates the battery power consumption generated by APP */ - CONSUMPTION_TYPE_APP, - - /** Indicates the battery power consumption generated by bluetooth */ - CONSUMPTION_TYPE_BLUETOOTH, - - /** Indicates the battery power consumption generated when the CPU is idle */ - CONSUMPTION_TYPE_IDLE, - - /** Indicates the battery power consumption generated when phone call is active */ - CONSUMPTION_TYPE_PHONE, + interface BundleStateInfo { + /** + * The identifier of BundleStateInfo. + */ + id: number; + /** + * The total duration, in milliseconds. + */ + abilityInFgTotalTime?: number; + /** + * The last time when the application was accessed, in milliseconds. + */ + abilityPrevAccessTime?: number; + /** + * The last time when the application was visible in the foreground, in milliseconds. + */ + abilityPrevSeenTime?: number; + /** + * The total duration, in milliseconds. + */ + abilitySeenTotalTime?: number; + /** + * The bundle name of the application. + */ + bundleName?: string; + /** + * The total duration, in milliseconds. + */ + fgAbilityAccessTotalTime?: number; + /** + * The last time when the foreground application was accessed, in milliseconds. + */ + fgAbilityPrevAccessTime?: number; + /** + * The time of the first bundle usage record in this {@code BundleActiveInfo} object, + * in milliseconds. + */ + infosBeginTime?: number; + /** + * The time of the last bundle usage record in this {@code BundleActiveInfo} object, + * in milliseconds. + */ + infosEndTime?: number; - /** Indicates the battery power consumption generated by radio */ - CONSUMPTION_TYPE_RADIO, - - /** Indicates the battery power consumption generated by screen */ - CONSUMPTION_TYPE_SCREEN, - - /** Indicates the battery power consumption generated by user */ - CONSUMPTION_TYPE_USER, + /** + * Merges a specified {@link BundleActiveInfo} object with this {@link BundleActiveInfo} object. + * The bundle name of both objects must be the same. + * + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @param toMerge Indicates the {@link BundleActiveInfo} object to merge. + * If the bundle names of the two {@link BundleActiveInfo} objects are different. + */ + merge(toMerge: BundleStateInfo): void; + } - /** Indicates the battery power consumption generated by WIFI */ - CONSUMPTION_TYPE_WIFI + /** + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.BundleEvents + */ + interface BundleActiveState { + /** + * The usage priority group of the application. + */ + appUsagePriorityGroup?: number; + /** + * The bundle name. + */ + bundleName?: string; + /** + * The shortcut ID. + */ + indexOfLink?: string; + /** + * The class name. + */ + nameOfClass?: string; + /** + * The time when this state occurred, in milliseconds. + */ + stateOccurredTime?: number; + /** + * The state type. + */ + stateType?: number; } /** - * Obtains the power consumption information list. + * Checks whether the application with a specified bundle name is in the idle state. * - * @returns {Promise>} Power consumption information list. - * @systemapi - * @since 8 + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + * @param bundleName Indicates the bundle name of the application to query. + * @return Returns {@code true} if the application is idle in a particular period; + * returns {@code false} otherwise. The time range of the particular period is defined by the system, + * which may be hours or days. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.isIdleState */ - function getBatteryStats(): Promise>; + function isIdleState(bundleName: string, callback: AsyncCallback): void; + function isIdleState(bundleName: string): Promise; /** - * Obtains the power consumption information list. + * Queries the usage priority group of the calling application. + * + *

The priority defined in a priority group restricts the resource usage of an application, + * for example, restricting the running of background tasks.

* - * @param {AsyncCallback} callback Indicates the callback of power consumption information list. - * @throws {BusinessError} 401 - If the callback is not valid. - * @systemapi - * @since 8 + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + * @return Returns the usage priority group of the calling application. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.queryAppGroup */ - function getBatteryStats(callback: AsyncCallback>): void; + function queryAppUsagePriorityGroup(callback: AsyncCallback): void; + function queryAppUsagePriorityGroup(): Promise; /** - * Obtains power consumption information(Mah) for a given uid. - * - * @param {number} uid Indicates the uid. - * @returns {number} Power consumption information(Mah). - * @throws {BusinessError} 4600101 - If connecting to the service failed. - * @systemapi - * @since 8 + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.BundleStatsMap */ - function getAppPowerValue(uid: number): number; + interface BundleActiveInfoResponse { + [key: string]: BundleStateInfo; + } /** - * Obtains power consumption information(Percent) for a given uid. + * Queries usage information about each bundle within a specified period. + * + *

This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.

* - * @param {number} uid Indicates the uid. - * @returns {number} Power consumption information(Percent). - * @throws {BusinessError} 4600101 - If connecting to the service failed. - * @systemapi - * @since 8 + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @permission ohos.permission.BUNDLE_ACTIVE_INFO + * @systemapi Hide this for inner system use. + * @param begin Indicates the start time of the query period, in milliseconds. + * @param end Indicates the end time of the query period, in milliseconds. + * @return Returns the {@link BundleActiveInfoResponse} objects containing the usage information about each bundle. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.queryBundleStatsInfos */ - function getAppPowerPercent(uid: number): number; + function queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback): void; + function queryBundleStateInfos(begin: number, end: number): Promise; /** - * Obtains power consumption information(Mah) for a given type. + * Declares interval type. * - * @param {ConsumptionType} type Indicates the hardware type. - * @returns {number} Power consumption information(Mah). - * @throws {BusinessError} 401 - If the type is not valid. - * @throws {BusinessError} 4600101 - If connecting to the service failed. - * @systemapi - * @since 8 + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.IntervalType */ - function getHardwareUnitPowerValue(type: ConsumptionType): number; + export enum IntervalType { + /** + * Indicates the interval type that will determine the optimal interval based on the start and end time. + */ + BY_OPTIMIZED = 0, + + /** + * Indicates the daily interval. + */ + BY_DAILY = 1, + + /** + * Indicates the weekly interval. + */ + BY_WEEKLY = 2, + + /** + * Indicates the monthly interval. + */ + BY_MONTHLY = 3, + + /** + * Indicates the annually interval. + */ + BY_ANNUALLY = 4 + } /** - * Obtains power consumption information(Percent) for a given type. + * Queries usage information about each bundle within a specified period at a specified interval. * - * @param {ConsumptionType} type Indicates the hardware type. - * @returns {number} Power consumption information(Percent). - * @throws {BusinessError} 401 - If the type is not valid. - * @throws {BusinessError} 4600101 - If connecting to the service failed. - * @systemapi - * @since 8 + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @permission ohos.permission.BUNDLE_ACTIVE_INFO + * @systemapi Hide this for inner system use. + * @param byInterval Indicates the interval at which the usage statistics are queried. + * The value can be {@link #BY_OPTIMIZED}, {@link #BY_DAILY}, + * {@link #BY_WEEKLY}, {@link #BY_MONTHLY}, or {@link #BY_ANNUALLY}. + * @param begin Indicates the start time of the query period, in milliseconds. + * @param end Indicates the end time of the query period, in milliseconds. + * @return Returns the list of {@link BundleStateInfo} objects containing the usage information about each bundle. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.queryBundleStatsInfoByInterval */ - function getHardwareUnitPowerPercent(type: ConsumptionType): number; + function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback>): void; + function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number): Promise>; /** - * Contains power consumption information of a device. + * Queries state data of all bundles within a specified period identified by the start and end time. * - *

Power consumption information includes the uid, type and power consumption value. - * - * @systemapi - * @since 8 + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @permission ohos.permission.BUNDLE_ACTIVE_INFO + * @systemapi Hide this for inner system use. + * @param begin Indicates the start time of the query period, in milliseconds. + * @param end Indicates the end time of the query period, in milliseconds. + * @return Returns the list of {@link BundleActiveState} objects containing the state data of all bundles. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.queryBundleEvents */ - interface BatteryStatsInfo { - /** The uid related with the power consumption info. */ - uid: number; - - /** The type related with the power consumption info. */ - type: ConsumptionType; + function queryBundleActiveStates(begin: number, end: number, callback: AsyncCallback>): void; + function queryBundleActiveStates(begin: number, end: number): Promise>; - /** The power consumption value(Mah). */ - power: number; - } + /** + * Queries state data of the current bundle within a specified period. + * + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @param begin Indicates the start time of the query period, in milliseconds. + * @param end Indicates the end time of the query period, in milliseconds. + * @return Returns the {@link BundleActiveState} object Array containing the state data of the current bundle. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.queryCurrentBundleEvents + */ + function queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallback>): void; + function queryCurrentBundleActiveStates(begin: number, end: number): Promise>; } -export default batteryStats; \ No newline at end of file + +export default bundleState; diff --git a/api/@ohos.resourceschedule.backgroundTaskManager.d.ts b/api/@ohos.resourceschedule.backgroundTaskManager.d.ts index fad30a7ad5..9b82d9d302 100644 --- a/api/@ohos.resourceschedule.backgroundTaskManager.d.ts +++ b/api/@ohos.resourceschedule.backgroundTaskManager.d.ts @@ -21,7 +21,7 @@ import Context from './application/BaseContext'; * Manages background tasks. * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.TransientTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask */ declare namespace backgroundTaskManager { /** @@ -29,7 +29,7 @@ declare namespace backgroundTaskManager { * * @name DelaySuspendInfo * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.TransientTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask */ interface DelaySuspendInfo { /** @@ -46,7 +46,7 @@ declare namespace backgroundTaskManager { * Cancels delayed transition to the suspended state. * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.TransientTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask * @param requestId Indicates the identifier of the delay request. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 9800001 - Memory operation failed. @@ -62,7 +62,7 @@ declare namespace backgroundTaskManager { * Obtains the remaining time before an application enters the suspended state. * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.TransientTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask * @param requestId Indicates the identifier of the delay request. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 9800001 - Memory operation failed. @@ -80,7 +80,7 @@ declare namespace backgroundTaskManager { * Requests delayed transition to the suspended state. * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.TransientTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask * @param reason Indicates the reason for delayed transition to the suspended state. * @param callback The callback delay time expired. * @throws { BusinessError } 401 - Parameter error. @@ -99,7 +99,7 @@ declare namespace backgroundTaskManager { * system will publish a notification related to the this service. * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @permission ohos.permission.KEEP_BACKGROUND_RUNNING * @param context app running context. * @param bgMode Indicates which background mode to request. @@ -121,7 +121,7 @@ declare namespace backgroundTaskManager { * Service ability uses this method to request stop running in background. * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @param context app running context. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. @@ -140,7 +140,7 @@ declare namespace backgroundTaskManager { * Apply or unapply efficiency resources. * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.EfficiencyResourcesApply + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 9800001 - Memory operation failed. @@ -156,7 +156,7 @@ declare namespace backgroundTaskManager { * Reset all efficiency resources apply. * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.EfficiencyResourcesApply + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply * @systemapi Hide this for inner system use. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. @@ -172,14 +172,14 @@ declare namespace backgroundTaskManager { * Supported background mode. * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ export enum BackgroundMode { /** * data transfer mode * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ DATA_TRANSFER = 1, @@ -187,7 +187,7 @@ declare namespace backgroundTaskManager { * audio playback mode * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ AUDIO_PLAYBACK = 2, @@ -195,7 +195,7 @@ declare namespace backgroundTaskManager { * audio recording mode * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ AUDIO_RECORDING = 3, @@ -203,7 +203,7 @@ declare namespace backgroundTaskManager { * location mode * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ LOCATION = 4, @@ -211,7 +211,7 @@ declare namespace backgroundTaskManager { * bluetooth interaction mode * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ BLUETOOTH_INTERACTION = 5, @@ -219,7 +219,7 @@ declare namespace backgroundTaskManager { * multi-device connection mode * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ MULTI_DEVICE_CONNECTION = 6, @@ -227,7 +227,7 @@ declare namespace backgroundTaskManager { * wifi interaction mode * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @systemapi Hide this for inner system use. */ WIFI_INTERACTION = 7, @@ -236,7 +236,7 @@ declare namespace backgroundTaskManager { * Voice over Internet Phone mode * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @systemapi Hide this for inner system use. */ VOIP = 8, @@ -246,7 +246,7 @@ declare namespace backgroundTaskManager { * only supported in particular device * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ TASK_KEEPING = 9, } @@ -255,7 +255,7 @@ declare namespace backgroundTaskManager { * The type of resource. * * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.EfficiencyResourcesApply + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply * @systemapi Hide this for inner system use. */ export enum ResourceType { @@ -300,7 +300,7 @@ declare namespace backgroundTaskManager { * * @name EfficiencyResourcesRequest * @since 9 - * @syscap SystemCapability.ResourceSchedule.backgroundTaskManager.EfficiencyResourcesApply + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply * @systemapi Hide this for inner system use. */ export interface EfficiencyResourcesRequest { -- Gitee From b50987a49f0a978ebb68a42fc53f78d12df761b0 Mon Sep 17 00:00:00 2001 From: zhutianyi Date: Sat, 26 Nov 2022 15:31:49 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhutianyi --- api/@ohos.workScheduler.d.ts | 301 ----------------------------------- 1 file changed, 301 deletions(-) delete mode 100644 api/@ohos.workScheduler.d.ts diff --git a/api/@ohos.workScheduler.d.ts b/api/@ohos.workScheduler.d.ts deleted file mode 100644 index 65a4879961..0000000000 --- a/api/@ohos.workScheduler.d.ts +++ /dev/null @@ -1,301 +0,0 @@ -/* - * 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 9 - * @syscap SystemCapability.ResourceSchedule.WorkScheduler - * @StageModelOnly - * @deprecated since 9 - * @useinstead ohos.resourceschedule.workScheduler - */ -declare namespace workScheduler { - /** - * The info of work. - * - * @name WorkInfo - * @since 9 - * @syscap SystemCapability.ResourceSchedule.WorkScheduler - * @StageModelOnly - * @deprecated since 9 - * @useinstead ohos.resourceschedule.workScheduler.WorkInfo - */ - export interface WorkInfo { - /** - * The id of the current work. - */ - workId: number; - /** - * The bundle name of the current work. - */ - bundleName: string; - /** - * The ability name of the current work. - */ - abilityName: string; - /** - * Whether the current work will be saved. - */ - isPersisted?: boolean; - /** - * The network type of the current work. - */ - networkType?: NetworkType; - /** - * 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; - /** - * The interval at which the work is repeated. - */ - repeatCycleTime?: number; - /** - * Whether the work has been set to repeat at the specified interval. - */ - isRepeat?: boolean; - /** - * The repeat of the current work. - */ - repeatCount?: number; - /** - * 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; - /** - * The parameters of the work. The value is only supported basic type(Number, String, Boolean). - */ - parameters?: {[key: string]: any}; - } - - /** - * Add a work to the queue. A work can be executed only when it meets the preset triggering condition - * and complies with the rules of work scheduler manager. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.WorkScheduler - * @StageModelOnly - * @param work The info of work. - * @return true if success, otherwise false. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.workScheduler.startWork - */ - function startWork(work: WorkInfo): boolean; - - /** - * Stop a work. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.WorkScheduler - * @StageModelOnly - * @param work The info of work. - * @param needCancel True if need to be canceled after being stopped, otherwise false. - * @return true if success, otherwise false. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.workScheduler.stopWork - */ - function stopWork(work: WorkInfo, needCancel?: boolean): boolean; - - /** - * Obtains the work info of the wordId. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.WorkScheduler - * @StageModelOnly - * @param workId The id of work. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.workScheduler.getWorkStatus - */ - function getWorkStatus(workId: number, callback: AsyncCallback): void; - function getWorkStatus(workId: number): Promise; - - /** - * Get all works of the calling application. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.WorkScheduler - * @StageModelOnly - * @return the work info list. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.workScheduler.obtainAllWorks - */ - function obtainAllWorks(callback: AsyncCallback): Array; - function obtainAllWorks(): Promise>; - - /** - * Stop all and clear all works of the calling application. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.WorkScheduler - * @StageModelOnly - * @return true if success, otherwise false. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.workScheduler.stopAndClearWorks - */ - function stopAndClearWorks(): boolean; - - /** - * Check whether last work running is timeout. The interface is for repeating work. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.WorkScheduler - * @StageModelOnly - * @param workId The id of work. - * @return true if last work running is timeout, otherwise false. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.workScheduler.isLastWorkTimeOut - */ - function isLastWorkTimeOut(workId: number, callback: AsyncCallback): boolean; - function isLastWorkTimeOut(workId: number): Promise; - - /** - * Describes network type. - * - * @name NetworkType - * @since 9 - * @syscap SystemCapability.ResourceSchedule.WorkScheduler - * @StageModelOnly - * @deprecated since 9 - * @useinstead ohos.resourceschedule.workScheduler.NetworkType - */ - 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 9 - * @syscap SystemCapability.ResourceSchedule.WorkScheduler - * @StageModelOnly - * @deprecated since 9 - * @useinstead ohos.resourceschedule.workScheduler.ChargingType - */ - 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 9 - * @syscap SystemCapability.ResourceSchedule.WorkScheduler - * @StageModelOnly - * @deprecated since 9 - * @useinstead ohos.resourceschedule.workScheduler.BatteryStatus - */ - 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 9 - * @syscap SystemCapability.ResourceSchedule.WorkScheduler - * @StageModelOnly - * @deprecated since 9 - * @useinstead ohos.resourceschedule.workScheduler.StorageRequest - */ - 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 a7f53ec61dfcbc8de7afb7c2745262f3d4e7fea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=A4=A9=E6=80=A1?= Date: Sat, 26 Nov 2022 07:45:06 +0000 Subject: [PATCH 3/4] bugfix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 朱天怡 --- api/@ohos.batteryStatistics.d.ts | 312 +++++++++---------------------- 1 file changed, 93 insertions(+), 219 deletions(-) diff --git a/api/@ohos.batteryStatistics.d.ts b/api/@ohos.batteryStatistics.d.ts index b2539343d2..45289ecc6a 100755 --- a/api/@ohos.batteryStatistics.d.ts +++ b/api/@ohos.batteryStatistics.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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 @@ -13,259 +13,133 @@ * limitations under the License. */ -import { AsyncCallback , Callback} from './basic'; +import {AsyncCallback, BusinessError} from "./basic"; /** - * Provides methods for managing bundle usage statistics, - * including the methods for querying bundle usage information and state data. + * Provides methods to get power consumption information. * - *

You can use the methods defined in this class to query - * the usage history and states of bundles in a specified period. - * The system stores the query result in a {@link BundleStateInfo} or {@link BundleActiveState} instance and - * then returns it to you. - * - * @since 7 - * @deprecated since 9 - * @useinstead ohos.resourceschedule.usageStatistics + * @syscap SystemCapability.PowerManager.BatteryStatistics + * @systemapi + * @since 8 */ -declare namespace bundleState { - +declare namespace batteryStats { /** - * @since 7 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App - * @deprecated since 9 - * @useinstead ohos.resourceschedule.usageStatistics.BundleStatsInfo + * Describes the consumption type. + * + * @systemapi + * @since 8 */ - interface BundleStateInfo { - /** - * The identifier of BundleStateInfo. - */ - id: number; - /** - * The total duration, in milliseconds. - */ - abilityInFgTotalTime?: number; - /** - * The last time when the application was accessed, in milliseconds. - */ - abilityPrevAccessTime?: number; - /** - * The last time when the application was visible in the foreground, in milliseconds. - */ - abilityPrevSeenTime?: number; - /** - * The total duration, in milliseconds. - */ - abilitySeenTotalTime?: number; - /** - * The bundle name of the application. - */ - bundleName?: string; - /** - * The total duration, in milliseconds. - */ - fgAbilityAccessTotalTime?: number; - /** - * The last time when the foreground application was accessed, in milliseconds. - */ - fgAbilityPrevAccessTime?: number; - /** - * The time of the first bundle usage record in this {@code BundleActiveInfo} object, - * in milliseconds. - */ - infosBeginTime?: number; - /** - * The time of the last bundle usage record in this {@code BundleActiveInfo} object, - * in milliseconds. - */ - infosEndTime?: number; + export enum ConsumptionType { + /** Indicates an invalid consumption type */ + CONSUMPTION_TYPE_INVALID = -17, - /** - * Merges a specified {@link BundleActiveInfo} object with this {@link BundleActiveInfo} object. - * The bundle name of both objects must be the same. - * - * @since 7 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App - * @param toMerge Indicates the {@link BundleActiveInfo} object to merge. - * If the bundle names of the two {@link BundleActiveInfo} objects are different. - */ - merge(toMerge: BundleStateInfo): void; - } + /** Indicates the battery power consumption generated by APP */ + CONSUMPTION_TYPE_APP, - /** - * @since 7 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App - * @deprecated since 9 - * @useinstead ohos.resourceschedule.usageStatistics.BundleEvents - */ - interface BundleActiveState { - /** - * The usage priority group of the application. - */ - appUsagePriorityGroup?: number; - /** - * The bundle name. - */ - bundleName?: string; - /** - * The shortcut ID. - */ - indexOfLink?: string; - /** - * The class name. - */ - nameOfClass?: string; - /** - * The time when this state occurred, in milliseconds. - */ - stateOccurredTime?: number; - /** - * The state type. - */ - stateType?: number; + /** Indicates the battery power consumption generated by bluetooth */ + CONSUMPTION_TYPE_BLUETOOTH, + + /** Indicates the battery power consumption generated when the CPU is idle */ + CONSUMPTION_TYPE_IDLE, + + /** Indicates the battery power consumption generated when phone call is active */ + CONSUMPTION_TYPE_PHONE, + + /** Indicates the battery power consumption generated by radio */ + CONSUMPTION_TYPE_RADIO, + + /** Indicates the battery power consumption generated by screen */ + CONSUMPTION_TYPE_SCREEN, + + /** Indicates the battery power consumption generated by user */ + CONSUMPTION_TYPE_USER, + + /** Indicates the battery power consumption generated by WIFI */ + CONSUMPTION_TYPE_WIFI } /** - * Checks whether the application with a specified bundle name is in the idle state. + * Obtains the power consumption information list. * - * @since 7 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup - * @param bundleName Indicates the bundle name of the application to query. - * @return Returns {@code true} if the application is idle in a particular period; - * returns {@code false} otherwise. The time range of the particular period is defined by the system, - * which may be hours or days. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.usageStatistics.isIdleState + * @returns {Promise>} Power consumption information list. + * @systemapi + * @since 8 */ - function isIdleState(bundleName: string, callback: AsyncCallback): void; - function isIdleState(bundleName: string): Promise; + function getBatteryStats(): Promise>; /** - * Queries the usage priority group of the calling application. - * - *

The priority defined in a priority group restricts the resource usage of an application, - * for example, restricting the running of background tasks.

+ * Obtains the power consumption information list. * - * @since 7 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup - * @return Returns the usage priority group of the calling application. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.usageStatistics.queryAppGroup - */ - function queryAppUsagePriorityGroup(callback: AsyncCallback): void; - function queryAppUsagePriorityGroup(): Promise; - - /** - * @since 7 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App - * @deprecated since 9 - * @useinstead ohos.resourceschedule.usageStatistics.BundleStatsMap + * @param {AsyncCallback} callback Indicates the callback of power consumption information list. + * @throws {BusinessError} 401 - If the callback is not valid. + * @systemapi + * @since 8 */ - interface BundleActiveInfoResponse { - [key: string]: BundleStateInfo; - } + function getBatteryStats(callback: AsyncCallback>): void; /** - * Queries usage information about each bundle within a specified period. - * - *

This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.

+ * Obtains power consumption information(Mah) for a given uid. * - * @since 7 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App - * @permission ohos.permission.BUNDLE_ACTIVE_INFO - * @systemapi Hide this for inner system use. - * @param begin Indicates the start time of the query period, in milliseconds. - * @param end Indicates the end time of the query period, in milliseconds. - * @return Returns the {@link BundleActiveInfoResponse} objects containing the usage information about each bundle. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.usageStatistics.queryBundleStatsInfos + * @param {number} uid Indicates the uid. + * @returns {number} Power consumption information(Mah). + * @throws {BusinessError} 4600101 - If connecting to the service failed. + * @systemapi + * @since 8 */ - function queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback): void; - function queryBundleStateInfos(begin: number, end: number): Promise; + function getAppPowerValue(uid: number): number; /** - * Declares interval type. + * Obtains power consumption information(Percent) for a given uid. * - * @since 7 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App - * @deprecated since 9 - * @useinstead ohos.resourceschedule.usageStatistics.IntervalType + * @param {number} uid Indicates the uid. + * @returns {number} Power consumption information(Percent). + * @throws {BusinessError} 4600101 - If connecting to the service failed. + * @systemapi + * @since 8 */ - export enum IntervalType { - /** - * Indicates the interval type that will determine the optimal interval based on the start and end time. - */ - BY_OPTIMIZED = 0, - - /** - * Indicates the daily interval. - */ - BY_DAILY = 1, - - /** - * Indicates the weekly interval. - */ - BY_WEEKLY = 2, - - /** - * Indicates the monthly interval. - */ - BY_MONTHLY = 3, - - /** - * Indicates the annually interval. - */ - BY_ANNUALLY = 4 - } + function getAppPowerPercent(uid: number): number; /** - * Queries usage information about each bundle within a specified period at a specified interval. + * Obtains power consumption information(Mah) for a given type. * - * @since 7 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App - * @permission ohos.permission.BUNDLE_ACTIVE_INFO - * @systemapi Hide this for inner system use. - * @param byInterval Indicates the interval at which the usage statistics are queried. - * The value can be {@link #BY_OPTIMIZED}, {@link #BY_DAILY}, - * {@link #BY_WEEKLY}, {@link #BY_MONTHLY}, or {@link #BY_ANNUALLY}. - * @param begin Indicates the start time of the query period, in milliseconds. - * @param end Indicates the end time of the query period, in milliseconds. - * @return Returns the list of {@link BundleStateInfo} objects containing the usage information about each bundle. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.usageStatistics.queryBundleStatsInfoByInterval + * @param {ConsumptionType} type Indicates the hardware type. + * @returns {number} Power consumption information(Mah). + * @throws {BusinessError} 401 - If the type is not valid. + * @throws {BusinessError} 4600101 - If connecting to the service failed. + * @systemapi + * @since 8 */ - function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback>): void; - function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number): Promise>; + function getHardwareUnitPowerValue(type: ConsumptionType): number; /** - * Queries state data of all bundles within a specified period identified by the start and end time. + * Obtains power consumption information(Percent) for a given type. * - * @since 7 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App - * @permission ohos.permission.BUNDLE_ACTIVE_INFO - * @systemapi Hide this for inner system use. - * @param begin Indicates the start time of the query period, in milliseconds. - * @param end Indicates the end time of the query period, in milliseconds. - * @return Returns the list of {@link BundleActiveState} objects containing the state data of all bundles. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.usageStatistics.queryBundleEvents + * @param {ConsumptionType} type Indicates the hardware type. + * @returns {number} Power consumption information(Percent). + * @throws {BusinessError} 401 - If the type is not valid. + * @throws {BusinessError} 4600101 - If connecting to the service failed. + * @systemapi + * @since 8 */ - function queryBundleActiveStates(begin: number, end: number, callback: AsyncCallback>): void; - function queryBundleActiveStates(begin: number, end: number): Promise>; + function getHardwareUnitPowerPercent(type: ConsumptionType): number; /** - * Queries state data of the current bundle within a specified period. + * Contains power consumption information of a device. * - * @since 7 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App - * @param begin Indicates the start time of the query period, in milliseconds. - * @param end Indicates the end time of the query period, in milliseconds. - * @return Returns the {@link BundleActiveState} object Array containing the state data of the current bundle. - * @deprecated since 9 - * @useinstead ohos.resourceschedule.usageStatistics.queryCurrentBundleEvents + *

Power consumption information includes the uid, type and power consumption value. + * + * @systemapi + * @since 8 */ - function queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallback>): void; - function queryCurrentBundleActiveStates(begin: number, end: number): Promise>; -} + interface BatteryStatsInfo { + /** The uid related with the power consumption info. */ + uid: number; -export default bundleState; + /** The type related with the power consumption info. */ + type: ConsumptionType; + + /** The power consumption value(Mah). */ + power: number; + } +} +export default batteryStats; \ No newline at end of file -- Gitee From bb7c4362c272e85aa656e8b603d669684c3c3fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=A4=A9=E6=80=A1?= Date: Mon, 28 Nov 2022 03:01:22 +0000 Subject: [PATCH 4/4] add MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 朱天怡 --- api/@ohos.backgroundTaskManager.d.ts | 111 ++++++++++ api/@ohos.workScheduler.d.ts | 301 +++++++++++++++++++++++++++ 2 files changed, 412 insertions(+) create mode 100644 api/@ohos.workScheduler.d.ts diff --git a/api/@ohos.backgroundTaskManager.d.ts b/api/@ohos.backgroundTaskManager.d.ts index f707324f0e..36bd393014 100644 --- a/api/@ohos.backgroundTaskManager.d.ts +++ b/api/@ohos.backgroundTaskManager.d.ts @@ -111,6 +111,29 @@ declare namespace backgroundTaskManager { function stopBackgroundRunning(context: Context, callback: AsyncCallback): void; function stopBackgroundRunning(context: Context): Promise; + /** + * Apply or unapply efficiency resources. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply + * @return True if efficiency resources apply success, else false. + * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.backgroundTaskManager.applyEfficiencyResources + */ + function applyEfficiencyResources(request: EfficiencyResourcesRequest): boolean; + + /** + * Reset all efficiency resources apply. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply + * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.backgroundTaskManager.resetAllEfficiencyResources + */ + function resetAllEfficiencyResources(): void; + /** * Supported background mode. * @@ -195,6 +218,94 @@ declare namespace backgroundTaskManager { */ TASK_KEEPING = 9, } + + /** + * The type of resource. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply + * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.backgroundTaskManager.ResourceType + */ + export enum ResourceType { + /** + * The cpu resource for not being suspended. + */ + CPU = 1, + + /** + * The resource for not being proxyed common_event. + */ + COMMON_EVENT = 1 << 1, + + /** + * The resource for not being proxyed timer. + */ + TIMER = 1 << 2, + + /** + * The resource for not being proxyed workscheduler. + */ + WORK_SCHEDULER = 1 << 3, + + /** + * The resource for not being proxyed bluetooth. + */ + BLUETOOTH = 1 << 4, + + /** + * The resource for not being proxyed gps. + */ + GPS = 1 << 5, + + /** + * The resource for not being proxyed audio. + */ + AUDIO = 1 << 6 + } + + /** + * The request of efficiency resources. + * + * @name EfficiencyResourcesRequest + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply + * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.backgroundTaskManager.EfficiencyResourcesRequest + */ + export interface EfficiencyResourcesRequest { + /** + * The set of resource types that app wants to apply. + */ + resourceTypes: number; + + /** + * True if the app begin to use, else false. + */ + isApply: boolean; + + /** + * The duration that the resource can be used most. + */ + timeOut: number; + + /** + * True if the apply action is persist, else false. Default value is false. + */ + isPersist?: boolean; + + /** + * True if apply action is for process, false is for package. Default value is false. + */ + isProcess?: boolean; + + /** + * The apply reason. + */ + reason: string; + } } export default backgroundTaskManager; diff --git a/api/@ohos.workScheduler.d.ts b/api/@ohos.workScheduler.d.ts new file mode 100644 index 0000000000..27999fb23d --- /dev/null +++ b/api/@ohos.workScheduler.d.ts @@ -0,0 +1,301 @@ +/* + * 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 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.resourceschedule.workScheduler + */ +declare namespace workScheduler { + /** + * The info of work. + * + * @name WorkInfo + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.resourceschedule.workScheduler.WorkInfo + */ + export interface WorkInfo { + /** + * The id of the current work. + */ + workId: number; + /** + * The bundle name of the current work. + */ + bundleName: string; + /** + * The ability name of the current work. + */ + abilityName: string; + /** + * Whether the current work will be saved. + */ + isPersisted?: boolean; + /** + * The network type of the current work. + */ + networkType?: NetworkType; + /** + * 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; + /** + * The interval at which the work is repeated. + */ + repeatCycleTime?: number; + /** + * Whether the work has been set to repeat at the specified interval. + */ + isRepeat?: boolean; + /** + * The repeat of the current work. + */ + repeatCount?: number; + /** + * 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; + /** + * The parameters of the work. The value is only supported basic type(Number, String, Boolean). + */ + parameters?: {[key: string]: any}; + } + + /** + * Add a work to the queue. A work can be executed only when it meets the preset triggering condition + * and complies with the rules of work scheduler manager. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @param work The info of work. + * @return true if success, otherwise false. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.workScheduler.startWork + */ + function startWork(work: WorkInfo): boolean; + + /** + * Stop a work. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @param work The info of work. + * @param needCancel True if need to be canceled after being stopped, otherwise false. + * @return true if success, otherwise false. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.workScheduler.stopWork + */ + function stopWork(work: WorkInfo, needCancel?: boolean): boolean; + + /** + * Obtains the work info of the wordId. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @param workId The id of work. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.workScheduler.getWorkStatus + */ + function getWorkStatus(workId: number, callback: AsyncCallback): void; + function getWorkStatus(workId: number): Promise; + + /** + * Get all works of the calling application. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @return the work info list. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.workScheduler.obtainAllWorks + */ + function obtainAllWorks(callback: AsyncCallback): Array; + function obtainAllWorks(): Promise>; + + /** + * Stop all and clear all works of the calling application. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @return true if success, otherwise false. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.workScheduler.stopAndClearWorks + */ + function stopAndClearWorks(): boolean; + + /** + * Check whether last work running is timeout. The interface is for repeating work. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @param workId The id of work. + * @return true if last work running is timeout, otherwise false. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.workScheduler.isLastWorkTimeOut + */ + function isLastWorkTimeOut(workId: number, callback: AsyncCallback): boolean; + function isLastWorkTimeOut(workId: number): Promise; + + /** + * Describes network type. + * + * @name NetworkType + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.resourceschedule.workScheduler.NetworkType + */ + 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 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.resourceschedule.workScheduler.ChargingType + */ + 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 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.resourceschedule.workScheduler.BatteryStatus + */ + 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 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.resourceschedule.workScheduler.StorageRequest + */ + 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