# @ohos.enterprise.bundleManager (Bundle Management) The **bundleManager** module provides APIs for bundle management, including adding, obtaining, and removing a list of bundles that are allowed to install. Only the enterprise device administrator applications can call the APIs provided by this module. > **NOTE** > > - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The APIs of this module can be called only after a [device administrator application](js-apis-enterprise-adminManager.md#adminmanagerenableadmin) is enabled. ## Modules to Import ```js import bundleManager from '@ohos.enterprise.bundleManager'; ``` ## bundleManager.addAllowedInstallBundles addAllowedInstallBundles(admin: Want, appIds: Array\, callback: AsyncCallback<void>): void; Adds a list of bundles that are allowed to be installed by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be added. | | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.addAllowedInstallBundles(wantTemp, appIds, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.addAllowedInstallBundles addAllowedInstallBundles(admin: Want, appIds: Array\, userId: number, callback: AsyncCallback<void>): void; Adds a list of bundles that are allowed to be installed by the given user (specified by **userId**) through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be added. | | userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.addAllowedInstallBundles addAllowedInstallBundles(admin: Want, appIds: Array\, userId?: number): Promise<void>; Adds a list of bundles that are allowed to be installed by the current user (if **userId** is not passed in) or the given user (if **userId** is passed in) through the specified device administrator application. This API uses a promise to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be added. | | userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| **Return value** | Type | Description | | --------------------- | ------------------------- | | Promise<void> | Promise that returns no value. If the operation fails, an error object is thrown. | **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100).then(() => { console.log("success"); }).catch(error => { console.log("error code:" + error.code + " error message:" + error.message); }); ``` ## bundleManager.removeAllowedInstallBundles removeAllowedInstallBundles(admin: Want, appIds: Array\, callback: AsyncCallback<void>): void; Removes a list of bundles that are allowed to be installed by the current user through the specified device administrator application. The bundles removed from the list can no longer be installed. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be removed. | | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.removeAllowedInstallBundles(wantTemp, appIds, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.removeAllowedInstallBundles removeAllowedInstallBundles(admin: Want, appIds: Array\, userId: number, callback: AsyncCallback<void>): void; Removes a list of bundles that are allowed to be installed by the given user (specified by **userId**) through the specified device administrator application. The bundles removed from the list can no longer be installed. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be removed. | | userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.removeAllowedInstallBundles removeAllowedInstallBundles(admin: Want, appIds: Array\, userId?: number): Promise<void>; Removes a list of bundles that are allowed to be installed by the current user (if **userId** is not passed in) or the given user (if **userId** is passed in) through the specified device administrator application. The bundles removed from the list can no longer be installed. This API uses a promise to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array\<string> | Yes | Bundles to be removed. | | userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| **Return value** | Type | Description | | --------------------- | ------------------------- | | Promise<void> | Promise that returns no value. If the operation fails, an error object is thrown. | **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100).then(() => { console.log("success"); }).catch(error => { console.log("error code:" + error.code + " error message:" + error.message); }); ``` ## bundleManager.getAllowedInstallBundles getAllowedInstallBundles(admin: Want, callback: AsyncCallback<Array<string>>): void; Obtains the list of bundles that are allowed to be installed by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; bundleManager.getAllowedInstallBundles(wantTemp, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.getAllowedInstallBundles getAllowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void; Obtains the list of bundles that are allowed to be installed by the given user (specified by **userId**) through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| | callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; bundleManager.getAllowedInstallBundles(wantTemp, 100, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.getAllowedInstallBundles getAllowedInstallBundles(admin: Want, userId?: number): Promise<Array<string>>; Obtains the list of bundles that are allowed to be installed by the current user (if **userId** is not passed in) or the given user (if **userId** is passed in) through the specified device administrator application. This API uses a promise to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.| | userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| **Return value** | Type | Description | | --------------------- | ------------------------- | | Promise<Array<string>> | Promise used to return the list of the bundles obtained.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; bundleManager.getAllowedInstallBundles(wantTemp, 100).then(() => { console.log("success"); }).catch(error => { console.log("error code:" + error.code + " error message:" + error.message); }); ``` ## bundleManager.addDisallowedInstallBundles addDisallowedInstallBundles(admin: Want, appIds: Array\, callback: AsyncCallback<void>): void; Adds a list of bundles that are not allowed to be installed by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be added. | | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.addDisallowedInstallBundles(wantTemp, appIds, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.addDisallowedInstallBundles addDisallowedInstallBundles(admin: Want, appIds: Array\, userId: number, callback: AsyncCallback<void>): void; Adds a list of bundles that are not allowed to be installed by the given user (specified by **userId**) through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be added. | | userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.addDisallowedInstallBundles(wantTemp, appIds, 100, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.addDisallowedInstallBundles addDisallowedInstallBundles(admin: Want, appIds: Array\, userId?: number): Promise<void>; Adds a list of bundles that are not allowed to be installed by the current user (if **userId** is not passed in) or the given user (if **userId** is passed in) through the specified device administrator application. This API uses a promise to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be added. | | userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| **Return value** | Type | Description | | --------------------- | ------------------------- | | Promise<void> | Promise that returns no value. If the operation fails, an error object is thrown. | **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.addDisallowedInstallBundles(wantTemp, appIds, 100).then(() => { console.log("success"); }).catch(error => { console.log("error code:" + error.code + " error message:" + error.message); }); ``` ## bundleManager.removeDisallowedInstallBundles removeDisallowedInstallBundles(admin: Want, appIds: Array\, callback: AsyncCallback<void>): void; Removes a list of bundles that are not allowed to be installed by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be removed. | | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.removeDisallowedInstallBundles removeAllowedInstallBundles(admin: Want, appIds: Array\, userId: number, callback: AsyncCallback<void>): void; Removes a list of bundles that are not allowed to be installed by the given user (specified by **userId**) through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be removed. | | userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.removeDisallowedInstallBundles removeDisallowedInstallBundles(admin: Want, appIds: Array\, userId?: number): Promise<void>; Removes a list of bundles that are not allowed to be installed by the current user (if **userId** is not passed in) or the given user (if **userId** is passed in) through the specified device administrator application. This API uses a promise to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array\<string> | Yes | Bundles to be removed. | | userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| **Return value** | Type | Description | | --------------------- | ------------------------- | | Promise<void> | Promise that returns no value. If the operation fails, an error object is thrown. | **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100).then(() => { console.log("success"); }).catch(error => { console.log("error code:" + error.code + " error message:" + error.message); }); ``` ## bundleManager.getDisallowedInstallBundles getDisallowedInstallBundles(admin: Want, callback: AsyncCallback<Array<string>>): void; Obtains the list of bundles that are not allowed to be installed by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; bundleManager.getDisallowedInstallBundles(wantTemp, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.getDisallowedInstallBundles getDisallowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void; Obtains the list of bundles that are not allowed to be installed by the given user (specified by **userId**) through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| | callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; bundleManager.getDisallowedInstallBundles(wantTemp, 100, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.getDisallowedInstallBundles getDisallowedInstallBundles(admin: Want, userId?: number): Promise<Array<string>>; Obtains the list of bundles that are not allowed to be installed by the current user (if **userId** is not passed in) or the given user (if **userId** is passed in) through the specified device administrator application. This API uses a promise to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.| | userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| **Return value** | Type | Description | | --------------------- | ------------------------- | | Promise<Array<string>> | Promise used to return the list of the bundles obtained.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; bundleManager.getDisallowedInstallBundles(wantTemp, 100).then(() => { console.log("success"); }).catch(error => { console.log("error code:" + error.code + " error message:" + error.message); }); ## bundleManager.addDisallowedUninstallBundles addDisallowedUninstallBundles(admin: Want, appIds: Array\, callback: AsyncCallback<void>): void Adds a list of bundles that are not allowed to be uninstalled by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be added. | | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.addDisallowedUninstallBundles addDisallowedUninstallBundles(admin: Want, appIds: Array\, userId: number, callback: AsyncCallback<void>): void Adds a list of bundles that are not allowed to be uninstalled by the given user (specified by **userId**) through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be added. | | userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, 100, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.addDisallowedUninstallBundles addDisallowedUninstallBundles(admin: Want, appIds: Array\, userId?: number): Promise<void> Adds a list of bundles that are not allowed to be uninstalled by the current user (if **userId** is not passed in) or the given user (if **userId** is passed in) through the specified device administrator application. This API uses a promise to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be added. | | userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| **Return value** | Type | Description | | --------------------- | ------------------------- | | Promise<void> | Promise that returns no value. If the operation fails, an error object is thrown. | **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, 100).then(() => { console.log("success"); }).catch(error => { console.log("error code:" + error.code + " error message:" + error.message); }); ``` ## bundleManager.removeDisallowedUninstallBundles removeDisallowedUninstallBundles(admin: Want, appIds: Array\, callback: AsyncCallback<void>): void Removes a list of bundles that are not allowed to be uninstalled by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be removed. | | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.removeDisallowedUninstallBundles removeDisallowedUninstallBundles(admin: Want, appIds: Array\, userId: number, callback: AsyncCallback<void>): void Removes a list of bundles that are not allowed to be uninstalled by the given user (specified by **userId**) through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array<string> | Yes | Bundles to be removed. | | userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, 100, (error) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } }); ``` ## bundleManager.removeDisallowedUninstallBundles removeDisallowedUninstallBundles(admin: Want, appIds: Array\, userId?: number): Promise<void> Removes a list of bundles that are not allowed to be uninstalled by the current user (if **userId** is not passed in) or the given user (if **userId** is passed in) through the specified device administrator application. This API uses a promise to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | appIds | Array\<string> | Yes | Bundles to be removed. | | userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| **Return value** | Type | Description | | --------------------- | ------------------------- | | Promise<void> | Promise that returns no value. If the operation fails, an error object is thrown. | **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; let appIds = ["com.example.myapplication"]; bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, 100).then(() => { console.log("success"); }).catch(error => { console.log("error code:" + error.code + " error message:" + error.message); }); ``` ## bundleManager.getDisallowedUninstallBundles getDisallowedUninstallBundles(admin: Want, callback: AsyncCallback<Array<string>>): void Obtains the list of bundles that are not allowed to be uninstalled by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; bundleManager.getDisallowedUninstallBundles(wantTemp, (error, data) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } else { console.log("success: " + data); } }); ``` ## bundleManager.getDisallowedUninstallBundles getDisallowedUninstallBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void Obtains the list of bundles that are not allowed to be uninstalled by the given user (specified by **userId**) through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. | | userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| | callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; bundleManager.getDisallowedUninstallBundles(wantTemp, 100, (error, data) => { if (error != null) { console.log("error code:" + error.code + " error message:" + error.message); } else { console.log("success: " + data); } }); ``` ## bundleManager.getDisallowedUninstallBundles getDisallowedUninstallBundles(admin: Want, userId?: number): Promise<Array<string>> Obtains the list of bundles that are not allowed to be uninstalled by the current user (if **userId** is not passed in) or the given user (if **userId** is passed in) through the specified device administrator application. This API uses a promise to return the result. **Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.| | userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.| **Return value** | Type | Description | | --------------------- | ------------------------- | | Promise<Array<string>> | Promise used to return the bundle list obtained.| **Error codes** For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | | 9200001 | the application is not an administrator of the device. | | 9200002 | the administrator application does not have permission to manage the device. | **Example** ```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "EntryAbility", }; bundleManager.getDisallowedUninstallBundles(wantTemp, 100).then((data) => { console.log("success: " + data); }).catch(error => { console.log("error code:" + error.code + " error message:" + error.message); }); ```