未验证 提交 bdef0994 编写于 作者: O openharmony_ci 提交者: Gitee

!22359 [翻译完成】#I7OYPT

Merge pull request !22359 from Annie_wang/PR21553
......@@ -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
......
......@@ -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)
......@@ -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}`);
});
```
......@@ -491,214 +491,11 @@ networkManager.setNetworkInterfaceDisabled(wantTemp, 'eth0', true).then(() => {
});
```
## networkManager.setGlobalProxy
setGlobalProxy(admin: Want, httpProxy: connection.HttpProxy, callback: AsyncCallback\<void>): 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&lt;void&gt; | 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\<void>
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&lt;void&gt; | 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\<connection.HttpProxy>): 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&lt;[connection.HttpProxy](js-apis-net-connection.md#httpproxy10)&gt; | 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\<connection.HttpProxy>
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&lt;[connection.HttpProxy](js-apis-net-connection.md#httpproxy10)&gt; | 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>): 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\<void>
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
......
# @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>): 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\<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: '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\<void>
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\<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. |
**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.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册