• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 分布式调度子系统ChangeLog
2
3## cl.DistributedManagerService.1 continuationManager事件监听接口on/off变更
4
5- continuationManager事件监听接口on/off传入的参数事件类型名,命名不符合OpenHarmony的API接口规范。
6- continuationManager.on对于不同的事件接口返回值未进行统一,不符合OpenHarmony的API接口规范。
7
8已做出以下变更:
9
10- continuationManager.oncontinuationManager.off的设备选择事件名由原来的"deviceConnect"变更为"deviceSelected",设备取消选择事件名由原来的"deviceDisconnect"变更为"deviceUnselected"。
11- continuationManager.on对于不同事件统一callback返回值类型"Callback<Array<ContinuationResult>>"。
12
13**变更影响**
14
15基于此前版本开发的应用,需适配变更接口,否则会影响原有业务逻辑。
16
17**关键的接口/组件变更**
18
19- 涉及接口
20
21  continuationManager.on;
22  continuationManager.off;
23
24- 变更前:
25
26```js
27  function on(type: "deviceConnect", token: number, callback: Callback<Array<ContinuationResult>>): void;
28  function off(type: "deviceConnect", token: number): void;
29  function on(type: "deviceDisconnect", token: number, callback: Callback<Array<string>>): void;
30  function off(type: "deviceDisconnect", token: number): void;
31```
32
33- 变更后:
34
35```js
36  function on(type: "deviceSelected", token: number, callback: Callback<Array<ContinuationResult>>): void;
37  function off(type: "deviceSelected", token: number): void;
38  function on(type: "deviceUnselected", token: number, callback: Callback<Array<ContinuationResult>>): void;
39  function off(type: "deviceUnselected", token: number): void;
40```
41
42**适配指导**
43修改事件名称,示例代码如下:
44
45continuationManager.on 设备选择事件
46
47```ts
48  let token = 1;
49  try {
50    continuationManager.on("deviceSelected", token, (data) => {
51      console.info('onDeviceSelected len: ' + data.length);
52      for (let i = 0; i < data.length; i++) {
53        console.info('onDeviceSelected deviceId: ' + JSON.stringify(data[i].id));
54        console.info('onDeviceSelected deviceType: ' + JSON.stringify(data[i].type));
55        console.info('onDeviceSelected deviceName: ' + JSON.stringify(data[i].name));
56      }
57    });
58  } catch (err) {
59    console.error('on failed, cause: ' + JSON.stringify(err));
60  }
61```
62
63continuationManager.off 设备选择事件
64
65```ts
66  let token = 1;
67  try {
68    continuationManager.off("deviceSelected", token);
69  } catch (err) {
70    console.error('off failed, cause: ' + JSON.stringify(err));
71  }
72```
73
74continuationManager.on 设备取消选择事件
75
76```ts
77  let token = 1;
78  try {
79    continuationManager.on("deviceUnselected", token, (data) => {
80      console.info('onDeviceUnselected len: ' + data.length);
81      for (let i = 0; i < data.length; i++) {
82        console.info('onDeviceUnselected deviceId: ' + JSON.stringify(data[i].id));
83        console.info('onDeviceUnselected deviceType: ' + JSON.stringify(data[i].type));
84        console.info('onDeviceUnselected deviceName: ' + JSON.stringify(data[i].name));
85      }
86      console.info('onDeviceUnselected finished.');
87    });
88  } catch (err) {
89    console.error('on failed, cause: ' + JSON.stringify(err));
90  }
91```
92
93continuationManager.off 设备取消选择事件
94
95```ts
96  let token = 1;
97  try {
98    continuationManager.off("deviceUnselected", token);
99  } catch (err) {
100    console.error('off failed, cause: ' + JSON.stringify(err));
101  }
102```
103
104## cl.DistributedManagerService.2 continuationManager接口新增DATASYNC权限校验
105
106此前版本continuationManager接口未对调用方进行校验,不符合OpenHarmony的API接口规范。
107已做出以下变更:调用方使用continuationManager前需提前申请"ohos.permission.DISTRIBUTED_DATASYNC"权限。
108
109**变更影响**
110
111基于此前版本开发的应用,需提前申请"ohos.permission.DISTRIBUTED_DATASYNC"权限,否则会影响原有业务逻辑。
112
113**关键的接口/组件变更**
114
115涉及接口
116
117  - continuationManager.registerContinuation;
118  - continuationManager.on;
119  - continuationManager.off;
120  - continuationManager.unregisterContinuation;
121  - continuationManager.updateContinuationState;
122  - continuationManager.startContinuationDeviceManager;