diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 0de7d46e88f8a4d568593616b1bf73bf4c44b95e..260dc2ba2f6c92a30cac9799bf4bb36233a93651 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -319,11 +319,14 @@ - [@ohos.account.osAccount (OS Account Management)](js-apis-osAccount.md) - Custom Management - [@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.dateTimeManager (System Time Management)](js-apis-enterprise-dateTimeManager.md) - [@ohos.enterprise.deviceControl (Device Control Management)](js-apis-enterprise-deviceControl.md) - [@ohos.enterprise.deviceInfo (Device Information Management)](js-apis-enterprise-deviceInfo.md) - [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](js-apis-EnterpriseAdminExtensionAbility.md) + - [@ohos.enterprise.networkManager (Network Management)](js-apis-enterprise-networkManager.md) + - [@ohos.enterprise.wifiManager (Wi-Fi Management)](js-apis-enterprise-wifiManager.md) - Language Base Class Library - [@ohos.buffer (Buffer)](js-apis-buffer.md) diff --git a/en/application-dev/reference/apis/js-apis-enterprise-accountManager.md b/en/application-dev/reference/apis/js-apis-enterprise-accountManager.md new file mode 100644 index 0000000000000000000000000000000000000000..6910779cd902d3368ad743ef1f6e4e179f2caf19 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-enterprise-accountManager.md @@ -0,0 +1,104 @@ +# @ohos.enterprise.accountManager (Account Management) + +The **accountManager** module provides account management capabilities for enterprise devices. 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 accountManager from '@ohos.enterprise.accountManager'; +``` + +## accountManager.disallowAddLocalAccount + +disallowAddLocalAccount(admin: Want, disallow: boolean, callback: AsyncCallback<void>): void + +Disallows local accounts. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.ENTERPRISE_SET_ACCOUNT_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. | +| disallow | boolean | Yes | Whether to disallow local accounts. The value **true** means disallow local accounts; the value **false** means the opposite. | +| 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", +}; +accountManager.disallowAddLocalAccount(admin, true, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## accountManager.disallowAddLocalAccount + +disallowAddLocalAccount(admin: Want, disallow: boolean): Promise<void> + +Disallows local accounts. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.ENTERPRISE_SET_ACCOUNT_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.| +| disallow | boolean | Yes | Whether to disallow local accounts. The value **true** means disallow local accounts; the value **false** means the opposite. | + +**Return value** + +| Type | Description | +| --------------------- | ------------------------- | +| Promise<void> | Promise that returns no value. | + +**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", +}; +accountManager.disallowAddLocalAccount(wantTemp, true).then(() => { + console.log("success"); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.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 new file mode 100644 index 0000000000000000000000000000000000000000..8e527defb2e34a3269b08f19c6bbd049569cff2e --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-enterprise-networkManager.md @@ -0,0 +1,290 @@ +# @ohos.enterprise.networkManager (Network Management) + +The **networkManager** module provides network management capabilities for enterprise devices, including obtaining the device IP address and MAC address. 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 networkManager from '@ohos.enterprise.networkManager'; +``` + +## networkManager.getAllNetworkInterfaces + +getAllNetworkInterfaces(admin: Want, callback: AsyncCallback<Array<string>>): void + +Obtains all active network interfaces. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.GET_NETWORK_INFO + +**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 active network interfaces 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.getAllNetworkInterfaces(admin, (error, result) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + return; + } + console.log(JSON.stringify(result)); +}); +``` + +## networkManager.getAllNetworkInterfaces + +getAllNetworkInterfaces(admin: Want): Promise<Array<string>> + +Obtains all active network interfaces. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.ENTERPRISE_GET_NETWORK_INFO + +**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<Array<string>> | Promise used to return the active network interfaces 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.getAllNetworkInterfaces(wantTemp).then((result) => { + console.log(JSON.stringify(result)); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.message); +}); +``` + +## networkManager.getIpAddress + +getIpAddress(admin: Want, networkInterface: string, callback: AsyncCallback<string>): void + +Obtains the IP address of a device. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.GET_NETWORK_INFO + +**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. | +| networkInterface | string | Yes | Network interface. | +| callback | AsyncCallback<string> | Yes | Callback invoked to return the device IP address 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.getIpAddress(wantTemp, "eth0", (error, result) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + return; + } + console.log(result); +}); +``` + +## networkManager.getIpAddress + +getIpAddress(admin: Want, networkInterface: string): Promise<string> + +Obtains the IP address of a device. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.ENTERPRISE_GET_NETWORK_INFO + +**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.| +| networkInterface | string | Yes | Network interface. | + +**Return value** + +| Type | Description | +| --------------------- | ------------------------- | +| Promise<string> | Promise used to return the device IP address 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.getIpAddress(wantTemp, "eth0").then((result) => { + console.log(result); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.message); +}); +``` + +## networkManager.getMac + +getMac(admin: Want, networkInterface: string, callback: AsyncCallback<string>): void + +Obtains the MAC address of a device. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.ENTERPRISE_GET_NETWORK_INFO + +**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. | +| networkInterface | string | Yes | Network interface. | +| callback | AsyncCallback<string> | Yes | Callback invoked to return the device MAC address 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.getMac(wantTemp, "eth0", (error, result) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + return; + } + console.log(result); +}); +``` + +## networkManager.getMac + +getIpAddress(admin: Want, networkInterface: string): Promise<string> + +Obtains the MAC address of a device. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.ENTERPRISE_GET_NETWORK_INFO + +**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.| +| networkInterface | string | Yes | Network interface. | + +**Return value** + +| Type | Description | +| --------------------- | ------------------------- | +| Promise<string> | Promise used to return the device MAC address 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.getMac(wantTemp, "eth0").then((result) => { + console.log(result); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.message); +}); +``` diff --git a/en/application-dev/reference/apis/js-apis-enterprise-wifiManager.md b/en/application-dev/reference/apis/js-apis-enterprise-wifiManager.md new file mode 100644 index 0000000000000000000000000000000000000000..44ed633f182665681e3dbb844c38406113bf9ff7 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-enterprise-wifiManager.md @@ -0,0 +1,104 @@ +# @ohos.enterprise.wifiManager (Wi-Fi Management) + +The **wifiManager** module provides Wi-Fi management capabilities for enterprise devices. 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 wifiManager from '@ohos.enterprise.wifiManager'; +``` + +## wifiManager.isWifiActive + +isWifiActive(admin: Want, callback: AsyncCallback<boolean>): void + +Checks whether Wi-Fi is enabled. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.ENTERPRISE_SET_WIFI + +**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<boolean> | Yes | Callback invoked to return whether Wi-Fi is enabled. | + +**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", +}; +wifiManager.isWifiActive(wantTemp, (error, result) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + return; + } + console.log(result); +}); +``` + +## wifiManager.isWifiActive + +isWifiActive(admin: Want): Promise<boolean> + +Checks whether Wi-Fi is active. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.ENTERPRISE_SET_WIFI + +**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<boolean> | Promise used to return whether Wi-Fi is active. | + +**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", +}; +wifiManager.isWifiActive(wantTemp).then((result) => { + console.log(result); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.message); +}); +```