Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
d490f0f7
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d490f0f7
编写于
2月 18, 2023
作者:
F
fangyun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增网络管理接口文档
Signed-off-by:
N
fangyun
<
fangyun2@huawei.com
>
上级
ec2a3982
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
292 addition
and
1 deletion
+292
-1
zh-cn/application-dev/reference/apis/Readme-CN.md
zh-cn/application-dev/reference/apis/Readme-CN.md
+2
-1
zh-cn/application-dev/reference/apis/js-apis-enterprise-networkManager.md
...n-dev/reference/apis/js-apis-enterprise-networkManager.md
+290
-0
未找到文件。
zh-cn/application-dev/reference/apis/Readme-CN.md
浏览文件 @
d490f0f7
# 接口
# 接口
-
[
开发说明
](
development-intro.md
)
-
[
开发说明
](
development-intro.md
)
...
@@ -336,6 +336,7 @@
...
@@ -336,6 +336,7 @@
-
[
@ohos.enterprise.adminManager (企业设备管理)
](
js-apis-enterprise-adminManager.md
)
-
[
@ohos.enterprise.adminManager (企业设备管理)
](
js-apis-enterprise-adminManager.md
)
-
[
@ohos.enterprise.dateTimeManager (系统时间管理)
](
js-apis-enterprise-dateTimeManager.md
)
-
[
@ohos.enterprise.dateTimeManager (系统时间管理)
](
js-apis-enterprise-dateTimeManager.md
)
-
[
@ohos.enterprise.deviceControl (设备控制管理)
](
js-apis-enterprise-deviceControl.md
)
-
[
@ohos.enterprise.deviceControl (设备控制管理)
](
js-apis-enterprise-deviceControl.md
)
-
[
@ohos.enterprise.networkManager (网络管理)
](
js-apis-enterprise-networkManager.md
)
-
语言基础类库
-
语言基础类库
-
[
@ohos.buffer (Buffer)
](
js-apis-buffer.md
)
-
[
@ohos.buffer (Buffer)
](
js-apis-buffer.md
)
...
...
zh-cn/application-dev/reference/apis/js-apis-enterprise-networkManager.md
0 → 100644
浏览文件 @
d490f0f7
# @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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录