• 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 
21 import { AsyncCallback } from './@ohos.base';
22 import { DispatchInfo as _DispatchInfo } from './bundleManager/DispatchInfo';
23 import * as _PackInfo from './bundleManager/BundlePackInfo';
24 
25 /**
26  * Free install bundle manager.
27  *
28  * @namespace freeInstall
29  * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
30  * @systemapi
31  * @since 9
32  */
33 declare namespace freeInstall {
34   /**
35    * Used to set the enumeration value of upgrading for free installation.
36    *
37    * @enum { number }
38    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
39    * @systemapi
40    * @since 9
41    */
42   export enum UpgradeFlag {
43     /**
44      * Indicates module not need to be upgraded
45      *
46      * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
47      * @systemapi
48      * @since 9
49      */
50     NOT_UPGRADE = 0,
51     /**
52      * Indicates single module need to be upgraded
53      *
54      * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
55      * @systemapi
56      * @since 9
57      */
58     SINGLE_UPGRADE = 1,
59     /**
60      * Indicates relation module need to be upgraded
61      *
62      * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
63      * @systemapi
64      * @since 9
65      */
66     RELATION_UPGRADE = 2
67   }
68 
69   /**
70    * Used to query the enumeration value of bundlePackInfo.
71    *
72    * @enum { number }
73    * @syscap SystemCapability.BundleManager.BundleFramework
74    * @systemapi
75    * @since 9
76    */
77   export enum BundlePackFlag {
78     /**
79      * Query all package information.
80      *
81      * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
82      * @systemapi
83      * @since 9
84      */
85     GET_PACK_INFO_ALL = 0x00000000,
86     /**
87      * Query package information
88      *
89      * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
90      * @systemapi
91      * @since 9
92      */
93     GET_PACKAGES = 0x00000001,
94     /**
95      * Query the brief information of the package
96      *
97      * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
98      * @systemapi
99      * @since 9
100      */
101     GET_BUNDLE_SUMMARY = 0x00000002,
102     /**
103      * Query the brief information of the module.
104      *
105      * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
106      * @systemapi
107      * @since 9
108      */
109     GET_MODULE_SUMMARY = 0x00000004
110   }
111 
112   /**
113    * Sets whether to upgrade the module.
114    *
115    * @permission ohos.permission.INSTALL_BUNDLE
116    * @param { string } bundleName - Indicates the bundle name of the application.
117    * @param { string } moduleName - Indicates the module name of the application.
118    * @param { UpgradeFlag } upgradeFlag - Indicates upgradeFlag of the application.
119    * @param { AsyncCallback<void> } callback - The callback of setting module upgrade flag result.
120    * @throws { BusinessError } 201 - Permission denied.
121    * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
122    * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
123    * @throws { BusinessError } 801 - Capability not supported.
124    * @throws { BusinessError } 17700001 - The specified bundle name is not found.
125    * @throws { BusinessError } 17700002 - The specified module name is not found.
126    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
127    * @systemapi
128    * @since 9
129    */
130   function setHapModuleUpgradeFlag(bundleName: string,
131     moduleName: string, upgradeFlag: UpgradeFlag, callback: AsyncCallback<void>): void;
132 
133   /**
134    * Sets whether to upgrade the module.
135    *
136    * @permission ohos.permission.INSTALL_BUNDLE
137    * @param { string } bundleName - Indicates the bundle name of the application.
138    * @param { string } moduleName - Indicates the module name of the application.
139    * @param { UpgradeFlag } upgradeFlag - Indicates upgradeFlag of the application.
140    * @returns { Promise<void> } - Return the result of setting module upgrade flag.
141    * @throws { BusinessError } 201 - Permission denied.
142    * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
143    * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
144    * @throws { BusinessError } 801 - Capability not supported.
145    * @throws { BusinessError } 17700001 - The specified bundle name is not found.
146    * @throws { BusinessError } 17700002 - The specified module name is not found.
147    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
148    * @systemapi
149    * @since 9
150    */
151   function setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag): Promise<void>;
152 
153   /**
154    * Checks whether a specified module is removable.
155    *
156    * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
157    * @param { string } bundleName - Indicates the bundle name of the application.
158    * @param { string } moduleName - Indicates the module name of the application.
159    * @param { AsyncCallback<boolean> } callback - The callback of checking module removable result.
160    *  The result is true if the module is removable, false otherwise.
161    * @throws { BusinessError } 201 - Permission denied.
162    * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
163    * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
164    * @throws { BusinessError } 801 - Capability not supported.
165    * @throws { BusinessError } 17700001 - The specified bundle name is not found.
166    * @throws { BusinessError } 17700002 - The specified module name is not found.
167    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
168    * @systemapi
169    * @since 9
170    */
171   function isHapModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCallback<boolean>): void;
172 
173   /**
174    * Checks whether a specified module is removable.
175    *
176    * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
177    * @param { string } bundleName - Indicates the bundle name of the application.
178    * @param { string } moduleName - Indicates the module name of the application.
179    * @returns { Promise<boolean> } Returns true if the module is removable; returns false otherwise.
180    * @throws { BusinessError } 201 - Permission denied.
181    * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
182    * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
183    * @throws { BusinessError } 801 - Capability not supported.
184    * @throws { BusinessError } 17700001 - The specified bundle name is not found.
185    * @throws { BusinessError } 17700002 - The specified module name is not found.
186    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
187    * @systemapi
188    * @since 9
189    */
190   function isHapModuleRemovable(bundleName: string, moduleName: string): Promise<boolean>;
191 
192   /**
193    * Obtains bundlePackInfo based on bundleName and bundlePackFlags.
194    *
195    * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
196    * @param { string } bundleName - Indicates the application bundle name to be queried.
197    * @param { BundlePackFlag } bundlePackFlag - Indicates the application bundle pack flag to be queried.
198    * @param { AsyncCallback<BundlePackInfo> } callback - The callback of getting the BundlePackInfo object result.
199    * @throws { BusinessError } 201 - Permission denied.
200    * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
201    * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
202    * @throws { BusinessError } 801 - Capability not supported.
203    * @throws { BusinessError } 17700001 - The specified bundle name is not found.
204    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
205    * @systemapi
206    * @since 9
207    */
208   function getBundlePackInfo(bundleName: string,
209     bundlePackFlag: BundlePackFlag, callback: AsyncCallback<BundlePackInfo>): void;
210 
211   /**
212    * Obtains bundlePackInfo based on bundleName and bundlePackFlags.
213    *
214    * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
215    * @param { string } bundleName - Indicates the application bundle name to be queried.
216    * @param { BundlePackFlag } bundlePackFlag - Indicates the application bundle pack flag to be queried.
217    * @returns { Promise<BundlePackInfo> } Returns the BundlePackInfo object.
218    * @throws { BusinessError } 201 - Permission denied.
219    * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
220    * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
221    * @throws { BusinessError } 801 - Capability not supported.
222    * @throws { BusinessError } 17700001 - The specified bundle name is not found.
223    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
224    * @systemapi
225    * @since 9
226    */
227   function getBundlePackInfo(bundleName: string, bundlePackFlag: BundlePackFlag): Promise<BundlePackInfo>;
228 
229   /**
230    * Obtains information about the dispatcher version.
231    *
232    * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
233    * @param { AsyncCallback<DispatchInfo> } callback - The callback of getting the dispatchInfo object for the current ability result.
234    * @throws { BusinessError } 201 - Permission denied.
235    * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
236    * @throws { BusinessError } 801 - Capability not supported.
237    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
238    * @systemapi
239    * @since 9
240    */
241   function getDispatchInfo(callback: AsyncCallback<DispatchInfo>): void;
242 
243   /**
244    * Obtains information about the dispatcher version.
245    *
246    * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
247    * @returns { Promise<DispatchInfo> } Returns the DispatchInfo object for the current ability.
248    * @throws { BusinessError } 201 - Permission denied.
249    * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
250    * @throws { BusinessError } 801 - Capability not supported.
251    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
252    * @systemapi
253    * @since 9
254    */
255   function getDispatchInfo(): Promise<DispatchInfo>;
256 
257   /**
258    * The dispatch info class.
259    *
260    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
261    * @systemapi
262    * @since 9
263    */
264   export type DispatchInfo = _DispatchInfo;
265 
266   /**
267    * The bundle pack info class.
268    *
269    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
270    * @systemapi
271    * @since 9
272    */
273   export type BundlePackInfo = _PackInfo.BundlePackInfo;
274 
275   /**
276    * The package info class.
277    *
278    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
279    * @systemapi
280    * @since 9
281    */
282   export type PackageConfig = _PackInfo.PackageConfig;
283 
284   /**
285    * The package summary class.
286    *
287    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
288    * @systemapi
289    * @since 9
290    */
291   export type PackageSummary = _PackInfo.PackageSummary;
292 
293   /**
294    * The bundle summary class.
295    *
296    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
297    * @systemapi
298    * @since 9
299    */
300   export type BundleConfigInfo = _PackInfo.BundleConfigInfo;
301 
302   /**
303    * The extension ability forms class.
304    *
305    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
306    * @systemapi
307    * @since 9
308    */
309   export type ExtensionAbility = _PackInfo.ExtensionAbility;
310 
311   /**
312    * The module summary of a bundle.
313    *
314    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
315    * @systemapi
316    * @since 9
317    */
318   export type ModuleConfigInfo = _PackInfo.ModuleConfigInfo;
319 
320   /**
321    * The bundle info summary class.
322    *
323    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
324    * @systemapi
325    * @since 9
326    */
327   export type ModuleDistroInfo = _PackInfo.ModuleDistroInfo;
328 
329   /**
330    * The ability info of a module.
331    *
332    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
333    * @systemapi
334    * @since 9
335    */
336   export type ModuleAbilityInfo = _PackInfo.ModuleAbilityInfo;
337 
338   /**
339    * The form info of an ability.
340    *
341    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
342    * @systemapi
343    * @since 9
344    */
345   export type AbilityFormInfo = _PackInfo.AbilityFormInfo;
346 
347   /**
348    * The bundle version class.
349    *
350    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
351    * @systemapi
352    * @since 9
353    */
354   export type Version = _PackInfo.Version;
355 
356   /**
357    * The bundle Api version class.
358    *
359    * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
360    * @systemapi
361    * @since 9
362    */
363   export type ApiVersion = _PackInfo.ApiVersion;
364 }
365 
366 export default freeInstall;
367