1e41f4b71Sopenharmony_ci# @ohos.enterprise.bundleManager (Bundle Management) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **bundleManager** module provides APIs for bundle management, including adding, obtaining, and removing a list of bundles that are allowed to install. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> The APIs of this module can be used only in the stage model. 10e41f4b71Sopenharmony_ci> 11e41f4b71Sopenharmony_ci> The APIs of this module can be called only by a [device administrator application](../../mdm/mdm-kit-guide.md#introduction) that is enabled. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci## Modules to Import 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci```ts 16e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.MDMKit'; 17e41f4b71Sopenharmony_ci``` 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci## bundleManager.addAllowedInstallBundlesSync 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ciaddAllowedInstallBundlesSync(admin: Want, appIds: Array<string>, accountId?: number): void 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciAdds the applications that can be installed by the current or specified user through the specified device administrator application. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci**Parameters** 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 33e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 34e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 35e41f4b71Sopenharmony_ci| appIds | Array<string> | Yes | IDs of the applications to add. | 36e41f4b71Sopenharmony_ci| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci**Error codes** 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci| ID| Error Message | 43e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 44e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 45e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 46e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 47e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci**Example** 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci```ts 52e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 53e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 54e41f4b71Sopenharmony_cilet wantTemp: Want = { 55e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 56e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 57e41f4b71Sopenharmony_ci}; 58e41f4b71Sopenharmony_cilet appIds: Array<string> = ['com.example.myapplication']; 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_citry { 61e41f4b71Sopenharmony_ci bundleManager.addAllowedInstallBundlesSync(wantTemp, appIds, 100); 62e41f4b71Sopenharmony_ci console.info('Succeeded in adding allowed install bundles.'); 63e41f4b71Sopenharmony_ci} catch (err) { 64e41f4b71Sopenharmony_ci console.error(`Failed to add allowed install bundles. Code is ${err.code}, message is ${err.message}`); 65e41f4b71Sopenharmony_ci} 66e41f4b71Sopenharmony_ci``` 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci## bundleManager.removeAllowedInstallBundlesSync 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ciremoveAllowedInstallBundlesSync(admin: Want, appIds: Array<string>, accountId?: number): void 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ciRemoves the applications that can be installed by the current or specified user through the specified device administrator application. 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci**Parameters** 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 82e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 83e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 84e41f4b71Sopenharmony_ci| appIds | Array<string> | Yes | IDs of the applications to remove. | 85e41f4b71Sopenharmony_ci| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci**Error codes** 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci| ID| Error Message | 92e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 93e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 94e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 95e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 96e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci**Example** 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_ci```ts 101e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 102e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 103e41f4b71Sopenharmony_cilet wantTemp: Want = { 104e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 105e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 106e41f4b71Sopenharmony_ci}; 107e41f4b71Sopenharmony_cilet appIds: Array<string> = ['com.example.myapplication']; 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_citry { 110e41f4b71Sopenharmony_ci bundleManager.removeAllowedInstallBundlesSync(wantTemp, appIds, 100); 111e41f4b71Sopenharmony_ci console.info('Succeeded in removing allowed install bundles.'); 112e41f4b71Sopenharmony_ci} catch (err) { 113e41f4b71Sopenharmony_ci console.error(`Failed to remove allowed install bundles. Code is ${err.code}, message is ${err.message}`); 114e41f4b71Sopenharmony_ci} 115e41f4b71Sopenharmony_ci``` 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ci## bundleManager.getAllowedInstallBundlesSync 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_cigetAllowedInstallBundlesSync(admin: Want, accountId?: number): Array<string> 120e41f4b71Sopenharmony_ci 121e41f4b71Sopenharmony_ciObtains the applications that can be installed by the current or specified user through the specified device administrator application. 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci**Parameters** 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 131e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 132e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 133e41f4b71Sopenharmony_ci| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 134e41f4b71Sopenharmony_ci 135e41f4b71Sopenharmony_ci**Return value** 136e41f4b71Sopenharmony_ci 137e41f4b71Sopenharmony_ci| Type | Description | 138e41f4b71Sopenharmony_ci| ------------------- | ------------------------------ | 139e41f4b71Sopenharmony_ci| Array<string> | Applications that can be installed by the user.| 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci**Error codes** 142e41f4b71Sopenharmony_ci 143e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci| ID| Error Message | 146e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 147e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 148e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 149e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 150e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci**Example** 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ci```ts 155e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 156e41f4b71Sopenharmony_cilet wantTemp: Want = { 157e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 158e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 159e41f4b71Sopenharmony_ci}; 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_citry { 162e41f4b71Sopenharmony_ci let result: Array<string> = bundleManager.getAllowedInstallBundlesSync(wantTemp, 100); 163e41f4b71Sopenharmony_ci console.info(`Succeeded in getting allowed install bundles, result : ${JSON.stringify(result)}`); 164e41f4b71Sopenharmony_ci} catch (err) { 165e41f4b71Sopenharmony_ci console.error(`Failed to get allowed install bundles. Code is ${err.code}, message is ${err.message}`); 166e41f4b71Sopenharmony_ci} 167e41f4b71Sopenharmony_ci``` 168e41f4b71Sopenharmony_ci 169e41f4b71Sopenharmony_ci## bundleManager.addDisallowedInstallBundlesSync 170e41f4b71Sopenharmony_ci 171e41f4b71Sopenharmony_ciaddDisallowedInstallBundlesSync(admin: Want, appIds: Array<string>, accountId?: number): void 172e41f4b71Sopenharmony_ci 173e41f4b71Sopenharmony_ciAdds the applications that cannot be installed by the current or specified user through the specified device administrator application. 174e41f4b71Sopenharmony_ci 175e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 176e41f4b71Sopenharmony_ci 177e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 178e41f4b71Sopenharmony_ci 179e41f4b71Sopenharmony_ci**Parameters** 180e41f4b71Sopenharmony_ci 181e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 182e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 183e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 184e41f4b71Sopenharmony_ci| appIds | Array<string> | Yes | IDs of the applications to add. | 185e41f4b71Sopenharmony_ci| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 186e41f4b71Sopenharmony_ci 187e41f4b71Sopenharmony_ci**Error codes** 188e41f4b71Sopenharmony_ci 189e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 190e41f4b71Sopenharmony_ci 191e41f4b71Sopenharmony_ci| ID| Error Message | 192e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 193e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 194e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 195e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 196e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ci**Example** 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_ci```ts 201e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 202e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 203e41f4b71Sopenharmony_cilet wantTemp: Want = { 204e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 205e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 206e41f4b71Sopenharmony_ci}; 207e41f4b71Sopenharmony_cilet appIds: Array<string> = ['com.example.myapplication']; 208e41f4b71Sopenharmony_ci 209e41f4b71Sopenharmony_citry { 210e41f4b71Sopenharmony_ci bundleManager.addDisallowedInstallBundlesSync(wantTemp, appIds, 100); 211e41f4b71Sopenharmony_ci console.info('Succeeded in adding disallowed install bundles.'); 212e41f4b71Sopenharmony_ci} catch (err) { 213e41f4b71Sopenharmony_ci console.error(`Failed to add disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 214e41f4b71Sopenharmony_ci} 215e41f4b71Sopenharmony_ci``` 216e41f4b71Sopenharmony_ci 217e41f4b71Sopenharmony_ci## bundleManager.removeDisallowedInstallBundlesSync 218e41f4b71Sopenharmony_ci 219e41f4b71Sopenharmony_ciremoveDisallowedInstallBundlesSync(admin: Want, appIds: Array<string>, accountId?: number): void 220e41f4b71Sopenharmony_ci 221e41f4b71Sopenharmony_ciRemoves the applications that cannot be installed by the current or specified user through the specified device administrator application. 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_ci**Parameters** 228e41f4b71Sopenharmony_ci 229e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 230e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 231e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 232e41f4b71Sopenharmony_ci| appIds | Array<string> | Yes | IDs of the applications to remove. | 233e41f4b71Sopenharmony_ci| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 234e41f4b71Sopenharmony_ci 235e41f4b71Sopenharmony_ci**Error codes** 236e41f4b71Sopenharmony_ci 237e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 238e41f4b71Sopenharmony_ci 239e41f4b71Sopenharmony_ci| ID| Error Message | 240e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 241e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 242e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 243e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 244e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 245e41f4b71Sopenharmony_ci 246e41f4b71Sopenharmony_ci**Example** 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ci```ts 249e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 250e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 251e41f4b71Sopenharmony_cilet wantTemp: Want = { 252e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 253e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 254e41f4b71Sopenharmony_ci}; 255e41f4b71Sopenharmony_cilet appIds: Array<string> = ['com.example.myapplication']; 256e41f4b71Sopenharmony_ci 257e41f4b71Sopenharmony_citry { 258e41f4b71Sopenharmony_ci bundleManager.removeDisallowedInstallBundlesSync(wantTemp, appIds, 100) 259e41f4b71Sopenharmony_ci console.info('Succeeded in removing disallowed install bundles.'); 260e41f4b71Sopenharmony_ci} catch (err) { 261e41f4b71Sopenharmony_ci console.error(`Failed to remove disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 262e41f4b71Sopenharmony_ci} 263e41f4b71Sopenharmony_ci``` 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ci## bundleManager.getDisallowedInstallBundlesSync 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_cigetDisallowedInstallBundlesSync(admin: Want, accountId?: number): Array<string> 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_ciObtains the applications that cannot be installed by the current or specified user through the specified device administrator application. 270e41f4b71Sopenharmony_ci 271e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 272e41f4b71Sopenharmony_ci 273e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 274e41f4b71Sopenharmony_ci 275e41f4b71Sopenharmony_ci 276e41f4b71Sopenharmony_ci**Parameters** 277e41f4b71Sopenharmony_ci 278e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 279e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 280e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 281e41f4b71Sopenharmony_ci| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 282e41f4b71Sopenharmony_ci 283e41f4b71Sopenharmony_ci**Return value** 284e41f4b71Sopenharmony_ci 285e41f4b71Sopenharmony_ci| Type | Description | 286e41f4b71Sopenharmony_ci| ------------------- | ------------------------------ | 287e41f4b71Sopenharmony_ci| Array<string> | Applications that cannot be installed by the user.| 288e41f4b71Sopenharmony_ci 289e41f4b71Sopenharmony_ci**Error codes** 290e41f4b71Sopenharmony_ci 291e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 292e41f4b71Sopenharmony_ci 293e41f4b71Sopenharmony_ci| ID| Error Message | 294e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 295e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 296e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 297e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 298e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 299e41f4b71Sopenharmony_ci 300e41f4b71Sopenharmony_ci**Example** 301e41f4b71Sopenharmony_ci 302e41f4b71Sopenharmony_ci```ts 303e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 304e41f4b71Sopenharmony_cilet wantTemp: Want = { 305e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 306e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 307e41f4b71Sopenharmony_ci}; 308e41f4b71Sopenharmony_ci 309e41f4b71Sopenharmony_citry { 310e41f4b71Sopenharmony_ci let result: Array<string> = bundleManager.getDisallowedInstallBundlesSync(wantTemp, 100); 311e41f4b71Sopenharmony_ci console.info(`Succeeded in getting disallowed install bundles, result : ${JSON.stringify(result)}`); 312e41f4b71Sopenharmony_ci} catch (err) { 313e41f4b71Sopenharmony_ci console.error(`Failed to get disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 314e41f4b71Sopenharmony_ci} 315e41f4b71Sopenharmony_ci``` 316e41f4b71Sopenharmony_ci 317e41f4b71Sopenharmony_ci## bundleManager.addDisallowedUninstallBundlesSync 318e41f4b71Sopenharmony_ci 319e41f4b71Sopenharmony_ciaddDisallowedUninstallBundlesSync(admin: Want, appIds: Array<string>, accountId?: number): void 320e41f4b71Sopenharmony_ci 321e41f4b71Sopenharmony_ciAdds the applications that cannot be uninstalled by the current or specified user through the specified device administrator application. 322e41f4b71Sopenharmony_ci 323e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 324e41f4b71Sopenharmony_ci 325e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 326e41f4b71Sopenharmony_ci 327e41f4b71Sopenharmony_ci 328e41f4b71Sopenharmony_ci**Parameters** 329e41f4b71Sopenharmony_ci 330e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 331e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 332e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 333e41f4b71Sopenharmony_ci| appIds | Array<string> | Yes | IDs of the applications to add. | 334e41f4b71Sopenharmony_ci| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 335e41f4b71Sopenharmony_ci 336e41f4b71Sopenharmony_ci**Error codes** 337e41f4b71Sopenharmony_ci 338e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 339e41f4b71Sopenharmony_ci 340e41f4b71Sopenharmony_ci| ID| Error Message | 341e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 342e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 343e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 344e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 345e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 346e41f4b71Sopenharmony_ci 347e41f4b71Sopenharmony_ci**Example** 348e41f4b71Sopenharmony_ci 349e41f4b71Sopenharmony_ci```ts 350e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 351e41f4b71Sopenharmony_cilet wantTemp: Want = { 352e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 353e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 354e41f4b71Sopenharmony_ci}; 355e41f4b71Sopenharmony_cilet appIds: Array<string> = ['com.example.myapplication']; 356e41f4b71Sopenharmony_ci 357e41f4b71Sopenharmony_citry { 358e41f4b71Sopenharmony_ci bundleManager.addDisallowedUninstallBundlesSync(wantTemp, appIds, 100); 359e41f4b71Sopenharmony_ci console.info('Succeeded in adding disallowed uninstall bundles.'); 360e41f4b71Sopenharmony_ci} catch (err) { 361e41f4b71Sopenharmony_ci console.error(`Failed to add disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 362e41f4b71Sopenharmony_ci} 363e41f4b71Sopenharmony_ci``` 364e41f4b71Sopenharmony_ci 365e41f4b71Sopenharmony_ci## bundleManager.removeDisallowedUninstallBundlesSync 366e41f4b71Sopenharmony_ci 367e41f4b71Sopenharmony_ciremoveDisallowedUninstallBundlesSync(admin: Want, appIds: Array<string>, accountId?: number): void 368e41f4b71Sopenharmony_ci 369e41f4b71Sopenharmony_ciRemoves the applications that cannot be uninstalled by the current or specified user through the specified device administrator application. 370e41f4b71Sopenharmony_ci 371e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 372e41f4b71Sopenharmony_ci 373e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 374e41f4b71Sopenharmony_ci 375e41f4b71Sopenharmony_ci 376e41f4b71Sopenharmony_ci**Parameters** 377e41f4b71Sopenharmony_ci 378e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 379e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 380e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 381e41f4b71Sopenharmony_ci| appIds | Array<string> | Yes | IDs of the applications to remove. | 382e41f4b71Sopenharmony_ci| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 383e41f4b71Sopenharmony_ci 384e41f4b71Sopenharmony_ci**Error codes** 385e41f4b71Sopenharmony_ci 386e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_ci| ID| Error Message | 389e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 390e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 391e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 392e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 393e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 394e41f4b71Sopenharmony_ci 395e41f4b71Sopenharmony_ci**Example** 396e41f4b71Sopenharmony_ci 397e41f4b71Sopenharmony_ci```ts 398e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 399e41f4b71Sopenharmony_cilet wantTemp: Want = { 400e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 401e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 402e41f4b71Sopenharmony_ci}; 403e41f4b71Sopenharmony_cilet appIds: Array<string> = ['com.example.myapplication']; 404e41f4b71Sopenharmony_ci 405e41f4b71Sopenharmony_citry { 406e41f4b71Sopenharmony_ci bundleManager.removeDisallowedUninstallBundlesSync(wantTemp, appIds, 100); 407e41f4b71Sopenharmony_ci console.info('Succeeded in removing disallowed uninstall bundles.'); 408e41f4b71Sopenharmony_ci} catch (err) { 409e41f4b71Sopenharmony_ci console.error(`Failed to remove disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 410e41f4b71Sopenharmony_ci} 411e41f4b71Sopenharmony_ci``` 412e41f4b71Sopenharmony_ci 413e41f4b71Sopenharmony_ci## bundleManager.getDisallowedUninstallBundlesSync 414e41f4b71Sopenharmony_ci 415e41f4b71Sopenharmony_cigetDisallowedUninstallBundlesSync(admin: Want, accountId?: number): Array<string> 416e41f4b71Sopenharmony_ci 417e41f4b71Sopenharmony_ciObtains the applications that cannot be uninstalled by the current or specified user through the specified device administrator application. 418e41f4b71Sopenharmony_ci 419e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 420e41f4b71Sopenharmony_ci 421e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 422e41f4b71Sopenharmony_ci 423e41f4b71Sopenharmony_ci 424e41f4b71Sopenharmony_ci**Parameters** 425e41f4b71Sopenharmony_ci 426e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 427e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 428e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 429e41f4b71Sopenharmony_ci| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 430e41f4b71Sopenharmony_ci 431e41f4b71Sopenharmony_ci**Return value** 432e41f4b71Sopenharmony_ci 433e41f4b71Sopenharmony_ci| Type | Description | 434e41f4b71Sopenharmony_ci| ------------------- | ------------------------------ | 435e41f4b71Sopenharmony_ci| Array<string> | Applications that cannot be uninstalled by the user.| 436e41f4b71Sopenharmony_ci 437e41f4b71Sopenharmony_ci**Error codes** 438e41f4b71Sopenharmony_ci 439e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 440e41f4b71Sopenharmony_ci 441e41f4b71Sopenharmony_ci| ID| Error Message | 442e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 443e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 444e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 445e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 446e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 447e41f4b71Sopenharmony_ci 448e41f4b71Sopenharmony_ci**Example** 449e41f4b71Sopenharmony_ci 450e41f4b71Sopenharmony_ci```ts 451e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 452e41f4b71Sopenharmony_cilet wantTemp: Want = { 453e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 454e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 455e41f4b71Sopenharmony_ci}; 456e41f4b71Sopenharmony_ci 457e41f4b71Sopenharmony_citry { 458e41f4b71Sopenharmony_ci let result: Array<String> = bundleManager.getDisallowedUninstallBundlesSync(wantTemp, 100); 459e41f4b71Sopenharmony_ci console.info(`Succeeded in getting disallowed uninstall bundles, result : ${JSON.stringify(result)}`); 460e41f4b71Sopenharmony_ci} catch (err) { 461e41f4b71Sopenharmony_ci console.error(`Failed to get disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 462e41f4b71Sopenharmony_ci} 463e41f4b71Sopenharmony_ci``` 464e41f4b71Sopenharmony_ci 465e41f4b71Sopenharmony_ci## bundleManager.uninstall 466e41f4b71Sopenharmony_ci 467e41f4b71Sopenharmony_ciuninstall(admin: Want, bundleName: string, userId?: number, isKeepData?: boolean): Promise<void> 468e41f4b71Sopenharmony_ci 469e41f4b71Sopenharmony_ciUninstalls an application of the current or specified user through the specified device administrator application. The **isKeepData** parameter specifies whether to retain the bundle data. This API uses a promise to return the result. 470e41f4b71Sopenharmony_ci 471e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE 472e41f4b71Sopenharmony_ci 473e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 474e41f4b71Sopenharmony_ci 475e41f4b71Sopenharmony_ci 476e41f4b71Sopenharmony_ci**Parameters** 477e41f4b71Sopenharmony_ci 478e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 479e41f4b71Sopenharmony_ci| ---------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 480e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 481e41f4b71Sopenharmony_ci| bundleName | string | Yes | Name of the bundle to uninstall. | 482e41f4b71Sopenharmony_ci| userId | number | No | User ID, which must be greater than or equal to 0.<br>- If **userId** is passed in, this API applies to the specified user.<br>- If **userId** is not passed in, this API applies to the current user.| 483e41f4b71Sopenharmony_ci| isKeepData | boolean | No | Whether to retain the bundle data. The value **true** means to retain the bundle data; the value **false** means the opposite. | 484e41f4b71Sopenharmony_ci 485e41f4b71Sopenharmony_ci**Return value** 486e41f4b71Sopenharmony_ci 487e41f4b71Sopenharmony_ci| Type | Description | 488e41f4b71Sopenharmony_ci| ------------------- | ----------------------------------------------------- | 489e41f4b71Sopenharmony_ci| Promise<void> | Promise that returns no value. An error object will be thrown if the application fails to be uninstalled.| 490e41f4b71Sopenharmony_ci 491e41f4b71Sopenharmony_ci**Error codes** 492e41f4b71Sopenharmony_ci 493e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 494e41f4b71Sopenharmony_ci 495e41f4b71Sopenharmony_ci| ID| Error Message | 496e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 497e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 498e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 499e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 500e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 501e41f4b71Sopenharmony_ci 502e41f4b71Sopenharmony_ci**Example** 503e41f4b71Sopenharmony_ci 504e41f4b71Sopenharmony_ci```ts 505e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 506e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 507e41f4b71Sopenharmony_cilet wantTemp: Want = { 508e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 509e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 510e41f4b71Sopenharmony_ci}; 511e41f4b71Sopenharmony_ci 512e41f4b71Sopenharmony_cibundleManager.uninstall(wantTemp, 'bundleName', 100, true).then(() => { 513e41f4b71Sopenharmony_ci console.info('Succeeded in uninstalling bundles.'); 514e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 515e41f4b71Sopenharmony_ci console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`); 516e41f4b71Sopenharmony_ci}); 517e41f4b71Sopenharmony_ci``` 518e41f4b71Sopenharmony_ci 519e41f4b71Sopenharmony_ci## bundleManager.install 520e41f4b71Sopenharmony_ci 521e41f4b71Sopenharmony_ciinstall(admin: Want, hapFilePaths: Array\<string>, installParam?: InstallParam): Promise\<void> 522e41f4b71Sopenharmony_ci 523e41f4b71Sopenharmony_ciInstalls applications through the specified device administrator application. This API uses a promise to return the result. 524e41f4b71Sopenharmony_ci 525e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE 526e41f4b71Sopenharmony_ci 527e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 528e41f4b71Sopenharmony_ci 529e41f4b71Sopenharmony_ci 530e41f4b71Sopenharmony_ci**Parameters** 531e41f4b71Sopenharmony_ci 532e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 533e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------------------- | ---- | ---------------------- | 534e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 535e41f4b71Sopenharmony_ci| hapFilePaths | Array\<string> | Yes | Applications to install.| 536e41f4b71Sopenharmony_ci| installParam | [InstallParam](#installparam) | No | Application installation parameters. | 537e41f4b71Sopenharmony_ci 538e41f4b71Sopenharmony_ci**Return value** 539e41f4b71Sopenharmony_ci 540e41f4b71Sopenharmony_ci| Type | Description | 541e41f4b71Sopenharmony_ci| ------------------- | ------------------------------------------------------- | 542e41f4b71Sopenharmony_ci| Promise<void> | Promise that returns no value. If the operation fails, an error object will be thrown.| 543e41f4b71Sopenharmony_ci 544e41f4b71Sopenharmony_ci**Error codes** 545e41f4b71Sopenharmony_ci 546e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 547e41f4b71Sopenharmony_ci 548e41f4b71Sopenharmony_ci| ID| Error Message | 549e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 550e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 551e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 552e41f4b71Sopenharmony_ci| 9201002 | Failed to install the application. | 553e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 554e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 555e41f4b71Sopenharmony_ci 556e41f4b71Sopenharmony_ci**Example** 557e41f4b71Sopenharmony_ci 558e41f4b71Sopenharmony_ci```ts 559e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 560e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 561e41f4b71Sopenharmony_cilet wantTemp: Want = { 562e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 563e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 564e41f4b71Sopenharmony_ci}; 565e41f4b71Sopenharmony_cilet hapFilePaths: Array<string> = ['/data/storage/el2/base/haps/entry/testinstall/ExtensionTest.hap']; 566e41f4b71Sopenharmony_ci 567e41f4b71Sopenharmony_cibundleManager.install(wantTemp, hapFilePaths).then(() => { 568e41f4b71Sopenharmony_ci console.info('Succeeded in installing bundles.'); 569e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 570e41f4b71Sopenharmony_ci console.error(`Failed to install bundles. Code is ${err.code}, message is ${err.message}`); 571e41f4b71Sopenharmony_ci}); 572e41f4b71Sopenharmony_ci``` 573e41f4b71Sopenharmony_ci 574e41f4b71Sopenharmony_ci## InstallParam 575e41f4b71Sopenharmony_ci 576e41f4b71Sopenharmony_ciDefines the parameters for application installation. 577e41f4b71Sopenharmony_ci 578e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 579e41f4b71Sopenharmony_ci 580e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 581e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | ------------------------------------------------------------ | 582e41f4b71Sopenharmony_ci| userId | number | No | User ID, which must be greater than or equal to 0. The default value is the user ID of the caller. | 583e41f4b71Sopenharmony_ci| installFlag | number | No | Installation flag.<br>- **0**: initial installation.<br>- **1**: overwrite installation.<br>- **2**: installation-free.<br>Default value: **0**| 584