1e41f4b71Sopenharmony_ci# @ohos.bundle.freeInstall (freeInstall模块)(系统接口)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci本模块提供免安装相关的设置和查询能力,支持BundlePackInfo、DispatchInfo等信息的查询。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **说明:**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> 本模块为系统接口。
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## 导入模块
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci```js
14e41f4b71Sopenharmony_ciimport freeInstall from '@ohos.bundle.freeInstall';
15e41f4b71Sopenharmony_ci```
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## 权限列表
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci| 权限                                       | 权限等级     | 描述               |
20e41f4b71Sopenharmony_ci| ------------------------------------------ | ------------ | ------------------ |
21e41f4b71Sopenharmony_ci| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息。 |
22e41f4b71Sopenharmony_ci| ohos.permission.INSTALL_BUNDLE             | system_core  | 允许应用安装、卸载其他应用(除了企业相关应用,目前有企业InHouse应用,企业MDM应用和企业normal应用)。   |
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci权限等级参考[权限APL等级说明](../../security/AccessToken/app-permission-mgmt-overview.md#权限机制中的基本概念)。
25e41f4b71Sopenharmony_ci## UpgradeFlag
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci| 名称             | 值   | 说明             |
32e41f4b71Sopenharmony_ci| ---------------- | ---- | ---------------- |
33e41f4b71Sopenharmony_ci| NOT_UPGRADE      | 0    | 模块无需升级。     |
34e41f4b71Sopenharmony_ci| SINGLE_UPGRADE   | 1    | 单个模块需要升级。 |
35e41f4b71Sopenharmony_ci| RELATION_UPGRADE | 2    | 关系模块需要升级。 |
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci## BundlePackFlag
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci| 名称               | 值         | 说明                               |
44e41f4b71Sopenharmony_ci| ------------------ | ---------- | ---------------------------------- |
45e41f4b71Sopenharmony_ci| GET_PACK_INFO_ALL  | 0x00000000 | 获取应用包pack.info的所有信息。    |
46e41f4b71Sopenharmony_ci| GET_PACKAGES       | 0x00000001 | 获取应用包pack.info的package信息。 |
47e41f4b71Sopenharmony_ci| GET_BUNDLE_SUMMARY | 0x00000002 | 获取应用包pack.info的bundle摘要信息。  |
48e41f4b71Sopenharmony_ci| GET_MODULE_SUMMARY | 0x00000004 | 获取应用包pack.info的module摘要信息。  |
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci## freeInstall.setHapModuleUpgradeFlag
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_cisetHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag, callback: AsyncCallback\<void>):void
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci设置指定模块是否升级。使用callback异步回调。
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.INSTALL_BUNDLE
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci**参数:**
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci| 参数名     | 类型                        | 必填 | 说明                       |
65e41f4b71Sopenharmony_ci| ----------- | --------------------------- | ---- | ---------------------------- |
66e41f4b71Sopenharmony_ci| bundleName  | string                      | 是   | 应用Bundle名称。     |
67e41f4b71Sopenharmony_ci| moduleName  | string                      | 是   | 应用程序模块名称。           |
68e41f4b71Sopenharmony_ci| upgradeFlag | [UpgradeFlag](#upgradeflag) | 是   | 仅供内部系统使用标志位       |
69e41f4b71Sopenharmony_ci| callback    | AsyncCallback\<void>        | 是   | 回调函数。当函数调用成功,err为null,否则为错误对象。 |
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci**错误码:**
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                            |
76e41f4b71Sopenharmony_ci|----------|---------------------------------------- |
77e41f4b71Sopenharmony_ci| 201 | Permission denied. |
78e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
79e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
80e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
81e41f4b71Sopenharmony_ci| 17700001 | The specified bundle name is not found. |
82e41f4b71Sopenharmony_ci| 17700002 | The specified module name is not found. |
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci**示例:**
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci```js
87e41f4b71Sopenharmony_ciimport freeInstall from '@ohos.bundle.freeInstall';
88e41f4b71Sopenharmony_cilet bundleName = 'com.example.myapplication';
89e41f4b71Sopenharmony_cilet moduleName = 'entry';
90e41f4b71Sopenharmony_cilet upgradeFlag = freeInstall.UpgradeFlag.SINGLE_UPGRADE;
91e41f4b71Sopenharmony_citry {
92e41f4b71Sopenharmony_ci    freeInstall.setHapModuleUpgradeFlag(bundleName, moduleName, upgradeFlag, err => {
93e41f4b71Sopenharmony_ci        if (err) {
94e41f4b71Sopenharmony_ci            console.error('Operation failed:' + JSON.stringify(err));
95e41f4b71Sopenharmony_ci        } else {
96e41f4b71Sopenharmony_ci            console.info('Operation succeed');
97e41f4b71Sopenharmony_ci        }
98e41f4b71Sopenharmony_ci    });
99e41f4b71Sopenharmony_ci} catch (err) {
100e41f4b71Sopenharmony_ci    console.error('Operation failed:' + JSON.stringify(err));
101e41f4b71Sopenharmony_ci}
102e41f4b71Sopenharmony_ci```
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci## setHapModuleUpgradeFlag
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_cisetHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag): Promise\<void>
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci设置指定模块是否升级。使用Promise异步回调。
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.INSTALL_BUNDLE
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci**参数:**
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci| 参数名      | 类型                        | 必填 | 说明                   |
119e41f4b71Sopenharmony_ci| ----------- | --------------------------- | ---- | ---------------------- |
120e41f4b71Sopenharmony_ci| bundleName  | string                      | 是   | 应用Bundle名称。 |
121e41f4b71Sopenharmony_ci| moduleName  | string                      | 是   | 应用程序模块名称。     |
122e41f4b71Sopenharmony_ci| upgradeFlag | [UpgradeFlag](#upgradeflag) | 是   | 仅供内部系统使用标志位。|
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci**返回值:**
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci| 类型          | 说明                                 |
127e41f4b71Sopenharmony_ci| ------------- | ------------------------------------ |
128e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。无返回结果的Promise对象。 |
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci**错误码:**
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                            |
135e41f4b71Sopenharmony_ci|----------|----------------------------------------|
136e41f4b71Sopenharmony_ci| 201 | Permission denied. |
137e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
138e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
139e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
140e41f4b71Sopenharmony_ci| 17700001 | The specified bundle name is not found. |
141e41f4b71Sopenharmony_ci| 17700002 | The specified module name is not found. |
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci**示例:**
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci```js
146e41f4b71Sopenharmony_ciimport freeInstall from '@ohos.bundle.freeInstall';
147e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
148e41f4b71Sopenharmony_cilet bundleName = 'com.example.myapplication';
149e41f4b71Sopenharmony_cilet moduleName = 'entry';
150e41f4b71Sopenharmony_cilet upgradeFlag = freeInstall.UpgradeFlag.SINGLE_UPGRADE;
151e41f4b71Sopenharmony_citry {
152e41f4b71Sopenharmony_ci    freeInstall.setHapModuleUpgradeFlag(bundleName, moduleName, upgradeFlag).then(() => {
153e41f4b71Sopenharmony_ci        console.info('Operation succeed')
154e41f4b71Sopenharmony_ci    }).catch((err: BusinessError) => {
155e41f4b71Sopenharmony_ci        console.error('Operation failed:' + JSON.stringify(err));
156e41f4b71Sopenharmony_ci    });
157e41f4b71Sopenharmony_ci} catch (err) {
158e41f4b71Sopenharmony_ci    console.error('Operation failed:' + JSON.stringify(err));
159e41f4b71Sopenharmony_ci}
160e41f4b71Sopenharmony_ci```
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci## isHapModuleRemovable
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ciisHapModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCallback\<boolean>): void
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci查询指定模块是否可以被移除。使用callback异步回调。
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci**参数:**
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci| 参数名      | 类型                   | 必填 | 说明                                          |
177e41f4b71Sopenharmony_ci| ---------- | ---------------------- | ---- | --------------------------------------------- |
178e41f4b71Sopenharmony_ci| bundleName | string                 | 是   | 应用Bundle名称。                      |
179e41f4b71Sopenharmony_ci| moduleName | string                 | 是   | 应用程序模块名称。                            |
180e41f4b71Sopenharmony_ci| callback   | AsyncCallback\<boolean> | 是   | 回调函数。返回true表示可以移除;返回false表示不可移除。 |
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci**错误码:**
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                            |
187e41f4b71Sopenharmony_ci|----------|----------------------------------------|
188e41f4b71Sopenharmony_ci| 201 | Permission denied. |
189e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
190e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
191e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
192e41f4b71Sopenharmony_ci| 17700001 | The specified bundle name is not found. |
193e41f4b71Sopenharmony_ci| 17700002 | The specified module name is not found. |
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci**示例:**
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci```js
198e41f4b71Sopenharmony_ciimport freeInstall from '@ohos.bundle.freeInstall';
199e41f4b71Sopenharmony_cilet bundleName = 'com.example.myapplication';
200e41f4b71Sopenharmony_cilet moduleName = 'entry';
201e41f4b71Sopenharmony_citry {
202e41f4b71Sopenharmony_ci    freeInstall.isHapModuleRemovable(bundleName, moduleName, (err, data) => {
203e41f4b71Sopenharmony_ci        if (err) {
204e41f4b71Sopenharmony_ci            console.error('Operation failed:' + JSON.stringify(err));
205e41f4b71Sopenharmony_ci        } else {
206e41f4b71Sopenharmony_ci            console.info('Operation succeed:' + JSON.stringify(data));
207e41f4b71Sopenharmony_ci        }
208e41f4b71Sopenharmony_ci    });
209e41f4b71Sopenharmony_ci} catch (err) {
210e41f4b71Sopenharmony_ci    console.error('Operation failed:' + JSON.stringify(err));
211e41f4b71Sopenharmony_ci}
212e41f4b71Sopenharmony_ci```
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ci## isHapModuleRemovable
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ciisHapModuleRemovable(bundleName: string, moduleName: string): Promise\<boolean>
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ci查询指定模块是否可以被移除。使用Promise异步回调。
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci**参数:**
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci| 参数名     | 类型   | 必填 | 说明               |
229e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ------------------ |
230e41f4b71Sopenharmony_ci| bundleName | string | 是   | 应用Bundle名称。   |
231e41f4b71Sopenharmony_ci| moduleName | string | 是   | 应用程序模块名称。 |
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci**返回值:**
234e41f4b71Sopenharmony_ci
235e41f4b71Sopenharmony_ci| 类型             | 说明                         |
236e41f4b71Sopenharmony_ci| ---------------- | ---------------------------- |
237e41f4b71Sopenharmony_ci| Promise\<boolean> | Promise对象。返回true表示可以移除;返回false表示不可移除。 |
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci**错误码:**
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                            |
244e41f4b71Sopenharmony_ci|----------|----------------------------------------|
245e41f4b71Sopenharmony_ci| 201 | Permission denied. |
246e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
247e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
248e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
249e41f4b71Sopenharmony_ci| 17700001 | The specified bundle name is not found. |
250e41f4b71Sopenharmony_ci| 17700002 | The specified module name is not found. |
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci**示例:**
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci```js
255e41f4b71Sopenharmony_ciimport freeInstall from '@ohos.bundle.freeInstall';
256e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
257e41f4b71Sopenharmony_cilet bundleName = 'com.example.myapplication';
258e41f4b71Sopenharmony_cilet moduleName = 'entry';
259e41f4b71Sopenharmony_citry {
260e41f4b71Sopenharmony_ci    freeInstall.isHapModuleRemovable(bundleName, moduleName).then(data => {
261e41f4b71Sopenharmony_ci        console.info('Operation succeed:' + JSON.stringify(data));
262e41f4b71Sopenharmony_ci    }).catch((err: BusinessError) => {
263e41f4b71Sopenharmony_ci        console.error('Operation failed:' + JSON.stringify(err));
264e41f4b71Sopenharmony_ci    });
265e41f4b71Sopenharmony_ci} catch (err) {
266e41f4b71Sopenharmony_ci    console.error('Operation failed:' + JSON.stringify(err));
267e41f4b71Sopenharmony_ci}
268e41f4b71Sopenharmony_ci```
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ci## getBundlePackInfo
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_cigetBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag, callback: AsyncCallback\<BundlePackInfo>): void
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ci基于bundleName和bundlePackFlag来获取bundlePackInfo。使用callback异步回调。
275e41f4b71Sopenharmony_ci
276e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ci**参数:**
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_ci| 参数名         | 类型                                                         | 必填 | 说明                                                         |
285e41f4b71Sopenharmony_ci| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
286e41f4b71Sopenharmony_ci| bundleName     | string                                                       | 是   | 应用Bundle名称。                                             |
287e41f4b71Sopenharmony_ci| bundlePackFlag | [BundlePackFlag](#bundlepackflag)                            | 是   | 指示要查询的应用包标志。                                     |
288e41f4b71Sopenharmony_ci| callback       | AsyncCallback<[BundlePackInfo](js-apis-bundleManager-BundlePackInfo-sys.md)> | 是   | 回调函数。当函数调用成功,err为null,data为获取到的BundlePackInfo信息。否则为错误对象。 |
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ci**错误码:**
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                            |
295e41f4b71Sopenharmony_ci|----------|----------------------------------------|
296e41f4b71Sopenharmony_ci| 201 | Permission denied. |
297e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
298e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
299e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
300e41f4b71Sopenharmony_ci| 17700001 | The specified bundle name is not found. |
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci**示例:**
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci```js
305e41f4b71Sopenharmony_ciimport freeInstall from '@ohos.bundle.freeInstall';
306e41f4b71Sopenharmony_cilet bundleName = 'com.example.myapplication';
307e41f4b71Sopenharmony_cilet bundlePackFlag = freeInstall.BundlePackFlag.GET_PACK_INFO_ALL;
308e41f4b71Sopenharmony_citry {
309e41f4b71Sopenharmony_ci    freeInstall.getBundlePackInfo(bundleName, bundlePackFlag, (err, data) => {
310e41f4b71Sopenharmony_ci        if (err) {
311e41f4b71Sopenharmony_ci            console.error('Operation failed:' + JSON.stringify(err));
312e41f4b71Sopenharmony_ci        } else {
313e41f4b71Sopenharmony_ci            console.info('Operation succeed:' + JSON.stringify(data));
314e41f4b71Sopenharmony_ci        }
315e41f4b71Sopenharmony_ci    });
316e41f4b71Sopenharmony_ci} catch (err) {
317e41f4b71Sopenharmony_ci    console.error('Operation failed:' + JSON.stringify(err));
318e41f4b71Sopenharmony_ci}
319e41f4b71Sopenharmony_ci```
320e41f4b71Sopenharmony_ci## getBundlePackInfo
321e41f4b71Sopenharmony_ci
322e41f4b71Sopenharmony_cigetBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag): Promise\<BundlePackInfo>
323e41f4b71Sopenharmony_ci
324e41f4b71Sopenharmony_ci基于bundleName和BundlePackFlag来获取bundlePackInfo。使用Promise异步回调。
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
327e41f4b71Sopenharmony_ci
328e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
329e41f4b71Sopenharmony_ci
330e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
331e41f4b71Sopenharmony_ci
332e41f4b71Sopenharmony_ci**参数:**
333e41f4b71Sopenharmony_ci
334e41f4b71Sopenharmony_ci| 参数名         | 类型                              | 必填 | 说明                   |
335e41f4b71Sopenharmony_ci| -------------- | --------------------------------- | ---- | ---------------------- |
336e41f4b71Sopenharmony_ci| bundleName     | string                            | 是   | 应用程序Bundle名称。 |
337e41f4b71Sopenharmony_ci| bundlePackFlag | [BundlePackFlag](#bundlepackflag) | 是   | 指示要查询的应用包标志。|
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci**返回值:**
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci| 类型                                                       | 说明                                |
342e41f4b71Sopenharmony_ci| ---------------------------------------------------------- | ----------------------------------- |
343e41f4b71Sopenharmony_ci| Promise<[BundlePackInfo](js-apis-bundleManager-BundlePackInfo-sys.md)> | Promise对象,返回BundlePackInfo信息。 |
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci**错误码:**
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                            |
350e41f4b71Sopenharmony_ci|----------|----------------------------------------|
351e41f4b71Sopenharmony_ci| 201 | Permission denied. |
352e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
353e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
354e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
355e41f4b71Sopenharmony_ci| 17700001 | The specified bundle name is not found. |
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci**示例:**
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci```js
360e41f4b71Sopenharmony_ciimport freeInstall from '@ohos.bundle.freeInstall';
361e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
362e41f4b71Sopenharmony_cilet bundleName = 'com.example.myapplication';
363e41f4b71Sopenharmony_cilet bundlePackFlag = freeInstall.BundlePackFlag.GET_PACK_INFO_ALL;
364e41f4b71Sopenharmony_citry {
365e41f4b71Sopenharmony_ci    freeInstall.getBundlePackInfo(bundleName, bundlePackFlag).then(data => {
366e41f4b71Sopenharmony_ci        console.info('Operation succeed:' + JSON.stringify(data));
367e41f4b71Sopenharmony_ci    }).catch((err: BusinessError) => {
368e41f4b71Sopenharmony_ci        console.error('Operation failed:' + JSON.stringify(err));
369e41f4b71Sopenharmony_ci    });
370e41f4b71Sopenharmony_ci} catch (err) {
371e41f4b71Sopenharmony_ci    console.error('Operation failed:' + JSON.stringify(err));
372e41f4b71Sopenharmony_ci}
373e41f4b71Sopenharmony_ci```
374e41f4b71Sopenharmony_ci
375e41f4b71Sopenharmony_ci## getDispatchInfo
376e41f4b71Sopenharmony_ci
377e41f4b71Sopenharmony_cigetDispatchInfo(callback: AsyncCallback\<DispatchInfo>): void
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci获取有关dispatch版本的信息。使用callback异步回调。
380e41f4b71Sopenharmony_ci
381e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
382e41f4b71Sopenharmony_ci
383e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
384e41f4b71Sopenharmony_ci
385e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
386e41f4b71Sopenharmony_ci
387e41f4b71Sopenharmony_ci**参数:**
388e41f4b71Sopenharmony_ci
389e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
390e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
391e41f4b71Sopenharmony_ci| callback | AsyncCallback<[DispatchInfo](js-apis-bundleManager-dispatchInfo-sys.md)> | 是   | 回调函数。当函数调用成功,err为null,data为获取到的[DispatchInfo](js-apis-bundleManager-dispatchInfo-sys.md)信息。否则为错误对象。 |
392e41f4b71Sopenharmony_ci
393e41f4b71Sopenharmony_ci**错误码:**
394e41f4b71Sopenharmony_ci
395e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
396e41f4b71Sopenharmony_ci
397e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                            |
398e41f4b71Sopenharmony_ci|----------|----------------------------------------|
399e41f4b71Sopenharmony_ci| 201 | Permission denied. |
400e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
401e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci**示例:**
404e41f4b71Sopenharmony_ci
405e41f4b71Sopenharmony_ci```js
406e41f4b71Sopenharmony_ciimport freeInstall from '@ohos.bundle.freeInstall';
407e41f4b71Sopenharmony_citry {
408e41f4b71Sopenharmony_ci    freeInstall.getDispatchInfo((err, data) => {
409e41f4b71Sopenharmony_ci        if (err) {
410e41f4b71Sopenharmony_ci            console.error('Operation failed:' + JSON.stringify(err));
411e41f4b71Sopenharmony_ci        } else {
412e41f4b71Sopenharmony_ci            console.info('Operation succeed:' + JSON.stringify(data));
413e41f4b71Sopenharmony_ci        }
414e41f4b71Sopenharmony_ci    });
415e41f4b71Sopenharmony_ci} catch (err) {
416e41f4b71Sopenharmony_ci    console.error('Operation failed:' + JSON.stringify(err));
417e41f4b71Sopenharmony_ci}
418e41f4b71Sopenharmony_ci```
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_ci## getDispatchInfo
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_cigetDispatchInfo(): Promise\<DispatchInfo>
423e41f4b71Sopenharmony_ci
424e41f4b71Sopenharmony_ci获取有关dispatch版本的信息。使用Promise异步回调。
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
427e41f4b71Sopenharmony_ci
428e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_ci**返回值:**
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_ci| 类型                                             | 说明                                                         |
435e41f4b71Sopenharmony_ci| ------------------------------------------------ | ------------------------------------------------------------ |
436e41f4b71Sopenharmony_ci| Promise<[DispatchInfo](js-apis-bundleManager-dispatchInfo-sys.md)> | Promise对象,返回[DispatchInfo](js-apis-bundleManager-dispatchInfo-sys.md)信息。 |
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ci**错误码:**
439e41f4b71Sopenharmony_ci
440e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
441e41f4b71Sopenharmony_ci
442e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                            |
443e41f4b71Sopenharmony_ci|----------|----------------------------------------|
444e41f4b71Sopenharmony_ci| 201 | Permission denied. |
445e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
446e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
447e41f4b71Sopenharmony_ci
448e41f4b71Sopenharmony_ci**示例:**
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci```js
451e41f4b71Sopenharmony_ciimport freeInstall from '@ohos.bundle.freeInstall';
452e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
453e41f4b71Sopenharmony_citry {
454e41f4b71Sopenharmony_ci    freeInstall.getDispatchInfo().then(data => {
455e41f4b71Sopenharmony_ci        console.info('Operation succeed:' + JSON.stringify(data));
456e41f4b71Sopenharmony_ci    }).catch((err: BusinessError) => {
457e41f4b71Sopenharmony_ci        console.error('Operation failed:' + JSON.stringify(err));
458e41f4b71Sopenharmony_ci    });
459e41f4b71Sopenharmony_ci} catch (err) {
460e41f4b71Sopenharmony_ci    console.error('Operation failed:' + JSON.stringify(err));
461e41f4b71Sopenharmony_ci}
462e41f4b71Sopenharmony_ci```
463