1# @ohos.enterprise.bundleManager(包管理) 2 3本模块提供包管理能力,包括添加包安装白名单、获取包安装白名单、移除包安装白名单等。 4 5> **说明:** 6> 7> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8> 9> 本模块接口仅可在Stage模型下使用。 10> 11> 本模块接口仅对[设备管理应用](enterpriseDeviceManagement-overview.md#基本概念)开放,需将[设备管理应用激活](js-apis-enterprise-adminManager.md#adminmanagerenableadmin)后调用,实现相应功能。 12 13## 导入模块 14 15```ts 16import bundleManager from '@ohos.enterprise.bundleManager'; 17``` 18 19## bundleManager.addAllowedInstallBundles 20 21addAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback<void>): void; 22 23指定设备管理应用添加应用至包安装白名单,添加至白名单的应用允许在当前用户下安装,否则不允许安装,使用callback异步回调。 24 25**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 26 27**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 28 29**系统API**: 此接口为系统接口。 30 31**参数:** 32 33| 参数名 | 类型 | 必填 | 说明 | 34| -------- | ---------------------------------------- | ---- | ------------------------------- | 35| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 36| appIds | Array<string> | 是 | 应用ID数组。 | 37| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | 38 39**错误码**: 40 41以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 42 43| 错误码ID | 错误信息 | 44| ------- | ---------------------------------------------------------------------------- | 45| 9200001 | the application is not an administrator of the device. | 46| 9200002 | the administrator application does not have permission to manage the device. | 47 48**示例:** 49 50```ts 51import Want from '@ohos.app.ability.Want'; 52let wantTemp: Want = { 53 bundleName: 'com.example.myapplication', 54 abilityName: 'EntryAbility', 55}; 56let appIds: Array<string> = ['com.example.myapplication']; 57 58bundleManager.addAllowedInstallBundles(wantTemp, appIds, (err) => { 59 if (err) { 60 console.error(`Failed to add allowed install bundles. Code is ${err.code}, message is ${err.message}`); 61 return; 62 } 63 console.info('Succeeded in adding allowed install bundles'); 64}); 65``` 66 67## bundleManager.addAllowedInstallBundles 68 69addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback<void>): void; 70 71指定设备管理应用添加应用至包安装白名单,添加至白名单的应用允许在指定用户(通过userId指定)下安装,否则不允许安装,使用callback异步回调。 72 73**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 74 75**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 76 77**系统API**: 此接口为系统接口。 78 79**参数:** 80 81| 参数名 | 类型 | 必填 | 说明 | 82| ----- | ----------------------------------- | ---- | ------- | 83| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 84| appIds | Array<string> | 是 | 应用ID数组。 | 85| userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 | 86| callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 87 88**错误码**: 89 90以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 91 92| 错误码ID | 错误信息 | 93| ------- | ---------------------------------------------------------------------------- | 94| 9200001 | the application is not an administrator of the device. | 95| 9200002 | the administrator application does not have permission to manage the device. | 96 97**示例:** 98 99```ts 100import Want from '@ohos.app.ability.Want'; 101let wantTemp: Want = { 102 bundleName: 'com.example.myapplication', 103 abilityName: 'EntryAbility', 104}; 105let appIds: Array<string> = ['com.example.myapplication']; 106 107bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100, (err) => { 108 if (err) { 109 console.error(`Failed to add allowed install bundles. Code is ${err.code}, message is ${err.message}`); 110 return; 111 } 112 console.info('Succeeded in adding allowed install bundles'); 113}); 114``` 115 116## bundleManager.addAllowedInstallBundles 117 118addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise<void>; 119 120指定设备管理应用添加应用至包安装白名单,添加至白名单的应用允许在当前/指定用户下安装,否则不允许安装。使用promise异步回调。 121 122**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 123 124**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 125 126**系统API**: 此接口为系统接口。 127 128**参数:** 129 130| 参数名 | 类型 | 必填 | 说明 | 131| ----- | ----------------------------------- | ---- | ------- | 132| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 133| appIds | Array<string> | 是 | 应用ID数组。 | 134| userId | number | 否 |用户ID,取值范围:大于等于0。<br> - 调用接口时,若传入userId,表示指定用户。<br> - 调用接口时,若未传入userId,表示当前用户。 | 135 136**返回值:** 137 138| 类型 | 说明 | 139| --------------------- | ------------------------- | 140| Promise<void> | 无返回结果的Promise对象。当指定设备管理应用添加包安装白名单失败时,会抛出错误对象。 | 141 142**错误码**: 143 144以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 145 146| 错误码ID | 错误信息 | 147| ------- | ---------------------------------------------------------------------------- | 148| 9200001 | the application is not an administrator of the device. | 149| 9200002 | the administrator application does not have permission to manage the device. | 150 151**示例:** 152 153```ts 154import Want from '@ohos.app.ability.Want'; 155import { BusinessError } from '@ohos.base'; 156let wantTemp: Want = { 157 bundleName: 'com.example.myapplication', 158 abilityName: 'EntryAbility', 159}; 160let appIds: Array<string> = ['com.example.myapplication']; 161 162bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100).then(() => { 163 console.info('Succeeded in adding allowed install bundles'); 164}).catch((err: BusinessError) => { 165 console.error(`Failed to add allowed install bundles. Code is ${err.code}, message is ${err.message}`); 166}); 167``` 168 169## bundleManager.removeAllowedInstallBundles 170 171removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback<void>): void; 172 173指定设备管理应用在包安装白名单中移除应用,在白名单存在的情况下,不在包安装白名单中的应用不允许在当前用户下安装,使用callback异步回调。 174 175**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 176 177**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 178 179**系统API**: 此接口为系统接口。 180 181**参数:** 182 183| 参数名 | 类型 | 必填 | 说明 | 184| -------- | ---------------------------------------- | ---- | ------------------------------- | 185| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 186| appIds | Array<string> | 是 | 应用ID数组。 | 187| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | 188 189**错误码**: 190 191以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 192 193| 错误码ID | 错误信息 | 194| ------- | ---------------------------------------------------------------------------- | 195| 9200001 | the application is not an administrator of the device. | 196| 9200002 | the administrator application does not have permission to manage the device. | 197 198**示例:** 199 200```ts 201import Want from '@ohos.app.ability.Want'; 202let wantTemp: Want = { 203 bundleName: 'com.example.myapplication', 204 abilityName: 'EntryAbility', 205}; 206let appIds: Array<string> = ['com.example.myapplication']; 207 208bundleManager.removeAllowedInstallBundles(wantTemp, appIds, (err) => { 209 if (err) { 210 console.error(`Failed to remove allowed install bundles. Code is ${err.code}, message is ${err.message}`); 211 return; 212 } 213 console.info('Succeeded in removing allowed install bundles'); 214}); 215``` 216 217## bundleManager.removeAllowedInstallBundles 218 219removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback<void>): void; 220 221指定设备管理应用在包安装白名单中移除应用,在白名单存在的情况下,不在包安装白名单中的应用不允许在指定用户(通过userId指定)下安装,使用callback异步回调。 222 223**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 224 225**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 226 227**系统API**: 此接口为系统接口。 228 229**参数:** 230 231| 参数名 | 类型 | 必填 | 说明 | 232| ----- | ----------------------------------- | ---- | ------- | 233| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 234| appIds | Array<string> | 是 | 应用ID数组。 | 235| userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 | 236| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | 237 238**错误码**: 239 240以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 241 242| 错误码ID | 错误信息 | 243| ------- | ---------------------------------------------------------------------------- | 244| 9200001 | the application is not an administrator of the device. | 245| 9200002 | the administrator application does not have permission to manage the device. | 246 247**示例:** 248 249```ts 250import Want from '@ohos.app.ability.Want'; 251let wantTemp: Want = { 252 bundleName: 'com.example.myapplication', 253 abilityName: 'EntryAbility', 254}; 255let appIds: Array<string> = ['com.example.myapplication']; 256 257bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100, (err) => { 258 if (err) { 259 console.error(`Failed to remove allowed install bundles. Code is ${err.code}, message is ${err.message}`); 260 return; 261 } 262 console.info('Succeeded in removing allowed install bundles'); 263}); 264``` 265 266## bundleManager.removeAllowedInstallBundles 267 268removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise<void>; 269 270指定设备管理应用在包安装白名单中移除应用,在白名单存在的情况下,不在包安装白名单中的应用不允许在当前/指定用户下安装。使用promise异步回调。 271 272**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 273 274**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 275 276**系统API**: 此接口为系统接口。 277 278**参数:** 279 280| 参数名 | 类型 | 必填 | 说明 | 281| ----- | ----------------------------------- | ---- | ------- | 282| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 283| appIds | Array\<string> | 是 | 应用ID数组。 | 284| userId | number | 否 | 用户ID,取值范围:大于等于0。<br> - 调用接口时,若传入userId,表示指定用户。<br> - 调用接口时,若未传入userId,表示当前用户。 | 285 286**返回值:** 287 288| 类型 | 说明 | 289| --------------------- | ------------------------- | 290| Promise<void> | 无返回结果的Promise对象。当指定设备管理应用移除包安装白名单失败时,会抛出错误对象。 | 291 292**错误码**: 293 294以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 295 296| 错误码ID | 错误信息 | 297| ------- | ---------------------------------------------------------------------------- | 298| 9200001 | the application is not an administrator of the device. | 299| 9200002 | the administrator application does not have permission to manage the device. | 300 301**示例:** 302 303```ts 304import Want from '@ohos.app.ability.Want'; 305import { BusinessError } from '@ohos.base'; 306let wantTemp: Want = { 307 bundleName: 'com.example.myapplication', 308 abilityName: 'EntryAbility', 309}; 310let appIds: Array<string> = ['com.example.myapplication']; 311 312bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100).then(() => { 313 console.info('Succeeded in removing allowed install bundles'); 314}).catch((err: BusinessError) => { 315 console.error(`Failed to remove allowed install bundles. Code is ${err.code}, message is ${err.message}`); 316}); 317``` 318 319## bundleManager.getAllowedInstallBundles 320 321getAllowedInstallBundles(admin: Want, callback: AsyncCallback<Array<string>>): void; 322 323指定设备管理应用获取当前用户下的包安装白名单,使用callback异步回调。 324 325**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 326 327**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 328 329**系统API**: 此接口为系统接口。 330 331**参数:** 332 333| 参数名 | 类型 | 必填 | 说明 | 334| -------- | ---------------------------------------- | ---- | ------------------------------- | 335| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 336| callback | AsyncCallback<Array<string>> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 337 338**错误码**: 339 340以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 341 342| 错误码ID | 错误信息 | 343| ------- | ---------------------------------------------------------------------------- | 344| 9200001 | the application is not an administrator of the device. | 345| 9200002 | the administrator application does not have permission to manage the device. | 346 347**示例:** 348 349```ts 350import Want from '@ohos.app.ability.Want'; 351let wantTemp: Want = { 352 bundleName: 'com.example.myapplication', 353 abilityName: 'EntryAbility', 354}; 355 356bundleManager.getAllowedInstallBundles(wantTemp, (err, result) => { 357 if (err) { 358 console.error(`Failed to get allowed install bundles. Code is ${err.code}, message is ${err.message}`); 359 return; 360 } 361 console.info(`Succeeded in getting allowed install bundles, result : ${JSON.stringify(result)}`); 362}); 363``` 364 365## bundleManager.getAllowedInstallBundles 366 367getAllowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void; 368 369指定设备管理应用获取指定用户(通过userId指定)下的包安装白名单,使用callback异步回调。 370 371**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 372 373**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 374 375**系统API**: 此接口为系统接口。 376 377**参数:** 378 379| 参数名 | 类型 | 必填 | 说明 | 380| -------- | ---------------------------------------- | ---- | ------------------------------- | 381| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 382| userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 | 383| callback | AsyncCallback<Array<string>> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 384 385**错误码**: 386 387以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 388 389| 错误码ID | 错误信息 | 390| ------- | ---------------------------------------------------------------------------- | 391| 9200001 | the application is not an administrator of the device. | 392| 9200002 | the administrator application does not have permission to manage the device. | 393 394**示例:** 395 396```ts 397import Want from '@ohos.app.ability.Want'; 398let wantTemp: Want = { 399 bundleName: 'com.example.myapplication', 400 abilityName: 'EntryAbility', 401}; 402 403bundleManager.getAllowedInstallBundles(wantTemp, 100, (err, result) => { 404 if (err) { 405 console.error(`Failed to get allowed install bundles. Code is ${err.code}, message is ${err.message}`); 406 return; 407 } 408 console.info(`Succeeded in getting allowed install bundles, result : ${JSON.stringify(result)}`); 409}); 410``` 411 412## bundleManager.getAllowedInstallBundles 413 414getAllowedInstallBundles(admin: Want, userId?: number): Promise<Array<string>>; 415 416指定设备管理应用获取当前/指定用户下的包安装白名单,使用promise异步回调。 417 418**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 419 420**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 421 422**系统API**: 此接口为系统接口。 423 424**参数:** 425 426| 参数名 | 类型 | 必填 | 说明 | 427| ----- | ----------------------------------- | ---- | ------- | 428| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 429| userId | number | 否 | 用户ID,取值范围:大于等于0。<br> - 调用接口时,若传入userId,表示指定用户。<br> - 调用接口时,若未传入userId,表示当前用户。 | 430 431**返回值:** 432 433| 类型 | 说明 | 434| --------------------- | ------------------------- | 435| Promise<Array<string>> | Promise对象,返回当前用户下的包安装白名单。 | 436 437**错误码**: 438 439以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 440 441| 错误码ID | 错误信息 | 442| ------- | ---------------------------------------------------------------------------- | 443| 9200001 | the application is not an administrator of the device. | 444| 9200002 | the administrator application does not have permission to manage the device. | 445 446**示例:** 447 448```ts 449import Want from '@ohos.app.ability.Want'; 450import { BusinessError } from '@ohos.base'; 451let wantTemp: Want = { 452 bundleName: 'com.example.myapplication', 453 abilityName: 'EntryAbility', 454}; 455 456bundleManager.getAllowedInstallBundles(wantTemp, 100).then((result) => { 457 console.info(`Succeeded in getting allowed install bundles, result : ${JSON.stringify(result)}`); 458}).catch((err: BusinessError) => { 459 console.error(`Failed to get allowed install bundles. Code is ${err.code}, message is ${err.message}`); 460}); 461``` 462 463## bundleManager.addDisallowedInstallBundles 464 465addDisallowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback<void>): void; 466 467指定设备管理应用添加应用至包安装黑名单,添加至黑名单的应用不允许在当前用户下安装,使用callback异步回调。 468 469**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 470 471**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 472 473**系统API**: 此接口为系统接口。 474 475**参数:** 476 477| 参数名 | 类型 | 必填 | 说明 | 478| -------- | ---------------------------------------- | ---- | ------------------------------- | 479| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 480| appIds | Array<string> | 是 | 应用ID数组。 | 481| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | 482 483**错误码**: 484 485以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 486 487| 错误码ID | 错误信息 | 488| ------- | ---------------------------------------------------------------------------- | 489| 9200001 | the application is not an administrator of the device. | 490| 9200002 | the administrator application does not have permission to manage the device. | 491 492**示例:** 493 494```ts 495import Want from '@ohos.app.ability.Want'; 496let wantTemp: Want = { 497 bundleName: 'com.example.myapplication', 498 abilityName: 'EntryAbility', 499}; 500let appIds: Array<string> = ['com.example.myapplication']; 501 502bundleManager.addDisallowedInstallBundles(wantTemp, appIds, (err) => { 503 if (err) { 504 console.error(`Failed to add disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 505 return; 506 } 507 console.info('Succeeded in adding disallowed install bundles'); 508}); 509``` 510 511## bundleManager.addDisallowedInstallBundles 512 513addDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback<void>): void; 514 515指定设备管理应用添加应用至包安装黑名单,添加至黑名单的应用不允许在指定用户(通过userId指定)下安装。使用callback异步回调。 516 517**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 518 519**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 520 521**系统API**: 此接口为系统接口。 522 523**参数:** 524 525| 参数名 | 类型 | 必填 | 说明 | 526| ----- | ----------------------------------- | ---- | ------- | 527| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 528| appIds | Array<string> | 是 | 应用ID数组。 | 529| userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 | 530| callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 531 532**错误码**: 533 534以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 535 536| 错误码ID | 错误信息 | 537| ------- | ---------------------------------------------------------------------------- | 538| 9200001 | the application is not an administrator of the device. | 539| 9200002 | the administrator application does not have permission to manage the device. | 540 541**示例:** 542 543```ts 544import Want from '@ohos.app.ability.Want'; 545let wantTemp: Want = { 546 bundleName: 'com.example.myapplication', 547 abilityName: 'EntryAbility', 548}; 549let appIds: Array<string> = ['com.example.myapplication']; 550 551bundleManager.addDisallowedInstallBundles(wantTemp, appIds, 100, (err) => { 552 if (err) { 553 console.error(`Failed to add disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 554 return; 555 } 556 console.info('Succeeded in adding disallowed install bundles'); 557}); 558``` 559 560## bundleManager.addDisallowedInstallBundles 561 562addDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise<void>; 563 564指定设备管理应用添加应用至包安装黑名单,添加至黑名单的应用不允许在当前/指定用户下安装。使用promise异步回调。 565 566**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 567 568**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 569 570**系统API**: 此接口为系统接口。 571 572**参数:** 573 574| 参数名 | 类型 | 必填 | 说明 | 575| ----- | ----------------------------------- | ---- | ------- | 576| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 577| appIds | Array<string> | 是 | 应用ID数组。 | 578| userId | number | 否 | 用户ID,取值范围:大于等于0。<br> - 调用接口时,若传入userId,表示指定用户。<br> - 调用接口时,若未传入userId,表示当前用户。 | 579 580**返回值:** 581 582| 类型 | 说明 | 583| --------------------- | ------------------------- | 584| Promise<void> | 无返回结果的Promise对象。当指定设备管理应用添加包安装黑名单失败时,会抛出错误对象。 | 585 586**错误码**: 587 588以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 589 590| 错误码ID | 错误信息 | 591| ------- | ---------------------------------------------------------------------------- | 592| 9200001 | the application is not an administrator of the device. | 593| 9200002 | the administrator application does not have permission to manage the device. | 594 595**示例:** 596 597```ts 598import Want from '@ohos.app.ability.Want'; 599import { BusinessError } from '@ohos.base'; 600let wantTemp: Want = { 601 bundleName: 'com.example.myapplication', 602 abilityName: 'EntryAbility', 603}; 604let appIds: Array<string> = ['com.example.myapplication']; 605 606bundleManager.addDisallowedInstallBundles(wantTemp, appIds, 100).then(() => { 607 console.info('Succeeded in adding disallowed install bundles'); 608}).catch((err: BusinessError) => { 609 console.error(`Failed to add disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 610}); 611``` 612 613## bundleManager.removeDisallowedInstallBundles 614 615removeDisallowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback<void>): void; 616 617指定设备管理应用在包安装黑名单中移除应用,在黑名单存在的情况下,在包安装黑名单中的应用不允许在当前用户下安装。使用callback异步回调。 618 619**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 620 621**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 622 623**系统API**: 此接口为系统接口。 624 625**参数:** 626 627| 参数名 | 类型 | 必填 | 说明 | 628| -------- | ---------------------------------------- | ---- | ------------------------------- | 629| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 630| appIds | Array<string> | 是 | 应用ID数组。 | 631| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | 632 633**错误码**: 634 635以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 636 637| 错误码ID | 错误信息 | 638| ------- | ---------------------------------------------------------------------------- | 639| 9200001 | the application is not an administrator of the device. | 640| 9200002 | the administrator application does not have permission to manage the device. | 641 642**示例:** 643 644```ts 645import Want from '@ohos.app.ability.Want'; 646let wantTemp: Want = { 647 bundleName: 'com.example.myapplication', 648 abilityName: 'EntryAbility', 649}; 650let appIds: Array<string> = ['com.example.myapplication']; 651 652bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, (err) => { 653 if (err) { 654 console.error(`Failed to remove disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 655 return; 656 } 657 console.info('Succeeded in removing disallowed install bundles'); 658}); 659``` 660 661## bundleManager.removeDisallowedInstallBundles 662 663removeDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback<void>): void; 664 665指定设备管理应用在包安装黑名单中移除应用,在黑名单存在的情况下,在包安装黑名单中的应用不允许在指定用户(通过userId指定)下安装,使用callback异步回调。 666 667**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 668 669**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 670 671**系统API**: 此接口为系统接口。 672 673**参数:** 674 675| 参数名 | 类型 | 必填 | 说明 | 676| ----- | ----------------------------------- | ---- | ------- | 677| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 678| appIds | Array<string> | 是 | 应用ID数组。 | 679| userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 | 680| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | 681 682**错误码**: 683 684以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 685 686| 错误码ID | 错误信息 | 687| ------- | ---------------------------------------------------------------------------- | 688| 9200001 | the application is not an administrator of the device. | 689| 9200002 | the administrator application does not have permission to manage the device. | 690 691**示例:** 692 693```ts 694import Want from '@ohos.app.ability.Want'; 695let wantTemp: Want = { 696 bundleName: 'com.example.myapplication', 697 abilityName: 'EntryAbility', 698}; 699let appIds: Array<string> = ['com.example.myapplication']; 700 701bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100, (err) => { 702 if (err) { 703 console.error(`Failed to remove disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 704 return; 705 } 706 console.info('Succeeded in removing disallowed install bundles'); 707}); 708``` 709 710## bundleManager.removeDisallowedInstallBundles 711 712removeDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise<void>; 713 714指定设备管理应用在包安装黑名单中移除应用,在黑名单存在的情况下,在包安装黑名单中的应用不允许在当前/指定用户下安装。使用promise异步回调。 715 716**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 717 718**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 719 720**系统API**: 此接口为系统接口。 721 722**参数:** 723 724| 参数名 | 类型 | 必填 | 说明 | 725| ----- | ----------------------------------- | ---- | ------- | 726| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 727| appIds | Array\<string> | 是 | 应用ID数组。 | 728| userId | number | 否 | 用户ID,取值范围:大于等于0。<br> - 调用接口时,若传入userId,表示指定用户。<br> - 调用接口时,若未传入userId,表示当前用户。 | 729 730**返回值:** 731 732| 类型 | 说明 | 733| --------------------- | ------------------------- | 734| Promise<void> | 无返回结果的Promise对象。当指定设备管理应用移除包安装黑名单失败时,会抛出错误对象。 | 735 736**错误码**: 737 738以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 739 740| 错误码ID | 错误信息 | 741| ------- | ---------------------------------------------------------------------------- | 742| 9200001 | the application is not an administrator of the device. | 743| 9200002 | the administrator application does not have permission to manage the device. | 744 745**示例:** 746 747```ts 748import Want from '@ohos.app.ability.Want'; 749import { BusinessError } from '@ohos.base'; 750let wantTemp: Want = { 751 bundleName: 'com.example.myapplication', 752 abilityName: 'EntryAbility', 753}; 754let appIds: Array<string> = ['com.example.myapplication']; 755 756bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100).then(() => { 757 console.info('Succeeded in removing disallowed install bundles'); 758}).catch((err: BusinessError) => { 759 console.error(`Failed to remove disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 760}); 761``` 762 763## bundleManager.getDisallowedInstallBundles 764 765getDisallowedInstallBundles(admin: Want, callback: AsyncCallback<Array<string>>): void; 766 767指定设备管理应用获取当前用户下的包安装黑名单,使用callback异步回调。 768 769**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 770 771**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 772 773**系统API**: 此接口为系统接口。 774 775**参数:** 776 777| 参数名 | 类型 | 必填 | 说明 | 778| -------- | ---------------------------------------- | ---- | ------------------------------- | 779| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 780| callback | AsyncCallback<Array<string>> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 781 782**错误码**: 783 784以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 785 786| 错误码ID | 错误信息 | 787| ------- | ---------------------------------------------------------------------------- | 788| 9200001 | the application is not an administrator of the device. | 789| 9200002 | the administrator application does not have permission to manage the device. | 790 791**示例:** 792 793```ts 794import Want from '@ohos.app.ability.Want'; 795let wantTemp: Want = { 796 bundleName: 'com.example.myapplication', 797 abilityName: 'EntryAbility', 798}; 799 800bundleManager.getDisallowedInstallBundles(wantTemp, (err, result) => { 801 if (err) { 802 console.error(`Failed to get disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 803 return; 804 } 805 console.info(`Succeeded in getting disallowed install bundles, result : ${JSON.stringify(result)}`); 806}); 807``` 808 809## bundleManager.getDisallowedInstallBundles 810 811getDisallowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void; 812 813指定设备管理应用获取指定用户(通过userId指定)下的包安装黑名单,使用callback异步回调。 814 815**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 816 817**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 818 819**系统API**: 此接口为系统接口。 820 821**参数:** 822 823| 参数名 | 类型 | 必填 | 说明 | 824| -------- | ---------------------------------------- | ---- | ------------------------------- | 825| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 826| userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 | 827| callback | AsyncCallback<Array<string>> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 828 829**错误码**: 830 831以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 832 833| 错误码ID | 错误信息 | 834| ------- | ---------------------------------------------------------------------------- | 835| 9200001 | the application is not an administrator of the device. | 836| 9200002 | the administrator application does not have permission to manage the device. | 837 838**示例:** 839 840```ts 841import Want from '@ohos.app.ability.Want'; 842let wantTemp: Want = { 843 bundleName: 'com.example.myapplication', 844 abilityName: 'EntryAbility', 845}; 846 847bundleManager.getDisallowedInstallBundles(wantTemp, 100, (err, result) => { 848 if (err) { 849 console.error(`Failed to get disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 850 return; 851 } 852 console.info(`Succeeded in getting disallowed install bundles, result : ${JSON.stringify(result)}`); 853}); 854``` 855 856## bundleManager.getDisallowedInstallBundles 857 858getDisallowedInstallBundles(admin: Want, userId?: number): Promise<Array<string>>; 859 860指定设备管理应用获取当前/指定用户下的包安装黑名单,使用promise异步回调。 861 862**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 863 864**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 865 866**系统API**: 此接口为系统接口。 867 868**参数:** 869 870| 参数名 | 类型 | 必填 | 说明 | 871| ----- | ----------------------------------- | ---- | ------- | 872| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 873| userId | number | 否 | 用户ID,取值范围:大于等于0。<br> - 调用接口时,若传入userId,表示指定用户。<br> - 调用接口时,若未传入userId,表示当前用户。 | 874 875**返回值:** 876 877| 类型 | 说明 | 878| --------------------- | ------------------------- | 879| Promise<Array<string>> | Promise对象,返回当前用户下的包安装白名单。 | 880 881**错误码**: 882 883以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 884 885| 错误码ID | 错误信息 | 886| ------- | ---------------------------------------------------------------------------- | 887| 9200001 | the application is not an administrator of the device. | 888| 9200002 | the administrator application does not have permission to manage the device. | 889 890**示例:** 891 892```ts 893import Want from '@ohos.app.ability.Want'; 894import { BusinessError } from '@ohos.base'; 895let wantTemp: Want = { 896 bundleName: 'com.example.myapplication', 897 abilityName: 'EntryAbility', 898}; 899 900bundleManager.getDisallowedInstallBundles(wantTemp, 100).then((result) => { 901 console.info(`Succeeded in getting disallowed install bundles, result : ${JSON.stringify(result)}`); 902}).catch((err: BusinessError) => { 903 console.error(`Failed to get disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 904}); 905``` 906 907## bundleManager.addDisallowedUninstallBundles 908 909addDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback<void>): void 910 911指定设备管理应用添加应用至包卸载黑名单,添加至黑名单的应用不允许在当前用户下卸载,使用callback异步回调。 912 913**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 914 915**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 916 917**系统API**: 此接口为系统接口。 918 919**参数:** 920 921| 参数名 | 类型 | 必填 | 说明 | 922| -------- | ---------------------------------------- | ---- | ------------------------------- | 923| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 924| appIds | Array<string> | 是 | 应用ID数组。 | 925| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | 926 927**错误码**: 928 929以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 930 931| 错误码ID | 错误信息 | 932| ------- | ---------------------------------------------------------------------------- | 933| 9200001 | the application is not an administrator of the device. | 934| 9200002 | the administrator application does not have permission to manage the device. | 935 936**示例:** 937 938```ts 939import Want from '@ohos.app.ability.Want'; 940let wantTemp: Want = { 941 bundleName: 'com.example.myapplication', 942 abilityName: 'EntryAbility', 943}; 944let appIds: Array<string> = ['com.example.myapplication']; 945 946bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, (err) => { 947 if (err) { 948 console.error(`Failed to add disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 949 return; 950 } 951 console.info('Succeeded in adding disallowed uninstall bundles'); 952}); 953``` 954 955## bundleManager.addDisallowedUninstallBundles 956 957addDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback<void>): void 958 959指定设备管理应用添加应用至包卸载黑名单,添加至黑名单的应用不允许在指定用户(通过userId指定)下卸载。使用callback异步回调。 960 961**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 962 963**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 964 965**系统API**: 此接口为系统接口。 966 967**参数:** 968 969| 参数名 | 类型 | 必填 | 说明 | 970| ----- | ----------------------------------- | ---- | ------- | 971| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 972| appIds | Array<string> | 是 | 应用ID数组。 | 973| userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 | 974| callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 975 976**错误码**: 977 978以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 979 980| 错误码ID | 错误信息 | 981| ------- | ---------------------------------------------------------------------------- | 982| 9200001 | the application is not an administrator of the device. | 983| 9200002 | the administrator application does not have permission to manage the device. | 984 985**示例:** 986 987```ts 988import Want from '@ohos.app.ability.Want'; 989let wantTemp: Want = { 990 bundleName: 'com.example.myapplication', 991 abilityName: 'EntryAbility', 992}; 993let appIds: Array<string> = ['com.example.myapplication']; 994 995bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, 100, (err) => { 996 if (err) { 997 console.error(`Failed to add disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 998 return; 999 } 1000 console.info('Succeeded in adding disallowed uninstall bundles'); 1001}); 1002``` 1003 1004## bundleManager.addDisallowedUninstallBundles 1005 1006addDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise<void> 1007 1008指定设备管理应用添加应用至包卸载黑名单,添加至黑名单的应用不允许在当前/指定用户下卸载。使用promise异步回调。 1009 1010**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1011 1012**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1013 1014**系统API**: 此接口为系统接口。 1015 1016**参数:** 1017 1018| 参数名 | 类型 | 必填 | 说明 | 1019| ----- | ----------------------------------- | ---- | ------- | 1020| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1021| appIds | Array<string> | 是 | 应用ID数组。 | 1022| userId | number | 否 | 用户ID,取值范围:大于等于0。<br> - 调用接口时,若传入userId,表示指定用户。<br> - 调用接口时,若未传入userId,表示当前用户。 | 1023 1024**返回值:** 1025 1026| 类型 | 说明 | 1027| --------------------- | ------------------------- | 1028| Promise<void> | 无返回结果的Promise对象。当指定设备管理应用添加包卸载黑名单失败时,会抛出错误对象。 | 1029 1030**错误码**: 1031 1032以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1033 1034| 错误码ID | 错误信息 | 1035| ------- | ---------------------------------------------------------------------------- | 1036| 9200001 | the application is not an administrator of the device. | 1037| 9200002 | the administrator application does not have permission to manage the device. | 1038 1039**示例:** 1040 1041```ts 1042import Want from '@ohos.app.ability.Want'; 1043import { BusinessError } from '@ohos.base'; 1044let wantTemp: Want = { 1045 bundleName: 'com.example.myapplication', 1046 abilityName: 'EntryAbility', 1047}; 1048let appIds: Array<string> = ['com.example.myapplication']; 1049 1050bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, 100).then(() => { 1051 console.info('Succeeded in adding disallowed uninstall bundles'); 1052}).catch((err: BusinessError) => { 1053 console.error(`Failed to add disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1054}); 1055``` 1056 1057## bundleManager.removeDisallowedUninstallBundles 1058 1059removeDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback<void>): void 1060 1061指定设备管理应用在包卸载黑名单中移除应用,在黑名单存在的情况下,在包卸载黑名单中的应用不允许在当前用户下卸载,使用callback异步回调。 1062 1063**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1064 1065**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1066 1067**系统API**: 此接口为系统接口。 1068 1069**参数:** 1070 1071| 参数名 | 类型 | 必填 | 说明 | 1072| -------- | ---------------------------------------- | ---- | ------------------------------- | 1073| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1074| appIds | Array<string> | 是 | 应用ID数组。 | 1075| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | 1076 1077**错误码**: 1078 1079以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1080 1081| 错误码ID | 错误信息 | 1082| ------- | ---------------------------------------------------------------------------- | 1083| 9200001 | the application is not an administrator of the device. | 1084| 9200002 | the administrator application does not have permission to manage the device. | 1085 1086**示例:** 1087 1088```ts 1089import Want from '@ohos.app.ability.Want'; 1090let wantTemp: Want = { 1091 bundleName: 'com.example.myapplication', 1092 abilityName: 'EntryAbility', 1093}; 1094let appIds: Array<string> = ['com.example.myapplication']; 1095 1096bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, (err) => { 1097 if (err) { 1098 console.error(`Failed to remove disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1099 return; 1100 } 1101 console.info('Succeeded in removing disallowed uninstall bundles'); 1102}); 1103``` 1104 1105## bundleManager.removeDisallowedUninstallBundles 1106 1107removeDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback<void>): void 1108 1109指定设备管理应用在包卸载黑名单中移除应用,在黑名单存在的情况下,在包卸载黑名单中的应用不允许在指定用户(通过userId指定)下卸载。使用callback异步回调。 1110 1111**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1112 1113**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1114 1115**系统API**: 此接口为系统接口。 1116 1117**参数:** 1118 1119| 参数名 | 类型 | 必填 | 说明 | 1120| ----- | ----------------------------------- | ---- | ------- | 1121| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1122| appIds | Array<string> | 是 | 应用ID数组。 | 1123| userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 | 1124| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | 1125 1126**错误码**: 1127 1128以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1129 1130| 错误码ID | 错误信息 | 1131| ------- | ---------------------------------------------------------------------------- | 1132| 9200001 | the application is not an administrator of the device. | 1133| 9200002 | the administrator application does not have permission to manage the device. | 1134 1135**示例:** 1136 1137```ts 1138import Want from '@ohos.app.ability.Want'; 1139let wantTemp: Want = { 1140 bundleName: 'com.example.myapplication', 1141 abilityName: 'EntryAbility', 1142}; 1143let appIds: Array<string> = ['com.example.myapplication']; 1144 1145bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, 100, (err) => { 1146 if (err) { 1147 console.error(`Failed to remove disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1148 return; 1149 } 1150 console.info('Succeeded in removing disallowed uninstall bundles'); 1151}); 1152``` 1153 1154## bundleManager.removeDisallowedUninstallBundles 1155 1156removeDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise<void> 1157 1158指定设备管理应用在包卸载黑名单中移除应用。在黑名单存在的情况下,在包卸载黑名单中的应用不允许在当前/指定用户下卸载。使用promise异步回调。 1159 1160**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1161 1162**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1163 1164**系统API**: 此接口为系统接口。 1165 1166**参数:** 1167 1168| 参数名 | 类型 | 必填 | 说明 | 1169| ----- | ----------------------------------- | ---- | ------- | 1170| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1171| appIds | Array\<string> | 是 | 应用ID数组。 | 1172| userId | number | 否 | 用户ID,取值范围:大于等于0。<br> - 调用接口时,若传入userId,表示指定用户。<br> - 调用接口时,若未传入userId,表示当前用户。 | 1173 1174**返回值:** 1175 1176| 类型 | 说明 | 1177| --------------------- | ------------------------- | 1178| Promise<void> | 无返回结果的Promise对象。当指定设备管理应用移除包卸载黑名单失败时会抛出错误对象。 | 1179 1180**错误码**: 1181 1182以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1183 1184| 错误码ID | 错误信息 | 1185| ------- | ---------------------------------------------------------------------------- | 1186| 9200001 | the application is not an administrator of the device. | 1187| 9200002 | the administrator application does not have permission to manage the device. | 1188 1189**示例:** 1190 1191```ts 1192import Want from '@ohos.app.ability.Want'; 1193import { BusinessError } from '@ohos.base'; 1194let wantTemp: Want = { 1195 bundleName: 'com.example.myapplication', 1196 abilityName: 'EntryAbility', 1197}; 1198let appIds: Array<string> = ['com.example.myapplication']; 1199 1200bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, 100).then(() => { 1201 console.info('Succeeded in removing disallowed uninstall bundles'); 1202}).catch((err: BusinessError) => { 1203 console.error(`Failed to remove disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1204}); 1205``` 1206 1207## bundleManager.getDisallowedUninstallBundles 1208 1209getDisallowedUninstallBundles(admin: Want, callback: AsyncCallback<Array<string>>): void 1210 1211指定设备管理应用获取当前用户下的包卸载黑名单,使用callback异步回调。 1212 1213**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1214 1215**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1216 1217**系统API**: 此接口为系统接口。 1218 1219**参数:** 1220 1221| 参数名 | 类型 | 必填 | 说明 | 1222| -------- | ---------------------------------------- | ---- | ------------------------------- | 1223| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1224| callback | AsyncCallback<Array<string>> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 1225 1226**错误码**: 1227 1228以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1229 1230| 错误码ID | 错误信息 | 1231| ------- | ---------------------------------------------------------------------------- | 1232| 9200001 | the application is not an administrator of the device. | 1233| 9200002 | the administrator application does not have permission to manage the device. | 1234 1235**示例:** 1236 1237```ts 1238import Want from '@ohos.app.ability.Want'; 1239let wantTemp: Want = { 1240 bundleName: 'com.example.myapplication', 1241 abilityName: 'EntryAbility', 1242}; 1243 1244bundleManager.getDisallowedUninstallBundles(wantTemp, (err, result) => { 1245 if (err) { 1246 console.error(`Failed to get disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1247 return; 1248 } 1249 console.info(`Succeeded in getting disallowed uninstall bundles, result : ${JSON.stringify(result)}`); 1250}); 1251``` 1252 1253## bundleManager.getDisallowedUninstallBundles 1254 1255getDisallowedUninstallBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void 1256 1257指定设备管理应用获取指定用户(通过userId指定)下的包卸载黑名单,使用callback异步回调。 1258 1259**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1260 1261**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1262 1263**系统API**: 此接口为系统接口。 1264 1265**参数:** 1266 1267| 参数名 | 类型 | 必填 | 说明 | 1268| -------- | ---------------------------------------- | ---- | ------------------------------- | 1269| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1270| userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 | 1271| callback | AsyncCallback<Array<string>> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 1272 1273**错误码**: 1274 1275以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1276 1277| 错误码ID | 错误信息 | 1278| ------- | ---------------------------------------------------------------------------- | 1279| 9200001 | the application is not an administrator of the device. | 1280| 9200002 | the administrator application does not have permission to manage the device. | 1281 1282**示例:** 1283 1284```ts 1285import Want from '@ohos.app.ability.Want'; 1286let wantTemp: Want = { 1287 bundleName: 'com.example.myapplication', 1288 abilityName: 'EntryAbility', 1289}; 1290 1291bundleManager.getDisallowedUninstallBundles(wantTemp, 100, (err, result) => { 1292 if (err) { 1293 console.error(`Failed to get disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1294 return; 1295 } 1296 console.info(`Succeeded in getting disallowed uninstall bundles, result : ${JSON.stringify(result)}`); 1297}); 1298``` 1299 1300## bundleManager.getDisallowedUninstallBundles 1301 1302getDisallowedUninstallBundles(admin: Want, userId?: number): Promise<Array<string>> 1303 1304指定设备管理应用获取当前/指定用户下包卸载黑名单接口,使用promise异步回调。 1305 1306**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1307 1308**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1309 1310**系统API**: 此接口为系统接口。 1311 1312**参数:** 1313 1314| 参数名 | 类型 | 必填 | 说明 | 1315| ----- | ----------------------------------- | ---- | ------- | 1316| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1317| userId | number | 否 | 用户ID,取值范围:大于等于0。<br> - 调用接口时,若传入userId,表示指定用户。<br> - 调用接口时,若未传入userId,表示当前用户。 | 1318 1319**返回值:** 1320 1321| 类型 | 说明 | 1322| --------------------- | ------------------------- | 1323| Promise<Array<string>> | Promise对象,返回当前用户下的包卸载白名单。 | 1324 1325**错误码**: 1326 1327以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1328 1329| 错误码ID | 错误信息 | 1330| ------- | ---------------------------------------------------------------------------- | 1331| 9200001 | the application is not an administrator of the device. | 1332| 9200002 | the administrator application does not have permission to manage the device. | 1333 1334**示例:** 1335 1336```ts 1337import Want from '@ohos.app.ability.Want'; 1338import { BusinessError } from '@ohos.base'; 1339let wantTemp: Want = { 1340 bundleName: 'com.example.myapplication', 1341 abilityName: 'EntryAbility', 1342}; 1343 1344bundleManager.getDisallowedUninstallBundles(wantTemp, 100).then((result) => { 1345 console.info(`Succeeded in getting disallowed uninstall bundles, result : ${JSON.stringify(result)}`); 1346}).catch((err: BusinessError) => { 1347 console.error(`Failed to get disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1348}); 1349``` 1350 1351## bundleManager.uninstall 1352 1353uninstall(admin: Want, bundleName: string, callback: AsyncCallback<void>): void 1354 1355指定设备管理应用卸载当前用户下的指定包,且不保留包数据。使用callback异步回调。 1356 1357**需要权限:** ohos.permission.ENTERPRISE_INSTALL_BUNDLE 1358 1359**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1360 1361**系统API**: 此接口为系统接口。 1362 1363**参数:** 1364 1365| 参数名 | 类型 | 必填 | 说明 | 1366| -------- | ---------------------------------------- | ---- | ------------------------------- | 1367| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1368| bundleName | string | 是 | 包名。 | 1369| callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 1370 1371**错误码**: 1372 1373以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1374 1375| 错误码ID | 错误信息 | 1376| ------- | ---------------------------------------------------------------------------- | 1377| 9200001 | the application is not an administrator of the device. | 1378| 9200002 | the administrator application does not have permission to manage the device. | 1379 1380**示例:** 1381 1382```ts 1383import Want from '@ohos.app.ability.Want'; 1384let wantTemp: Want = { 1385 bundleName: 'com.example.myapplication', 1386 abilityName: 'EntryAbility', 1387}; 1388 1389bundleManager.uninstall(wantTemp, 'bundleName', (err) => { 1390 if (err) { 1391 console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1392 } 1393 console.info('Succeeded in uninstalling bundles'); 1394}); 1395``` 1396 1397## bundleManager.uninstall 1398 1399uninstall(admin: Want, bundleName: string, userId: number, callback: AsyncCallback<void>): void 1400 1401指定设备管理应用卸载指定用户下(由参数userId指定)的指定包,且不保留包数据。使用callback异步回调。 1402 1403**需要权限:** ohos.permission.ENTERPRISE_INSTALL_BUNDLE 1404 1405**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1406 1407**系统API**: 此接口为系统接口。 1408 1409**参数:** 1410 1411| 参数名 | 类型 | 必填 | 说明 | 1412| -------- | ---------------------------------------- | ---- | ------------------------------- | 1413| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1414| bundleName | string | 是 | 包名。 | 1415| userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 | 1416| callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 1417 1418**错误码**: 1419 1420以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1421 1422| 错误码ID | 错误信息 | 1423| ------- | ---------------------------------------------------------------------------- | 1424| 9200001 | the application is not an administrator of the device. | 1425| 9200002 | the administrator application does not have permission to manage the device. | 1426 1427**示例:** 1428 1429```ts 1430import Want from '@ohos.app.ability.Want'; 1431let wantTemp: Want = { 1432 bundleName: 'com.example.myapplication', 1433 abilityName: 'EntryAbility', 1434}; 1435 1436bundleManager.uninstall(wantTemp, 'bundleName', 100, (err) => { 1437 if (err) { 1438 console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1439 } 1440 console.info('Succeeded in uninstalling bundles'); 1441}); 1442``` 1443 1444## bundleManager.uninstall 1445 1446uninstall(admin: Want, bundleName: string, isKeepData: boolean, callback: AsyncCallback<void>): void 1447 1448指定设备管理应用卸载当前用户下的指定包,选择是否保留包数据(由isKeepData指定)。使用callback异步回调。 1449 1450**需要权限:** ohos.permission.ENTERPRISE_INSTALL_BUNDLE 1451 1452**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1453 1454**系统API**: 此接口为系统接口。 1455 1456**参数:** 1457 1458| 参数名 | 类型 | 必填 | 说明 | 1459| -------- | ---------------------------------------- | ---- | ------------------------------- | 1460| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1461| bundleName | string | 是 | 包名。 | 1462| isKeepData | boolean | 是 | 是否保留包数据,true表示保留,false表示不保留。 | 1463| callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 1464 1465**错误码**: 1466 1467以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1468 1469| 错误码ID | 错误信息 | 1470| ------- | ---------------------------------------------------------------------------- | 1471| 9200001 | the application is not an administrator of the device. | 1472| 9200002 | the administrator application does not have permission to manage the device. | 1473 1474**示例:** 1475 1476```ts 1477import Want from '@ohos.app.ability.Want'; 1478let wantTemp: Want = { 1479 bundleName: 'com.example.myapplication', 1480 abilityName: 'EntryAbility', 1481}; 1482 1483bundleManager.uninstall(wantTemp, 'bundleName', true, (err) => { 1484 if (err) { 1485 console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1486 } 1487 console.info('Succeeded in uninstalling bundles'); 1488}); 1489``` 1490 1491## bundleManager.uninstall 1492 1493uninstall(admin: Want, bundleName: string, userId: number, isKeepData: boolean, callback: AsyncCallback<void>): void 1494 1495指定设备管理应用卸载指定用户下(由参数userId指定)的指定包接口,选择是否保留包数据(由isKeepData指定)。使用callback异步回调。 1496 1497**需要权限:** ohos.permission.ENTERPRISE_INSTALL_BUNDLE 1498 1499**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1500 1501**系统API**: 此接口为系统接口。 1502 1503**参数:** 1504 1505| 参数名 | 类型 | 必填 | 说明 | 1506| -------- | ---------------------------------------- | ---- | ------------------------------- | 1507| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1508| bundleName | string | 是 | 包名。 | 1509| userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 | 1510| isKeepData | boolean | 是 | 是否保留包数据,true表示保留,false表示不保留。 | 1511| callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 1512 1513**错误码**: 1514 1515以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1516 1517| 错误码ID | 错误信息 | 1518| ------- | ---------------------------------------------------------------------------- | 1519| 9200001 | the application is not an administrator of the device. | 1520| 9200002 | the administrator application does not have permission to manage the device. | 1521 1522**示例:** 1523 1524```ts 1525import Want from '@ohos.app.ability.Want'; 1526let wantTemp: Want = { 1527 bundleName: 'com.example.myapplication', 1528 abilityName: 'EntryAbility', 1529}; 1530 1531bundleManager.uninstall(wantTemp, 'bundleName', 100, true, (err) => { 1532 if (err) { 1533 console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1534 } 1535 console.info('Succeeded in uninstalling bundles'); 1536}); 1537``` 1538 1539## bundleManager.uninstall 1540 1541uninstall(admin: Want, bundleName: string, userId?: number, isKeepData?: boolean): Promise<void> 1542 1543指定设备管理应用卸载当前/指定用户下的指定包接口,选择是否保留包数据(由isKeepData指定)。使用promise异步回调。 1544 1545**需要权限:** ohos.permission.ENTERPRISE_INSTALL_BUNDLE 1546 1547**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1548 1549**系统API**: 此接口为系统接口。 1550 1551**参数:** 1552 1553| 参数名 | 类型 | 必填 | 说明 | 1554| ----- | ----------------------------------- | ---- | ------- | 1555| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1556| bundleName | string | 是 | 包名。 | 1557| userId | number | 否 | 用户ID,取值范围:大于等于0。<br> - 调用接口时,若传入userId,表示指定用户。<br> - 调用接口时,若未传入userId,表示当前用户。 | 1558| isKeepData | boolean | 否 | 是否保留包数据,true表示保留,false表示不保留。 | 1559 1560**返回值:** 1561 1562| 类型 | 说明 | 1563| --------------------- | ------------------------- | 1564| Promise<void> | 无返回结果的Promise对象。当包卸载失败时抛出错误对象。 | 1565 1566**错误码**: 1567 1568以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1569 1570| 错误码ID | 错误信息 | 1571| ------- | ---------------------------------------------------------------------------- | 1572| 9200001 | the application is not an administrator of the device. | 1573| 9200002 | the administrator application does not have permission to manage the device. | 1574 1575**示例:** 1576 1577```ts 1578import Want from '@ohos.app.ability.Want'; 1579import { BusinessError } from '@ohos.base'; 1580let wantTemp: Want = { 1581 bundleName: 'com.example.myapplication', 1582 abilityName: 'EntryAbility', 1583}; 1584 1585bundleManager.uninstall(wantTemp, 'bundleName', 100, true).then(() => { 1586 console.info('Succeeded in uninstalling bundles'); 1587}).catch((err: BusinessError) => { 1588 console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1589}); 1590``` 1591 1592## bundleManager.install 1593 1594install(admin: Want, hapFilePaths: Array\<string>, callback: AsyncCallback\<void>): void 1595 1596指定设备管理应用安装指定路径下的应用包。使用callback异步回调。 1597 1598**需要权限:** ohos.permission.ENTERPRISE_INSTALL_BUNDLE 1599 1600**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1601 1602**系统API**: 此接口为系统接口。 1603 1604**参数:** 1605 1606| 参数名 | 类型 | 必填 | 说明 | 1607| -------- | ---------------------------------------- | ---- | ------------------------------- | 1608| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1609| hapFilePaths | Array\<string> | 是 | 待安装应用包路径数组。 | 1610| callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 1611 1612**错误码**: 1613 1614以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1615 1616| 错误码ID | 错误信息 | 1617| ------- | ---------------------------------------------------------------------------- | 1618| 9200001 | the application is not an administrator of the device. | 1619| 9200002 | the administrator application does not have permission to manage the device. | 1620| 9201002 | the application install failed. | 1621 1622**示例:** 1623 1624```ts 1625import Want from '@ohos.app.ability.Want'; 1626let wantTemp: Want = { 1627 bundleName: 'com.example.myapplication', 1628 abilityName: 'EntryAbility', 1629}; 1630let hapFilePaths: Array<string> = ['/data/storage/el2/base/haps/entry/testinstall/ExtensionTest.hap'] 1631 1632bundleManager.install(wantTemp, hapFilePaths, (err) => { 1633 if (err) { 1634 console.error(`Failed to install bundles. Code is ${err.code}, message is ${err.message}`); 1635 } 1636 console.info('Succeeded in installing bundles'); 1637}); 1638``` 1639 1640## bundleManager.install 1641 1642install(admin: Want, hapFilePaths: Array\<string>, installParam: InstallParam, callback: AsyncCallback\<void>): void 1643 1644指定设备管理应用安装指定路径下的指定安装参数的应用包,。使用callback异步回调。 1645 1646**需要权限:** ohos.permission.ENTERPRISE_INSTALL_BUNDLE 1647 1648**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1649 1650**系统API**: 此接口为系统接口。 1651 1652**参数:** 1653 1654| 参数名 | 类型 | 必填 | 说明 | 1655| -------- | ---------------------------------------- | ---- | ------------------------------- | 1656| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1657| hapFilePaths | Array\<string> | 是 | 待安装应用包路径数组。 | 1658| installParam | [InstallParam](#installparam) | 是 | 应用包安装参数。 | 1659| callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | 1660 1661**错误码**: 1662 1663以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1664 1665| 错误码ID | 错误信息 | 1666| ------- | ---------------------------------------------------------------------------- | 1667| 9200001 | the application is not an administrator of the device. | 1668| 9200002 | the administrator application does not have permission to manage the device. | 1669| 9201002 | the application install failed. | 1670 1671**示例:** 1672 1673```ts 1674import Want from '@ohos.app.ability.Want'; 1675let wantTemp: Want = { 1676 bundleName: 'com.example.myapplication', 1677 abilityName: 'EntryAbility', 1678}; 1679let hapFilePaths: Array<string> = ['/data/storage/el2/base/haps/entry/testinstall/ExtensionTest.hap'] 1680let installParam: bundleManager.InstallParam = { 1681 userId: 100, 1682 installFlag: 1, 1683}; 1684 1685bundleManager.install(wantTemp, hapFilePaths, installParam, (err) => { 1686 if (err) { 1687 console.error(`Failed to install bundles. Code is ${err.code}, message is ${err.message}`); 1688 } 1689 console.info('Succeeded in installing bundles'); 1690}); 1691``` 1692 1693## bundleManager.install 1694 1695install(admin: Want, hapFilePaths: Array\<string>, installParam?: InstallParam): Promise\<void> 1696 1697指定设备管理应用安装指定路径下的应用包。使用promise异步回调。 1698 1699**需要权限:** ohos.permission.ENTERPRISE_INSTALL_BUNDLE 1700 1701**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1702 1703**系统API**: 此接口为系统接口。 1704 1705**参数:** 1706 1707| 参数名 | 类型 | 必填 | 说明 | 1708| ----- | ----------------------------------- | ---- | ------- | 1709| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理应用。 | 1710| hapFilePaths | Array\<string> | 是 | 待安装应用包路径数组。 | 1711| installParam | [InstallParam](#installparam) | 否 | 应用包安装参数。 | 1712 1713**返回值:** 1714 1715| 类型 | 说明 | 1716| --------------------- | ------------------------- | 1717| Promise<void> | 无返回结果的Promise对象。当包安装失败时,抛出错误对象。 | 1718 1719**错误码**: 1720 1721以下错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) 1722 1723| 错误码ID | 错误信息 | 1724| ------- | ---------------------------------------------------------------------------- | 1725| 9200001 | the application is not an administrator of the device. | 1726| 9200002 | the administrator application does not have permission to manage the device. | 1727| 9201002 | the application install failed. | 1728 1729**示例:** 1730 1731```ts 1732import Want from '@ohos.app.ability.Want'; 1733import { BusinessError } from '@ohos.base'; 1734let wantTemp: Want = { 1735 bundleName: 'com.example.myapplication', 1736 abilityName: 'EntryAbility', 1737}; 1738let hapFilePaths: Array<string> = ['/data/storage/el2/base/haps/entry/testinstall/ExtensionTest.hap'] 1739 1740bundleManager.install(wantTemp, hapFilePaths).then(() => { 1741 console.info('Succeeded in installing bundles'); 1742}).catch((err: BusinessError) => { 1743 console.error(`Failed to install bundles. Code is ${err.code}, message is ${err.message}`); 1744}); 1745``` 1746 1747## InstallParam 1748 1749应用包安装需指定的参数信息。 1750 1751 **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 1752 1753 **系统接口:** 此接口为系统接口。 1754 1755| 名称 | 类型 | 必填 | 说明 | 1756| ------------------------------ | ------------------------------ | ------------------ | ------------------ | 1757| userId | number | 否 | 指示用户id,默认值:调用方所在用户,取值范围:大于等于0。 1758| installFlag | number | 否 | 安装标志。枚举值:0:应用初次安装,1:应用覆盖安装,2:应用免安装,默认值为应用初次安装。 |