From 2690515bf8f527dbbda2e41271f5049d92125bf4 Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Mon, 29 May 2023 20:33:11 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../reference/apis/Readme-EN.md | 1 + .../js-apis-enterprise-applicationManager.md | 434 ++++++++++++++++++ 2 files changed, 435 insertions(+) create mode 100644 en/application-dev/reference/apis/js-apis-enterprise-applicationManager.md diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index b942d5aa2a..63a868c4d5 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -365,6 +365,7 @@ - [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md) - [@ohos.enterprise.accountManager (Account Management)](js-apis-enterprise-accountManager.md) - [@ohos.enterprise.adminManager (Enterprise Device Management)](js-apis-enterprise-adminManager.md) + - [@ohos.enterprise.applicationManager (Application Management)](js-apis-enterprise-applicationManager.md) - [@ohos.enterprise.bundleManager (Bundle Management)](js-apis-enterprise-bundleManager.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-applicationManager.md b/en/application-dev/reference/apis/js-apis-enterprise-applicationManager.md new file mode 100644 index 0000000000..0f9d2852f8 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-enterprise-applicationManager.md @@ -0,0 +1,434 @@ +# @ohos.enterprise.applicationManager (Application Management) + +The **applicationManager** module provides application management capabilities, including adding applications to or removing applications from an application blocklist, and obtaining the application blocklist. The application blocklist contains the applications that are forbidden to run. 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 applicationManager from '@ohos.enterprise.applicationManager'; +``` + +## applicationManager.addDisallowedRunningBundles + +addDisallowedRunningBundles(admin: Want, appIds: Array\, callback: AsyncCallback<void>): void; + +Adds applications to the application blocklist using the specified device administrator application. This API uses an asynchronous callback to return the result. The applications added to the blocklist cannot run under the administrator user. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_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 | IDs of the applications to add. | +| 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"]; + +applicationManager.addDisallowedRunningBundles(wantTemp, appIds, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## applicationManager.addDisallowedRunningBundles + +addDisallowedRunningBundles(admin: Want, appIds: Array\, userId: number, callback: AsyncCallback<void>): void; + +Adds applications to the application list for a user using the specified device administrator application. This API uses an asynchronous callback to return the result. The applications added to the blocklist cannot run under the user specified by **userId**. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_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 | IDs of the applications to add. | +| 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"]; + +applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## applicationManager.addDisallowedRunningBundles + +addDisallowedRunningBundles(admin: Want, appIds: Array\, userId?: number): Promise<void>; + +Adds applications to the application blocklist using the specified device administrator application. This API uses a promise to return the result. If **userId** is passed in when this API is called, the added applications cannot run under the specified user. If **userId** is not passed in, the added applications cannot run under the current user. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_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 | IDs of the applications to add. | +| 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. An error object is thrown when the applications fail to be added. | + +**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"]; + +applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100).then(() => { + console.log("success"); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.message); +}); +``` + +## applicationManager.removeDisallowedRunningBundles + +removeDisallowedRunningBundles(admin: Want, appIds: Array\, callback: AsyncCallback<void>): void; + +Removes applications from the application blocklist using the specified device administrator application. This API uses an asynchronous callback to return the result. If an application blocklist exists, the applications in the blocklist cannot run under the current user. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_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 | IDs of the applications to remove. | +| 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"]; + +applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## applicationManager.removeDisallowedRunningBundles + +removeDisallowedRunningBundles(admin: Want, appIds: Array\, userId: number, callback: AsyncCallback<void>): void; + +Removes applications from the application blocklist of a user using the specified device administrator application. This API uses an asynchronous callback to return the result. If an application blocklist exists, the applications in the blocklist cannot run under the user specified by **userId**. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_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 | IDs of the applications to remove. | +| 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"]; + +applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## applicationManager.removeDisallowedRunningBundles + +removeDisallowedRunningBundles(admin: Want, appIds: Array\, userId?: number): Promise<void>; + +Removes applications from the application blocklist using the specified device administrator application. This API uses a promise to return the result. If **userId** is passed in when this API is called to remove applications from the blocklist, the applications in the blocklist cannot run under the specified user. If **userId** is not passed in, the applications in the blocklist cannot run under the current user. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_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 | IDs of the applications to remove. | +| 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. An error object is thrown when the applications fail to be removed. | + +**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"]; + +applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100).then(() => { + console.log("success"); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.message); +}); +``` + +## applicationManager.getDisallowedRunningBundles + +getDisallowedRunningBundles(admin: Want, callback: AsyncCallback<Array<string>>): void; + +Obtains the application blocklist of the administrator user using the specified device administrator application. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_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", +}; + +applicationManager.getDisallowedRunningBundles(wantTemp, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## applicationManager.getDisallowedRunningBundles + +getDisallowedRunningBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void; + +Obtains the application blocklist of a user using the specified device administrator application. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_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", +}; + +applicationManager.getDisallowedRunningBundles(wantTemp, 100, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## applicationManager.getDisallowedRunningBundles + +getDisallowedRunningBundles(admin: Want, userId?: number): Promise<Array<string>>; + +Obtains the application blocklist using the specified device administrator application. This API uses a promise to return the result. If **userId** is passed in when this API is called, the device administrator application obtains the application blocklist of the specified user. If **userId** is not passed in, the device administrator application obtains the application blocklist of the current user. + +**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_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 application blocklist of the administrator user.| + +**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", +}; +applicationManager.getDisallowedRunningBundles(wantTemp, 100).then(() => { + console.log("success"); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.message); +}); +``` -- GitLab