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

!14838 【EDM】新增网络管理接口文档

Merge pull request !14838 from 方昀/dev_network
......@@ -19,8 +19,8 @@
- [@ohos.application.DataShareExtensionAbility (数据共享扩展能力)](js-apis-application-dataShareExtensionAbility.md)
- [@ohos.application.StaticSubscriberExtensionAbility (StaticSubscriberExtensionAbility)](js-apis-application-staticSubscriberExtensionAbility.md)
- Stage模型能力的接口(待停用)
- [@ohos.application.Ability (Ability)](js-apis-application-ability.md)
- [@ohos.application.AbilityLifecycleCallback (AbilityLifecycleCallback)](js-apis-application-abilityLifecycleCallback.md)
- [@ohos.application.Ability (Ability)](js-apis-app-ability-ability.md)
- [@ohos.application.AbilityLifecycleCallback (AbilityLifecycleCallback)](js-apis-app-ability-abilityLifecycleCallback.md)
- [@ohos.application.EnvironmentCallback (EnvironmentCallback)](js-apis-application-environmentCallback.md)
- FA模型能力的接口
- [@ohos.ability.ability (Ability)](js-apis-ability-ability.md)
......@@ -53,7 +53,7 @@
- [@ohos.application.appManager (appManager)](js-apis-application-appManager.md)
- [@ohos.application.Configuration (Configuration)](js-apis-application-configuration.md)
- [@ohos.application.ConfigurationConstant (ConfigurationConstant)](js-apis-application-configurationConstant.md)
- [@ohos.application.errorManager (ErrorManager)](js-apis-application-errorManager.md)
- [@ohos.application.errorManager (ErrorManager)](js-apis-app-ability-errorManager.md)
- [@ohos.application.formBindingData (卡片数据绑定类)](js-apis-application-formBindingData.md)
- [@ohos.application.formError (FormError)](js-apis-application-formError.md)
- [@ohos.application.formHost (FormHost)](js-apis-application-formHost.md)
......@@ -76,7 +76,7 @@
- [context](js-apis-inner-app-context.md)
- [processInfo](js-apis-inner-app-processInfo.md)
- application
- [AbilityContext](js-apis-ability-context.md)
- [AbilityContext](js-apis-inner-application-uiAbilityContext.md)
- [abilityDelegator](js-apis-inner-application-abilityDelegator.md)
- [abilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md)
- [abilityMonitor](js-apis-inner-application-abilityMonitor.md)
......@@ -338,6 +338,8 @@
- [@ohos.enterprise.dateTimeManager (系统时间管理)](js-apis-enterprise-dateTimeManager.md)
- [@ohos.enterprise.deviceControl (设备控制管理)](js-apis-enterprise-deviceControl.md)
- [@ohos.enterprise.wifiManager (WiFi管理)](js-apis-enterprise-wifiManager.md)
- [@ohos.enterprise.accountManager (账户管理)](js-apis-enterprise-accountManager.md)
- [@ohos.enterprise.networkManager (网络管理)](js-apis-enterprise-networkManager.md)
- 语言基础类库
- [@ohos.buffer (Buffer)](js-apis-buffer.md)
......
# @ohos.enterprise.accountManager(账户管理)
本模块提供设备账户管理能力,包括禁止创建本地用户等。仅企业设备管理员应用才能调用。
> **说明:**
>
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```js
import accountManager from '@ohos.enterprise.accountManager';
```
## accountManager.disallowAddLocalAccount
disallowAddLocalAccount(admin: Want, disallow: boolean, callback: AsyncCallback<void>): void
是否禁止创建本地用户接口,使用callback异步回调。
**需要权限:** ohos.permission.ENTERPRISE_SET_ACCOUNT_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 |
| disallow | boolean | 是 | 是否禁止创建本地用户,true表示禁止,false表示解除禁止。 |
| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```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>
是否禁止创建本地用户,使用promise异步回调。
**需要权限:** ohos.permission.ENTERPRISE_SET_ACCOUNT_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 |
| disallow | boolean | 是 | 是否禁止创建本地用户,true表示禁止,false表示解除禁止。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise<void> | 无返回结果的Promise对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```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);
});
```
# @ohos.enterprise.networkManager(网络管理)
本模块提供设备网络管理能力,包括查询设备IP地址、MAC地址信息等。仅企业设备管理员应用才能调用。
> **说明:**
>
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```js
import networkManager from '@ohos.enterprise.networkManager';
```
## networkManager.getAllNetworkInterfaces
getAllNetworkInterfaces(admin: Want, callback: AsyncCallback<Array<string>>): void
获取所有活动的网络接口,使用callback形式返回网络接口名称数组。
**需要权限:** ohos.permission.GET_NETWORK_INFO
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 |
| callback | AsyncCallback<Array<string>> | 是 | callback方式返回网络接口名称数组 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```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>>
获取所有活动的网络接口,使用promise形式返回网络接口名称数组。
**需要权限:** ohos.permission.ENTERPRISE_GET_NETWORK_INFO
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise<Array<string>> | Promise方式返回网络接口名称数组 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```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
获取设备IP地址,使用callback形式返回设备IP地址。
**需要权限:** ohos.permission.GET_NETWORK_INFO
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 |
| networkInterface | string | 是 | 指定网络接口 |
| callback | AsyncCallback<string> | 是 | callback方式返回设备IP地址 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```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>
获取设备IP地址,使用promise形式返回设备IP地址。
**需要权限:** ohos.permission.ENTERPRISE_GET_NETWORK_INFO
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 |
| networkInterface | string | 是 | 指定网络接口 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise<string> | Promise方式返回设备IP地址 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```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
获取设备MAC地址,使用callback形式返回设备MAC地址。
**需要权限:** ohos.permission.ENTERPRISE_GET_NETWORK_INFO
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 |
| networkInterface | string | 是 | 指定网络接口 |
| callback | AsyncCallback<string> | 是 | callback方式返回设备MAC地址 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```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>
获取设备MAC地址,使用promise形式返回设备IP地址。
**需要权限:** ohos.permission.ENTERPRISE_GET_NETWORK_INFO
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 |
| networkInterface | string | 是 | 指定网络接口 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise<string> | Promise方式返回设备MAC地址 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```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);
});
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册