Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
249901ce
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
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看板
提交
249901ce
编写于
6月 28, 2023
作者:
史
史晓晓
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改接口
Signed-off-by:
N
史晓晓
<
shixiaoxiao.30044129@huawei.com
>
上级
5265522d
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
72 addition
and
532 deletion
+72
-532
zh-cn/application-dev/reference/apis/js-apis-distributedDeviceManager.md
...on-dev/reference/apis/js-apis-distributedDeviceManager.md
+44
-494
zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/changelogs-distributedDeviceManager.md
...penHarmony_4.0.9.2/changelogs-distributedDeviceManager.md
+28
-38
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-distributedDeviceManager.md
浏览文件 @
249901ce
...
...
@@ -10,9 +10,6 @@
-
查询可信设备列表
-
查询本地设备信息,包括设备名称,设备类型和设备标识
系统应用可调用接口实现如下功能:
-
发布设备发现
> **说明:**
>
...
...
@@ -84,36 +81,6 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager
| UNAVAILABLE | 2 | 设备物理下线,此时状态未知。 |
## DiscoverMode
表示发现模式的枚举。
**系统能力**
:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
**系统API**
: 此接口为系统接口。
| 名称 | 值 | 说明 |
| --------------------- | ---- | ----- |
| DISCOVER_MODE_PASSIVE | 0x55 | 被动模式。 |
| DISCOVER_MODE_ACTIVE | 0xAA | 主动模式。 |
## ExchangeFreq
表示发现频率的枚举。
**系统能力**
:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
**系统API**
: 此接口为系统接口。
| 名称 | 值 | 说明 |
| ---------- | ---- | ----- |
| LOW | 0 | 低频率。 |
| MID | 1 | 中频率。 |
| HIGH | 2 | 高频率。 |
| SUPER_HIGH | 3 | 超高频率。 |
## BindParam
认证参数。
...
...
@@ -123,36 +90,8 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager
| 名称 | 类型 | 必填 | 说明 |
| --------- | -------------------- | ---- | ---------- |
| bindType | number | 是 | 认证类型。 |
| extraInfo | {[key:string]
:
any
} | 否 | 认证参数可扩展字段。可选,默认为undefined。 |
| extraInfo | {[key:string]
:
Object
} | 否 | 认证参数可扩展字段。可选,默认为undefined。 |
## AuthInfo
认证信息。
**系统能力**
:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
**系统API**
: 此接口为系统接口。
| 名称 | 类型 | 必填 | 说明 |
| --------- | -------------------- | ---- | ---------- |
| authType | number | 是 | 认证类型。 |
| token | number | 是 | 认证Token。 |
| extraInfo | {[key:string]
:
any} | 否 | 认证信息可扩展字段。可选,默认为undefined。 |
## PublishInfo
发布设备参数
**系统能力**
:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
**系统API**
: 此接口为系统接口。
| 名称 | 类型 | 必填 | 说明 |
| ------------- | --------------------------------- | ---- | ----------------- |
| publishId | number | 是 | 发布设备标识,用于标识不同的发布周期。 |
| mode |
[
DiscoverMode
](
#discovermode
)
| 是 | 发现模式。 |
| freq |
[
ExchangeFreq
](
#exchangefreq
)
| 是 | 发现频率。 |
| ranging | boolean | 是 | 发布的设备是否支持测距能力。 |
## DeviceManager
...
...
@@ -520,9 +459,9 @@ getDeviceTypeSync(networkId: string): number;
}
```
### startD
eviceDiscovery
### startD
iscovering
startD
eviceDiscovery
(subscribeId: number, filterOptions?: string): void;
startD
iscovering
(subscribeId: number, filterOptions?: string): void;
发现周边设备。发现状态持续两分钟,超过两分钟,会停止发现,最大发现数量99个。
...
...
@@ -561,15 +500,15 @@ startDeviceDiscovery(subscribeId: number, filterOptions?: string): void;
]
};
try
{
dmInstance
.
startD
eviceDiscovery
(
subscribeId
,
filterOptions
);
// 当有设备发现时,通过deviceFound
回调通知给应用程序
dmInstance
.
startD
iscovering
(
subscribeId
,
filterOptions
);
// 当有设备发现时,通过discoverSuccess
回调通知给应用程序
}
catch
(
err
)
{
console
.
error
(
"
startD
eviceDiscovery
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
startD
iscovering
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
### stopD
eviceDiscovery
### stopD
iscovering
stopD
eviceDiscovery
(subscribeId: number): void;
stopD
iscovering
(subscribeId: number): void;
停止发现周边设备。
...
...
@@ -595,100 +534,17 @@ stopDeviceDiscovery(subscribeId: number): void;
```
js
try
{
// stopD
eviceDiscovery和startDeviceDiscovery需配对使用,入参需要和startDeviceDiscovery
接口传入的subscribeId值相等
// stopD
iscovering和startDiscovering需配对使用,入参需要和startDiscovering
接口传入的subscribeId值相等
var
subscribeId
=
12345
;
dmInstance
.
stopD
eviceDiscovery
(
subscribeId
);
dmInstance
.
stopD
iscovering
(
subscribeId
);
}
catch
(
err
)
{
console
.
error
(
"
stopD
eviceDiscovery
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
stopD
iscovering
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
### publishDeviceDiscovery
publishDeviceDiscovery(publishInfo: PublishInfo): void;
### bindTarget
发布设备发现。发布状态持续两分钟,超过两分钟会停止发布。
**需要权限**
:ohos.permission.ACCESS_SERVICE_DM
**系统能力**
:SystemCapability.DistributedHardware.DeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------- | ---- | ----- |
| publishInfo |
[
PublishInfo
](
#publishinfo
)
| 是 | 发布设备发现信息。 |
**错误码:**
以下的错误码的详细介绍请参见
[
设备管理错误码
](
../errorcodes/errorcode-device-manager.md
)
| 错误码ID | 错误信息 |
| -------- | --------------------------------------------------------------- |
| 11600101 | Failed to execute the function. |
| 11600105 | Publish invalid. |
**示例:**
```
js
// 生成发布标识,随机数确保每次调用发布接口的标识不一致
var
publishId
=
Math
.
floor
(
Math
.
random
()
*
10000
+
1000
);
var
publishInfo
=
{
"
publishId
"
:
publishId
,
"
mode
"
:
0xAA
,
// 主动模式
"
freq
"
:
2
,
// 高频率
"
ranging
"
:
true
// 支持发现时测距
};
try
{
dmInstance
.
publishDeviceDiscovery
(
publishInfo
);
// 当有发布结果时,通过回调通知给应用程序
}
catch
(
err
)
{
console
.
error
(
"
publishDeviceDiscovery errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
### unPublishDeviceDiscovery
unPublishDeviceDiscovery(publishId: number): void;
停止发布设备发现。
**需要权限**
:ohos.permission.ACCESS_SERVICE_DM
**系统能力**
:SystemCapability.DistributedHardware.DeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | -------- | ---- | ----- |
| publishId | number | 是 | 发布标识。 |
**错误码:**
以下的错误码的详细介绍请参见
[
设备管理错误码
](
../errorcodes/errorcode-device-manager.md
)
| 错误码ID | 错误信息 |
| -------- | --------------------------------------------------------------- |
| 11600101 | Failed to execute the function. |
**示例:**
```
js
try
{
// unPublishDeviceDiscovery和publishDeviceDiscovery配对使用,入参需要和publishDeviceDiscovery接口传入的publishId值相等
var
publishId
=
12345
;
dmInstance
.
unPublishDeviceDiscovery
(
publishId
);
}
catch
(
err
)
{
console
.
error
(
"
unPublishDeviceDiscovery errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
### bindDevice
bindDevice(deviceId: string, bindParam: BindParam, callback: AsyncCallback
<
{deviceId: string}
>
): void;
bindTarget(deviceId: string, bindParam: BindParam, callback: AsyncCallback
<
{deviceId: string}
>
): void;
认证设备。
...
...
@@ -729,21 +585,21 @@ bindDevice(deviceId: string, bindParam: BindParam, callback: AsyncCallback<{d
'
extraInfo
'
:
extraInfo
}
try
{
dmInstance
.
bind
Device
(
deviceId
,
authParam
,
(
err
,
data
)
=>
{
dmInstance
.
bind
Target
(
deviceId
,
authParam
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
"
bind
Device
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
bind
Target
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
return
;
}
console
.
info
(
"
bind
Device
result:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
bind
Target
result:
"
+
JSON
.
stringify
(
data
));
});
}
catch
(
err
)
{
console
.
error
(
"
bind
Device
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
bind
Target
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
### unbind
Device
### unbind
Target
unbind
Device
(deviceId: string): void;
unbind
Target
(deviceId: string): void;
解除认证设备。
...
...
@@ -770,65 +626,17 @@ unbindDevice(deviceId: string): void;
```
js
try
{
var
deviceId
=
"
XXXXXXXX
"
;
dmInstance
.
unbindDevice
(
deviceId
);
}
catch
(
err
)
{
console
.
error
(
"
unbindDevice errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
### verifyAuthInfo
verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback
<
{deviceId: string, level: number}
>
): void;
验证认证信息。
**需要权限**
:ohos.permission.ACCESS_SERVICE_DM
**系统能力**
:SystemCapability.DistributedHardware.DeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------- |
| authInfo |
[
AuthInfo
](
#authinfo
)
| 是 | 认证信息。 |
| callback | AsyncCallback
<
{deviceId:
string,
level:
number}
>
| 是 | 验证结果回调。 |
**错误码:**
以下的错误码的详细介绍请参见
[
设备管理错误码
](
../errorcodes/errorcode-device-manager.md
)
| 错误码ID | 错误信息 |
| -------- | --------------------------------------------------------------- |
| 11600101 | Failed to execute the function. |
**示例:**
```
js
let
authInfo
=
{
"
authType
"
:
1
,
"
token
"
:
123456
,
"
extraInfo
"
:
{}
}
try
{
dmInstance
.
verifyAuthInfo
(
authInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
"
verifyAuthInfo errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
return
;
}
console
.
info
(
"
verifyAuthInfo result:
"
+
JSON
.
stringify
(
data
));
});
dmInstance
.
unbindTarget
(
deviceId
);
}
catch
(
err
)
{
console
.
error
(
"
verifyAuthInfo
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
unbindTarget
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
###
setUserOpera
tion
###
replyUiAc
tion
setUserOperation(operateA
ction: number, params: string): void;
replyUiAction(a
ction: number, params: string): void;
设置
用户ui操作行为。
回复
用户ui操作行为。
**需要权限**
:ohos.permission.ACCESS_SERVICE_DM
...
...
@@ -840,7 +648,7 @@ setUserOperation(operateAction: number, params: string): void;
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | --------------- | ---- | ------------------- |
|
operateAction
| number | 是 | 用户操作动作。 |
|
action
| number | 是 | 用户操作动作。 |
| params | string | 是 | 表示用户的输入参数。 |
**示例:**
...
...
@@ -848,159 +656,25 @@ setUserOperation(operateAction: number, params: string): void;
```
js
try
{
/*
operateA
ction = 0 - 允许授权
operateA
ction = 1 - 取消授权
operateA
ction = 2 - 授权框用户操作超时
operateA
ction = 3 - 取消pin码框展示
operateA
ction = 4 - 取消pin码输入框展示
operateA
ction = 5 - pin码输入框确定操作
a
ction = 0 - 允许授权
a
ction = 1 - 取消授权
a
ction = 2 - 授权框用户操作超时
a
ction = 3 - 取消pin码框展示
a
ction = 4 - 取消pin码输入框展示
a
ction = 5 - pin码输入框确定操作
*/
let
operation
=
0
;
dmInstance
.
setUserOpera
tion
(
operation
,
"
extra
"
)
dmInstance
.
replyUiAc
tion
(
operation
,
"
extra
"
)
}
catch
(
err
)
{
console
.
error
(
"
setUserOpera
tion errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
replyUiAc
tion errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
###
requestCredentialRegisterInfo
###
on('replyResult')
requestCredentialRegisterInfo(requestInfo: string, callback: AsyncCallback
<
{registerInfo
: string}
>
): void;
on(type: 'replyResult', callback: Callback
<
{ param
: string}
>
): void;
获取凭据的注册信息。
**需要权限**
:ohos.permission.ACCESS_SERVICE_DM
**系统能力**
:SystemCapability.DistributedHardware.DeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | --------------- | ---- | ------------------- |
| requestInfo | string | 是 | 请求凭据信息。 |
| callback | AsyncCallback
<
{registerInfo: string}
>
| 是 | 凭据的注册信息回调。 |
**示例:**
```
js
let
credentialInfo
=
{
"
version
"
:
"
1.2.3
"
,
"
userId
"
:
"
123
"
}
try
{
dmInstance
.
requestCredentialRegisterInfo
(
credentialInfo
,
(
data
)
=>
{
if
(
data
)
{
console
.
info
(
"
requestCredentialRegisterInfo result:
"
+
JSON
.
stringify
(
data
));
}
else
{
console
.
info
(
"
requestCredentialRegisterInfo result: data is null
"
);
}
});
}
catch
(
err
)
{
console
.
error
(
"
requestCredentialRegisterInfo err:
"
+
err
.
code
+
"
,
"
+
err
.
message
);
}
```
### importCredential
importCredential(credentialInfo: string, callback: AsyncCallback
<
{resultInfo: string}
>
): void;
导入凭据信息。
**需要权限**
:ohos.permission.ACCESS_SERVICE_DM
**系统能力**
:SystemCapability.DistributedHardware.DeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | --------------- | ---- | ------------------- |
| credentialInfo| string | 是 | 导入凭据信息。 |
| callback | AsyncCallback
<
{resultInfo: string}
>
| 是 | 导入凭据结果回调。 |
**示例:**
```
js
let
credentialInfo
=
{
"
processType
"
:
1
,
"
authType
"
:
1
,
"
userId
"
:
"
123
"
,
"
deviceId
"
:
"
aaa
"
,
"
version
"
:
"
1.2.3
"
,
"
devicePk
"
:
"
0000
"
,
"
credentialData
"
:
[
{
"
credentialType
"
:
2
,
"
credentialId
"
:
"
102
"
,
"
serverPk
"
:
"
3059301306072A8648CE3D020106082A8648CE3D03
"
,
"
pkInfoSignature
"
:
"
30440220490BCB4F822004C9A76AB8D97F80041FC0E
"
,
"
pkInfo
"
:
""
,
"
authCode
"
:
""
,
"
peerDeviceId
"
:
""
}
]
}
try
{
dmInstance
.
importCredential
(
credentialInfo
,
(
data
)
=>
{
if
(
data
)
{
console
.
info
(
"
importCredential result:
"
+
JSON
.
stringify
(
data
));
}
else
{
console
.
info
(
"
importCredential result: data is null
"
);
}
});
}
catch
(
err
)
{
console
.
error
(
"
importCredential err:
"
+
err
.
code
+
"
,
"
+
err
.
message
);
}
```
### deleteCredential
deleteCredential(queryInfo: string, callback: AsyncCallback
<
{resultInfo: string}
>
): void;
删除凭据信息。
**需要权限**
:ohos.permission.ACCESS_SERVICE_DM
**系统能力**
:SystemCapability.DistributedHardware.DeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | --------------- | ---- | ------------------- |
| queryInfo | string | 是 | 删除凭据信息。 |
| callback | AsyncCallback
<
{resultInfo: string}
>
| 是 | 删除凭据结果回调。 |
**示例:**
```
js
let
queryInfo
=
{
"
processType
"
:
1
,
"
authType
"
:
1
,
"
userId
"
:
"
123
"
}
try
{
dmInstance
.
deleteCredential
(
queryInfo
,
(
data
)
=>
{
if
(
data
)
{
console
.
info
(
"
deleteCredential result:
"
+
JSON
.
stringify
(
data
));
}
else
{
console
.
info
(
"
deleteCredential result: data is null
"
);
}
});
}
catch
(
err
)
{
console
.
error
(
"
deleteCredential err:
"
+
err
.
code
+
"
,
"
+
err
.
message
);
}
```
### on('uiStateChange')
on(type: 'uiStateChange', callback: Callback
<
{ param: string}
>
): void;
ui状态变更回调。
回复UI操作结果回调。
**需要权限**
:ohos.permission.ACCESS_SERVICE_DM
...
...
@@ -1019,22 +693,22 @@ ui状态变更回调。
```
js
try
{
dmInstance
.
on
(
'
uiStateChange
'
,
(
data
)
=>
{
console
.
log
(
"
uiStateChange
executed, dialog closed
"
+
JSON
.
stringify
(
data
))
dmInstance
.
on
(
'
replyResult
'
,
(
data
)
=>
{
console
.
log
(
"
replyResult
executed, dialog closed
"
+
JSON
.
stringify
(
data
))
var
tmpStr
=
JSON
.
parse
(
data
.
param
)
var
isShow
=
tmpStr
.
verifyFailed
console
.
log
(
"
uiStateChange
executed, dialog closed
"
+
isShow
)
console
.
log
(
"
replyResult
executed, dialog closed
"
+
isShow
)
});
}
catch
(
err
)
{
console
.
error
(
"
uiStateChange
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
replyResult
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
### off('
uiStateChange
')
### off('
replyResult
')
off(type: '
uiStateChange
', callback?: Callback
<
{ param: string}
>
): void;
off(type: '
replyResult
', callback?: Callback
<
{ param: string}
>
): void;
取消
ui状态变更
回调。
取消
回复UI操作结果
回调。
**需要权限**
:ohos.permission.ACCESS_SERVICE_DM
...
...
@@ -1053,9 +727,9 @@ off(type: 'uiStateChange', callback?: Callback<{ param: string}>): void;
```
js
try
{
dmInstance
.
off
(
'
uiStateChange
'
);
dmInstance
.
off
(
'
replyResult
'
);
}
catch
(
err
)
{
console
.
error
(
"
uiStateChange
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
replyResult
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
...
...
@@ -1291,130 +965,6 @@ off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason:
}
```
### on('publishSuccess')
on(type: 'publishSuccess', callback: Callback
<
{ publishId: number }
>
): void;
注册发布设备成功回调监听。
**需要权限**
:ohos.permission.ACCESS_SERVICE_DM
**系统能力**
:SystemCapability.DistributedHardware.DeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | -------------------------- |
| type | string | 是 | 注册发布设备成功回调,以便将发布成功时通知应用程序。 |
| callback | Callback
<
{
publishId:
number
}
>
| 是 | 注册设备发布成功的回调方法。 |
**示例:**
```
js
try
{
dmInstance
.
on
(
'
publishSuccess
'
,
(
data
)
=>
{
console
.
info
(
"
publishSuccess:
"
+
JSON
.
stringify
(
data
));
});
}
catch
(
err
)
{
console
.
error
(
"
publishSuccess errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
### off('publishSuccess')
off(type: 'publishSuccess', callback?: Callback
<
{ publishId: number }
>
): void;
取消注册设备发布成功回调。
**需要权限**
:ohos.permission.ACCESS_SERVICE_DM
**系统能力**
:SystemCapability.DistributedHardware.DeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | --------------------------- |
| type | string | 是 | 取消注册设备发布成功回调。 |
| callback | Callback
<
{
publishId:
number
}
>
| 否 | 指示要取消注册的设备发布成功回调。 |
**示例:**
```
js
try
{
dmInstance
.
off
(
'
publishSuccess
'
,
(
data
)
=>
{
console
.
info
(
'
publishSuccess
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
err
)
{
console
.
error
(
"
publishSuccess errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
### on('publishFail')
on(type: 'publishFail', callback: Callback
<
{ publishId: number, reason: number }
>
): void;
注册设备发布失败回调监听。
**需要权限**
:ohos.permission.ACCESS_SERVICE_DM
**系统能力**
:SystemCapability.DistributedHardware.DeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------- | ---- | ------------------------------ |
| type | string | 是 | 注册设备发布失败回调,以便在发布设备失败时通知应用程序。 |
| callback | Callback
<
{
publishId:
number,
reason:
number
}
>
| 是 | 注册设备发布失败的回调方法。 |
**示例:**
```
js
try
{
dmInstance
.
on
(
'
publishFail
'
,
(
data
)
=>
{
console
.
info
(
"
publishFail on:
"
+
JSON
.
stringify
(
data
));
});
}
catch
(
err
)
{
console
.
error
(
"
publishFail errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
### off('publishFail')
off(type: 'publishFail', callback?: Callback
<
{ publishId: number, reason: number }
>
): void;
取消注册设备发布失败回调。
**需要权限**
:ohos.permission.ACCESS_SERVICE_DM
**系统能力**
:SystemCapability.DistributedHardware.DeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------- | ---- | ----------------- |
| type | string | 是 | 取消注册设备发布失败回调。 |
| callback | Callback
<
{
publishId:
number,
reason:
number
}
>
| 否 | 指示要取消注册设备发布失败回调。 |
**示例:**
```
js
try
{
dmInstance
.
off
(
'
publishFail
'
,
(
data
)
=>
{
console
.
info
(
'
publishFail
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
err
)
{
console
.
error
(
"
publishFail errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
### on('serviceDie')
on(type: 'serviceDie', callback: () =
>
void): void;
...
...
zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/changelogs-distributedDeviceManager.md
浏览文件 @
249901ce
# 设备管理ChangeLog
## cl.distributedDeviceManager.1 接口变更
从Opeharmonny 4.0.9.2版本开始,新增了设备管理接口
,部分接口仅系统应用可调用
。
从Opeharmonny 4.0.9.2版本开始,新增了设备管理接口。
**变更影响**
原有的接口暂时可继续使用,但是停止维护,建议使用新接口进行开发。
原有的接口
[
API参考
](
../../../application-dev/reference/apis/js-apis-device-manager.md
)
暂时可继续使用,但是停止维护,建议使用新接口进行开发。
**关键的接口/组件变更**
...
...
@@ -13,44 +13,34 @@
| 模块名 | 类名 | 新增接口声明 | 是否支持三方应用调用 |
| ------------------------- | ------------------- | ------------------------------------------------------------ | ------------------------------- |
| @ohos.distributedDeviceManager | deviceManager |
**function**
createDeviceManager(bundleName: string, callback: AsyncCallback
<
DeviceManager
>
): void | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
releaseDeviceManager(): void | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getAvailableDeviceListSync(): Array
<
DeviceBasicInfo
>
| 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getAvailableDeviceList(callback:AsyncCallback
<
Array
<
DeviceBasicInfo
>>
): void | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getAvailableDeviceList(): Promise
<
Array
<
DeviceBasicInfo
>>
| 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getLocalDeviceNetworkIdSync(): string | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getLocalDeviceNameSync(): string | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getLocalDeviceTypeSync(): number | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getLocalDeviceIdSync(): string | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
createDeviceManager(bundleName: string, callback: AsyncCallback
<
DeviceManager
>
): void
;
| 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
releaseDeviceManager(): void
;
| 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getAvailableDeviceListSync(): Array
<
DeviceBasicInfo
>
;
| 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getAvailableDeviceList(callback:AsyncCallback
<
Array
<
DeviceBasicInfo
>>
): void
;
| 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getAvailableDeviceList(): Promise
<
Array
<
DeviceBasicInfo
>>
;
| 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getLocalDeviceNetworkIdSync(): string
;
| 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getLocalDeviceNameSync(): string
;
| 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getLocalDeviceTypeSync(): number
;
| 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getLocalDeviceIdSync(): string
;
| 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getDeviceNameSync(networkId: string): string; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
getDeviceTypeSync(networkId: string): number; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
startDeviceDiscovery(subscribeId: number, filterOptions?: string): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
stopDeviceDiscovery(subscribeId: number): void | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
bindDevice(deviceId: string, bindParam: BindParam, callback: AsyncCallback
<
{deviceId: string}
>
): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
unbindDevice(deviceId: string): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
publishDeviceDiscovery(publishInfo: PublishInfo): void | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
unPublishDeviceDiscovery(publishId: number): void | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback
<
{deviceId: string, level: number}
>
): void | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
setUserOperation(operateAction: number, params: string): void; | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
requestCredentialRegisterInfo(requestInfo: string, callback: AsyncCallback
<
{registerInfo: string}
>
): void; | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
importCredential(credentialInfo: string, callback: AsyncCallback
<
{resultInfo: string}
>
): void; | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
deleteCredential(queryInfo: string, callback: AsyncCallback
<
{resultInfo: string}
>
): void; | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
startDiscovering(subscribeId: number, filterOptions?: string): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
stopDiscovering(subscribeId: number): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
bindTarget(deviceId: string, bindParam: BindParam, callback: AsyncCallback
<
{deviceId: string}
>
): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
unbindTarget(deviceId: string): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
replyUiAction(action: number, params: string): void; | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
on(type: 'replyResult', callback: Callback
<
{ param: string}
>
): void; | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
off(type: 'replyResult', callback?: Callback
<
{ param: string}
>
): void; |否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
on(type: 'deviceStatusChange', callback: Callback
<
{ action: DeviceStatusChange, device: DeviceBasicInfo }
>
): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
off(type: 'deviceStatusChange', callback?: Callback
<
{ action: DeviceStatusChange, device: DeviceBasicInfo }
>
): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
on(type: 'discoverSuccess', callback: Callback
<
{ subscribeId: number, device: DeviceBasicInfo }
>
): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
off(type: 'discoverSuccess', callback?: Callback
<
{ subscribeId: number, device: DeviceBasicInfo }
>
): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
on(type: 'deviceNameChange', callback: Callback
<
{ deviceName: string }
>
): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
off(type: 'deviceNameChange', callback?: Callback
<
{ deviceName: string }
>
): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
on(type: 'discoverFail', callback: Callback
<
{ subscribeId: number, reason: number }
>
): void | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
off(type: 'discoverFail', callback?: Callback
<
{ subscribeId: number, reason: number }
>
): void | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
on(type: 'serviceDie', callback: () =
>
void): void | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
off(type: 'serviceDie', callback?: () =
>
void): void | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
on(type: 'uiStateChange', callback: Callback
<
{ param: string}
>
): void; | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
off(type: 'uiStateChange', callback?: Callback
<
{ param: string}
>
): void; | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
on(type: 'publishSuccess', callback: Callback
<
{ publishId: number }
>
): void | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
off(type: 'publishSuccess', callback?: Callback
<
{ publishId: number }
>
): void | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
on(type: 'publishFail', callback: Callback
<
{ publishId: number, reason: number }
>
): void | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
off(type: 'publishFail', callback?: Callback
<
{ publishId: number, reason: number }
>
): void | 否 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
on(type: 'discoverFail', callback: Callback
<
{ subscribeId: number, reason: number }
>
): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
off(type: 'discoverFail', callback?: Callback
<
{ subscribeId: number, reason: number }
>
): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
on(type: 'serviceDie', callback: () =
>
void): void; | 是 |
| @ohos.distributedDeviceManager | deviceManager |
**function**
off(type: 'serviceDie', callback?: () =
>
void): void; | 是 |
**适配指导**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录