| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| AppScope/ | 06-May-2025 | - | 36 | 33 | ||
| entry/ | 06-May-2025 | - | 2,998 | 2,815 | ||
| hvigor/ | 06-May-2025 | - | 23 | 22 | ||
| screenshots/device/ | 06-May-2025 | - | ||||
| .gitignore | D | 06-May-2025 | 119 | 11 | 11 | |
| DMSample测试用例报告.md | D | 06-May-2025 | 2.9 KiB | 14 | 12 | |
| README.md | D | 06-May-2025 | 852 | 22 | 10 | |
| README_zh.md | D | 06-May-2025 | 4.5 KiB | 82 | 57 | |
| build-profile.json5 | D | 06-May-2025 | 1.1 KiB | 43 | 42 | |
| hvigorfile.ts | D | 06-May-2025 | 159 | 2 | 1 | |
| hvigorw | D | 06-May-2025 | 2 KiB | 62 | 28 | |
| hvigorw.bat | D | 06-May-2025 | 2 KiB | 73 | 56 | |
| oh-package.json5 | D | 06-May-2025 | 824 | 27 | 25 | |
| ohosTest.md | D | 06-May-2025 | 923 | 9 | 8 |
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本示例主要展示了设备管理相关的功能,使用[@ohos.distributedDeviceManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-distributedservice-kit/js-apis-distributedDeviceManager.md) 6等接口,实现了包括获取本机设备信息,获取授信设备列表,根据过滤条件扫描设备,设备认证,设备状态订阅等功能。 7 8### 效果预览 9 10|主页| 选择过滤条件 | 发现与可信设备列表 |取消认证| 11|--------------------------------|-------------------------------------------------------|-----------------------------------------------|--------------------------------| 12|  |  | 13 14使用说明 151. 进入应用会自动获取本机设备信息,并且注册设备状态监听,在有设备上下线的时候,刷新可信设备列表; 162. 在主界面,可以点击刷新,刷新可信设备列表,点击已认证,解除认证关系(只能解除本应用组网设备); 173. 在主界面,可以点击过滤条件,选择对应的过滤条件,在发现设备时进行过滤; 184. 在主界面,可以点击发现,发现周边的设备,并点击发现的设备,进行PIN码认证。 19 20### 工程目录 21 22``` 23entry/src/main/ets/ 24|---common 25| |---Constant.ets // 常量 26| |---Logger.ets // 日志工具 27|---entryability 28|---model 29| |---RemoteDeviceModel.ets // 主要封装了DeviceManager库相关的接口,实现相关的功能 30|---pages 31| |---index.ets // 首页 32| |---FilterOption.ets // 过滤条件页面 33| |---ListDeviceView.ets // 列表设备组件 34``` 35 36### 具体实现 37 38获取本机设备信息,获取授信设备列表,根据过滤条件扫描设备,设备认证,设备状态订阅,控制设备是否允许被发现等功能,接口封装在RemoteDeviceModel,源码参考:[RemoteDeviceModel.ts](entry/src/main/ets/model/RemoteDeviceModel.ets) 39 40 * 使用RemoteDeviceModel.createDeviceManager()来获取DeviceManager对象; 41 * 获取本机设备信息:调用RemoteDeviceModel.getLocalDeviceInfo()来获取本机设备信息; 42 * 注册设备状态监听:调用RemoteDeviceModel.registerDeviceStateListener(),来注册设备状态监听; 43 * 获取可信设备列表:调用RemoteDeviceModel.getTrustedDeviceList()来获取可信设备列表; 44 * 发现和停止发现设备:调用RemoteDeviceModel.startDeviceDiscovery()发现设备,调用RemoteDeviceModel.stopDeviceDiscovery()停止发现设备; 45 * 认证和取消认证设备:调用RemoteDeviceModel.authenticateDevice()认证,调用RemoteDeviceModel.unAuthenticateDevice()取消认证设备; 46 47### 相关概念 48 49设备管理:用于获取可信设备和本地设备的相关信息。在调用DeviceManager的方法前,需要先通过createDeviceManager构建一个DeviceManager实例。 50 51### 相关权限 52 53允许不同设备间的数据交换:ohos.permission.DISTRIBUTED_DATASYNC。 54 55### 约束与限制 56 571.本示例需要组网测试。 58 592.本示例仅支持标准系统上运行,支持设备:RK3568。 60 613.本示例为Stage模型,支持API12版本SDK,SDK版本号(API Version 12 Release),镜像版本号(5.0 Release)。 62 634.本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。 64 655.本示例需要使用@ohos.distributedDeviceManager系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md) 66。 67 686.本示例涉及系统接口,需要配置系统应用签名,可以参考[特殊权限配置方法](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md) 69,把配置文件中的“app-feature”字段信息改为“hos_system_app”。 70 71### 下载 72 73如需单独下载本工程,执行如下命令: 74 75``` 76git init 77git config core.sparsecheckout true 78echo code/SystemFeature/DistributedAppDev/DistributedAuthentication > .git/info/sparse-checkout 79git remote add origin https://gitee.com/openharmony/applications_app_samples.git 80git pull origin master 81``` 82