• 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 { DispatchInfo as _DispatchInfo } from './bundleManager/DispatchInfo';
23import * 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 */
33declare 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   * @typedef { _DispatchInfo }
261   * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
262   * @systemapi
263   * @since 9
264   */
265  export type DispatchInfo = _DispatchInfo;
266
267  /**
268   * The bundle pack info class.
269   *
270   * @typedef { _PackInfo.BundlePackInfo }
271   * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
272   * @systemapi
273   * @since 9
274   */
275  export type BundlePackInfo = _PackInfo.BundlePackInfo;
276
277  /**
278   * The package info class.
279   *
280   * @typedef { _PackInfo.PackageConfig }
281   * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
282   * @systemapi
283   * @since 9
284   */
285  export type PackageConfig = _PackInfo.PackageConfig;
286
287  /**
288   * The package summary class.
289   *
290   * @typedef { _PackInfo.PackageSummary }
291   * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
292   * @systemapi
293   * @since 9
294   */
295  export type PackageSummary = _PackInfo.PackageSummary;
296
297  /**
298   * The bundle summary class.
299   *
300   * @typedef { _PackInfo.BundleConfigInfo }
301   * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
302   * @systemapi
303   * @since 9
304   */
305  export type BundleConfigInfo = _PackInfo.BundleConfigInfo;
306
307  /**
308   * The extension ability forms class.
309   *
310   * @typedef { _PackInfo.ExtensionAbility }
311   * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
312   * @systemapi
313   * @since 9
314   */
315  export type ExtensionAbility = _PackInfo.ExtensionAbility;
316
317  /**
318   * The module summary of a bundle.
319   *
320   * @typedef { _PackInfo.ModuleConfigInfo }
321   * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
322   * @systemapi
323   * @since 9
324   */
325  export type ModuleConfigInfo = _PackInfo.ModuleConfigInfo;
326
327  /**
328   * The bundle info summary class.
329   *
330   * @typedef { _PackInfo.ModuleDistroInfo }
331   * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
332   * @systemapi
333   * @since 9
334   */
335  export type ModuleDistroInfo = _PackInfo.ModuleDistroInfo;
336
337  /**
338   * The ability info of a module.
339   *
340   * @typedef { _PackInfo.ModuleAbilityInfo }
341   * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
342   * @systemapi
343   * @since 9
344   */
345  export type ModuleAbilityInfo = _PackInfo.ModuleAbilityInfo;
346
347  /**
348   * The form info of an ability.
349   *
350   * @typedef { _PackInfo.AbilityFormInfo }
351   * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
352   * @systemapi
353   * @since 9
354   */
355  export type AbilityFormInfo = _PackInfo.AbilityFormInfo;
356
357  /**
358   * The bundle version class.
359   *
360   * @typedef { _PackInfo.Version }
361   * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
362   * @systemapi
363   * @since 9
364   */
365  export type Version = _PackInfo.Version;
366
367  /**
368   * The bundle Api version class.
369   *
370   * @typedef { _PackInfo.ApiVersion }
371   * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall
372   * @systemapi
373   * @since 9
374   */
375  export type ApiVersion = _PackInfo.ApiVersion;
376}
377
378export default freeInstall;
379