Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
f81126a6
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f81126a6
编写于
12月 15, 2022
作者:
@
@shi-xiaoxiao-iris
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[设备管理]api错误码整改changelog添加
Signed-off-by:
N
@shi-xiaoxiao-iris
<
shixiaoxiao2@huawei.com
>
上级
1eddd8d7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
105 addition
and
0 deletion
+105
-0
zh-cn/release-notes/changelogs/OpenHarmony_3.2.8.3/changelogs-device-manager.md
...angelogs/OpenHarmony_3.2.8.3/changelogs-device-manager.md
+105
-0
未找到文件。
zh-cn/release-notes/changelogs/OpenHarmony_3.2.8.3/changelogs-device-manager.md
0 → 100644
浏览文件 @
f81126a6
# 设备管理changeLog
## cl.device_manager.1 API错误信息返回方式变更
设备管理接口使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。从API9开始作以下变更:
异步接口:通过AsyncCallback或Promise的error对象返回错误信息。
同步接口:通过抛出异常的方式返回错误信息。
**变更影响**
基于此前版本开发的应用,需适配接口的错误信息返回方式,否则会影响原有业务逻辑。
**关键接口/组件变更**
-
createDeviceManager(bundleName: string, callback: AsyncCallback
<
DeviceManager
>
): void;
-
release(): void;
-
getTrustedDeviceListSync(): Array
<
DeviceInfo
>
-
getTrustedDeviceList(callback:AsyncCallback
<
Array
<
DeviceInfo
>>
): void;
-
getTrustedDeviceList(): Promise
<
Array
<
DeviceInfo
>>
-
getLocalDeviceInfoSync():
[
DeviceInfo
](
#deviceinfo
)
;
-
getLocalDeviceInfo(callback:AsyncCallback
<
DeviceInfo
>
): void;
-
getLocalDeviceInfo(): Promise
<
DeviceInfo
>
-
startDeviceDiscovery(subscribeInfo: SubscribeInfo): void;
-
startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void;
-
stopDeviceDiscovery(subscribeId: number): void;
-
publishDeviceDiscovery(publishInfo: PublishInfo): void;
-
unPublishDeviceDiscovery(publishId: number): void;
-
authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback
<
{deviceId: string, pinToken ?: number}
>
): void;
-
unAuthenticateDevice(deviceInfo: DeviceInfo): void;
-
verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback
<
{deviceId: string, level: number}
>
): void;
-
setUserOperation(operateAction: number, params: string): void;
-
on(type: 'uiStateChange', callback: Callback
<
{ param: string}
>
): void;
-
off(type: 'uiStateChange', callback?: Callback
<
{ param: string}
>
): void;
-
on(type: 'deviceStateChange', callback: Callback
<
{ action: DeviceStateChangeAction, device: DeviceInfo }
>
): void;
-
off(type: 'deviceStateChange', callback?: Callback
<
{ action: DeviceStateChangeAction, device: DeviceInfo }
>
): void;
-
on(type: 'deviceFound', callback: Callback
<
{ subscribeId: number, device: DeviceInfo }
>
): void;
-
off(type: 'deviceFound', callback?: Callback
<
{ subscribeId: number, device: DeviceInfo }
>
): void;
-
on(type: 'discoverFail', callback: Callback
<
{ subscribeId: number, reason: number }
>
): void;
-
off(type: 'discoverFail', callback?: Callback
<
{ subscribeId: number, reason: number }
>
): void;
-
on(type: 'publishSuccess', callback: Callback
<
{ publishId: number }
>
): void;
-
off(type: 'publishSuccess', callback?: Callback
<
{ publishId: number }
>
): void;
-
on(type: 'publishFail', callback: Callback
<
{ publishId: number, reason: number }
>
): void;
-
off(type: 'publishFail', callback?: Callback
<
{ publishId: number, reason: number }
>
): void;
-
on(type: 'serviceDie', callback: () =
>
void): void;
-
off(type: 'serviceDie', callback?: () =
>
void): void;
**适配指导**
异步接口以getTrustedDeviceList为例,示例代码如下:
```
js
import
account_osAccount
from
"
@ohos.distributedHardware.deviceManager
"
dmInstance
.
getTrustedDeviceList
((
err
,
data
)
=>
{
console
.
log
(
"
getTrustedDeviceList err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
get trusted device info:
'
+
JSON
.
stringify
(
data
));
});
try
{
dmInstance
.
getTrustedDeviceList
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
"
getTrustedDeviceList errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
return
;
}
console
.
log
(
'
get trusted device info:
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
err
)
{
console
.
error
(
"
getTrustedDeviceList errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
同步接口以startDeviceDiscovery为例,示例代码如下:
```
js
// 生成发现标识,随机数确保每次调用发现接口的标识不一致
var
subscribeId
=
Math
.
floor
(
Math
.
random
()
*
10000
+
1000
);
var
subscribeInfo
=
{
"
subscribeId
"
:
subscribeId
,
"
mode
"
:
0xAA
,
// 主动模式
"
medium
"
:
0
,
// 自动发现类型,同时支持多种发现类型
"
freq
"
:
2
,
// 高频率
"
isSameAccount
"
:
false
,
"
isWakeRemote
"
:
false
,
"
capability
"
:
1
};
dmInstance
.
startDeviceDiscovery
(
subscribeInfo
);
// 当有设备发现时,通过deviceFound回调通知给应用程序
// 生成发现标识,随机数确保每次调用发现接口的标识不一致
var
subscribeId
=
Math
.
floor
(
Math
.
random
()
*
10000
+
1000
);
var
subscribeInfo
=
{
"
subscribeId
"
:
subscribeId
,
"
mode
"
:
0xAA
,
// 主动模式
"
medium
"
:
0
,
// 自动发现类型,同时支持多种发现类型
"
freq
"
:
2
,
// 高频率
"
isSameAccount
"
:
false
,
"
isWakeRemote
"
:
false
,
"
capability
"
:
1
};
try
{
dmInstance
.
startDeviceDiscovery
(
subscribeInfo
);
// 当有设备发现时,通过deviceFound回调通知给应用程序
}
catch
(
err
)
{
console
.
error
(
"
startDeviceDiscovery errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录