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