• 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
16/**
17 * @file
18 * @kit BackgroundTasksKit
19 */
20
21import { AsyncCallback } from './@ohos.base';
22
23/**
24 * Provides methods for managing device standby,
25 * including the methods for querying standby status and exemption list.
26 *
27 * @namespace deviceStandby
28 * @since arkts{ '1.1':'10','1.2':'20'}
29 * @arkts 1.1&1.2
30 */
31declare namespace deviceStandby {
32
33  /**
34   * Returns the information about the specified exempted application.
35   *
36   * @permission ohos.permission.DEVICE_STANDBY_EXEMPTION
37   * @param { int } resourceTypes - the combination of {@link ResourceType} values.
38   * @param { AsyncCallback<Array<ExemptedAppInfo>> } callback - the callback of getExemptedApps.
39   * @throws { BusinessError } 201 - Permission denied.
40   * @throws { BusinessError } 202 - Not System App.
41   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
42   * 2. Incorrect parameter types. 3. Parameter verification failed.
43   * @throws { BusinessError } 9800001 - Memory operation failed.
44   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters.
45   * @throws { BusinessError } 9800003 - Failed to complete inner transaction.
46   * @throws { BusinessError } 9800004 - Failed to get device standby service. Possible cause: A necessary system service is not ready.
47   * @throws { BusinessError } 18700001 - Caller information verification failed.
48   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
49   * @systemapi Hide this for inner system use.
50   * @since arkts{ '1.1':'10','1.2':'20'}
51   * @arkts 1.1&1.2
52   */
53  function getExemptedApps(resourceTypes: int, callback: AsyncCallback<Array<ExemptedAppInfo>>): void;
54
55  /**
56   * Returns the information about the specified exempted application.
57   *
58   * @permission ohos.permission.DEVICE_STANDBY_EXEMPTION
59   * @param { int } resourceTypes - the combination of {@link ResourceType} values.
60   * @returns { Promise<Array<ExemptedAppInfo>> } the promise returned by getExemptedApps.
61   * @throws { BusinessError } 201 - Permission denied.
62   * @throws { BusinessError } 202 - Not System App.
63   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
64   * 2. Incorrect parameter types. 3. Parameter verification failed.
65   * @throws { BusinessError } 9800001 - Memory operation failed.
66   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters.
67   * @throws { BusinessError } 9800003 - Failed to complete inner transaction.
68   * @throws { BusinessError } 9800004 - Failed to get device standby service. Possible cause: A necessary system service is not ready.
69   * @throws { BusinessError } 18700001 - Caller information verification failed.
70   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
71   * @systemapi Hide this for inner system use.
72   * @since arkts{ '1.1':'10','1.2':'20'}
73   * @arkts 1.1&1.2
74   */
75  function getExemptedApps(resourceTypes: int): Promise<Array<ExemptedAppInfo>>;
76
77  /**
78   * Requests exemption resources.
79   *
80   * @permission ohos.permission.DEVICE_STANDBY_EXEMPTION
81   * @param { ResourceRequest } request - requesting or releasing resources.
82   * @throws { BusinessError } 201 - Permission denied.
83   * @throws { BusinessError } 202 - Not System App.
84   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
85   * 2. Incorrect parameter types. 3. Parameter verification failed.
86   * @throws { BusinessError } 9800001 - Memory operation failed.
87   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters.
88   * @throws { BusinessError } 9800003 - Failed to complete inner transaction.
89   * @throws { BusinessError } 9800004 - Failed to get device standby service. Possible cause: A necessary system service is not ready.
90   * @throws { BusinessError } 18700001 - Caller information verification failed.
91   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
92   * @systemapi Hide this for inner system use.
93   * @since arkts{ '1.1':'10','1.2':'20'}
94   * @arkts 1.1&1.2
95   */
96  function requestExemptionResource(request: ResourceRequest): void;
97
98  /**
99   * Releases exemption resources.
100   *
101   * @permission ohos.permission.DEVICE_STANDBY_EXEMPTION
102   * @param { ResourceRequest } request - requesting or releasing resources.
103   * @throws { BusinessError } 201 - Permission denied.
104   * @throws { BusinessError } 202 - Not System App.
105   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
106   * 2. Incorrect parameter types. 3. Parameter verification failed.
107   * @throws { BusinessError } 9800001 - Memory operation failed.
108   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters.
109   * @throws { BusinessError } 9800003 - Failed to complete inner transaction.
110   * @throws { BusinessError } 9800004 - Failed to get device standby service. Possible cause: A necessary system service is not ready.
111   * @throws { BusinessError } 18700001 - Caller information verification failed.
112   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
113   * @systemapi Hide this for inner system use.
114   * @since arkts{ '1.1':'10','1.2':'20'}
115   * @arkts 1.1&1.2
116   */
117  function releaseExemptionResource(request: ResourceRequest): void;
118
119  /**
120   * The type of exemption resources requested by the application.
121   *
122   * @enum { int }
123   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
124   * @systemapi Hide this for inner system use.
125   * @since arkts{ '1.1':'10','1.2':'20'}
126   * @arkts 1.1&1.2
127   */
128  export enum ResourceType {
129    /**
130     * The resource for non-standby network access.
131     *
132     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
133     * @systemapi Hide this for inner system use.
134     * @since arkts{ '1.1':'10','1.2':'20'}
135     * @arkts 1.1&1.2
136     */
137    NETWORK = 1,
138
139    /**
140     * The resource for non-standby cpu running-lock.
141     *
142     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
143     * @systemapi Hide this for inner system use.
144     * @since arkts{ '1.1':'10','1.2':'20'}
145     * @arkts 1.1&1.2
146     */
147    RUNNING_LOCK = 1 << 1,
148
149    /**
150     * The resource for non-standby timer.
151     *
152     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
153     * @systemapi Hide this for inner system use.
154     * @since arkts{ '1.1':'10','1.2':'20'}
155     * @arkts 1.1&1.2
156     */
157    TIMER = 1 << 2,
158
159    /**
160     * The resource for non-standby workscheduler.
161     *
162     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
163     * @systemapi Hide this for inner system use.
164     * @since arkts{ '1.1':'10','1.2':'20'}
165     * @arkts 1.1&1.2
166     */
167    WORK_SCHEDULER = 1 << 3,
168
169    /**
170     * The resource for non-standby automatic synchronization.
171     *
172     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
173     * @systemapi Hide this for inner system use.
174     * @since arkts{ '1.1':'10','1.2':'20'}
175     * @arkts 1.1&1.2
176     */
177    AUTO_SYNC = 1 << 4,
178
179    /**
180     * The resource for non-standby push-kit.
181     *
182     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
183     * @systemapi Hide this for inner system use.
184     * @since arkts{ '1.1':'10','1.2':'20'}
185     * @arkts 1.1&1.2
186     */
187    PUSH = 1 << 5,
188
189    /**
190     * The resource for non-standby freezing application.
191     *
192     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
193     * @systemapi Hide this for inner system use.
194     * @since arkts{ '1.1':'10','1.2':'20'}
195     * @arkts 1.1&1.2
196     */
197    FREEZE = 1 << 6
198  }
199
200  /**
201   * Information about an exempted application.
202   *
203   * @interface ExemptedAppInfo
204   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
205   * @systemapi Hide this for inner system use.
206   * @since arkts{ '1.1':'10','1.2':'20'}
207   * @arkts 1.1&1.2
208   */
209  export interface ExemptedAppInfo {
210    /**
211     * The set of resource types that an application requests.
212     *
213     * @type { int }
214     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
215     * @systemapi Hide this for inner system use.
216     * @since arkts{ '1.1':'10','1.2':'20'}
217     * @arkts 1.1&1.2
218     */
219    resourceTypes: int;
220
221    /**
222     * The application name.
223     *
224     * @type { string }
225     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
226     * @systemapi Hide this for inner system use.
227     * @since arkts{ '1.1':'10','1.2':'20'}
228     * @arkts 1.1&1.2
229     */
230    name: string;
231
232    /**
233     * The exemption duration.
234     *
235     * @type { int }
236     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
237     * @systemapi Hide this for inner system use.
238     * @since arkts{ '1.1':'10','1.2':'20'}
239     * @arkts 1.1&1.2
240     */
241    duration: int;
242  }
243
244  /**
245   * The request of standby resources.
246   *
247   * @interface ResourceRequest
248   * @syscap SystemCapability.ResourceSchedule.DeviceStandby
249   * @systemapi Hide this for inner system use.
250   * @since arkts{ '1.1':'10','1.2':'20'}
251   * @arkts 1.1&1.2
252   */
253  export interface ResourceRequest {
254    /**
255     * The set of resource types that an application requests.
256     *
257     * @type { int }
258     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
259     * @systemapi Hide this for inner system use.
260     * @since arkts{ '1.1':'10','1.2':'20'}
261     * @arkts 1.1&1.2
262     */
263    resourceTypes: int;
264
265    /**
266     * The application uid.
267     *
268     * @type { int }
269     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
270     * @systemapi Hide this for inner system use.
271     * @since arkts{ '1.1':'10','1.2':'20'}
272     * @arkts 1.1&1.2
273     */
274    uid: int;
275
276    /**
277     * The application name.
278     *
279     * @type { string }
280     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
281     * @systemapi Hide this for inner system use.
282     * @since arkts{ '1.1':'10','1.2':'20'}
283     * @arkts 1.1&1.2
284     */
285    name: string;
286
287    /**
288     * The exemption duration.
289     *
290     * @type { int }
291     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
292     * @systemapi Hide this for inner system use.
293     * @since arkts{ '1.1':'10','1.2':'20'}
294     * @arkts 1.1&1.2
295     */
296    duration: int;
297
298    /**
299     * The reason for the request.
300     *
301     * @type { string }
302     * @syscap SystemCapability.ResourceSchedule.DeviceStandby
303     * @systemapi Hide this for inner system use.
304     * @since arkts{ '1.1':'10','1.2':'20'}
305     * @arkts 1.1&1.2
306     */
307    reason: string;
308  }
309}
310
311export default deviceStandby;