• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { AsyncCallback } from './@ohos.base';
17
18/**
19 * Provides methods for managing device standby,
20 * including the methods for querying standby status and exemption list.
21 *
22 * @namespace deviceStandby
23 * @since 10
24 */
25declare namespace deviceStandby {
26
27  /**
28   * Returns the information about the specified exempted application.
29   *
30   * @permission ohos.permission.DEVICE_STANDBY_EXEMPTION
31   * @param { number } resourceTypes - the combination of {@link ResourceType} values.
32   * @param { AsyncCallback<Array<ExemptedAppInfo>> } callback - the callback of getExemptedApps.
33   * @throws { BusinessError } 201 - Permission denied.
34   * @throws { BusinessError } 202 - Not System App.
35   * @throws { BusinessError } 401 - Parameter error.
36   * @throws { BusinessError } 9800001 - Memory operation failed.
37   * @throws { BusinessError } 9800002 - Parcel operation failed.
38   * @throws { BusinessError } 9800003 - Inner transact failed.
39   * @throws { BusinessError } 9800004 - System service operation failed.
40   * @throws { BusinessError } 18700001 - Caller information verification failed.
41   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
42   * @systemapi Hide this for inner system use.
43   * @since 10
44   */
45  function getExemptedApps(resourceTypes: number, callback: AsyncCallback<Array<ExemptedAppInfo>>): void;
46
47  /**
48   * Returns the information about the specified exempted application.
49   *
50   * @permission ohos.permission.DEVICE_STANDBY_EXEMPTION
51   * @param { number } resourceTypes - the combination of {@link ResourceType} values.
52   * @returns { Promise<Array<ExemptedAppInfo>> } the promise returned by getExemptedApps.
53   * @throws { BusinessError } 201 - Permission denied.
54   * @throws { BusinessError } 202 - Not System App.
55   * @throws { BusinessError } 401 - Parameter error.
56   * @throws { BusinessError } 9800001 - Memory operation failed.
57   * @throws { BusinessError } 9800002 - Parcel operation failed.
58   * @throws { BusinessError } 9800003 - Inner transact failed.
59   * @throws { BusinessError } 9800004 - System service operation failed.
60   * @throws { BusinessError } 18700001 - Caller information verification failed.
61   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
62   * @systemapi Hide this for inner system use.
63   * @since 10
64   */
65  function getExemptedApps(resourceTypes: number): Promise<Array<ExemptedAppInfo>>;
66
67  /**
68   * Requests exemption resources.
69   *
70   * @permission ohos.permission.DEVICE_STANDBY_EXEMPTION
71   * @param { ResourceRequest } request - requesting or releasing resources.
72   * @throws { BusinessError } 201 - Permission denied.
73   * @throws { BusinessError } 202 - Not System App.
74   * @throws { BusinessError } 401 - Parameter error.
75   * @throws { BusinessError } 9800001 - Memory operation failed.
76   * @throws { BusinessError } 9800002 - Parcel operation failed.
77   * @throws { BusinessError } 9800003 - Inner transact failed.
78   * @throws { BusinessError } 9800004 - System service operation failed.
79   * @throws { BusinessError } 18700001 - Caller information verification failed.
80   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
81   * @systemapi Hide this for inner system use.
82   * @since 10
83   */
84  function requestExemptionResource(request: ResourceRequest): void;
85
86  /**
87   * Releases exemption resources.
88   *
89   * @permission ohos.permission.DEVICE_STANDBY_EXEMPTION
90   * @param { ResourceRequest } request - requesting or releasing resources.
91   * @throws { BusinessError } 201 - Permission denied.
92   * @throws { BusinessError } 202 - Not System App.
93   * @throws { BusinessError } 401 - Parameter error.
94   * @throws { BusinessError } 9800001 - Memory operation failed.
95   * @throws { BusinessError } 9800002 - Parcel operation failed.
96   * @throws { BusinessError } 9800003 - Inner transact failed.
97   * @throws { BusinessError } 9800004 - System service operation failed.
98   * @throws { BusinessError } 18700001 - Caller information verification failed.
99   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
100   * @systemapi Hide this for inner system use.
101   * @since 10
102   */
103  function releaseExemptionResource(request: ResourceRequest): void;
104
105  /**
106   * The type of exemption resources requested by the application.
107   *
108   * @enum { number }
109   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
110   * @systemapi Hide this for inner system use.
111   * @since 10
112   */
113  export enum ResourceType {
114    /**
115     * The resource for non-standby network access.
116     *
117     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
118     * @systemapi Hide this for inner system use.
119     * @since 10
120     */
121    NETWORK = 1,
122
123    /**
124     * The resource for non-standby cpu running-lock.
125     *
126     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
127     * @systemapi Hide this for inner system use.
128     * @since 10
129     */
130    RUNNING_LOCK = 1 << 1,
131
132    /**
133     * The resource for non-standby timer.
134     *
135     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
136     * @systemapi Hide this for inner system use.
137     * @since 10
138     */
139    TIMER = 1 << 2,
140
141    /**
142     * The resource for non-standby workscheduler.
143     *
144     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
145     * @systemapi Hide this for inner system use.
146     * @since 10
147     */
148    WORK_SCHEDULER = 1 << 3,
149
150    /**
151     * The resource for non-standby automatic synchronization.
152     *
153     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
154     * @systemapi Hide this for inner system use.
155     * @since 10
156     */
157    AUTO_SYNC = 1 << 4,
158
159    /**
160     * The resource for non-standby push-kit.
161     *
162     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
163     * @systemapi Hide this for inner system use.
164     * @since 10
165     */
166    PUSH = 1 << 5,
167
168    /**
169     * The resource for non-standby freezing application.
170     *
171     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
172     * @systemapi Hide this for inner system use.
173     * @since 10
174     */
175    FREEZE = 1 << 6
176  }
177
178  /**
179   * Information about an exempted application.
180   *
181   * @interface ExemptedAppInfo
182   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
183   * @systemapi Hide this for inner system use.
184   * @since 10
185   */
186  export interface ExemptedAppInfo {
187    /**
188     * The set of resource types that an application requests.
189     *
190     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
191     * @systemapi Hide this for inner system use.
192     * @since 10
193     */
194    resourceTypes: number;
195
196    /**
197     * The application name.
198     *
199     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
200     * @systemapi Hide this for inner system use.
201     * @since 10
202     */
203    name: string;
204
205    /**
206     * The exemption duration.
207     *
208     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
209     * @systemapi Hide this for inner system use.
210     * @since 10
211     */
212    duration: number;
213  }
214
215  /**
216   * The request of standby resources.
217   *
218   * @interface ResourceRequest
219   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
220   * @systemapi Hide this for inner system use.
221   * @since 10
222   */
223  export interface ResourceRequest {
224    /**
225     * The set of resource types that an application requests.
226     *
227     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
228     * @systemapi Hide this for inner system use.
229     * @since 10
230     */
231    resourceTypes: number;
232
233    /**
234     * The application uid.
235     *
236     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
237     * @systemapi Hide this for inner system use.
238     * @since 10
239     */
240    uid: number;
241
242    /**
243     * The application name.
244     *
245     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
246     * @systemapi Hide this for inner system use.
247     * @since 10
248     */
249    name: string;
250
251    /**
252     * The exemption duration.
253     *
254     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
255     * @systemapi Hide this for inner system use.
256     * @since 10
257     */
258    duration: number;
259
260    /**
261     * The reason for the request.
262     *
263     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
264     * @systemapi Hide this for inner system use.
265     * @since 10
266     */
267    reason: string;
268  }
269}
270
271export default deviceStandby;