1# @ohos.bundle.installer (installer模块) 2 3> **说明:** 4> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 5 6在设备上安装、升级和卸载应用。 7 8## 导入模块 9 10```js 11import installer from '@ohos.bundle.installer'; 12``` 13 14## 权限列表 15 16| 权限 | 权限等级 | 描述 | 17| ------------------------------ | ----------- | ---------------- | 18| ohos.permission.INSTALL_BUNDLE | system_core | 允许应用安装、卸载其他应用(除了企业相关应用,目前有企业InHouse应用,企业MDM应用和企业normal应用)。 | 19| ohos.permission.INSTALL_ENTERPRISE_BUNDLE | system_core | 允许应用安装企业InHouse应用。 | 20| ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE | system_core | 允许在企业设备上安装企业MDM应用包。 | 21| ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE | system_core | 允许在企业设备上安装企业NORMAL应用包。 | 22| ohos.permission.UNINSTALL_BUNDLE | system_core | 允许应用卸载应用。 | 23| ohos.permission.RECOVER_BUNDLE | system_core | 允许应用恢复预置应用。 | 24| ohos.permission.INSTALL_SELF_BUNDLE | system_core | 允许企业MDM应用在企业设备上自升级。| 25 26 27权限等级参考[权限等级说明](../../security/accesstoken-overview.md#权限等级说明)。 28 29## BundleInstaller.getBundleInstaller 30 31getBundleInstaller(callback: AsyncCallback\<BundleInstaller>): void 32 33获取BundleInstaller对象,使用callback形式返回结果。 34 35**系统接口:** 此接口为系统接口。 36 37**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 38 39**参数:** 40 41| 参数名 | 类型 | 必填 | 说明 | 42| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 43| callback | AsyncCallback\<BundleInstaller> | 是 | 回调函数,获取BundleInstaller对象,err为null,data为获取到的BundleInstaller对象;否则为错误对象。 | 44 45**示例:** 46 47```ts 48import installer from '@ohos.bundle.installer'; 49import { BusinessError } from '@ohos.base'; 50 51try { 52 installer.getBundleInstaller((err: BusinessError, data: installer.BundleInstaller) => { 53 if (err) { 54 console.error('getBundleInstaller failed:' + err.message); 55 } else { 56 console.info('getBundleInstaller successfully'); 57 } 58 }); 59} catch (error) { 60 let message = (error as BusinessError).message; 61 console.error('getBundleInstaller failed:' + message); 62} 63``` 64 65## BundleInstaller.getBundleInstaller 66 67getBundleInstaller(): Promise\<BundleInstaller> 68 69获取BundleInstaller对象,使用Promise形式返回结果。 70 71**系统接口:** 此接口为系统接口。 72 73**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 74 75**返回值:** 76| 类型 | 说明 | 77| ------------------------------------------------------------ | ------------------------------------ | 78| Promise\<BundleInstaller> | Promise对象,返回BundleInstaller对象。 | 79 80**示例:** 81 82```ts 83import installer from '@ohos.bundle.installer'; 84import { BusinessError } from '@ohos.base'; 85 86try { 87 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 88 console.info('getBundleInstaller successfully.'); 89 }).catch((error: BusinessError) => { 90 console.error('getBundleInstaller failed. Cause: ' + error.message); 91 }); 92} catch (error) { 93 let message = (error as BusinessError).message; 94 console.error('getBundleInstaller failed. Cause: ' + message); 95} 96``` 97 98## BundleInstaller.getBundleInstallerSync<sup>10+</sup> 99 100getBundleInstallerSync(): BundleInstaller 101 102获取并返回BundleInstaller对象。 103 104**系统接口:** 此接口为系统接口。 105 106**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 107 108**返回值:** 109| 类型 | 说明 | 110| ------------------------------------------------------------ | ------------------------------------ | 111| BundleInstaller | 返回BundleInstaller对象。 | 112 113**示例:** 114 115```ts 116import installer from '@ohos.bundle.installer'; 117import { BusinessError } from '@ohos.base'; 118 119try { 120 installer.getBundleInstallerSync(); 121 console.info('getBundleInstallerSync successfully.'); 122} catch (error) { 123 let message = (error as BusinessError).message; 124 console.error('getBundleInstallerSync failed. Cause: ' + message); 125} 126``` 127 128## BundleInstaller.install 129install(hapFilePaths: Array<string>, installParam: InstallParam, callback: AsyncCallback<void>): void 130 131以异步方法安装应用,使用callback形式返回结果。 132 133**系统接口:** 此接口为系统接口。 134 135**需要权限:** ohos.permission.INSTALL_BUNDLE 或 ohos.permission.INSTALL_ENTERPRISE_BUNDLE<sup>10+</sup> 或 ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE<sup>10+</sup> 或 ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE<sup>10+</sup> 136> **说明:** 从API version 10起,可通过ohos.permission.INSTALL_ENTERPRISE_BUNDLE 或 ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE 或 ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE权限调用此接口。 137> 138> 安装企业应用需要ohos.permission.INSTALL_ENTERPRISE_BUNDLE权限。 139> 140> 安装企业NORMAL应用需要ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE或ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE权限。 141> 142> 安装企业MDM应用需要ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE权限。 143> 144> 安装普通应用需要ohos.permission.INSTALL_BUNDLE权限。 145 146**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 147 148**参数:** 149 150| 参数名 | 类型 | 必填 | 说明 | 151| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | 152| hapFilePaths | Array<string> | 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP,且这些HAP的签名需要保持一致。 | 153| installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数。 | 154| callback | AsyncCallback<void> | 是 | 回调函数,安装应用成功,err为null,否则为错误对象。 | 155 156**错误码:** 157 158以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 159 160| 错误码ID | 错误信息 | 161| -------- | ------------------------------------------------------------ | 162| 17700004 | The specified user ID is not found. | 163| 17700010 | Failed to install the HAP because the HAP fails to be parsed. | 164| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. | 165| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. | 166| 17700015 | Failed to install the HAPs because they have different configuration information. | 167| 17700016 | Failed to install the HAP because of insufficient system disk space. | 168| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | 169| 17700018 | Failed to install because the dependent module does not exist. | 170| 17700031 | Failed to install the HAP because the overlay check of the HAP is failed. | 171| 17700036 | Failed to install the HSP because lacks appropriate permissions. | 172| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. | 173| 17700041 | Failed to install because enterprise device management disallow install. | 174| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. | 175| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). | 176| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. | 177| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. | 178| 17700048 | Failed to install the HAP because the code signature verification is failed. | 179| 17700050 | Failed to install the HAP because enterprise normal/MDM bundle cannot be installed on non-enterprise device. | 180 181**示例:** 182 183```ts 184import installer from '@ohos.bundle.installer'; 185import { BusinessError } from '@ohos.base'; 186 187let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; 188let installParam: installer.InstallParam = { 189 userId: 100, 190 isKeepData: false, 191 installFlag: 1, 192}; 193 194try { 195 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 196 data.install(hapFilePaths, installParam, (err: BusinessError) => { 197 if (err) { 198 console.error('install failed:' + err.message); 199 } else { 200 console.info('install successfully.'); 201 } 202 }); 203 }).catch((error: BusinessError) => { 204 console.error('getBundleInstaller failed. Cause: ' + error.message); 205 }); 206} catch (error) { 207 let message = (error as BusinessError).message; 208 console.error('getBundleInstaller failed. Cause: ' + message); 209} 210``` 211## BundleInstaller.install 212install(hapFilePaths: Array<string>, callback: AsyncCallback<void>): void 213 214以异步方法安装应用,使用callback形式返回结果。 215 216**系统接口:** 此接口为系统接口。 217 218**需要权限:** ohos.permission.INSTALL_BUNDLE 或 ohos.permission.INSTALL_ENTERPRISE_BUNDLE<sup>10+</sup> 或 ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE<sup>10+</sup> 或 ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE<sup>10+</sup> 219> **说明:** 从API version 10起,可通过ohos.permission.INSTALL_ENTERPRISE_BUNDLE 或 ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE 或 ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE权限调用此接口。 220> 221> 安装企业应用需要ohos.permission.INSTALL_ENTERPRISE_BUNDLE权限。 222> 223> 安装企业NORMAL应用需要ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE或ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE权限。 224> 225> 安装企业MDM应用需要ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE权限。 226> 227> 安装普通应用需要ohos.permission.INSTALL_BUNDLE权限。 228 229**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 230 231**参数:** 232 233| 参数名 | 类型 | 必填 | 说明 | 234| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | 235| hapFilePaths | Array<string> | 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP,且这些HAP的签名需要保持一致。 | 236| callback | AsyncCallback<void> | 是 | 回调函数,安装应用成功,err为null,否则为错误对象。 | 237 238**错误码:** 239 240以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 241 242| 错误码ID | 错误信息 | 243| -------- | ------------------------------------------------------------ | 244| 17700010 | Failed to install the HAP because the HAP fails to be parsed. | 245| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. | 246| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. | 247| 17700015 | Failed to install the HAPs because they have different configuration information. | 248| 17700016 | Failed to install the HAP because of insufficient system disk space. | 249| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | 250| 17700018 | Failed to install because the dependent module does not exist. | 251| 17700031 | Failed to install the HAP because the overlay check of the HAP is failed. | 252| 17700036 | Failed to install the HSP because lacks appropriate permissions. | 253| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. | 254| 17700041 | Failed to install because enterprise device management disallow install. | 255| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. | 256| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). | 257| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. | 258| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. | 259| 17700048 | Failed to install the HAP because the code signature verification is failed. | 260| 17700050 | Failed to install the HAP because enterprise normal/MDM bundle cannot be installed on non-enterprise device. | 261 262**示例:** 263 264```ts 265import installer from '@ohos.bundle.installer'; 266import { BusinessError } from '@ohos.base'; 267 268let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; 269 270try { 271 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 272 data.install(hapFilePaths, (err: BusinessError) => { 273 if (err) { 274 console.error('install failed:' + err.message); 275 } else { 276 console.info('install successfully.'); 277 } 278 }); 279 }).catch((error: BusinessError) => { 280 console.error('getBundleInstaller failed. Cause: ' + error.message); 281 }); 282} catch (error) { 283 let message = (error as BusinessError).message; 284 console.error('getBundleInstaller failed. Cause: ' + message); 285} 286``` 287 288## BundleInstaller.install 289 290install(hapFilePaths: Array\<string\>, installParam?: InstallParam) : Promise\<void\> 291 292以异步方法安装应用,使用Promise形式返回结果。 293 294**系统接口:** 此接口为系统接口。 295 296**需要权限:** ohos.permission.INSTALL_BUNDLE 或 ohos.permission.INSTALL_ENTERPRISE_BUNDLE<sup>10+</sup> 或 ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE<sup>10+</sup> 或 ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE<sup>10+</sup> 297> **说明:** 从API version 10起,可通过ohos.permission.INSTALL_ENTERPRISE_BUNDLE 或 ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE 或 ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE权限调用此接口。 298> 299> 安装企业应用需要ohos.permission.INSTALL_ENTERPRISE_BUNDLE权限。 300> 301> 安装企业NORMAL应用需要ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE或ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE权限。 302> 303> 安装企业MDM应用需要ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE权限。 304> 305> 安装普通应用需要ohos.permission.INSTALL_BUNDLE权限。 306 307**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 308 309**参数:** 310 311| 参数名 | 类型 | 必填 | 说明 | 312| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | 313| hapFilePaths | Array\<string\> | 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP,且这些HAP的签名需要保持一致。 | 314| installParam | [InstallParam](#installparam) | 否 | 指定安装所需的其他参数,默认值:参照[InstallParam](#installparam)的默认值。 | 315 316**返回值:** 317 318| 类型 | 说明 | 319| --------------- | -------------------------------------- | 320| Promise\<void\> | Promise对象。无返回结果的Promise对象。 | 321 322**错误码:** 323 324以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 325 326| 错误码ID | 错误信息 | 327| -------- | ------------------------------------------------------------ | 328| 17700004 | The specified user ID is not found. | 329| 17700010 | Failed to install the HAP because the HAP fails to be parsed. | 330| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. | 331| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. | 332| 17700015 | Failed to install the HAPs because they have different configuration information. | 333| 17700016 | Failed to install the HAP because of insufficient system disk space. | 334| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | 335| 17700018 | Failed to install because the dependent module does not exist. | 336| 17700031 | Failed to install the HAP because the overlay check of the HAP is failed. | 337| 17700036 | Failed to install the HSP because lacks appropriate permissions. | 338| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. | 339| 17700041 | Failed to install because enterprise device management disallow install. | 340| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. | 341| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). | 342| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. | 343| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. | 344| 17700048 | Failed to install the HAP because the code signature verification is failed. | 345| 17700050 | Failed to install the HAP because enterprise normal/MDM bundle cannot be installed on non-enterprise device. | 346 347**示例:** 348 349```ts 350import installer from '@ohos.bundle.installer'; 351import { BusinessError } from '@ohos.base'; 352 353let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; 354let installParam: installer.InstallParam = { 355 userId: 100, 356 isKeepData: false, 357 installFlag: 1, 358}; 359 360try { 361 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 362 data.install(hapFilePaths, installParam) 363 .then((data: void) => { 364 console.info('install successfully: ' + JSON.stringify(data)); 365 }).catch((error: BusinessError) => { 366 console.error('install failed:' + error.message); 367 }); 368 }).catch((error: BusinessError) => { 369 console.error('getBundleInstaller failed. Cause: ' + error.message); 370 }); 371} catch (error) { 372 let message = (error as BusinessError).message; 373 console.error('getBundleInstaller failed. Cause: ' + message); 374} 375``` 376 377## BundleInstaller.uninstall 378 379uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallback<void>): void 380 381以异步方法卸载应用,使用callback形式返回结果。 382 383**系统接口:** 此接口为系统接口。 384 385**需要权限:** ohos.permission.INSTALL_BUNDLE 或 ohos.permission.UNINSTALL_BUNDLE 386 387**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 388 389**参数:** 390 391| 参数名 | 类型 | 必填 | 说明 | 392| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | 393| bundleName | string | 是 | 待卸载应用的包名。 | 394| installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数。 | 395| callback | AsyncCallback<void> | 是 | 回调函数,卸载应用成功,err为null,否则为错误对象。 | 396 397**错误码:** 398 399以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 400 401| 错误码ID | 错误信息 | 402| -------- | ------------------------------------------------------------ | 403| 17700001 | The specified bundle name is not found. | 404| 17700004 | The specified user ID is not found. | 405| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | 406| 17700040 | The specified bundle is a shared bundle which cannot be uninstalled. | 407| 17700045 | Failed to uninstall because enterprise device management disallow uninstall. | 408 409**示例:** 410 411```ts 412import installer from '@ohos.bundle.installer'; 413import { BusinessError } from '@ohos.base'; 414 415let bundleName = 'com.ohos.demo'; 416let installParam: installer.InstallParam = { 417 userId: 100, 418 isKeepData: false, 419 installFlag: 1 420}; 421 422try { 423 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 424 data.uninstall(bundleName, installParam, (err: BusinessError) => { 425 if (err) { 426 console.error('uninstall failed:' + err.message); 427 } else { 428 console.info('uninstall successfully.'); 429 } 430 }); 431 }).catch((error: BusinessError) => { 432 console.error('getBundleInstaller failed. Cause: ' + error.message); 433 }); 434} catch (error) { 435 let message = (error as BusinessError).message; 436 console.error('getBundleInstaller failed. Cause: ' + message); 437} 438``` 439 440## BundleInstaller.uninstall 441 442uninstall(bundleName: string, callback: AsyncCallback<void>): void 443 444以异步方法卸载应用,使用callback形式返回结果。 445 446**系统接口:** 此接口为系统接口。 447 448**需要权限:** ohos.permission.INSTALL_BUNDLE 或 ohos.permission.UNINSTALL_BUNDLE 449 450**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 451 452**参数:** 453 454| 参数名 | 类型 | 必填 | 说明 | 455| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | 456| bundleName | string | 是 | 待卸载应用的包名。 | 457| callback | AsyncCallback<void> | 是 | 回调函数,卸载应用成功,err为null,否则为错误对象。 | 458 459**错误码:** 460 461以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 462 463| 错误码ID | 错误信息 | 464| -------- | ------------------------------------------------------------ | 465| 17700001 | The specified bundle name is not found. | 466| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | 467| 17700040 | The specified bundle is a shared bundle which cannot be uninstalled. | 468| 17700045 | Failed to uninstall because enterprise device management disallow uninstall. | 469 470**示例:** 471 472```ts 473import installer from '@ohos.bundle.installer'; 474import { BusinessError } from '@ohos.base'; 475 476let bundleName = 'com.ohos.demo'; 477 478try { 479 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 480 data.uninstall(bundleName, (err: BusinessError) => { 481 if (err) { 482 console.error('uninstall failed:' + err.message); 483 } else { 484 console.info('uninstall successfully.'); 485 } 486 }); 487 }).catch((error: BusinessError) => { 488 console.error('getBundleInstaller failed. Cause: ' + error.message); 489 }); 490} catch (error) { 491 let message = (error as BusinessError).message; 492 console.error('getBundleInstaller failed. Cause: ' + message); 493} 494``` 495## BundleInstaller.uninstall 496 497uninstall(bundleName: string, installParam?: InstallParam) : Promise\<void\> 498 499以异步方法卸载应用,使用Promise形式返回结果。 500 501**系统接口:** 此接口为系统接口。 502 503**需要权限:** ohos.permission.INSTALL_BUNDLE 或 ohos.permission.UNINSTALL_BUNDLE 504 505**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 506 507**参数:** 508 509| 参数名 | 类型 | 必填 | 说明 | 510| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | 511| bundleName | string | 是 | 待卸载应用的包名。 | 512| installParam | [InstallParam](#installparam) | 否 | 指定安装所需的其他参数,默认值:参照[InstallParam](#installparam)的默认值。 | 513 514**返回值:** 515 516| 类型 | 说明 | 517| --------------- | -------------------------------------- | 518| Promise\<void\> | Promise对象。无返回结果的Promise对象。 | 519 520**错误码:** 521 522以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 523 524| 错误码ID | 错误信息 | 525| -------- | ------------------------------------------------------------ | 526| 17700001 | The specified bundle name is not found. | 527| 17700004 | The specified user ID is not found. | 528| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | 529| 17700040 | The specified bundle is a shared bundle which cannot be uninstalled. | 530| 17700045 | Failed to uninstall because enterprise device management disallow uninstall. | 531 532**示例:** 533```ts 534import installer from '@ohos.bundle.installer'; 535import { BusinessError } from '@ohos.base'; 536 537let bundleName = 'com.ohos.demo'; 538let installParam: installer.InstallParam = { 539 userId: 100, 540 isKeepData: false, 541 installFlag: 1, 542}; 543 544try { 545 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 546 data.uninstall(bundleName, installParam) 547 .then((data: void) => { 548 console.info('uninstall successfully: ' + JSON.stringify(data)); 549 }).catch((error: BusinessError) => { 550 console.error('uninstall failed:' + error.message); 551 }); 552 }).catch((error: BusinessError) => { 553 console.error('getBundleInstaller failed. Cause: ' + error.message); 554 }); 555} catch (error) { 556 let message = (error as BusinessError).message; 557 console.error('getBundleInstaller failed. Cause: ' + message); 558} 559``` 560 561## BundleInstaller.recover 562 563recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback<void>): void 564 565以异步方法回滚应用到初次安装时的状态,使用callback形式返回结果。 566 567**系统接口:** 此接口为系统接口。 568 569**需要权限:** ohos.permission.INSTALL_BUNDLE 或 ohos.permission.RECOVER_BUNDLE 570 571**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 572 573**参数:** 574 575| 参数名 | 类型 | 必填 | 说明 | 576| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | 577| bundleName | string | 是 | 待恢复应用的包名。 | 578| installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数。 | 579| callback | AsyncCallback<void> | 是 | 回调函数,回滚应用成功,err为null,否则为错误对象。 | 580 581**错误码:** 582 583以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 584 585| 错误码ID | 错误信息 | 586| -------- | ----------------------------------- | 587| 17700001 | The specified bundle name is not found. | 588| 17700004 | The specified user ID is not found. | 589 590**示例:** 591 592```ts 593import installer from '@ohos.bundle.installer'; 594import { BusinessError } from '@ohos.base'; 595 596let bundleName = 'com.ohos.demo'; 597let installParam: installer.InstallParam = { 598 userId: 100, 599 isKeepData: false, 600 installFlag: 1 601}; 602 603try { 604 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 605 data.recover(bundleName, installParam, (err: BusinessError) => { 606 if (err) { 607 console.error('recover failed:' + err.message); 608 } else { 609 console.info('recover successfully.'); 610 } 611 }); 612 }).catch((error: BusinessError) => { 613 console.error('getBundleInstaller failed. Cause: ' + error.message); 614 }); 615} catch (error) { 616 let message = (error as BusinessError).message; 617 console.error('getBundleInstaller failed. Cause: ' + message); 618} 619``` 620 621 622## BundleInstaller.recover 623 624recover(bundleName: string, callback: AsyncCallback<void>): void 625 626以异步方法回滚应用到初次安装时的状态,使用callback形式返回结果。 627 628**系统接口:** 此接口为系统接口。 629 630**需要权限:** ohos.permission.INSTALL_BUNDLE 或 ohos.permission.RECOVER_BUNDLE 631 632**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 633 634**参数:** 635 636| 参数名 | 类型 | 必填 | 说明 | 637| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | 638| bundleName | string | 是 | 待恢复应用的包名。 | 639| callback | AsyncCallback<void> | 是 | 回调函数,回滚应用成功,err为null,否则为错误对象。 | 640 641**错误码:** 642 643以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 644 645| 错误码ID | 错误信息 | 646| -------- | ----------------------------------- | 647| 17700001 | The specified bundle name is not found. | 648 649**示例:** 650 651```ts 652import installer from '@ohos.bundle.installer'; 653import { BusinessError } from '@ohos.base'; 654 655let bundleName = 'com.ohos.demo'; 656 657try { 658 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 659 data.recover(bundleName, (err: BusinessError) => { 660 if (err) { 661 console.error('recover failed:' + err.message); 662 } else { 663 console.info('recover successfully.'); 664 } 665 }); 666 }).catch((error: BusinessError) => { 667 console.error('getBundleInstaller failed. Cause: ' + error.message); 668 }); 669} catch (error) { 670 let message = (error as BusinessError).message; 671 console.error('getBundleInstaller failed. Cause: ' + message); 672} 673``` 674 675## BundleInstaller.recover 676 677recover(bundleName: string, installParam?: InstallParam) : Promise\<void\> 678 679以异步方法回滚应用到初次安装时的状态,使用Promise形式返回结果。 680 681**系统接口:** 此接口为系统接口。 682 683**需要权限:** ohos.permission.INSTALL_BUNDLE 或 ohos.permission.RECOVER_BUNDLE 684 685**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 686 687**参数:** 688 689| 参数名 | 类型 | 必填 | 说明 | 690| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | 691| bundleName | string | 是 | 待卸载应用的包名。 | 692| installParam | [InstallParam](#installparam) | 否 | 指定安装所需的其他参数,默认值:参照[InstallParam](#installparam)的默认值。 | 693 694**返回值:** 695 696| 类型 | 说明 | 697| --------------- | -------------------------------------- | 698| Promise\<void\> | Promise对象。无返回结果的Promise对象。 | 699 700**错误码:** 701 702以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 703 704| 错误码ID | 错误信息 | 705| -------- | ----------------------------------- | 706| 17700001 | The specified bundle name is not found. | 707| 17700004 | The specified user ID is not found. | 708 709**示例:** 710```ts 711import installer from '@ohos.bundle.installer'; 712import { BusinessError } from '@ohos.base'; 713 714let bundleName = 'com.ohos.demo'; 715let installParam: installer.InstallParam = { 716 userId: 100, 717 isKeepData: false, 718 installFlag: 1, 719}; 720 721try { 722 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 723 data.recover(bundleName, installParam) 724 .then((data: void) => { 725 console.info('recover successfully: ' + JSON.stringify(data)); 726 }).catch((error: BusinessError) => { 727 console.error('recover failed:' + error.message); 728 }); 729 }).catch((error: BusinessError) => { 730 console.error('getBundleInstaller failed. Cause: ' + error.message); 731 }); 732} catch (error) { 733 let message = (error as BusinessError).message; 734 console.error('getBundleInstaller failed. Cause: ' + message); 735} 736``` 737 738## BundleInstaller.uninstall<sup>10+</sup> 739 740uninstall(uninstallParam: UninstallParam, callback : AsyncCallback\<void>) : void 741 742以异步方法卸载一个共享包,使用callback形式返回结果。 743 744**系统接口:** 此接口为系统接口。 745 746**需要权限:** ohos.permission.INSTALL_BUNDLE 或 ohos.permission.UNINSTALL_BUNDLE 747 748**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 749 750**参数:** 751 752| 参数名 | 类型 | 必填 | 说明 | 753| -------------- | ----------------------------------- | ---- | -------------------------------------------------------- | 754| uninstallParam | [UninstallParam](#uninstallparam10) | 是 | 共享包卸载需指定的参数信息。 | 755| callback | AsyncCallback<void> | 是 | 回调函数,卸载应用成功,err为null,否则为错误对象。 | 756 757**错误码:** 758 759以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 760 761| 错误码ID | 错误信息 | 762| -------- | ------------------------------------------------------------ | 763| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | 764| 17700037 | The version of shared bundle is dependent on other applications. | 765| 17700038 | The specified shared bundle does not exist. | 766 767**示例:** 768 769```ts 770import installer from '@ohos.bundle.installer'; 771import { BusinessError } from '@ohos.base'; 772 773let uninstallParam: installer.UninstallParam = { 774 bundleName: "com.ohos.demo", 775}; 776 777try { 778 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 779 data.uninstall(uninstallParam, (err: BusinessError) => { 780 if (err) { 781 console.error('uninstall failed:' + err.message); 782 } else { 783 console.info('uninstall successfully.'); 784 } 785 }); 786 }).catch((error: BusinessError) => { 787 console.error('getBundleInstaller failed. Cause: ' + error.message); 788 }); 789} catch (error) { 790 let message = (error as BusinessError).message; 791 console.error('getBundleInstaller failed. Cause: ' + message); 792} 793``` 794 795## BundleInstaller.uninstall<sup>10+</sup> 796 797uninstall(uninstallParam: UninstallParam) : Promise\<void> 798 799以异步方法卸载一个共享包,使用Promise形式返回结果。 800 801**系统接口:** 此接口为系统接口。 802 803**需要权限:** ohos.permission.INSTALL_BUNDLE 或 ohos.permission.UNINSTALL_BUNDLE 804 805**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 806 807**参数:** 808 809| 参数名 | 类型 | 必填 | 说明 | 810| -------------- | ----------------------------------- | ---- | ---------------------------- | 811| uninstallParam | [UninstallParam](#uninstallparam10) | 是 | 共享包卸载需指定的参数信息。 | 812 813**返回值:** 814 815| 类型 | 说明 | 816| ------------- | -------------------------------------- | 817| Promise\<void\> | Promise对象。无返回结果的Promise对象。 | 818 819**错误码:** 820 821以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 822 823| 错误码ID | 错误信息 | 824| -------- | ------------------------------------------------------------ | 825| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | 826| 17700037 | The version of shared bundle is dependent on other applications. | 827| 17700038 | The specified shared bundle does not exist. | 828 829**示例:** 830 831```ts 832import installer from '@ohos.bundle.installer'; 833import { BusinessError } from '@ohos.base'; 834 835let uninstallParam: installer.UninstallParam = { 836 bundleName: "com.ohos.demo", 837}; 838 839try { 840 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 841 data.uninstall(uninstallParam, (err: BusinessError) => { 842 if (err) { 843 console.error('uninstall failed:' + err.message); 844 } else { 845 console.info('uninstall successfully.'); 846 } 847 }); 848 }).catch((error: BusinessError) => { 849 console.error('getBundleInstaller failed. Cause: ' + error.message); 850 }); 851} catch (error) { 852 let message = (error as BusinessError).message; 853 console.error('getBundleInstaller failed. Cause: ' + message); 854} 855``` 856 857## BundleInstaller.updateBundleForSelf<sup>10+</sup> 858 859updateBundleForSelf(hapFilePaths: Array\<string\>, installParam: InstallParam, callback: AsyncCallback\<void\>): void 860 861以异步方法更新当前应用,仅限企业设备上的企业MDM应用调用,且传入的hapFilePaths中的hap必须都属于当前应用,使用callback形式返回结果。 862 863**系统接口:** 此接口为系统接口。 864 865**需要权限:** ohos.permission.INSTALL_SELF_BUNDLE 866 867**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 868 869**参数:** 870 871| 参数名 | 类型 | 必填 | 说明 | 872| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | 873| hapFilePaths | Array<string> | 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP,且这些HAP的签名需要保持一致。 | 874| installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数。 | 875| callback | AsyncCallback<void> | 是 | 回调函数,安装应用成功,err为null,否则为错误对象。 | 876 877**错误码:** 878 879以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 880 881| 错误码ID | 错误信息 | 882| -------- | ------------------------------------------------------------ | 883| 17700004 | The specified user ID is not found. | 884| 17700010 | Failed to install the HAP because the HAP fails to be parsed. | 885| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. | 886| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. | 887| 17700015 | Failed to install the HAPs because they have different configuration information. | 888| 17700016 | Failed to install the HAP because of insufficient system disk space. | 889| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | 890| 17700018 | Failed to install because the dependent module does not exist. | 891| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. | 892| 17700041 | Failed to install because enterprise device management disallow install. | 893| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. | 894| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). | 895| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. | 896| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. | 897| 17700048 | Failed to install the HAP because the code signature verification is failed. | 898| 17700049 | Failed to install the HAP because the bundleName is different from the bundleName of the caller application. | 899| 17700050 | Failed to install the HAP because enterprise normal/MDM bundle cannot be installed on non-enterprise device. | 900| 17700051 | Failed to install the HAP because the distribution type of caller application is not enterprise_mdm. | 901 902**示例:** 903 904```ts 905import installer from '@ohos.bundle.installer'; 906import { BusinessError } from '@ohos.base'; 907 908let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; 909let installParam: installer.InstallParam = { 910 userId: 100, 911 isKeepData: false, 912 installFlag: 1, 913}; 914 915try { 916 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 917 data.updateBundleForSelf(hapFilePaths, installParam, (err: BusinessError) => { 918 if (err) { 919 console.error('updateBundleForSelf failed:' + err.message); 920 } else { 921 console.info('updateBundleForSelf successfully.'); 922 } 923 }); 924 }).catch((error: BusinessError) => { 925 console.error('getBundleInstaller failed. Cause: ' + error.message); 926 }); 927} catch (error) { 928 let message = (error as BusinessError).message; 929 console.error('getBundleInstaller failed. Cause: ' + message); 930} 931``` 932 933## BundleInstaller.updateBundleForSelf<sup>10+</sup> 934 935updateBundleForSelf(hapFilePaths: Array\<string\>, callback: AsyncCallback\<void\>): void 936 937以异步方法更新当前应用,仅限企业设备上的企业MDM应用调用,且传入的hapFilePaths中的hap必须都属于当前应用,使用callback形式返回结果。 938 939**系统接口:** 此接口为系统接口。 940 941**需要权限:** ohos.permission.INSTALL_SELF_BUNDLE 942 943**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 944 945**参数:** 946 947| 参数名 | 类型 | 必填 | 说明 | 948| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | 949| hapFilePaths | Array<string> | 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP,且这些HAP的签名需要保持一致。 | 950| callback | AsyncCallback<void> | 是 | 回调函数,安装应用成功,err为null,否则为错误对象。 | 951 952**错误码:** 953 954以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 955 956| 错误码ID | 错误信息 | 957| -------- | ------------------------------------------------------------ | 958| 17700010 | Failed to install the HAP because the HAP fails to be parsed. | 959| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. | 960| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. | 961| 17700015 | Failed to install the HAPs because they have different configuration information. | 962| 17700016 | Failed to install the HAP because of insufficient system disk space. | 963| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | 964| 17700018 | Failed to install because the dependent module does not exist. | 965| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. | 966| 17700041 | Failed to install because enterprise device management disallow install. | 967| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. | 968| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). | 969| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. | 970| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. | 971| 17700048 | Failed to install the HAP because the code signature verification is failed. | 972| 17700049 | Failed to install the HAP because the bundleName is different from the bundleName of the caller application. | 973| 17700050 | Failed to install the HAP because enterprise normal/MDM bundle cannot be installed on non-enterprise device. | 974| 17700051 | Failed to install the HAP because the distribution type of caller application is not enterprise_mdm. | 975 976**示例:** 977 978```ts 979import installer from '@ohos.bundle.installer'; 980import { BusinessError } from '@ohos.base'; 981 982let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; 983 984try { 985 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 986 data.updateBundleForSelf(hapFilePaths, (err: BusinessError) => { 987 if (err) { 988 console.error('updateBundleForSelf failed:' + err.message); 989 } else { 990 console.info('updateBundleForSelf successfully.'); 991 } 992 }); 993 }).catch((error: BusinessError) => { 994 console.error('getBundleInstaller failed. Cause: ' + error.message); 995 }); 996} catch (error) { 997 let message = (error as BusinessError).message; 998 console.error('getBundleInstaller failed. Cause: ' + message); 999} 1000``` 1001 1002## BundleInstaller.updateBundleForSelf<sup>10+</sup> 1003 1004updateBundleForSelf(hapFilePaths: Array\<string\>, installParam?: InstallParam): Promise\<void\> 1005 1006以异步方法更新当前应用,仅限企业设备上的企业MDM应用调用,且传入的hapFilePaths中的hap必须都属于当前应用,使用promise形式返回结果。 1007 1008**系统接口:** 此接口为系统接口。 1009 1010**需要权限:** ohos.permission.INSTALL_SELF_BUNDLE 1011 1012**系统能力:** SystemCapability.BundleManager.BundleFramework.Core 1013 1014**参数:** 1015 1016| 参数名 | 类型 | 必填 | 说明 | 1017| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | 1018| hapFilePaths | Array<string> | 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP,且这些HAP的签名需要保持一致。 | 1019| installParam | [InstallParam](#installparam) | 否 | 指定安装所需的其他参数,默认值:参照[InstallParam](#installparam)的默认值。 | 1020 1021**返回值:** 1022 1023| 类型 | 说明 | 1024| ------------- | -------------------------------------- | 1025| Promise\<void\> | Promise对象。无返回结果的Promise对象。 | 1026 1027**错误码:** 1028 1029以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 1030 1031| 错误码ID | 错误信息 | 1032| -------- | ------------------------------------------------------------ | 1033| 17700004 | The specified user ID is not found. | 1034| 17700010 | Failed to install the HAP because the HAP fails to be parsed. | 1035| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. | 1036| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. | 1037| 17700015 | Failed to install the HAPs because they have different configuration information. | 1038| 17700016 | Failed to install the HAP because of insufficient system disk space. | 1039| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | 1040| 17700018 | Failed to install because the dependent module does not exist. | 1041| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. | 1042| 17700041 | Failed to install because enterprise device management disallow install. | 1043| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. | 1044| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). | 1045| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. | 1046| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. | 1047| 17700048 | Failed to install the HAP because the code signature verification is failed. | 1048| 17700049 | Failed to install the HAP because the bundleName is different from the bundleName of the caller application. | 1049| 17700050 | Failed to install the HAP because enterprise normal/MDM bundle cannot be installed on non-enterprise device. | 1050| 17700051 | Failed to install the HAP because the distribution type of caller application is not enterprise_mdm. | 1051 1052**示例:** 1053 1054```ts 1055import installer from '@ohos.bundle.installer'; 1056import { BusinessError } from '@ohos.base'; 1057 1058let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; 1059let installParam: installer.InstallParam = { 1060 userId: 100, 1061 isKeepData: false, 1062 installFlag: 1, 1063}; 1064 1065try { 1066 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 1067 data.updateBundleForSelf(hapFilePaths, installParam) 1068 .then((data: void) => { 1069 console.info('updateBundleForSelf successfully: ' + JSON.stringify(data)); 1070 }).catch((error: BusinessError) => { 1071 console.error('updateBundleForSelf failed:' + error.message); 1072 }); 1073 }).catch((error: BusinessError) => { 1074 console.error('getBundleInstaller failed. Cause: ' + error.message); 1075 }); 1076} catch (error) { 1077 let message = (error as BusinessError).message; 1078 console.error('getBundleInstaller failed. Cause: ' + message); 1079} 1080``` 1081 1082## HashParam 1083 1084应用程序安装卸载哈希参数信息。 1085 1086 **系统能力:** SystemCapability.BundleManager.BundleFramework.Core 1087 1088 **系统接口:** 此接口为系统接口。 1089 1090| 名称 | 类型 | 必填 | 说明 | 1091| ---------- | ------ | ---------------- | ---------------- | 1092| moduleName | string | 是 | 应用程序模块名称。 | 1093| hashValue | string | 是 | 哈希值。 | 1094 1095## InstallParam 1096 1097应用程序安装、卸载或恢复需指定的参数信息。 1098 1099 **系统能力:** SystemCapability.BundleManager.BundleFramework.Core 1100 1101 **系统接口:** 此接口为系统接口。 1102 1103| 名称 | 类型 | 必填 | 说明 | 1104| ------------------------------ | ------------------------------ | ------------------ | ------------------ | 1105| userId | number | 否 | 指示用户id,默认值:调用方所在用户,取值范围:大于等于0,可使用[queryOsAccountLocalIdFromProcess](js-apis-osAccount.md#getOsAccountLocalId)获取当前进程所在用户。 | 1106| installFlag | number | 否 | 指示安装标志,枚举值:0x00:应用初次安装,0x01:应用覆盖安装,0x10:应用免安装,默认值为应用初次安装。 | 1107| isKeepData | boolean | 否 | 卸载时是否保留数据目录,默认值为false。 | 1108| hashParams | Array<[HashParam](#hashparam)> | 否 | 哈希值参数,默认值为空。 | 1109| crowdtestDeadline| number | 否 | 众测活动的截止日期,默认值为-1,表示无截止日期约束。 | 1110| sharedBundleDirPaths<sup>10+</sup> | Array\<String> | 否 |共享包文件所在路径,默认值为空。 | 1111| specifiedDistributionType<sup>10+</sup> | string | 否 |应用安装时指定的分发类型,默认值为空,最大长度为128字节。该字段通常由操作系统运营方的应用市场指定。 | 1112| additionalInfo<sup>10+</sup> | string | 否 |应用安装时的额外信息,默认值为空,最大长度为3000字节。该字段通常由操作系统运营方的应用市场在安装企业应用时指定,用于保存应用的额外信息。 | 1113| verifyCodeParams<sup>10+</sup> | Array<[VerifyCodeParam](#verifycodeparam10)> | 否 | 代码签名文件参数,默认值为空。 | 1114 1115## UninstallParam<sup>10+</sup> 1116 1117共享包卸载需指定的参数信息。 1118 1119 **系统能力:** SystemCapability.BundleManager.BundleFramework.Core 1120 1121 **系统接口:** 此接口为系统接口。 1122 1123| 名称 | 类型 | 必填 | 说明 | 1124| ----------- | ------ | ---- | ------------------------------------------------------------ | 1125| bundleName | string | 是 | 共享包包名。 | 1126| versionCode | number | 否 | 指示共享包的版本号。默认值:如果不填写versionCode,则卸载该包名的所有共享包。 | 1127 1128## VerifyCodeParam<sup>10+</sup> 1129 1130应用程序代码签名文件信息。 1131 1132 **系统能力:** SystemCapability.BundleManager.BundleFramework.Core 1133 1134 **系统接口:** 此接口为系统接口。 1135 1136| 名称 | 类型 | 必填 | 说明 | 1137| ---------- | ------ | ---------------- | ---------------- | 1138| moduleName | string | 是 | 应用程序模块名称。 | 1139| signatureFilePath | string | 是 | 代码签名文件路径。 |