diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 69989d5c01c2f369c1e9adc72bc3a18105847d86..16ca26e360b85d5f7b1e73b91882c1f839fecd04 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -266,7 +266,6 @@ - [@ohos.net.socket (Socket Connection)](js-apis-socket.md) - [@ohos.net.webSocket (WebSocket Connection)](js-apis-webSocket.md) - [@ohos.request (Upload and Download)](js-apis-request.md) - - [@ohos.net.mdns (mDNS Management)](js-apis-net-mdns.md) - Connectivity - [@ohos.bluetooth (Bluetooth)(To Be Deprecated Soon)](js-apis-bluetooth.md) @@ -355,6 +354,7 @@ - Customization - [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md) - [@ohos.enterprise.accountManager (Account Management)](js-apis-enterprise-accountManager.md) + - [@ohos.enterprise.bundleManager (Bundle Management)](js-apis-enterprise-bundleManager.md) - [@ohos.enterprise.adminManager (Enterprise Device Management)](js-apis-enterprise-adminManager.md) - [@ohos.enterprise.dateTimeManager (System Time Management)](js-apis-enterprise-dateTimeManager.md) - [@ohos.enterprise.deviceControl (Device Control Management)](js-apis-enterprise-deviceControl.md) diff --git a/en/application-dev/reference/apis/js-apis-enterprise-bundleManager.md b/en/application-dev/reference/apis/js-apis-enterprise-bundleManager.md new file mode 100644 index 0000000000000000000000000000000000000000..813f551a9fa9aca4363acd222686fe4a5b728b0e --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-enterprise-bundleManager.md @@ -0,0 +1,432 @@ +# @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. + +## 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 administrator for an enterprise 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 | Target enterprise device administrator application. | +| appIds | Array<string> | Yes | Bundles to be added to the allowed bundle list. | +| callback | AsyncCallback<void> | Yes | Callback used 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 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**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 specified user for an enterprise 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 | Target enterprise device administrator application. | +| appIds | Array<string> | Yes | Bundles to be added to the allowed bundle list. | +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| +| callback | AsyncCallback<void> | Yes | Callback used 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 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**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 administrator (if **userId** is not passed in) or the specified user (if **userId** is passed in) for an enterprise 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 | Target enterprise device administrator application. | +| appIds | Array<string> | Yes | Bundles to be added to the allowed bundle list. | +| userId | number | No | User ID. The default value is the user ID of the caller. The value 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 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**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 administrator for an enterprise 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 | Target enterprise device administrator application. | +| appIds | Array<string> | Yes | Bundles to be removed from the allowed bundle list. | +| callback | AsyncCallback<void> | Yes | Callback used 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 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**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 specified user for an enterprise 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 | Target enterprise device administrator application. | +| appIds | Array<string> | Yes | Bundles to be removed from the allowed bundle list. | +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| +| callback | AsyncCallback<void> | Yes | Callback used 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 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**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 administrator (if **userId** is not passed in) or the specified user (if **userId** is passed in) for an enterprise 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 | Target enterprise device administrator application. | +| appIds | Array\<string> | Yes | Bundles to be removed from the allowed bundle list. | +| userId | number | No | User ID. The default value is the user ID of the caller. The value 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 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**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 administrator for an enterprise 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 | Target enterprise device administrator application. | +| callback | AsyncCallback<Array<string>> | Yes | Callback used 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 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**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 specified user for an enterprise 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 | Target enterprise device administrator application. | +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| +| callback | AsyncCallback<Array<string>> | Yes | Callback used 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 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**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 for an enterprise 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 | Target enterprise device administrator application.| +| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| + +**Return value** + +| Type | Description | +| --------------------- | ------------------------- | +| Promise<Array<string>> | Promise used to return the allowed bundle list.| + +**Error codes** + +For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). + +| ID| Error Message | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**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); +}); +```