From e0bd23d375fb9990bc878d6fe170f31f8bab58ab Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Wed, 16 Aug 2023 14:11:54 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../reference/apis/Readme-EN.md | 1 - .../enterpriseDeviceManagement-overview.md | 1 - .../apis/js-apis-enterprise-deviceSettings.md | 229 ------------------ .../apis/js-apis-enterprise-networkManager.md | 207 +--------------- .../apis/js-apis-enterprise-usbManager.md | 127 ---------- 5 files changed, 2 insertions(+), 563 deletions(-) delete mode 100644 en/application-dev/reference/apis/js-apis-enterprise-usbManager.md diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index b833a40103..d8fd233696 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -431,7 +431,6 @@ - [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](js-apis-EnterpriseAdminExtensionAbility.md) - [@ohos.enterprise.networkManager (Network Management)](js-apis-enterprise-networkManager.md) - [@ohos.enterprise.restrictions (Restrictions)](js-apis-enterprise-restrictions.md) - - [@ohos.enterprise.usbManager (USB Management)](js-apis-enterprise-usbManager.md) - [@ohos.enterprise.wifiManager (Wi-Fi Management)](js-apis-enterprise-wifiManager.md) - Common Library diff --git a/en/application-dev/reference/apis/enterpriseDeviceManagement-overview.md b/en/application-dev/reference/apis/enterpriseDeviceManagement-overview.md index 099e3dc841..c92c774533 100644 --- a/en/application-dev/reference/apis/enterpriseDeviceManagement-overview.md +++ b/en/application-dev/reference/apis/enterpriseDeviceManagement-overview.md @@ -42,5 +42,4 @@ OpenHarmony provides Enterprise Device Management APIs to support enterprise API - [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](js-apis-EnterpriseAdminExtensionAbility.md) - [@ohos.enterprise.networkManager (Network Management)](js-apis-enterprise-networkManager.md) - [@ohos.enterprise.restrictions (Restrictions)](js-apis-enterprise-restrictions.md) -- [@ohos.enterprise.usbManager (USB Management)](js-apis-enterprise-usbManager.md) - [@ohos.enterprise.wifiManager (Wi-Fi Management)](js-apis-enterprise-wifiManager.md) diff --git a/en/application-dev/reference/apis/js-apis-enterprise-deviceSettings.md b/en/application-dev/reference/apis/js-apis-enterprise-deviceSettings.md index 3c7a4030f2..95ba646f7e 100644 --- a/en/application-dev/reference/apis/js-apis-enterprise-deviceSettings.md +++ b/en/application-dev/reference/apis/js-apis-enterprise-deviceSettings.md @@ -108,232 +108,3 @@ deviceSettings.getScreenOffTime(wantTemp).then((result) => { console.error(`Failed to get screen off time. Code: ${err.code}, message: ${err.message}`); }); ``` - -## deviceSettings.installUserCertificate - -installUserCertificate(admin: Want, certificate: CertBlob, callback: AsyncCallback<string>): void - -Installs a user certificate through the specified device administrator application. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE - -**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. | -| certificate | [CertBlob](#certblob) | Yes | Information about the certificate to install. | -| callback | AsyncCallback<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. | -| 9201001 | manage certificate failed | - -**Example** - -```js -let wantTemp = { - bundleName: 'com.example.myapplication', - abilityName: 'EntryAbility', -}; -var certFileArray: Uint8Array; -// The variable context needs to be initialized in MainAbility's onCreate callback function -// test.cer needs to be placed in the rawfile directory -await globalThis.context.resourceManager.getRawFileContent("test.cer") - .then(value => { - certFileArray = value - }) - .catch(error => { - console.error(`Failed to get row file content. message: ${error.message}`); - return - }); -new Promise((resolve, reject) => { - deviceSettings.installUserCertificate(wantTemp, {inData: certFileArray, alias: "cert_alias_xts"}, (err, result) => { - if (err) { - console.error(`Failed to install user certificate. Code: ${err.code}, message: ${err.message}`); - } else{ - console.info(`Succeeded in installing user certificate, result : ${JSON.stringify(result)}`); - } - }); -}); -``` - -## deviceSettings.installUserCertificate - -installUserCertificate(admin: Want, certificate: CertBlob): Promise<string> - -Installs a user certificate through the specified device administrator application. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE - -**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.| -| certificate | [CertBlob](#certblob) | Yes | Information about the certificate to install. | - -**Return value** - -| Type | Description | -| --------------------- | ------------------------- | -| Promise<string> | Promise used to return the URI of the installed certificate. This URI can be used to uninstall the certificate.| - -**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. | -| 9201001 | manage certificate failed | - -**Example** - -```js -let wantTemp = { - bundleName: 'com.example.myapplication', - abilityName: 'EntryAbility', -}; -var certFileArray: Uint8Array -// The variable context needs to be initialized in MainAbility's onCreate callback function -// test.cer needs to be placed in the rawfile directory -await globalThis.context.resourceManager.getRawFileContent("test.cer") - .then(data => { - certFileArray = data - }).catch(error => { - console.log('getRawFileContent error' + error) - return - }) -deviceSettings.installUserCertificate(wantTemp, { inData: certFileArray, alias: "cert_alias_xts" }) - .then((result) => { - console.info(`Succeeded in installing user certificate, result : ${JSON.stringify(result)}`); - }).catch(err => { - console.error(`Failed to install user certificate. Code: ${err.code}, message: ${err.message}`); - }) -``` - -## CertBlob - -Represents the certificate information. - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -| Name | Type | Mandatory| Description | -| ----------- | --------| ----- | ------------------------------- | -| inData | Uint8Array | Yes| Binary content of the certificate.| -| alias | string | Yes| Certificate alias.| - -## deviceSettings.uninstallUserCertificate - -uninstallUserCertificate(admin: Want, certUri: string, callback: AsyncCallback<void>): void - -Uninstalls a user certificate through the specified device administrator application. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE - -**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. | -| certUri | string | Yes | Certificate URI, which is returned by **installUserCertificate()**. | -| 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. | -| 9201001 | manage certificate failed | - -**Example** - -```js -let wantTemp = { - bundleName: 'com.example.myapplication', - abilityName: 'EntryAbility', -}; -let aliasStr = "certName" -deviceSettings.uninstallUserCertificate(wantTemp, aliasStr, (err) => { - if (err) { - console.error(`Failed to uninstall user certificate. Code: ${err.code}, message: ${err.message}`); - return; - } - console.info(`Succeeded in uninstalling user certificate`); -}); -``` - -## deviceSettings.uninstallUserCertificate - -uninstallUserCertificate(admin: Want, certUri: string): Promise<void> - -Uninstalls a user certificate through the specified device administrator application. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE - -**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.| -| certUri | string | Yes | Certificate URI, which is returned by **installUserCertificate()**. | - -**Return value** - -| Type | Description | -| --------------------- | ------------------------- | -| Promise<void> | Promise that returns no value. An error object will be thrown if the operation fails.| - -**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. | -| 9201001 | manage certificate failed | - -**Example** - -```js -let wantTemp = { - bundleName: 'com.example.myapplication', - abilityName: 'EntryAbility', -}; -let aliasStr = "certName" -deviceSettings.uninstallUserCertificate(wantTemp, aliasStr).then(() => { - console.info(`Succeeded in uninstalling user certificate`); -}).catch((err) => { - console.error(`Failed to uninstall user certificate. Code is ${err.code}, message is ${err.message}`); -}); -``` diff --git a/en/application-dev/reference/apis/js-apis-enterprise-networkManager.md b/en/application-dev/reference/apis/js-apis-enterprise-networkManager.md index 8d4ed0a25c..db4986fa05 100644 --- a/en/application-dev/reference/apis/js-apis-enterprise-networkManager.md +++ b/en/application-dev/reference/apis/js-apis-enterprise-networkManager.md @@ -491,214 +491,11 @@ networkManager.setNetworkInterfaceDisabled(wantTemp, 'eth0', true).then(() => { }); ``` -## networkManager.setGlobalProxy - -setGlobalProxy(admin: Want, httpProxy: connection.HttpProxy, callback: AsyncCallback\): void - -Sets the global network proxy through the specified device administrator application. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK - -**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. | -| httpProxy | [connection.HttpProxy](js-apis-net-connection.md#httpproxy10) | Yes | Global HTTP proxy to set. | -| 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 application 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 exclusionStr = "192.168,baidu.com" -let exclusionArray = exclusionStr.split(','); -let httpProxy = { - host: "192.168.xx.xxx", - port: 8080, - exclusionList: exclusionArray -}; - -networkManager.setGlobalProxy(wantTemp, httpProxy, (err) => { - if (err) { - console.error(`Failed to set network global proxy. Code: ${err.code}, message: ${err.message}`); - return; - } - console.info(`Succeeded in setting network global proxy`); -}); -``` - -## networkManager.setGlobalProxy - -setGlobalProxy(admin: Want, httpProxy: connection.HttpProxy): Promise\ - -Sets the global network proxy through the specified device administrator application. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK - -**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.| -| httpProxy | [connection.HttpProxy](js-apis-net-connection.md#httpproxy10) | Yes | Global HTTP proxy to set. | -| isDisabled | boolean | Yes | Network port status to set. The value **true** means to disable the network port, and **false** means to enable the network port. | - -**Return value** - -| Type | Description | -| --------------------- | ------------------------- | -| Promise<void> | Promise that returns no value. An error object will be thrown if the operation fails. | - -**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 application 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 exclusionStr = "192.168,baidu.com" -let exclusionArray = exclusionStr.split(','); -let httpProxy = { - host: "192.168.xx.xxx", - port: 8080, - exclusionList: exclusionArray -}; - -networkManager.setGlobalProxy(wantTemp, httpProxy).then(() => { - console.info(`Succeeded in setting network global proxy`); -}).catch((err) => { - console.error(`Failed to set network global proxy. Code: ${err.code}, message: ${err.message}`); -}); -``` - -## networkManager.getGlobalProxy - -getGlobalProxy(admin: Want, callback: AsyncCallback\): void - -Obtains the global network proxy through the specified device administrator application. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK - -**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<[connection.HttpProxy](js-apis-net-connection.md#httpproxy10)> | 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 application 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', -}; - -networkManager.getGlobalProxy(wantTemp, (err, result) => { - if (err) { - console.error(`Failed to get network global proxy. Code: ${err.code}, message: ${err.message}`); - return; - } - console.info(`Succeeded in getting network global proxy, result : ${JSON.stringify(result)}`); -}); -``` - -## networkManager.getGlobalProxy - -getGlobalProxy(admin: Want): Promise\ - -Obtains the global network proxy through the specified device administrator application. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK - -**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.| - -**Return value** - -| Type | Description | -| --------------------- | ------------------------- | -| Promise<[connection.HttpProxy](js-apis-net-connection.md#httpproxy10)> | Promise used to return the global HTTP proxy information 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 application 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', -}; - -networkManager.getGlobalProxy(wantTemp).then(() => { - console.info(`Succeeded in getting network global proxy`); -}).catch((err) => { - console.error(`Failed to get network global proxy. Code: ${err.code}, message: ${err.message}`); -}); -``` - ## networkManager.addIptablesFilterRule addIptablesFilterRule(admin: Want, filterRule: AddFilterRule, callback: AsyncCallback\): void -Adds a network packet filtering rule through the specified device administrator application. This API uses an asynchronous callback to return the result. +Adds a network packet filtering rule for devices through the specified device administrator application. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK @@ -756,7 +553,7 @@ networkManager.addIptablesFilterRule(wantTemp, filterRule, (err) => { addIptablesFilterRule(admin: Want, filterRule: AddFilterRule): Promise\ -Adds a network packet filtering rule through the specified device administrator application. This API uses a promise to return the result. +Adds a network packet filtering rule for devices through the specified device administrator application. This API uses a promise to return the result. **Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK diff --git a/en/application-dev/reference/apis/js-apis-enterprise-usbManager.md b/en/application-dev/reference/apis/js-apis-enterprise-usbManager.md deleted file mode 100644 index 0b67680727..0000000000 --- a/en/application-dev/reference/apis/js-apis-enterprise-usbManager.md +++ /dev/null @@ -1,127 +0,0 @@ -# @ohos.enterprise.usbManager (USB Management) - -The **usbManager** module provides APIs for USB management. - -> **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 used only in the stage model. -> -> The APIs provided by this module can be called only by a [device administrator application](enterpriseDeviceManagement-overview.md#basic-concepts) that is [enabled](js-apis-enterprise-adminManager.md#adminmanagerenableadmin). - -## Modules to Import - -```js -import usbManager from '@ohos.enterprise.usbManager' -``` - -## usbManager.setUsbPolicy - -setUsbPolicy(admin: Want, usbPolicy: UsbPolicy, callback: AsyncCallback\): void - -Sets the USB read/write policy through the specified device administrator application. This API uses an asynchronous callback to return the result. - -Required permissions: ohos.permission.ENTERPRISE_MANAGE_USB - -**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.| -| usbPolicy | [UsbPolicy](#usbpolicy) | Yes| USB read/write policy to set.| -| callback | AsyncCallback\ | 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: 'bundleName', - abilityName: 'abilityName', -}; -let policy = usbManager.UsbPolicy.READ_WRITE - -usbManager.setUsbPolicy(wantTemp, policy, (err) => { - if (err) { - console.error(`Failed to set usb policy. Code is ${err.code}, message is ${err.message}`); - return; - } - console.info('Succeeded in setting usb policy'); -}) -``` - -## usbManager.setUsbPolicy - -setUsbPolicy(admin: Want, usbPolicy: UsbPolicy): Promise\ - -Sets the USB read/write policy through the specified device administrator application. This API uses a promise to return the result. - -Required permissions: ohos.permission.ENTERPRISE_MANAGE_USB - -**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.| -| usbPolicy | [UsbPolicy](#usbpolicy) | Yes| USB read/write policy to set.| - -**Return value** - -| Type | Description | -| ----- | ----------------------------------- | -| Promise\ | Promise that returns no value. An error object will be thrown if the operation fails.| - -**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: 'bundleName', - abilityName: 'abilityName', -}; -let policy = usbManager.UsbPolicy.READ_WRITE - -usbManager.setUsbPolicy(wantTemp, policy).then(() => { - console.info('Succeeded in setting usb policy'); -}).catch((err) => { - console.error(`Failed to set usb policy. Code is ${err.code}, message is ${err.message}`); -}) -``` - -## UsbPolicy - -Enumerates the USB read/write policies. - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -| Name| Value| Description| -| -------- | -------- | -------- | -| READ_WRITE | 0 | The USB is readable and writable.| -| READ_ONLY | 1 | The USB is read-only.| -- GitLab