• Home
Name Date Size #Lines LOC

..--

entry/12-May-2024-1,4261,309

screenshots/device/12-May-2024-

.gitignoreD12-May-2024121 88

README.mdD12-May-20242.1 KiB4422

README_zh.mdD12-May-20241.9 KiB4322

build-profile.json5D12-May-20241 KiB4341

hvigorfile.jsD12-May-2024174 21

package.jsonD12-May-2024366 1818

README.md

1# Distributed Demo
2
3### Introduction
4
5This sample shows how to build distributed abilities and services. In this sample, you can:
6
71. Obtain a device through the API provided by the distributed hardware.
8
92. Start an ability on a remote device.
10
113. Bind a service on a remote device.
12
13The display effect is as follows:
14
15![](screenshots/device/main.png)
16
17### Concepts
18
19Distributed data service (DDS): The DDS implements distributed database collaboration across devices for applications. Applications save data to distributed databases by calling the DDS APIs. The DDS isolates data of different applications based on a triplet of account, application, and database to ensure secure data access. The DDS synchronizes application data between trusted devices to provide users with consistent data access experience on different devices.
20
21### Required Permissions
22
23ohos.permission.DISTRIBUTED_DATASYNC, which allows an application to exchange data with other devices.
24
25### Usage
26
271. Connect two devices to the network.
28
292. Grant the permissions in the displayed dialog box.
30
313. On the home page of the sample app on one device, touch **RegisterDeviceListCallback** to register the device. After the registration is successful, touch **AuthDevice** to authenticate the device. Enter the corresponding PIN on the other device.
32
334. After the connection is successful, check that you can invoke the local ability, remote ability, local service, and remote service.
34
355. When you perform operations on either device, the data displayed on both devices is the same.
36
37### Constraints
38
391. This sample can run only on standard-system devices, and API version 8 or later are supported.
40
412. DevEco Studio 3.0 Beta4 (Build version: 3.0.0.992, built on July 14, 2022) must be used.
42
433. This sample uses the system interface **@ohos.distributedHardware.deviceManager**. To use the Full SDK, you must manually obtain it from the mirror and switch to it in DevEco Studio. For details, see [Guide to Switching to Full SDK](https://gitee.com/openharmony/docs/blob/master/en/application-dev/quick-start/full-sdk-switch-guide.md).
44

README_zh.md

1# 分布式Demo
2
3### 简介
4
5本示例展示了如何构建分布式Ability和Service,包含:
6
71.通过分布式硬件提供的接口,获取设备。
8
92.远程拉起对端Ability。
10
113.远程绑定对端Service。
12
13实现效果如下:
14
15![](screenshots/device/main.png)
16
17### 相关概念
18
19分布式数据服务:分布式数据服务(Distributed Data Service,DDS)为应用程序提供不同设备间数据库的分布式协同能力。通过调用分布式数据接口,应用程序将数据保存到分布式数据库中。通过结合帐号、应用和数据库三元组,分布式数据服务对属于不同应用的数据进行隔离,保证不同应用之间的数据不能通过分布式数据服务互相访问。在通过可信认证的设备间,分布式数据服务支持应用数据相互同步,为用户提供在多种终端设备上最终一致的数据访问体验。
20
21### 相关权限
22
23允许不同设备间的数据交换:ohos.permission.DISTRIBUTED_DATASYNC
24
25### 使用说明
26
271.两台设备组网。
28
292.对弹出的分布式权限弹框进行授权。
30
313.在一台设备界面中点击RegisterDeviceListCallback注册设备,成功后点击AuthDevice认证设备,在另一台设备输入对应的PIN。
32
334.连接成功后可调用本地Ability、对端Ability、本地Service、远端Service。
34
355.操作对端设备,当前设备界面也会保持和对端设备界面显示一致。
36
37### 约束与限制
38
391.本示例仅支持标准系统上运行,支持API version 8及以上版本。
40
412.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。
42
433.本示例需要使用@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)