!2594 【新增特性】能效资源申请API接口修改

Merge pull request !2594 from 朱天怡/master
This commit is contained in:
openharmony_ci 2022-09-05 02:44:52 +00:00 committed by Gitee
commit f3fc2d43f8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -97,6 +97,25 @@ declare namespace backgroundTaskManager {
function stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): void;
function stopBackgroundRunning(context: Context): Promise<void>;
/**
* 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.
*/
function applyEfficiencyResources(request: EfficiencyResourcesRequest): boolean;
/**
* Reset all efficiency resources apply.
*
* @since 9
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply.
* @systemapi Hide this for inner system use.
*/
function resetAllEfficiencyResources(): void;
/**
* supported background mode.
*
@ -179,6 +198,90 @@ declare namespace backgroundTaskManager {
*/
TASK_KEEPING = 9,
}
/**
* The type of resource.
*
* @since 9
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply.
* @systemapi Hide this for inner system use.
*/
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.
*/
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;