• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 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 AbilityKit
19 */
20
21import { AsyncCallback } from './@ohos.base';
22import type { ElementName } from './bundleManager/ElementName';
23import Want from './@ohos.app.ability.Want';
24
25/**
26 * Used for application interception control
27 *
28 * @namespace appControl
29 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
30 * @systemapi
31 * @since 9
32 */
33declare namespace appControl {
34  /**
35   * Indicates the ability component type.
36   *
37   * @enum { number }
38   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
39   * @systemapi
40   * @since 11
41   */
42  export enum ComponentType {
43    /**
44     * Indicates the UI ability type.
45     *
46     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
47     * @systemapi
48     * @since 11
49     */
50    UI_ABILITY = 1,
51
52    /**
53     * Indicates the extension ability type.
54     *
55     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
56     * @systemapi
57     * @since 11
58     */
59    UI_EXTENSION = 2
60  }
61
62  /**
63   * Indicates the ability component type when uninstalled.
64   *
65   * @enum { number }
66   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
67   * @systemapi
68   * @since 15
69   */
70  export enum UninstallComponentType {
71    /**
72     * Indicates the service extension ability type.
73     *
74     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
75     * @systemapi
76     * @since 15
77     */
78    EXTENSION = 1,
79  }
80
81  /**
82   * Indicates when to intercept the specified application.
83   *
84   * @enum { number }
85   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
86   * @systemapi
87   * @since 11
88   */
89  export enum DisposedType {
90    /**
91     * All abilities will be blocked.
92     *
93     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
94     * @systemapi
95     * @since 11
96     */
97    BLOCK_APPLICATION = 1,
98    /**
99     * Only the specified abilities will be blocked.
100     *
101     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
102     * @systemapi
103     * @since 11
104     */
105    BLOCK_ABILITY = 2,
106    /**
107     * All abilities will not be blocked.
108     *
109     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
110     * @systemapi
111     * @since 11
112     */
113    NON_BLOCK = 3
114  }
115
116  /**
117   * Indicates the strategy to intercept the specified application.
118   *
119   * @enum { number }
120   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
121   * @systemapi
122   * @since 11
123   */
124  export enum ControlType {
125    /**
126     * Only the specified abilities are allowed to run.
127     *
128     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
129     * @systemapi
130     * @since 11
131     */
132    ALLOWED_LIST = 1,
133    /**
134     * The specified abilities are not allowed to run.
135     *
136     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
137     * @systemapi
138     * @since 11
139     */
140    DISALLOWED_LIST = 2
141  }
142
143  /**
144   * Indicates the rule for interception.
145   *
146   * @typedef DisposedRule
147   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
148   * @systemapi
149   * @since 11
150   */
151  export interface DisposedRule {
152    /**
153     * Indicates the ability that will be pulled up when interception occurs.
154     *
155     * @type { Want }
156     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
157     * @systemapi
158     * @since 11
159     */
160    want: Want;
161
162    /**
163     * Indicates the type of the ability that will be pulled up when interception occurs.
164     *
165     * @type { ComponentType }
166     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
167     * @systemapi
168     * @since 11
169     */
170    componentType: ComponentType;
171
172    /**
173     * Indicates when to intercept the specified application.
174     *
175     * @type { DisposedType }
176     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
177     * @systemapi
178     * @since 11
179     */
180    disposedType: DisposedType;
181
182    /**
183     * Indicates the interception policy.
184     *
185     * @type { ControlType }
186     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
187     * @systemapi
188     * @since 11
189     */
190    controlType: ControlType;
191
192    /**
193     * Indicates the abilities to be disposed of the specified application.
194     *
195     * @type { Array<ElementName> }
196     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
197     * @systemapi
198     * @since 11
199     */
200    elementList: Array<ElementName> ;
201
202    /**
203     * Indicates priority of the rule.
204     *
205     * @type { number }
206     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
207     * @systemapi
208     * @since 11
209     */
210    priority: number;
211  }
212
213  /**
214   * Indicates the uninstall rule for interception.
215   *
216   * @typedef UninstallDisposedRule
217   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
218   * @systemapi
219   * @since 15
220   */
221  export interface UninstallDisposedRule {
222    /**
223     * Indicates the ability that will be pulled up when interception occurs.
224     *
225     * @type { Want }
226     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
227     * @systemapi
228     * @since 15
229     */
230    want: Want;
231
232    /**
233     * Indicates the type of the ability that will be pulled up when interception occurs.
234     *
235     * @type { UninstallComponentType }
236     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
237     * @systemapi
238     * @since 15
239     */
240    uninstallComponentType: UninstallComponentType;
241
242    /**
243     * Indicates priority of the rule.
244     *
245     * @type { number }
246     * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
247     * @systemapi
248     * @since 15
249     */
250    priority: number;
251  }
252
253  /**
254   * Set the disposed status of a specified bundle.
255   *
256   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
257   * @param { string } appId - Indicates the app ID of the application.
258   * @param { Want } disposedWant - Indicates the disposed want.
259   * @param { AsyncCallback<void> } callback - The callback of setting the disposed status result.
260   * @throws { BusinessError } 201 - Permission denied.
261   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
262   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
263   * @throws { BusinessError } 801 - Capability not supported.
264   * @throws { BusinessError } 17700005 - The specified app ID is empty string.
265   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
266   * @systemapi
267   * @since 9
268   */
269  function setDisposedStatus(appId: string, disposedWant: Want, callback: AsyncCallback<void>): void;
270
271  /**
272   * Set the disposed status of a specified bundle.
273   *
274   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
275   * @param { string } appId - Indicates the app ID of the application.
276   * @param { Want } disposedWant - Indicates the disposed want.
277   * @returns { Promise<void> } The result of setting the disposed status of a specified bundle.
278   * @throws { BusinessError } 201 - Permission denied.
279   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
280   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
281   * @throws { BusinessError } 801 - Capability not supported.
282   * @throws { BusinessError } 17700005 - The specified app ID is empty string.
283   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
284   * @systemapi
285   * @since 9
286   */
287  function setDisposedStatus(appId: string, disposedWant: Want): Promise<void>;
288
289  /**
290   * Set the disposed status of a specified bundle.
291   *
292   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
293   * @param { string } appId - Indicates the app ID of the application.
294   * @param { Want } disposedWant - Indicates the disposed want.
295   * @throws { BusinessError } 201 - Permission denied.
296   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
297   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
298   * @throws { BusinessError } 801 - Capability not supported.
299   * @throws { BusinessError } 17700005 - The specified app ID is empty string.
300   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
301   * @systemapi
302   * @since 10
303   */
304  function setDisposedStatusSync(appId: string, disposedWant: Want): void;
305
306  /**
307   * Obtains the disposed status of a specified bundle.
308   *
309   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
310   * @param { string } appId - Indicates the app ID of the application.
311   * @param { AsyncCallback<Want> } callback - The callback of getting the disposed status of a specified bundle result.
312   * @throws { BusinessError } 201 - Permission denied.
313   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
314   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
315   * @throws { BusinessError } 801 - Capability not supported.
316   * @throws { BusinessError } 17700005 - The specified app ID is empty string.
317   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
318   * @systemapi
319   * @since 9
320   */
321  function getDisposedStatus(appId: string, callback: AsyncCallback<Want>): void;
322
323  /**
324   * Obtains the disposed status of a specified bundle.
325   *
326   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
327   * @param { string } appId - Indicates the app ID of the application.
328   * @returns { Promise<Want> } Returns the disposed status of a specified bundle.
329   * @throws { BusinessError } 201 - Permission denied.
330   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
331   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
332   * @throws { BusinessError } 801 - Capability not supported.
333   * @throws { BusinessError } 17700005 - The specified app ID is empty string.
334   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
335   * @systemapi
336   * @since 9
337   */
338  function getDisposedStatus(appId: string): Promise<Want>;
339
340  /**
341   * Obtains the disposed status of a specified bundle.
342   *
343   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
344   * @param { string } appId - Indicates the app ID of the application.
345   * @returns { Want } Returns the disposed status of a specified bundle.
346   * @throws { BusinessError } 201 - Permission denied.
347   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
348   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
349   * @throws { BusinessError } 801 - Capability not supported.
350   * @throws { BusinessError } 17700005 - The specified app ID is empty string.
351   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
352   * @systemapi
353   * @since 10
354   */
355  function getDisposedStatusSync(appId: string): Want;
356
357  /**
358   * Delete the disposed status of a specified bundle.
359   *
360   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
361   * @param { string } appId - Indicates the app ID of the application.
362   * @param { AsyncCallback<void> } callback - the callback of deleting the disposed status of a specified bundle result.
363   * @throws { BusinessError } 201 - Permission denied.
364   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
365   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
366   * @throws { BusinessError } 801 - Capability not supported.
367   * @throws { BusinessError } 17700005 - The specified app ID is empty string.
368   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
369   * @systemapi
370   * @since 9
371   */
372  function deleteDisposedStatus(appId: string, callback: AsyncCallback<void>): void;
373
374  /**
375   * Delete the disposed status of a specified bundle.
376   *
377   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
378   * @param { string } appId - Indicates the app ID of the application.
379   * @returns { Promise<void> } Returns the result of deleting the disposed status of a specified bundle.
380   * @throws { BusinessError } 201 - Permission denied.
381   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
382   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
383   * @throws { BusinessError } 801 - Capability not supported.
384   * @throws { BusinessError } 17700005 - The specified app ID is empty string.
385   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
386   * @systemapi
387   * @since 9
388   */
389  function deleteDisposedStatus(appId: string): Promise<void>;
390
391  /**
392   * Delete the disposed status of a specified bundle.
393   *
394   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
395   * @param { string } appId - Indicates the app ID of the application.
396   * @throws { BusinessError } 201 - Permission denied.
397   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
398   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
399   * @throws { BusinessError } 801 - Capability not supported.
400   * @throws { BusinessError } 17700005 - The specified app ID is empty string.
401   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
402   * @systemapi
403   * @since 10
404   */
405  /**
406   * Delete the disposed status of a specified bundle.
407   *
408   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
409   * @param { string } appId - Indicates the app ID of the application.
410   * @param { number } [appIndex] Indicates the index of clone app.
411   * @throws { BusinessError } 201 - Permission denied.
412   * @throws { BusinessError } 202 - Permission denied. A non-system application is not allowed to call a system API.
413   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
414   * @throws { BusinessError } 801 - Capability not supported.
415   * @throws { BusinessError } 17700005 - The specified app ID is invalid.
416   * @throws { BusinessError } 17700061 - AppIndex is not in the valid range.
417   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
418   * @systemapi
419   * @since 12
420   */
421  function deleteDisposedStatusSync(appId: string, appIndex?: number): void;
422
423  /**
424   * Obtains the disposed rule of a specified bundle.
425   *
426   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
427   * @param { string } appId - Indicates the app ID of the application.
428   * @returns { DisposedRule } Returns the disposed rule of a specified bundle.
429   * @throws { BusinessError } 201 - Permission denied.
430   * @throws { BusinessError } 202 - Permission denied. A non-system application is not allowed to call a system API.
431   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
432   * @throws { BusinessError } 801 - Capability not supported.
433   * @throws { BusinessError } 17700005 - The specified app ID is an empty string.
434   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
435   * @systemapi
436   * @since 11
437   */
438  /**
439   * Obtains the disposed rule of a specified bundle.
440   *
441   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
442   * @param { string } appId - Indicates the app ID of the application.
443   * @param { number } [appIndex] Indicates the index of clone app.
444   * @returns { DisposedRule } Returns the disposed rule of a specified bundle.
445   * @throws { BusinessError } 201 - Permission denied.
446   * @throws { BusinessError } 202 - Permission denied. A non-system application is not allowed to call a system API.
447   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
448   * @throws { BusinessError } 801 - Capability not supported.
449   * @throws { BusinessError } 17700005 - The specified app ID is invalid.
450   * @throws { BusinessError } 17700061 - AppIndex is not in the valid range.
451   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
452   * @systemapi
453   * @since 12
454   */
455  function getDisposedRule(appId: string, appIndex?: number): DisposedRule;
456
457  /**
458   * Sets the disposed rule of a specified bundle.
459   *
460   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
461   * @param { string } appId - Indicates the app ID of the application.
462   * @param { DisposedRule } rule - Indicates the disposed rule of a specified bundle.
463   * @throws { BusinessError } 201 - Permission denied.
464   * @throws { BusinessError } 202 - Permission denied. A non-system application is not allowed to call a system API.
465   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
466   * @throws { BusinessError } 801 - Capability not supported.
467   * @throws { BusinessError } 17700005 - The specified app ID is an empty string.
468   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
469   * @systemapi
470   * @since 11
471   */
472  /**
473   * Sets the disposed rule of a specified bundle.
474   *
475   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
476   * @param { string } appId - Indicates the app ID of the application.
477   * @param { DisposedRule } rule - Indicates the disposed rule of a specified bundle.
478   * @param { number } [appIndex] Indicates the index of clone app.
479   * @throws { BusinessError } 201 - Permission denied.
480   * @throws { BusinessError } 202 - Permission denied. A non-system application is not allowed to call a system API.
481   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
482   * @throws { BusinessError } 801 - Capability not supported.
483   * @throws { BusinessError } 17700005 - The specified app ID is invalid.
484   * @throws { BusinessError } 17700061 - AppIndex is not in the valid range.
485   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
486   * @systemapi
487   * @since 12
488   */
489    function setDisposedRule(appId: string, rule: DisposedRule, appIndex?: number): void;
490
491  /**
492   * Sets the uninstall disposed rule of a specified bundle.
493   *
494   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
495   * @param { string } appIdentifier - Indicates the appIdentifier of the application.
496   * @param { UninstallDisposedRule } rule - Indicates the uninstall disposed rule of a specified bundle.
497   * @param { number } [appIndex] Indicates the index of clone app.
498   * @throws { BusinessError } 201 - Permission denied.
499   * @throws { BusinessError } 202 - Permission denied. A non-system application is not allowed to call a system API.
500   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
501   * @throws { BusinessError } 801 - Capability not supported.
502   * @throws { BusinessError } 17700061 - AppIndex is not in the valid range.
503   * @throws { BusinessError } 17700074 - The specified appIdentifier is invalid.
504   * @throws { BusinessError } 17700075 - The specified bundleName of want is not the same with caller.
505   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
506   * @systemapi
507   * @since 15
508   */
509  function setUninstallDisposedRule(appIdentifier: string, rule: UninstallDisposedRule, appIndex?: number): void;
510
511  /**
512   * Obtains the uninstall disposed rule of a specified bundle.
513   *
514   * @permission ohos.permission.GET_DISPOSED_APP_STATUS or ohos.permission.MANAGE_DISPOSED_APP_STATUS
515   * @param { string } appIdentifier - Indicates the appIdentifier of the application.
516   * @param { number } [appIndex] Indicates the index of clone app.
517   * @returns { UninstallDisposedRule } Returns the uninstall disposed rule of a specified bundle.
518   * @throws { BusinessError } 201 - Permission denied.
519   * @throws { BusinessError } 202 - Permission denied. A non-system application is not allowed to call a system API.
520   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
521   * @throws { BusinessError } 801 - Capability not supported.
522   * @throws { BusinessError } 17700061 - AppIndex is not in the valid range.
523   * @throws { BusinessError } 17700074 - The specified appIdentifier is invalid.
524   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
525   * @systemapi
526   * @since 15
527   */
528  function getUninstallDisposedRule(appIdentifier: string, appIndex?: number): UninstallDisposedRule;
529
530  /**
531   * Delete the uninstall disposed rule of a specified bundle.
532   *
533   * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS
534   * @param { string } appIdentifier - Indicates the appIdentifier of the application.
535   * @param { number } [appIndex] Indicates the index of clone app.
536   * @throws { BusinessError } 201 - Permission denied.
537   * @throws { BusinessError } 202 - Permission denied. A non-system application is not allowed to call a system API.
538   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
539   * @throws { BusinessError } 801 - Capability not supported.
540   * @throws { BusinessError } 17700061 - AppIndex is not in the valid range.
541   * @throws { BusinessError } 17700074 - The specified appIdentifier is invalid.
542   * @syscap SystemCapability.BundleManager.BundleFramework.AppControl
543   * @systemapi
544   * @since 15
545   */
546  function deleteUninstallDisposedRule(appIdentifier: string, appIndex?: number): void;
547}
548
549export default appControl;
550