• Home
Name Date Size #Lines LOC

..--

entry/12-May-2024-954890

screenshots/device/12-May-2024-

.gitignoreD12-May-2024121 88

README.mdD12-May-2024852 2210

README_zh.mdD12-May-20241.4 KiB3317

build-profile.json5D12-May-20241 KiB4341

hvigorfile.jsD12-May-2024174 21

package.jsonD12-May-2024300 1615

README.md

1# DeviceManager
2
3
4
5### Introduction
6
7This sample shows the use of the **DeviceManager** API in eTS, including obtaining the trusted device list, scanning for devices, authenticating devices, and subscribing to device status changes.
8
9### Usage
10
111. The sample app automatically obtains the trusted devices and displays them in the **online** state on the device list. It also scans for devices and displays the discovered devices in the **discover** state on the device list.
12
132. Touch a device in the **discover** state to trigger authentication. After the authentication is complete, the page is automatically refreshed.
14
153. Subscribe to device status changes. When the device status changes, the page is automatically refreshed.
16
17### Constraints
18
191. This sample requires a networking test.
20
212. This sample can only be run on standard-system devices.
22

README_zh.md

1# 设备管理
2
3### 简介
4
5本示例展示了在eTS中DeviceManager接口的使用,包括获取授信设备列表,设备扫描,设备认证,设备状态订阅。实现效果如下:
6
7![main](screenshots/device/main.png)
8
9### 相关概念
10
11设备管理:用于获取可信设备和本地设备的相关信息。在调用DeviceManager的方法前,需要先通过createDeviceManager构建一个DeviceManager实例。
12
13### 相关权限
14
15不涉及。
16
17### 使用说明
18
191.进入应用会自动获取授信设备列表显示在设备列表中,状态显示为"online",并开始设备扫描发现设备,发现设备后会显示在设备列表中,状态显示为"discover"。
20
212.点击状态为"discover"的设备,会触发认证,认证完成会刷新界面。
22
233.设备状态订阅监听组网状态变化从而刷新界面。
24
25### 约束与限制
26
271.本示例需要组网测试。
28
292.本示例仅支持标准系统上运行。
30
313.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。
32
334.本示例需要使用@ohos.distributedHardware.deviceManager系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)