161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit BackgroundTasksKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport { AsyncCallback } from './@ohos.base';
2261847f8eSopenharmony_ci
2361847f8eSopenharmony_ci/**
2461847f8eSopenharmony_ci * Provides methods for managing device standby,
2561847f8eSopenharmony_ci * including the methods for querying standby status and exemption list.
2661847f8eSopenharmony_ci *
2761847f8eSopenharmony_ci * @namespace deviceStandby
2861847f8eSopenharmony_ci * @since 10
2961847f8eSopenharmony_ci */
3061847f8eSopenharmony_cideclare namespace deviceStandby {
3161847f8eSopenharmony_ci
3261847f8eSopenharmony_ci  /**
3361847f8eSopenharmony_ci   * Returns the information about the specified exempted application.
3461847f8eSopenharmony_ci   *
3561847f8eSopenharmony_ci   * @permission ohos.permission.DEVICE_STANDBY_EXEMPTION
3661847f8eSopenharmony_ci   * @param { number } resourceTypes - the combination of {@link ResourceType} values.
3761847f8eSopenharmony_ci   * @param { AsyncCallback<Array<ExemptedAppInfo>> } callback - the callback of getExemptedApps.
3861847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
3961847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Not System App.
4061847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.
4161847f8eSopenharmony_ci   * @throws { BusinessError } 9800001 - Memory operation failed.
4261847f8eSopenharmony_ci   * @throws { BusinessError } 9800002 - Parcel operation failed.
4361847f8eSopenharmony_ci   * @throws { BusinessError } 9800003 - Inner transact failed.
4461847f8eSopenharmony_ci   * @throws { BusinessError } 9800004 - System service operation failed.
4561847f8eSopenharmony_ci   * @throws { BusinessError } 18700001 - Caller information verification failed.
4661847f8eSopenharmony_ci   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
4761847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
4861847f8eSopenharmony_ci   * @since 10
4961847f8eSopenharmony_ci   */
5061847f8eSopenharmony_ci  function getExemptedApps(resourceTypes: number, callback: AsyncCallback<Array<ExemptedAppInfo>>): void;
5161847f8eSopenharmony_ci
5261847f8eSopenharmony_ci  /**
5361847f8eSopenharmony_ci   * Returns the information about the specified exempted application.
5461847f8eSopenharmony_ci   *
5561847f8eSopenharmony_ci   * @permission ohos.permission.DEVICE_STANDBY_EXEMPTION
5661847f8eSopenharmony_ci   * @param { number } resourceTypes - the combination of {@link ResourceType} values.
5761847f8eSopenharmony_ci   * @returns { Promise<Array<ExemptedAppInfo>> } the promise returned by getExemptedApps.
5861847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
5961847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Not System App.
6061847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.
6161847f8eSopenharmony_ci   * @throws { BusinessError } 9800001 - Memory operation failed.
6261847f8eSopenharmony_ci   * @throws { BusinessError } 9800002 - Parcel operation failed.
6361847f8eSopenharmony_ci   * @throws { BusinessError } 9800003 - Inner transact failed.
6461847f8eSopenharmony_ci   * @throws { BusinessError } 9800004 - System service operation failed.
6561847f8eSopenharmony_ci   * @throws { BusinessError } 18700001 - Caller information verification failed.
6661847f8eSopenharmony_ci   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
6761847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
6861847f8eSopenharmony_ci   * @since 10
6961847f8eSopenharmony_ci   */
7061847f8eSopenharmony_ci  function getExemptedApps(resourceTypes: number): Promise<Array<ExemptedAppInfo>>;
7161847f8eSopenharmony_ci
7261847f8eSopenharmony_ci  /**
7361847f8eSopenharmony_ci   * Requests exemption resources.
7461847f8eSopenharmony_ci   *
7561847f8eSopenharmony_ci   * @permission ohos.permission.DEVICE_STANDBY_EXEMPTION
7661847f8eSopenharmony_ci   * @param { ResourceRequest } request - requesting or releasing resources.
7761847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
7861847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Not System App.
7961847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.
8061847f8eSopenharmony_ci   * @throws { BusinessError } 9800001 - Memory operation failed.
8161847f8eSopenharmony_ci   * @throws { BusinessError } 9800002 - Parcel operation failed.
8261847f8eSopenharmony_ci   * @throws { BusinessError } 9800003 - Inner transact failed.
8361847f8eSopenharmony_ci   * @throws { BusinessError } 9800004 - System service operation failed.
8461847f8eSopenharmony_ci   * @throws { BusinessError } 18700001 - Caller information verification failed.
8561847f8eSopenharmony_ci   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
8661847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
8761847f8eSopenharmony_ci   * @since 10
8861847f8eSopenharmony_ci   */
8961847f8eSopenharmony_ci  function requestExemptionResource(request: ResourceRequest): void;
9061847f8eSopenharmony_ci
9161847f8eSopenharmony_ci  /**
9261847f8eSopenharmony_ci   * Releases exemption resources.
9361847f8eSopenharmony_ci   *
9461847f8eSopenharmony_ci   * @permission ohos.permission.DEVICE_STANDBY_EXEMPTION
9561847f8eSopenharmony_ci   * @param { ResourceRequest } request - requesting or releasing resources.
9661847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
9761847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Not System App.
9861847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.
9961847f8eSopenharmony_ci   * @throws { BusinessError } 9800001 - Memory operation failed.
10061847f8eSopenharmony_ci   * @throws { BusinessError } 9800002 - Parcel operation failed.
10161847f8eSopenharmony_ci   * @throws { BusinessError } 9800003 - Inner transact failed.
10261847f8eSopenharmony_ci   * @throws { BusinessError } 9800004 - System service operation failed.
10361847f8eSopenharmony_ci   * @throws { BusinessError } 18700001 - Caller information verification failed.
10461847f8eSopenharmony_ci   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
10561847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
10661847f8eSopenharmony_ci   * @since 10
10761847f8eSopenharmony_ci   */
10861847f8eSopenharmony_ci  function releaseExemptionResource(request: ResourceRequest): void;
10961847f8eSopenharmony_ci
11061847f8eSopenharmony_ci  /**
11161847f8eSopenharmony_ci   * The type of exemption resources requested by the application.
11261847f8eSopenharmony_ci   *
11361847f8eSopenharmony_ci   * @enum { number }
11461847f8eSopenharmony_ci   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
11561847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
11661847f8eSopenharmony_ci   * @since 10
11761847f8eSopenharmony_ci   */
11861847f8eSopenharmony_ci  export enum ResourceType {
11961847f8eSopenharmony_ci    /**
12061847f8eSopenharmony_ci     * The resource for non-standby network access.
12161847f8eSopenharmony_ci     *
12261847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
12361847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
12461847f8eSopenharmony_ci     * @since 10
12561847f8eSopenharmony_ci     */
12661847f8eSopenharmony_ci    NETWORK = 1,
12761847f8eSopenharmony_ci
12861847f8eSopenharmony_ci    /**
12961847f8eSopenharmony_ci     * The resource for non-standby cpu running-lock.
13061847f8eSopenharmony_ci     *
13161847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
13261847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
13361847f8eSopenharmony_ci     * @since 10
13461847f8eSopenharmony_ci     */
13561847f8eSopenharmony_ci    RUNNING_LOCK = 1 << 1,
13661847f8eSopenharmony_ci
13761847f8eSopenharmony_ci    /**
13861847f8eSopenharmony_ci     * The resource for non-standby timer.
13961847f8eSopenharmony_ci     *
14061847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
14161847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
14261847f8eSopenharmony_ci     * @since 10
14361847f8eSopenharmony_ci     */
14461847f8eSopenharmony_ci    TIMER = 1 << 2,
14561847f8eSopenharmony_ci
14661847f8eSopenharmony_ci    /**
14761847f8eSopenharmony_ci     * The resource for non-standby workscheduler.
14861847f8eSopenharmony_ci     *
14961847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
15061847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
15161847f8eSopenharmony_ci     * @since 10
15261847f8eSopenharmony_ci     */
15361847f8eSopenharmony_ci    WORK_SCHEDULER = 1 << 3,
15461847f8eSopenharmony_ci
15561847f8eSopenharmony_ci    /**
15661847f8eSopenharmony_ci     * The resource for non-standby automatic synchronization.
15761847f8eSopenharmony_ci     *
15861847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
15961847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
16061847f8eSopenharmony_ci     * @since 10
16161847f8eSopenharmony_ci     */
16261847f8eSopenharmony_ci    AUTO_SYNC = 1 << 4,
16361847f8eSopenharmony_ci
16461847f8eSopenharmony_ci    /**
16561847f8eSopenharmony_ci     * The resource for non-standby push-kit.
16661847f8eSopenharmony_ci     *
16761847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
16861847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
16961847f8eSopenharmony_ci     * @since 10
17061847f8eSopenharmony_ci     */
17161847f8eSopenharmony_ci    PUSH = 1 << 5,
17261847f8eSopenharmony_ci
17361847f8eSopenharmony_ci    /**
17461847f8eSopenharmony_ci     * The resource for non-standby freezing application.
17561847f8eSopenharmony_ci     *
17661847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
17761847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
17861847f8eSopenharmony_ci     * @since 10
17961847f8eSopenharmony_ci     */
18061847f8eSopenharmony_ci    FREEZE = 1 << 6
18161847f8eSopenharmony_ci  }
18261847f8eSopenharmony_ci
18361847f8eSopenharmony_ci  /**
18461847f8eSopenharmony_ci   * Information about an exempted application.
18561847f8eSopenharmony_ci   *
18661847f8eSopenharmony_ci   * @interface ExemptedAppInfo
18761847f8eSopenharmony_ci   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
18861847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
18961847f8eSopenharmony_ci   * @since 10
19061847f8eSopenharmony_ci   */
19161847f8eSopenharmony_ci  export interface ExemptedAppInfo {
19261847f8eSopenharmony_ci    /**
19361847f8eSopenharmony_ci     * The set of resource types that an application requests.
19461847f8eSopenharmony_ci     *
19561847f8eSopenharmony_ci     * @type { number }
19661847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
19761847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
19861847f8eSopenharmony_ci     * @since 10
19961847f8eSopenharmony_ci     */
20061847f8eSopenharmony_ci    resourceTypes: number;
20161847f8eSopenharmony_ci
20261847f8eSopenharmony_ci    /**
20361847f8eSopenharmony_ci     * The application name.
20461847f8eSopenharmony_ci     *
20561847f8eSopenharmony_ci     * @type { string }
20661847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
20761847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
20861847f8eSopenharmony_ci     * @since 10
20961847f8eSopenharmony_ci     */
21061847f8eSopenharmony_ci    name: string;
21161847f8eSopenharmony_ci
21261847f8eSopenharmony_ci    /**
21361847f8eSopenharmony_ci     * The exemption duration.
21461847f8eSopenharmony_ci     *
21561847f8eSopenharmony_ci     * @type { number }
21661847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
21761847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
21861847f8eSopenharmony_ci     * @since 10
21961847f8eSopenharmony_ci     */
22061847f8eSopenharmony_ci    duration: number;
22161847f8eSopenharmony_ci  }
22261847f8eSopenharmony_ci
22361847f8eSopenharmony_ci  /**
22461847f8eSopenharmony_ci   * The request of standby resources.
22561847f8eSopenharmony_ci   *
22661847f8eSopenharmony_ci   * @interface ResourceRequest
22761847f8eSopenharmony_ci   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
22861847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
22961847f8eSopenharmony_ci   * @since 10
23061847f8eSopenharmony_ci   */
23161847f8eSopenharmony_ci  export interface ResourceRequest {
23261847f8eSopenharmony_ci    /**
23361847f8eSopenharmony_ci     * The set of resource types that an application requests.
23461847f8eSopenharmony_ci     *
23561847f8eSopenharmony_ci     * @type { number }
23661847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
23761847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
23861847f8eSopenharmony_ci     * @since 10
23961847f8eSopenharmony_ci     */
24061847f8eSopenharmony_ci    resourceTypes: number;
24161847f8eSopenharmony_ci
24261847f8eSopenharmony_ci    /**
24361847f8eSopenharmony_ci     * The application uid.
24461847f8eSopenharmony_ci     *
24561847f8eSopenharmony_ci     * @type { number }
24661847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
24761847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
24861847f8eSopenharmony_ci     * @since 10
24961847f8eSopenharmony_ci     */
25061847f8eSopenharmony_ci    uid: number;
25161847f8eSopenharmony_ci
25261847f8eSopenharmony_ci    /**
25361847f8eSopenharmony_ci     * The application name.
25461847f8eSopenharmony_ci     *
25561847f8eSopenharmony_ci     * @type { string }
25661847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
25761847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
25861847f8eSopenharmony_ci     * @since 10
25961847f8eSopenharmony_ci     */
26061847f8eSopenharmony_ci    name: string;
26161847f8eSopenharmony_ci
26261847f8eSopenharmony_ci    /**
26361847f8eSopenharmony_ci     * The exemption duration.
26461847f8eSopenharmony_ci     *
26561847f8eSopenharmony_ci     * @type { number }
26661847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
26761847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
26861847f8eSopenharmony_ci     * @since 10
26961847f8eSopenharmony_ci     */
27061847f8eSopenharmony_ci    duration: number;
27161847f8eSopenharmony_ci
27261847f8eSopenharmony_ci    /**
27361847f8eSopenharmony_ci     * The reason for the request.
27461847f8eSopenharmony_ci     *
27561847f8eSopenharmony_ci     * @type { string }
27661847f8eSopenharmony_ci     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
27761847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
27861847f8eSopenharmony_ci     * @since 10
27961847f8eSopenharmony_ci     */
28061847f8eSopenharmony_ci    reason: string;
28161847f8eSopenharmony_ci  }
28261847f8eSopenharmony_ci}
28361847f8eSopenharmony_ci
28461847f8eSopenharmony_ciexport default deviceStandby;