1e41f4b71Sopenharmony_ci# @ohos.cooperate (Screen Hopping) (System API)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **cooperate** module implements screen hopping for two or more networked devices to share the keyboard and mouse for collaborative operations.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> - The APIs provided by this module are system APIs.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## Modules to Import
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci```ts
14e41f4b71Sopenharmony_ciimport cooperate from '@ohos.cooperate';
15e41f4b71Sopenharmony_ci```
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## cooperate.prepareCooperate<sup>11+</sup>
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ciprepareCooperate(callback: AsyncCallback&lt;void&gt;): void;
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ciPrepares for screen hopping. This API uses an asynchronous callback to return the result.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.COOPERATE_MANAGER
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**Parameters**
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci| Name  | Type                     | Mandatory| Description                                                        |
30e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
31e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci**Error codes**
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci| ID| Error Message         |
38e41f4b71Sopenharmony_ci| -------- | ----------------- |
39e41f4b71Sopenharmony_ci| 201 | Permission denied. |
40e41f4b71Sopenharmony_ci| 202 | Not system application. |
41e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci**Example**
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci```ts
46e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
47e41f4b71Sopenharmony_citry {
48e41f4b71Sopenharmony_ci  cooperate.prepareCooperate((error: BusinessError) => {
49e41f4b71Sopenharmony_ci    if (error) {
50e41f4b71Sopenharmony_ci      console.log(`Keyboard mouse crossing prepareCooperate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
51e41f4b71Sopenharmony_ci      return;
52e41f4b71Sopenharmony_ci    }
53e41f4b71Sopenharmony_ci    console.log(`Keyboard mouse crossing prepareCooperate success.`);
54e41f4b71Sopenharmony_ci  });
55e41f4b71Sopenharmony_ci} catch (error) {
56e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing prepareCooperate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
57e41f4b71Sopenharmony_ci}
58e41f4b71Sopenharmony_ci```
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci## cooperate.prepareCooperate<sup>11+</sup>
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ciprepareCooperate(): Promise&lt;void&gt;;
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ciPrepares for screen hopping. This API uses a promise to return the result.
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.COOPERATE_MANAGER
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci**Return value**
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci| Parameters               | Description                     |
73e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
74e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci**Error codes**
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci| ID| Error Message         |
81e41f4b71Sopenharmony_ci| -------- | ----------------- |
82e41f4b71Sopenharmony_ci| 201 | Permission denied. |
83e41f4b71Sopenharmony_ci| 202 | Not system application. |
84e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci**Example**
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci```ts
89e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
90e41f4b71Sopenharmony_citry {
91e41f4b71Sopenharmony_ci  cooperate.prepareCooperate().then(() => {
92e41f4b71Sopenharmony_ci    console.log(`Keyboard mouse crossing prepareCooperate success.`);
93e41f4b71Sopenharmony_ci  }, (error: BusinessError) => {
94e41f4b71Sopenharmony_ci    console.log(`Keyboard mouse crossing prepareCooperate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
95e41f4b71Sopenharmony_ci  });
96e41f4b71Sopenharmony_ci} catch (error) {
97e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing prepareCooperate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
98e41f4b71Sopenharmony_ci}
99e41f4b71Sopenharmony_ci```
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci## cooperate.unprepareCooperate<sup>11+</sup>
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ciunprepareCooperate(callback: AsyncCallback&lt;void&gt;): void;
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ciCancels the preparation for screen hopping. This API uses an asynchronous callback to return the result.
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.COOPERATE_MANAGER
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci| Name  | Type                     | Mandatory| Description                                                        |
114e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
115e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci**Error codes**
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ci| ID| Error Message         |
122e41f4b71Sopenharmony_ci| -------- | ----------------- |
123e41f4b71Sopenharmony_ci| 201 | Permission denied. |
124e41f4b71Sopenharmony_ci| 202 | Not system application. |
125e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci**Example**
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci```ts
130e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
131e41f4b71Sopenharmony_citry {
132e41f4b71Sopenharmony_ci  cooperate.unprepareCooperate((error: BusinessError) => {
133e41f4b71Sopenharmony_ci    if (error) {
134e41f4b71Sopenharmony_ci      console.log(`Keyboard mouse crossing unprepareCooperate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
135e41f4b71Sopenharmony_ci      return;
136e41f4b71Sopenharmony_ci    }
137e41f4b71Sopenharmony_ci    console.log(`Keyboard mouse crossing unprepareCooperate success.`);
138e41f4b71Sopenharmony_ci  });
139e41f4b71Sopenharmony_ci} catch (error) {
140e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing unprepareCooperate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
141e41f4b71Sopenharmony_ci}
142e41f4b71Sopenharmony_ci```
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci## cooperate.unprepareCooperate<sup>11+</sup>
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ciunprepareCooperate(): Promise&lt;void&gt;;
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ciCancels the preparation for screen hopping. This API uses a promise to return the result.
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.COOPERATE_MANAGER
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci**Return value**
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci| Parameters               | Description                     |
157e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
158e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci**Error codes**
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci| ID| Error Message         |
165e41f4b71Sopenharmony_ci| -------- | ----------------- |
166e41f4b71Sopenharmony_ci| 201 | Permission denied. |
167e41f4b71Sopenharmony_ci| 202 | Not system application. |
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci**Example**
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci```ts
172e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
173e41f4b71Sopenharmony_citry {
174e41f4b71Sopenharmony_ci  cooperate.unprepareCooperate().then(() => {
175e41f4b71Sopenharmony_ci    console.log(`Keyboard mouse crossing unprepareCooperate success.`);
176e41f4b71Sopenharmony_ci  }, (error: BusinessError) => {
177e41f4b71Sopenharmony_ci    console.log(`Keyboard mouse crossing unprepareCooperate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
178e41f4b71Sopenharmony_ci  });
179e41f4b71Sopenharmony_ci} catch (error) {
180e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing unprepareCooperate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
181e41f4b71Sopenharmony_ci}
182e41f4b71Sopenharmony_ci```
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci## cooperate.activateCooperate<sup>11+</sup>
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ciactivateCooperate(targetNetworkId: string, inputDeviceId: number, callback: AsyncCallback&lt;void&gt;): void;
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ciStarts screen hopping. This API uses an asynchronous callback to return the result.
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.COOPERATE_MANAGER
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ci**Parameters**
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ci| Name         | Type                     | Mandatory| Description                                                        |
199e41f4b71Sopenharmony_ci| --------------- | ------------------------- | ---- | ------------------------------------------------------------ |
200e41f4b71Sopenharmony_ci| targetNetworkId | string                    | Yes  | Descriptor of the target device for screen hopping.                                    |
201e41f4b71Sopenharmony_ci| inputDeviceId   | number                    | Yes  | Identifier of the input device for screen hopping.                                      |
202e41f4b71Sopenharmony_ci| callback        | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci**Error codes**
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ci| ID| Error Message         |
209e41f4b71Sopenharmony_ci| -------- | ----------------- |
210e41f4b71Sopenharmony_ci| 201 | Permission denied. |
211e41f4b71Sopenharmony_ci| 202 | Not system application. |
212e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
213e41f4b71Sopenharmony_ci| 20900001 | Operation failed. |
214e41f4b71Sopenharmony_ci
215e41f4b71Sopenharmony_ci**Example**
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci```ts
218e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
219e41f4b71Sopenharmony_cilet targetNetworkId = "networkId";
220e41f4b71Sopenharmony_cilet inputDeviceId = 0;
221e41f4b71Sopenharmony_citry {
222e41f4b71Sopenharmony_ci  cooperate.activateCooperate(targetNetworkId, inputDeviceId, (error: BusinessError) => {
223e41f4b71Sopenharmony_ci    if (error) {
224e41f4b71Sopenharmony_ci      console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
225e41f4b71Sopenharmony_ci      return;
226e41f4b71Sopenharmony_ci    }
227e41f4b71Sopenharmony_ci    console.log(`Start Keyboard mouse crossing success.`);
228e41f4b71Sopenharmony_ci  });
229e41f4b71Sopenharmony_ci} catch (error) {
230e41f4b71Sopenharmony_ci  console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
231e41f4b71Sopenharmony_ci}
232e41f4b71Sopenharmony_ci```
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci## cooperate.activateCooperate<sup>11+</sup>
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ciactivateCooperate(targetNetworkId: string, inputDeviceId: number): Promise&lt;void&gt;;
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_ciStarts screen hopping. This API uses a promise to return the result.
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.COOPERATE_MANAGER
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ci**Parameters**
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci| Name         | Type  | Mandatory| Description                    |
247e41f4b71Sopenharmony_ci| --------------- | ------ | ---- | ------------------------ |
248e41f4b71Sopenharmony_ci| targetNetworkId | string | Yes  | Descriptor of the target device for screen hopping.|
249e41f4b71Sopenharmony_ci| inputDeviceId   | number | Yes  | Identifier of the input device for screen hopping.  |
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_ci**Return value**
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_ci| Name             | Description                     |
254e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
255e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci**Error codes**
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci| ID| Error Message         |
262e41f4b71Sopenharmony_ci| -------- | ----------------- |
263e41f4b71Sopenharmony_ci| 201 | Permission denied. |
264e41f4b71Sopenharmony_ci| 202 | Not system application. |
265e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
266e41f4b71Sopenharmony_ci| 20900001 | Operation failed. |
267e41f4b71Sopenharmony_ci
268e41f4b71Sopenharmony_ci**Example**
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ci```ts
271e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
272e41f4b71Sopenharmony_cilet targetNetworkId = "networkId";
273e41f4b71Sopenharmony_cilet inputDeviceId = 0;
274e41f4b71Sopenharmony_citry {
275e41f4b71Sopenharmony_ci cooperate.activateCooperate(targetNetworkId, inputDeviceId).then(() => {
276e41f4b71Sopenharmony_ci    console.log(`Start Keyboard mouse crossing success.`);
277e41f4b71Sopenharmony_ci  }, (error: BusinessError) => {
278e41f4b71Sopenharmony_ci    console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
279e41f4b71Sopenharmony_ci  });
280e41f4b71Sopenharmony_ci} catch (error) {
281e41f4b71Sopenharmony_ci  console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
282e41f4b71Sopenharmony_ci}
283e41f4b71Sopenharmony_ci```
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ci## cooperate.deactivateCooperate<sup>11+</sup>
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_cideactivateCooperate(isUnchained: boolean, callback: AsyncCallback&lt;void&gt;): void;
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_ciStops screen hopping. This API uses an asynchronous callback to return the result.
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.COOPERATE_MANAGER
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci**Parameters**
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_ci| Name     | Type                     | Mandatory| Description                                                        |
300e41f4b71Sopenharmony_ci| ----------- | ------------------------- | ---- | ------------------------------------------------------------ |
301e41f4b71Sopenharmony_ci| isUnchained | boolean                   | Yes  | Whether to disable the cross-device link. The value **true** means to disable the cross-device link, and the value **false** means the opposite.|
302e41f4b71Sopenharmony_ci| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci**Error codes**
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
307e41f4b71Sopenharmony_ci
308e41f4b71Sopenharmony_ci| ID| Error Message         |
309e41f4b71Sopenharmony_ci| -------- | ----------------- |
310e41f4b71Sopenharmony_ci| 201 | Permission denied. |
311e41f4b71Sopenharmony_ci| 202 | Not system application. |
312e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_ci**Example**
315e41f4b71Sopenharmony_ci
316e41f4b71Sopenharmony_ci```ts
317e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
318e41f4b71Sopenharmony_citry {
319e41f4b71Sopenharmony_ci  cooperate.deactivateCooperate(false, (error: BusinessError) => {
320e41f4b71Sopenharmony_ci    if (error) {
321e41f4b71Sopenharmony_ci      console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
322e41f4b71Sopenharmony_ci      return;
323e41f4b71Sopenharmony_ci    }
324e41f4b71Sopenharmony_ci    console.log(`Stop Keyboard mouse crossing success.`);
325e41f4b71Sopenharmony_ci  });
326e41f4b71Sopenharmony_ci} catch (error) {
327e41f4b71Sopenharmony_ci  console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
328e41f4b71Sopenharmony_ci}
329e41f4b71Sopenharmony_ci```
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci## cooperate.deactivateCooperate<sup>11+</sup>
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_cideactivateCooperate(isUnchained: boolean): Promise&lt;void&gt;;
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ciStops screen hopping. This API uses a promise to return the result.
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.COOPERATE_MANAGER
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci**Parameters**
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ci| Name     | Type   | Mandatory| Description                                                        |
344e41f4b71Sopenharmony_ci| ----------- | ------- | ---- | ------------------------------------------------------------ |
345e41f4b71Sopenharmony_ci| isUnchained | boolean | Yes  | Whether to disable the cross-device link. The value **true** means to disable the cross-device link, and the value **false** means the opposite.|
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci**Return value**
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci| Name             | Description                     |
350e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
351e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ci**Error codes**
354e41f4b71Sopenharmony_ci
355e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci| ID| Error Message         |
358e41f4b71Sopenharmony_ci| -------- | ----------------- |
359e41f4b71Sopenharmony_ci| 201 | Permission denied. |
360e41f4b71Sopenharmony_ci| 202 | Not system application. |
361e41f4b71Sopenharmony_ci
362e41f4b71Sopenharmony_ci**Example**
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ci```ts
365e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
366e41f4b71Sopenharmony_citry {
367e41f4b71Sopenharmony_ci  cooperate.deactivateCooperate(false).then(() => {
368e41f4b71Sopenharmony_ci    console.log(`Stop Keyboard mouse crossing success.`);
369e41f4b71Sopenharmony_ci  }, (error: BusinessError) => {
370e41f4b71Sopenharmony_ci    console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
371e41f4b71Sopenharmony_ci  });
372e41f4b71Sopenharmony_ci} catch (error) {
373e41f4b71Sopenharmony_ci  console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
374e41f4b71Sopenharmony_ci}
375e41f4b71Sopenharmony_ci```
376e41f4b71Sopenharmony_ci
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci## cooperate.getCooperateSwitchState<sup>11+</sup>
380e41f4b71Sopenharmony_ci
381e41f4b71Sopenharmony_cigetCooperateSwitchState(networkId: string, callback: AsyncCallback&lt;boolean&gt;): void;
382e41f4b71Sopenharmony_ci
383e41f4b71Sopenharmony_ciObtains the screen hopping status of the target device. This API uses an asynchronous callback to return the result.
384e41f4b71Sopenharmony_ci
385e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.COOPERATE_MANAGER
386e41f4b71Sopenharmony_ci
387e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
388e41f4b71Sopenharmony_ci
389e41f4b71Sopenharmony_ci**Parameters**
390e41f4b71Sopenharmony_ci
391e41f4b71Sopenharmony_ci| Name   | Type                        | Mandatory| Description                                                        |
392e41f4b71Sopenharmony_ci| --------- | ---------------------------- | ---- | ------------------------------------------------------------ |
393e41f4b71Sopenharmony_ci| networkId | string                       | Yes  | Descriptor of the target device for screen hopping.                                    |
394e41f4b71Sopenharmony_ci| callback  | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. The value **true** indicates that screen hopping is enabled, and the value **false** indicates the opposite.|
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_ci**Error codes**
397e41f4b71Sopenharmony_ci
398e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
399e41f4b71Sopenharmony_ci
400e41f4b71Sopenharmony_ci| ID| Error Message         |
401e41f4b71Sopenharmony_ci| -------- | ----------------- |
402e41f4b71Sopenharmony_ci| 201 | Permission denied. |
403e41f4b71Sopenharmony_ci| 202 | Not system application. |
404e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
405e41f4b71Sopenharmony_ci
406e41f4b71Sopenharmony_ci**Example**
407e41f4b71Sopenharmony_ci
408e41f4b71Sopenharmony_ci```ts
409e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
410e41f4b71Sopenharmony_cilet deviceDescriptor = "networkId";
411e41f4b71Sopenharmony_citry {
412e41f4b71Sopenharmony_ci  cooperate.getCooperateSwitchState(deviceDescriptor, (error: BusinessError, data: boolean) => {
413e41f4b71Sopenharmony_ci    if (error) {
414e41f4b71Sopenharmony_ci      console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
415e41f4b71Sopenharmony_ci      return;
416e41f4b71Sopenharmony_ci    }
417e41f4b71Sopenharmony_ci    console.log(`Get the status success, data: ${JSON.stringify(data)}`);
418e41f4b71Sopenharmony_ci  });
419e41f4b71Sopenharmony_ci} catch (error) {
420e41f4b71Sopenharmony_ci  console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
421e41f4b71Sopenharmony_ci}
422e41f4b71Sopenharmony_ci```
423e41f4b71Sopenharmony_ci
424e41f4b71Sopenharmony_ci## cooperate.getCooperateSwitchState<sup>11+</sup>
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_cigetCooperateSwitchState(networkId: string): Promise&lt;boolean&gt;;
427e41f4b71Sopenharmony_ci
428e41f4b71Sopenharmony_ciObtains the screen hopping status of the target device. This API uses a promise to return the result.
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.COOPERATE_MANAGER
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_ci**Parameters**
435e41f4b71Sopenharmony_ci
436e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory| Description                    |
437e41f4b71Sopenharmony_ci| --------- | ------ | ---- | ------------------------ |
438e41f4b71Sopenharmony_ci| networkId | string | Yes  | Descriptor of the target device for screen hopping.|
439e41f4b71Sopenharmony_ci
440e41f4b71Sopenharmony_ci**Return value**
441e41f4b71Sopenharmony_ci
442e41f4b71Sopenharmony_ci| Parameters                  | Description                                                        |
443e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------ |
444e41f4b71Sopenharmony_ci| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** indicates that screen hopping is enabled, and the value **false** indicates the opposite.|
445e41f4b71Sopenharmony_ci
446e41f4b71Sopenharmony_ci**Error codes**
447e41f4b71Sopenharmony_ci
448e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci| ID| Error Message         |
451e41f4b71Sopenharmony_ci| -------- | ----------------- |
452e41f4b71Sopenharmony_ci| 201 | Permission denied. |
453e41f4b71Sopenharmony_ci| 202 | Not system application. |
454e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci**Example**
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci```ts
459e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
460e41f4b71Sopenharmony_cilet deviceDescriptor = "networkId";
461e41f4b71Sopenharmony_citry {
462e41f4b71Sopenharmony_ci  cooperate.getCooperateSwitchState(deviceDescriptor).then((data: boolean) => {
463e41f4b71Sopenharmony_ci    console.log(`Get the status success, data: ${JSON.stringify(data)}`);
464e41f4b71Sopenharmony_ci  }, (error: BusinessError) => {
465e41f4b71Sopenharmony_ci    console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
466e41f4b71Sopenharmony_ci  });
467e41f4b71Sopenharmony_ci} catch (error) {
468e41f4b71Sopenharmony_ci  console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
469e41f4b71Sopenharmony_ci}
470e41f4b71Sopenharmony_ci```
471e41f4b71Sopenharmony_ci
472e41f4b71Sopenharmony_ci
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ci## on('cooperateMessage')<sup>11+</sup>
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_cion(type: 'cooperateMessage', callback: Callback&lt;CooperateMessage&gt;): void;
477e41f4b71Sopenharmony_ci
478e41f4b71Sopenharmony_ciEnables listening for screen hopping status change events.
479e41f4b71Sopenharmony_ci
480e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.COOPERATE_MANAGER
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_ci**Parameters**
485e41f4b71Sopenharmony_ci
486e41f4b71Sopenharmony_ci| Name  | Type                                                 | Mandatory| Description                                |
487e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------- | ---- | ------------------------------------ |
488e41f4b71Sopenharmony_ci| type     | string                                                | Yes  | Event type. The value is **cooperateMessage**.  |
489e41f4b71Sopenharmony_ci| callback | Callback&lt;[CooperateMessage](#cooperatemessage11)&gt; | Yes  | Callback used to return the result.|
490e41f4b71Sopenharmony_ci
491e41f4b71Sopenharmony_ci**Error codes**
492e41f4b71Sopenharmony_ci
493e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
494e41f4b71Sopenharmony_ci
495e41f4b71Sopenharmony_ci| ID| Error Message         |
496e41f4b71Sopenharmony_ci| -------- | ----------------- |
497e41f4b71Sopenharmony_ci| 201 | Permission denied. |
498e41f4b71Sopenharmony_ci| 202 | Not system application. |
499e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
500e41f4b71Sopenharmony_ci
501e41f4b71Sopenharmony_ci**Example**
502e41f4b71Sopenharmony_ci
503e41f4b71Sopenharmony_ci```ts
504e41f4b71Sopenharmony_cifunction callback(msg: cooperate.CooperateMessage) {
505e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing event: ${JSON.stringify(msg)}`);
506e41f4b71Sopenharmony_ci  return false;
507e41f4b71Sopenharmony_ci}
508e41f4b71Sopenharmony_citry {
509e41f4b71Sopenharmony_ci  cooperate.on('cooperateMessage', callback);
510e41f4b71Sopenharmony_ci} catch (error) {
511e41f4b71Sopenharmony_ci  console.log(`Register failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
512e41f4b71Sopenharmony_ci}
513e41f4b71Sopenharmony_ci```
514e41f4b71Sopenharmony_ci
515e41f4b71Sopenharmony_ci
516e41f4b71Sopenharmony_ci
517e41f4b71Sopenharmony_ci## off('cooperateMessage')<sup>11+</sup>
518e41f4b71Sopenharmony_ci
519e41f4b71Sopenharmony_cioff(type: 'cooperateMessage', callback?: Callback&lt;CooperateMessage&gt;): void;
520e41f4b71Sopenharmony_ci
521e41f4b71Sopenharmony_ciDisables listening for screen hopping status change events.
522e41f4b71Sopenharmony_ci
523e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.COOPERATE_MANAGER
524e41f4b71Sopenharmony_ci
525e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
526e41f4b71Sopenharmony_ci
527e41f4b71Sopenharmony_ci**Parameters**
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci| Name  | Type                                                 | Mandatory| Description                                                        |
530e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ |
531e41f4b71Sopenharmony_ci| type     | string                                                | Yes  | Event type. The value is **cooperate**.                               |
532e41f4b71Sopenharmony_ci| callback | Callback&lt;[CooperateMessage](#cooperatemessage11)&gt; | No  | Callback to be unregistered. If this parameter is not specified, all callbacks registered by the current application will be unregistered.|
533e41f4b71Sopenharmony_ci
534e41f4b71Sopenharmony_ci**Error codes**
535e41f4b71Sopenharmony_ci
536e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
537e41f4b71Sopenharmony_ci
538e41f4b71Sopenharmony_ci| ID| Error Message         |
539e41f4b71Sopenharmony_ci| -------- | ----------------- |
540e41f4b71Sopenharmony_ci| 201 | Permission denied. |
541e41f4b71Sopenharmony_ci| 202 | Not system application. |
542e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
543e41f4b71Sopenharmony_ci
544e41f4b71Sopenharmony_ci**Example**
545e41f4b71Sopenharmony_ci
546e41f4b71Sopenharmony_ci```ts
547e41f4b71Sopenharmony_ci// Unregister a single callback.
548e41f4b71Sopenharmony_cifunction callbackOn(msgOn: cooperate.CooperateMessage) {
549e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing event: ${JSON.stringify(msgOn)}`);
550e41f4b71Sopenharmony_ci  return false;
551e41f4b71Sopenharmony_ci}
552e41f4b71Sopenharmony_cifunction callbackOff(msgOff: cooperate.CooperateMessage) {
553e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing event: ${JSON.stringify(msgOff)}`);
554e41f4b71Sopenharmony_ci  return false;
555e41f4b71Sopenharmony_ci}
556e41f4b71Sopenharmony_citry {
557e41f4b71Sopenharmony_ci  cooperate.on('cooperateMessage', callbackOn);
558e41f4b71Sopenharmony_ci  cooperate.off('cooperateMessage', callbackOff);
559e41f4b71Sopenharmony_ci} catch (error) {
560e41f4b71Sopenharmony_ci  console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
561e41f4b71Sopenharmony_ci}
562e41f4b71Sopenharmony_ci```
563e41f4b71Sopenharmony_ci
564e41f4b71Sopenharmony_ci```ts
565e41f4b71Sopenharmony_ci// Unregister all callbacks.
566e41f4b71Sopenharmony_cifunction callbackOn(msg: cooperate.CooperateMessage) {
567e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing event: ${JSON.stringify(msg)}`);
568e41f4b71Sopenharmony_ci  return false;
569e41f4b71Sopenharmony_ci}
570e41f4b71Sopenharmony_citry {
571e41f4b71Sopenharmony_ci  cooperate.on('cooperateMessage', callbackOn);
572e41f4b71Sopenharmony_ci  cooperate.off('cooperateMessage');
573e41f4b71Sopenharmony_ci} catch (error) {
574e41f4b71Sopenharmony_ci  console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
575e41f4b71Sopenharmony_ci}
576e41f4b71Sopenharmony_ci```
577e41f4b71Sopenharmony_ci
578e41f4b71Sopenharmony_ci
579e41f4b71Sopenharmony_ci## on('cooperateMouse')<sup>12+</sup>
580e41f4b71Sopenharmony_ci
581e41f4b71Sopenharmony_cion(type: 'cooperateMouse', networkId: string, callback: Callback&lt;MouseLocation&gt;): void;
582e41f4b71Sopenharmony_ci
583e41f4b71Sopenharmony_ciRegisters a listener for the mouse cursor position of a device.
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.COOPERATE_MANAGER
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
588e41f4b71Sopenharmony_ci
589e41f4b71Sopenharmony_ci**Parameters**
590e41f4b71Sopenharmony_ci
591e41f4b71Sopenharmony_ci| Name  | Type                                                 | Mandatory| Description                                |
592e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------- | ---- | ------------------------------------ |
593e41f4b71Sopenharmony_ci| type     | string                                                | Yes  | Event type, which is **'cooperateMouse'**.  |
594e41f4b71Sopenharmony_ci| networkId| string                                                | Yes  | Descriptor of the target device.  |
595e41f4b71Sopenharmony_ci| callback | Callback&lt;[MouseLocation](#mouselocation12)&gt; | Yes  | Callback used to return the mouse cursor position of the device.|
596e41f4b71Sopenharmony_ci
597e41f4b71Sopenharmony_ci**Error codes**
598e41f4b71Sopenharmony_ci
599e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
600e41f4b71Sopenharmony_ci
601e41f4b71Sopenharmony_ci| ID| Error Message         |
602e41f4b71Sopenharmony_ci| -------- | ----------------- |
603e41f4b71Sopenharmony_ci| 201 | Permission denied. |
604e41f4b71Sopenharmony_ci| 202 | Not system application. |
605e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
606e41f4b71Sopenharmony_ci
607e41f4b71Sopenharmony_ci**Example**
608e41f4b71Sopenharmony_ci
609e41f4b71Sopenharmony_ci```ts
610e41f4b71Sopenharmony_cifunction callback(data: cooperate.MouseLocation) {
611e41f4b71Sopenharmony_ci  console.log('displayX:' + data.displayX + 'displayY:' + data.displayX + 'displayWidth:' +
612e41f4b71Sopenharmony_ci    data.displayWidth + 'displayHeight:' + data.displayHeight );
613e41f4b71Sopenharmony_ci}
614e41f4b71Sopenharmony_citry {
615e41f4b71Sopenharmony_ci  let networkId: string = 'Default';
616e41f4b71Sopenharmony_ci  cooperate.on('cooperateMouse', networkId, callback);
617e41f4b71Sopenharmony_ci} catch (error) {
618e41f4b71Sopenharmony_ci  console.log(`Register failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
619e41f4b71Sopenharmony_ci}
620e41f4b71Sopenharmony_ci```
621e41f4b71Sopenharmony_ci
622e41f4b71Sopenharmony_ci
623e41f4b71Sopenharmony_ci
624e41f4b71Sopenharmony_ci## off('cooperateMouse')<sup>12+</sup>
625e41f4b71Sopenharmony_ci
626e41f4b71Sopenharmony_cioff(type: 'cooperateMouse', networkId: string, callback?: Callback&lt;MouseLocation&gt;): void;
627e41f4b71Sopenharmony_ci
628e41f4b71Sopenharmony_ciUnregisters the listener for the mouse cursor position of a device.
629e41f4b71Sopenharmony_ci
630e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.COOPERATE_MANAGER
631e41f4b71Sopenharmony_ci
632e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
633e41f4b71Sopenharmony_ci
634e41f4b71Sopenharmony_ci**Parameters**
635e41f4b71Sopenharmony_ci
636e41f4b71Sopenharmony_ci| Name  | Type                                                 | Mandatory| Description                                                        |
637e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ |
638e41f4b71Sopenharmony_ci| type     | string                                                | Yes  | Event type, which is **'cooperateMouse'**.                               |
639e41f4b71Sopenharmony_ci| networkId| string                                                | Yes  | Descriptor of the target device.  |
640e41f4b71Sopenharmony_ci| callback | Callback&lt;[MouseLocation](#mouselocation12)&gt; | No  | Callback to be unregistered. If this parameter is not specified, all callbacks registered by the current application will be unregistered.|
641e41f4b71Sopenharmony_ci
642e41f4b71Sopenharmony_ci**Error codes**
643e41f4b71Sopenharmony_ci
644e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
645e41f4b71Sopenharmony_ci
646e41f4b71Sopenharmony_ci| ID| Error Message         |
647e41f4b71Sopenharmony_ci| -------- | ----------------- |
648e41f4b71Sopenharmony_ci| 201 | Permission denied. |
649e41f4b71Sopenharmony_ci| 202 | Not system application. |
650e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
651e41f4b71Sopenharmony_ci
652e41f4b71Sopenharmony_ci**Example**
653e41f4b71Sopenharmony_ci
654e41f4b71Sopenharmony_ci```ts
655e41f4b71Sopenharmony_ci// Unregister a single callback.
656e41f4b71Sopenharmony_cifunction callbackOn(data: cooperate.MouseLocation) {
657e41f4b71Sopenharmony_ci  console.log('Register mouse location listener');
658e41f4b71Sopenharmony_ci  return false;
659e41f4b71Sopenharmony_ci}
660e41f4b71Sopenharmony_cifunction callbackOff(data: cooperate.MouseLocation) {
661e41f4b71Sopenharmony_ci  console.log('Unregister mouse location listener');
662e41f4b71Sopenharmony_ci  return false;
663e41f4b71Sopenharmony_ci}
664e41f4b71Sopenharmony_citry {
665e41f4b71Sopenharmony_ci  let networkId: string = 'Default';
666e41f4b71Sopenharmony_ci  cooperate.on('cooperateMouse', networkId, callbackOn);
667e41f4b71Sopenharmony_ci  cooperate.off('cooperateMouse', networkId, callbackOff);
668e41f4b71Sopenharmony_ci} catch (error) {
669e41f4b71Sopenharmony_ci  console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
670e41f4b71Sopenharmony_ci}
671e41f4b71Sopenharmony_ci```
672e41f4b71Sopenharmony_ci
673e41f4b71Sopenharmony_ci```ts
674e41f4b71Sopenharmony_ci// Unregister all callbacks.
675e41f4b71Sopenharmony_cifunction callbackOn(data: cooperate.MouseLocation) {
676e41f4b71Sopenharmony_ci  console.log('Register mouse location listener');
677e41f4b71Sopenharmony_ci}
678e41f4b71Sopenharmony_citry {
679e41f4b71Sopenharmony_ci  let networkId: string = 'Default';
680e41f4b71Sopenharmony_ci  cooperate.on('cooperateMouse', networkId, callbackOn);
681e41f4b71Sopenharmony_ci  cooperate.off('cooperateMouse', networkId);
682e41f4b71Sopenharmony_ci} catch (error) {
683e41f4b71Sopenharmony_ci  console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
684e41f4b71Sopenharmony_ci}
685e41f4b71Sopenharmony_ci```
686e41f4b71Sopenharmony_ci
687e41f4b71Sopenharmony_ci
688e41f4b71Sopenharmony_ci
689e41f4b71Sopenharmony_ci## CooperateMessage<sup>11+</sup>
690e41f4b71Sopenharmony_ci
691e41f4b71Sopenharmony_ciDefines a screen hopping status change event.
692e41f4b71Sopenharmony_ci
693e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
694e41f4b71Sopenharmony_ci
695e41f4b71Sopenharmony_ci| Name     | Type          | Readable| Writable| Description                    |
696e41f4b71Sopenharmony_ci| --------- | -------------- | ---- | ---- | ------------------------ |
697e41f4b71Sopenharmony_ci| networkId | string         | Yes  | No  | Descriptor of the target device for screen hopping.|
698e41f4b71Sopenharmony_ci| state     | CooperateState | Yes  | No  | Screen hopping status.        |
699e41f4b71Sopenharmony_ci
700e41f4b71Sopenharmony_ci
701e41f4b71Sopenharmony_ci## MouseLocation<sup>12+</sup>
702e41f4b71Sopenharmony_ci
703e41f4b71Sopenharmony_ciDefines the mouse pointer position for screen hopping.
704e41f4b71Sopenharmony_ci
705e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
706e41f4b71Sopenharmony_ci
707e41f4b71Sopenharmony_ci| Name          | Type           | Readable| Writable| Description                          |
708e41f4b71Sopenharmony_ci| ---------      | -------------- | ---- | ---- | ------------------------       |
709e41f4b71Sopenharmony_ci| displayX       | number         | Yes  | No  | Position of the mouse pointer on the X coordinate of the screen.|
710e41f4b71Sopenharmony_ci| displayY       | number         | Yes  | No  | Position of the mouse pointer on the Y coordinate of the screen.|
711e41f4b71Sopenharmony_ci| displayWidth   | number         | Yes  | No  | Screen width.                     |
712e41f4b71Sopenharmony_ci| displayHeight  | number         | Yes  | No  | Screen height.                     |
713e41f4b71Sopenharmony_ci
714e41f4b71Sopenharmony_ci
715e41f4b71Sopenharmony_ci
716e41f4b71Sopenharmony_ci## CooperateState<sup>11+</sup>
717e41f4b71Sopenharmony_ci
718e41f4b71Sopenharmony_ciScreen hopping status.
719e41f4b71Sopenharmony_ci
720e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
721e41f4b71Sopenharmony_ci
722e41f4b71Sopenharmony_ci| Name                          | Type   | Readable| Writable| Description                  |
723e41f4b71Sopenharmony_ci| ------------------------------ | ------ | ---- | ---- | ---------------------- |
724e41f4b71Sopenharmony_ci| COOPERATE_PREPARE              | number | Yes  | No  | The preparation for screen hopping is finished.    |
725e41f4b71Sopenharmony_ci| COOPERATE_UNPREPARE            | number | Yes  | No  | The preparation for screen hopping is cancelled.|
726e41f4b71Sopenharmony_ci| COOPERATE_ACTIVATE             | number | Yes  | No  | Screen hopping starts.    |
727e41f4b71Sopenharmony_ci| COOPERATE_ACTIVATE_SUCCESS     | number | Yes  | No  | Starting screen hopping succeeds.|
728e41f4b71Sopenharmony_ci| COOPERATE_ACTIVATE_FAIL        | number | Yes  | No  | Starting screen hopping fails.|
729e41f4b71Sopenharmony_ci| COOPERATE_DEACTIVATE_SUCCESS   | number | Yes  | No  | Stopping screen hopping succeeds.|
730e41f4b71Sopenharmony_ci| COOPERATE_DEACTIVATE_FAIL      | number | Yes  | No  | Stopping screen hopping fails.|
731e41f4b71Sopenharmony_ci| COOPERATE_SESSION_DISCONNECTED | number | Yes  | No  | The screen hopping session is disconnected.|
732e41f4b71Sopenharmony_ci| COOPERATE_ACTIVATE_FAILURE     | number | Yes  | No  | Screen hopping fails to start.|
733e41f4b71Sopenharmony_ci| COOPERATE_DEACTIVATE_FAILURE   | number | Yes  | No  | Screen hopping fails to stop.|
734e41f4b71Sopenharmony_ci
735e41f4b71Sopenharmony_ci
736e41f4b71Sopenharmony_ci## MouseLocation<sup>12+</sup>
737e41f4b71Sopenharmony_ci
738e41f4b71Sopenharmony_ciRepresents the mouse cursor position.
739e41f4b71Sopenharmony_ci
740e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
741e41f4b71Sopenharmony_ci
742e41f4b71Sopenharmony_ci| Name          | Type          | Readable| Writable| Description                    |
743e41f4b71Sopenharmony_ci| ---------     | -------------- | ---- | ---- | ------------------------ |
744e41f4b71Sopenharmony_ci| displayX      | number         | Yes  | No  | X coordinate of the mouse cursor.|
745e41f4b71Sopenharmony_ci| displayY      | number         | Yes  | No  | Y coordinate of the mouse cursor.|
746e41f4b71Sopenharmony_ci| displayWidth  | number         | Yes  | No  | Width of the screen where the mouse cursor is located.|
747e41f4b71Sopenharmony_ci| displayHeight | number         | Yes  | No  | Height of the screen where the mouse cursor is located.|
748e41f4b71Sopenharmony_ci
749e41f4b71Sopenharmony_ci
750e41f4b71Sopenharmony_ci## cooperate.prepare<sup>(deprecated)</sup>
751e41f4b71Sopenharmony_ci
752e41f4b71Sopenharmony_ciprepare(callback: AsyncCallback&lt;void&gt;): void;
753e41f4b71Sopenharmony_ci
754e41f4b71Sopenharmony_ciPrepares for screen hopping. This API uses an asynchronous callback to return the result.
755e41f4b71Sopenharmony_ci
756e41f4b71Sopenharmony_ci> **NOTE**
757e41f4b71Sopenharmony_ci>
758e41f4b71Sopenharmony_ci> This API is deprecated since API version 10. You are advised to use [cooperate.prepareCooperate](#cooperatepreparecooperate11).
759e41f4b71Sopenharmony_ci
760e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
761e41f4b71Sopenharmony_ci
762e41f4b71Sopenharmony_ci**Parameters**
763e41f4b71Sopenharmony_ci
764e41f4b71Sopenharmony_ci| Name   | Type     | Mandatory | Description   |
765e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | --------------------------- |
766e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;  | Yes|Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.  |
767e41f4b71Sopenharmony_ci
768e41f4b71Sopenharmony_ci**Error codes**
769e41f4b71Sopenharmony_ci
770e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
771e41f4b71Sopenharmony_ci
772e41f4b71Sopenharmony_ci| ID| Error Message         |
773e41f4b71Sopenharmony_ci| -------- | ----------------- |
774e41f4b71Sopenharmony_ci| 202 | Not system application. |
775e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
776e41f4b71Sopenharmony_ci
777e41f4b71Sopenharmony_ci**Example**
778e41f4b71Sopenharmony_ci
779e41f4b71Sopenharmony_ci```ts
780e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
781e41f4b71Sopenharmony_citry {
782e41f4b71Sopenharmony_ci  cooperate.prepare((error: BusinessError) => {
783e41f4b71Sopenharmony_ci    if (error) {
784e41f4b71Sopenharmony_ci      console.log(`Keyboard mouse crossing prepare failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
785e41f4b71Sopenharmony_ci      return;
786e41f4b71Sopenharmony_ci    }
787e41f4b71Sopenharmony_ci    console.log(`Keyboard mouse crossing prepare success.`);
788e41f4b71Sopenharmony_ci  });
789e41f4b71Sopenharmony_ci} catch (error) {
790e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing prepare failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
791e41f4b71Sopenharmony_ci}
792e41f4b71Sopenharmony_ci```
793e41f4b71Sopenharmony_ci
794e41f4b71Sopenharmony_ci## cooperate.prepare<sup>(deprecated)</sup>
795e41f4b71Sopenharmony_ci
796e41f4b71Sopenharmony_ciprepare(): Promise&lt;void&gt;;
797e41f4b71Sopenharmony_ci
798e41f4b71Sopenharmony_ciPrepares for screen hopping. This API uses a promise to return the result.
799e41f4b71Sopenharmony_ci
800e41f4b71Sopenharmony_ci> **NOTE**
801e41f4b71Sopenharmony_ci>
802e41f4b71Sopenharmony_ci> This API is deprecated since API version 10. You are advised to use [cooperate.prepareCooperate](#cooperatepreparecooperate11-1).
803e41f4b71Sopenharmony_ci
804e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
805e41f4b71Sopenharmony_ci
806e41f4b71Sopenharmony_ci**Return value**
807e41f4b71Sopenharmony_ci
808e41f4b71Sopenharmony_ci| Parameters                | Description                    |
809e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
810e41f4b71Sopenharmony_ci| Promise&lt;void&gt;      | Promise that returns no value.|
811e41f4b71Sopenharmony_ci
812e41f4b71Sopenharmony_ci**Error codes**
813e41f4b71Sopenharmony_ci
814e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
815e41f4b71Sopenharmony_ci
816e41f4b71Sopenharmony_ci| ID| Error Message         |
817e41f4b71Sopenharmony_ci| -------- | ----------------- |
818e41f4b71Sopenharmony_ci| 202 | Not system application. |
819e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
820e41f4b71Sopenharmony_ci
821e41f4b71Sopenharmony_ci**Example**
822e41f4b71Sopenharmony_ci
823e41f4b71Sopenharmony_ci```ts
824e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
825e41f4b71Sopenharmony_citry {
826e41f4b71Sopenharmony_ci  cooperate.prepare().then(() => {
827e41f4b71Sopenharmony_ci    console.log(`Keyboard mouse crossing prepare success.`);
828e41f4b71Sopenharmony_ci  }, (error: BusinessError) => {
829e41f4b71Sopenharmony_ci    console.log(`Keyboard mouse crossing prepare failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
830e41f4b71Sopenharmony_ci  });
831e41f4b71Sopenharmony_ci} catch (error) {
832e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing prepare failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
833e41f4b71Sopenharmony_ci}
834e41f4b71Sopenharmony_ci```
835e41f4b71Sopenharmony_ci
836e41f4b71Sopenharmony_ci
837e41f4b71Sopenharmony_ci
838e41f4b71Sopenharmony_ci## cooperate.unprepare<sup>(deprecated)</sup>
839e41f4b71Sopenharmony_ci
840e41f4b71Sopenharmony_ciunprepare(callback: AsyncCallback&lt;void&gt;): void;
841e41f4b71Sopenharmony_ci
842e41f4b71Sopenharmony_ciCancels the preparation for screen hopping. This API uses an asynchronous callback to return the result.
843e41f4b71Sopenharmony_ci
844e41f4b71Sopenharmony_ci> **NOTE**
845e41f4b71Sopenharmony_ci>
846e41f4b71Sopenharmony_ci> This API is deprecated since API version 10. You are advised to use [cooperate.unprepareCooperate](#cooperateunpreparecooperate11).
847e41f4b71Sopenharmony_ci
848e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
849e41f4b71Sopenharmony_ci
850e41f4b71Sopenharmony_ci| Name  | Type                     | Mandatory| Description                                      |
851e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------------ |
852e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
853e41f4b71Sopenharmony_ci
854e41f4b71Sopenharmony_ci**Error codes**
855e41f4b71Sopenharmony_ci
856e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
857e41f4b71Sopenharmony_ci
858e41f4b71Sopenharmony_ci| ID| Error Message         |
859e41f4b71Sopenharmony_ci| -------- | ----------------- |
860e41f4b71Sopenharmony_ci| 202 | Not system application. |
861e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
862e41f4b71Sopenharmony_ci
863e41f4b71Sopenharmony_ci**Example**
864e41f4b71Sopenharmony_ci
865e41f4b71Sopenharmony_ci```ts
866e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
867e41f4b71Sopenharmony_citry {
868e41f4b71Sopenharmony_ci  cooperate.unprepare((error: BusinessError) => {
869e41f4b71Sopenharmony_ci    if (error) {
870e41f4b71Sopenharmony_ci      console.log(`Keyboard mouse crossing unprepare failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
871e41f4b71Sopenharmony_ci      return;
872e41f4b71Sopenharmony_ci    }
873e41f4b71Sopenharmony_ci    console.log(`Keyboard mouse crossing unprepare success.`);
874e41f4b71Sopenharmony_ci  });
875e41f4b71Sopenharmony_ci} catch (error) {
876e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing unprepare failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
877e41f4b71Sopenharmony_ci}
878e41f4b71Sopenharmony_ci```
879e41f4b71Sopenharmony_ci
880e41f4b71Sopenharmony_ci## cooperate.unprepare<sup>(deprecated)</sup>
881e41f4b71Sopenharmony_ci
882e41f4b71Sopenharmony_ciunprepare(): Promise&lt;void&gt;;
883e41f4b71Sopenharmony_ci
884e41f4b71Sopenharmony_ciCancels the preparation for screen hopping. This API uses a promise to return the result.
885e41f4b71Sopenharmony_ci
886e41f4b71Sopenharmony_ci> **NOTE**
887e41f4b71Sopenharmony_ci>
888e41f4b71Sopenharmony_ci> This API is deprecated since API version 10. You are advised to use [cooperate.unprepareCooperate](#cooperateunpreparecooperate11-1).
889e41f4b71Sopenharmony_ci
890e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
891e41f4b71Sopenharmony_ci
892e41f4b71Sopenharmony_ci**Return value**
893e41f4b71Sopenharmony_ci
894e41f4b71Sopenharmony_ci| Parameters               | Description                                         |
895e41f4b71Sopenharmony_ci| ------------------- | --------------------------------------------- |
896e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
897e41f4b71Sopenharmony_ci
898e41f4b71Sopenharmony_ci**Error codes**
899e41f4b71Sopenharmony_ci
900e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
901e41f4b71Sopenharmony_ci
902e41f4b71Sopenharmony_ci| ID| Error Message         |
903e41f4b71Sopenharmony_ci| -------- | ----------------- |
904e41f4b71Sopenharmony_ci| 202 | Not system application. |
905e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
906e41f4b71Sopenharmony_ci
907e41f4b71Sopenharmony_ci**Example**
908e41f4b71Sopenharmony_ci
909e41f4b71Sopenharmony_ci```ts
910e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
911e41f4b71Sopenharmony_citry {
912e41f4b71Sopenharmony_ci  cooperate.unprepare().then(() => {
913e41f4b71Sopenharmony_ci    console.log(`Keyboard mouse crossing unprepare success.`);
914e41f4b71Sopenharmony_ci  }, (error: BusinessError) => {
915e41f4b71Sopenharmony_ci    console.log(`Keyboard mouse crossing unprepare failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
916e41f4b71Sopenharmony_ci  });
917e41f4b71Sopenharmony_ci} catch (error) {
918e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing unprepare failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
919e41f4b71Sopenharmony_ci}
920e41f4b71Sopenharmony_ci```
921e41f4b71Sopenharmony_ci
922e41f4b71Sopenharmony_ci
923e41f4b71Sopenharmony_ci
924e41f4b71Sopenharmony_ci## cooperate.activate<sup>(deprecated)</sup>
925e41f4b71Sopenharmony_ci
926e41f4b71Sopenharmony_ciactivate(targetNetworkId: string, inputDeviceId: number, callback: AsyncCallback&lt;void&gt;): void;
927e41f4b71Sopenharmony_ci
928e41f4b71Sopenharmony_ciStarts screen hopping. This API uses an asynchronous callback to return the result.
929e41f4b71Sopenharmony_ci
930e41f4b71Sopenharmony_ci> **NOTE**
931e41f4b71Sopenharmony_ci>
932e41f4b71Sopenharmony_ci> This API is deprecated since API version 10. You are advised to use [cooperate.activateCooperate](#cooperateactivatecooperate11).
933e41f4b71Sopenharmony_ci
934e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
935e41f4b71Sopenharmony_ci
936e41f4b71Sopenharmony_ci**Parameters**
937e41f4b71Sopenharmony_ci
938e41f4b71Sopenharmony_ci| Name               | Type                         | Mandatory | Description                           |
939e41f4b71Sopenharmony_ci| --------             | ---------------------------- | ----  | ----------------------------   |
940e41f4b71Sopenharmony_ci| targetNetworkId | string                       |  Yes  | Descriptor of the target device for screen hopping.            |
941e41f4b71Sopenharmony_ci| inputDeviceId | number                       |  Yes  | Identifier of the input device for screen hopping.|
942e41f4b71Sopenharmony_ci| callback             | AsyncCallback&lt;void&gt; |  Yes   | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
943e41f4b71Sopenharmony_ci
944e41f4b71Sopenharmony_ci**Error codes**
945e41f4b71Sopenharmony_ci
946e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
947e41f4b71Sopenharmony_ci
948e41f4b71Sopenharmony_ci| ID| Error Message|
949e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
950e41f4b71Sopenharmony_ci| 20900001 | Operation failed.|
951e41f4b71Sopenharmony_ci| 202 | Not system application. |
952e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
953e41f4b71Sopenharmony_ci
954e41f4b71Sopenharmony_ci**Example**
955e41f4b71Sopenharmony_ci
956e41f4b71Sopenharmony_ci```ts
957e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
958e41f4b71Sopenharmony_cilet targetNetworkId = "networkId";
959e41f4b71Sopenharmony_cilet inputDeviceId = 0;
960e41f4b71Sopenharmony_citry {
961e41f4b71Sopenharmony_ci  cooperate.activate(targetNetworkId, inputDeviceId, (error: BusinessError) => {
962e41f4b71Sopenharmony_ci    if (error) {
963e41f4b71Sopenharmony_ci      console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
964e41f4b71Sopenharmony_ci      return;
965e41f4b71Sopenharmony_ci    }
966e41f4b71Sopenharmony_ci    console.log(`Start Keyboard mouse crossing success.`);
967e41f4b71Sopenharmony_ci  });
968e41f4b71Sopenharmony_ci} catch (error) {
969e41f4b71Sopenharmony_ci  console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
970e41f4b71Sopenharmony_ci}
971e41f4b71Sopenharmony_ci```
972e41f4b71Sopenharmony_ci
973e41f4b71Sopenharmony_ci## cooperate.activate<sup>(deprecated)</sup>
974e41f4b71Sopenharmony_ci
975e41f4b71Sopenharmony_ciactivate(targetNetworkId: string, inputDeviceId: number): Promise&lt;void&gt;;
976e41f4b71Sopenharmony_ci
977e41f4b71Sopenharmony_ciStarts screen hopping. This API uses a promise to return the result.
978e41f4b71Sopenharmony_ci
979e41f4b71Sopenharmony_ci> **NOTE**
980e41f4b71Sopenharmony_ci>
981e41f4b71Sopenharmony_ci> This API is deprecated since API version 10. You are advised to use [cooperate.activateCooperate](#cooperateactivatecooperate11-1).
982e41f4b71Sopenharmony_ci
983e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
984e41f4b71Sopenharmony_ci
985e41f4b71Sopenharmony_ci**Parameters**
986e41f4b71Sopenharmony_ci
987e41f4b71Sopenharmony_ci| Name               | Type                         | Mandatory | Description                           |
988e41f4b71Sopenharmony_ci| --------             | ---------------------------- | ----  | ----------------------------   |
989e41f4b71Sopenharmony_ci| targetNetworkId | string                       |  Yes  | Descriptor of the target device for screen hopping.            |
990e41f4b71Sopenharmony_ci| inputDeviceId | number                       |  Yes  | Identifier of the input device for screen hopping.|
991e41f4b71Sopenharmony_ci
992e41f4b71Sopenharmony_ci
993e41f4b71Sopenharmony_ci
994e41f4b71Sopenharmony_ci**Return value**
995e41f4b71Sopenharmony_ci
996e41f4b71Sopenharmony_ci| Name                 | Description                            |
997e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------- |
998e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.    |
999e41f4b71Sopenharmony_ci
1000e41f4b71Sopenharmony_ci**Error codes**
1001e41f4b71Sopenharmony_ci
1002e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
1003e41f4b71Sopenharmony_ci
1004e41f4b71Sopenharmony_ci| ID| Error Message|
1005e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1006e41f4b71Sopenharmony_ci| 20900001 | Operation failed.   |
1007e41f4b71Sopenharmony_ci| 202 | Not system application. |
1008e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
1009e41f4b71Sopenharmony_ci
1010e41f4b71Sopenharmony_ci**Example**
1011e41f4b71Sopenharmony_ci
1012e41f4b71Sopenharmony_ci```ts
1013e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
1014e41f4b71Sopenharmony_cilet targetNetworkId = "networkId";
1015e41f4b71Sopenharmony_cilet inputDeviceId = 0;
1016e41f4b71Sopenharmony_citry {
1017e41f4b71Sopenharmony_ci cooperate.activate(targetNetworkId, inputDeviceId).then(() => {
1018e41f4b71Sopenharmony_ci    console.log(`Start Keyboard mouse crossing success.`);
1019e41f4b71Sopenharmony_ci  }, (error: BusinessError) => {
1020e41f4b71Sopenharmony_ci    console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
1021e41f4b71Sopenharmony_ci  });
1022e41f4b71Sopenharmony_ci} catch (error) {
1023e41f4b71Sopenharmony_ci  console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
1024e41f4b71Sopenharmony_ci}
1025e41f4b71Sopenharmony_ci```
1026e41f4b71Sopenharmony_ci
1027e41f4b71Sopenharmony_ci
1028e41f4b71Sopenharmony_ci
1029e41f4b71Sopenharmony_ci## cooperate.deactivate<sup>(deprecated)</sup>
1030e41f4b71Sopenharmony_ci
1031e41f4b71Sopenharmony_cideactivate(isUnchained: boolean, callback: AsyncCallback&lt;void&gt;): void;
1032e41f4b71Sopenharmony_ci
1033e41f4b71Sopenharmony_ciStops screen hopping. This API uses an asynchronous callback to return the result.
1034e41f4b71Sopenharmony_ci
1035e41f4b71Sopenharmony_ci> **NOTE**
1036e41f4b71Sopenharmony_ci>
1037e41f4b71Sopenharmony_ci> This API is deprecated since API version 10. You are advised to use [cooperate.deactivateCooperate](#cooperatedeactivatecooperate11).
1038e41f4b71Sopenharmony_ci
1039e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
1040e41f4b71Sopenharmony_ci
1041e41f4b71Sopenharmony_ci**Parameters**
1042e41f4b71Sopenharmony_ci
1043e41f4b71Sopenharmony_ci| Name               | Type                         | Mandatory | Description                           |
1044e41f4b71Sopenharmony_ci| --------             | ---------------------------- | ----  | ----------------------------   |
1045e41f4b71Sopenharmony_ci| isUnchained | boolean | Yes| Whether to disable the cross-device link.<br> The value **true** means to disable the cross-device link, and the value **false** means the opposite.|
1046e41f4b71Sopenharmony_ci| callback     | AsyncCallback&lt;void&gt; |  Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
1047e41f4b71Sopenharmony_ci
1048e41f4b71Sopenharmony_ci**Error codes**
1049e41f4b71Sopenharmony_ci
1050e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
1051e41f4b71Sopenharmony_ci
1052e41f4b71Sopenharmony_ci| ID| Error Message         |
1053e41f4b71Sopenharmony_ci| -------- | ----------------- |
1054e41f4b71Sopenharmony_ci| 202 | Not system application. |
1055e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
1056e41f4b71Sopenharmony_ci
1057e41f4b71Sopenharmony_ci**Example**
1058e41f4b71Sopenharmony_ci
1059e41f4b71Sopenharmony_ci```ts
1060e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
1061e41f4b71Sopenharmony_citry {
1062e41f4b71Sopenharmony_ci  cooperate.deactivate(false, (error: BusinessError) => {
1063e41f4b71Sopenharmony_ci    if (error) {
1064e41f4b71Sopenharmony_ci      console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
1065e41f4b71Sopenharmony_ci      return;
1066e41f4b71Sopenharmony_ci    }
1067e41f4b71Sopenharmony_ci    console.log(`Stop Keyboard mouse crossing success.`);
1068e41f4b71Sopenharmony_ci  });
1069e41f4b71Sopenharmony_ci} catch (error) {
1070e41f4b71Sopenharmony_ci  console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
1071e41f4b71Sopenharmony_ci}
1072e41f4b71Sopenharmony_ci```
1073e41f4b71Sopenharmony_ci
1074e41f4b71Sopenharmony_ci## cooperate.deactivate<sup>(deprecated)</sup>
1075e41f4b71Sopenharmony_ci
1076e41f4b71Sopenharmony_cideactivate(isUnchained: boolean): Promise&lt;void&gt;;
1077e41f4b71Sopenharmony_ci
1078e41f4b71Sopenharmony_ciStops screen hopping. This API uses a promise to return the result.
1079e41f4b71Sopenharmony_ci
1080e41f4b71Sopenharmony_ci> **NOTE**
1081e41f4b71Sopenharmony_ci>
1082e41f4b71Sopenharmony_ci> This API is deprecated since API version 10. You are advised to use [cooperate.deactivateCooperate](#cooperatedeactivatecooperate11-1).
1083e41f4b71Sopenharmony_ci
1084e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
1085e41f4b71Sopenharmony_ci
1086e41f4b71Sopenharmony_ci**Parameters**
1087e41f4b71Sopenharmony_ci
1088e41f4b71Sopenharmony_ci| Name     | Type   | Mandatory| Description              |
1089e41f4b71Sopenharmony_ci| ----------- | ------- | ---- | ------------------ |
1090e41f4b71Sopenharmony_ci| isUnchained | boolean | Yes  | Whether to disable the cross-device link.<br> The value **true** means to disable the cross-device link, and the value **false** means the opposite.|
1091e41f4b71Sopenharmony_ci
1092e41f4b71Sopenharmony_ci
1093e41f4b71Sopenharmony_ci
1094e41f4b71Sopenharmony_ci**Return value**
1095e41f4b71Sopenharmony_ci
1096e41f4b71Sopenharmony_ci| Name               | Description                           |
1097e41f4b71Sopenharmony_ci| --------             | ----------------------------   |
1098e41f4b71Sopenharmony_ci| Promise&lt;void&gt; |  Promise that returns no value.     |
1099e41f4b71Sopenharmony_ci
1100e41f4b71Sopenharmony_ci**Error codes**
1101e41f4b71Sopenharmony_ci
1102e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
1103e41f4b71Sopenharmony_ci
1104e41f4b71Sopenharmony_ci| ID| Error Message         |
1105e41f4b71Sopenharmony_ci| -------- | ----------------- |
1106e41f4b71Sopenharmony_ci| 202 | Not system application. |
1107e41f4b71Sopenharmony_ci
1108e41f4b71Sopenharmony_ci**Example**
1109e41f4b71Sopenharmony_ci
1110e41f4b71Sopenharmony_ci```ts
1111e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
1112e41f4b71Sopenharmony_citry {
1113e41f4b71Sopenharmony_ci  cooperate.deactivate(false).then(() => {
1114e41f4b71Sopenharmony_ci    console.log(`Stop Keyboard mouse crossing success.`);
1115e41f4b71Sopenharmony_ci  }, (error: BusinessError) => {
1116e41f4b71Sopenharmony_ci    console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
1117e41f4b71Sopenharmony_ci  });
1118e41f4b71Sopenharmony_ci} catch (error) {
1119e41f4b71Sopenharmony_ci  console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
1120e41f4b71Sopenharmony_ci}
1121e41f4b71Sopenharmony_ci```
1122e41f4b71Sopenharmony_ci
1123e41f4b71Sopenharmony_ci
1124e41f4b71Sopenharmony_ci
1125e41f4b71Sopenharmony_ci## cooperate.getCrossingSwitchState<sup>(deprecated)</sup>
1126e41f4b71Sopenharmony_ci
1127e41f4b71Sopenharmony_cigetCrossingSwitchState(networkId: string, callback: AsyncCallback&lt;boolean&gt;): void;
1128e41f4b71Sopenharmony_ci
1129e41f4b71Sopenharmony_ciObtains the screen hopping status of the target device. This API uses an asynchronous callback to return the result.
1130e41f4b71Sopenharmony_ci
1131e41f4b71Sopenharmony_ci> **NOTE**
1132e41f4b71Sopenharmony_ci>
1133e41f4b71Sopenharmony_ci> This API is deprecated since API version 10. You are advised to use [cooperate.deactivateCooperate](#cooperategetcooperateswitchstate11).
1134e41f4b71Sopenharmony_ci
1135e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
1136e41f4b71Sopenharmony_ci
1137e41f4b71Sopenharmony_ci**Parameters**
1138e41f4b71Sopenharmony_ci
1139e41f4b71Sopenharmony_ci| Name               | Type                         | Mandatory  | Description                           |
1140e41f4b71Sopenharmony_ci| --------             | ---------                    | ----  | ----------------------------    |
1141e41f4b71Sopenharmony_ci| networkId | string                       |  Yes   | Descriptor of the target device for screen hopping.            |
1142e41f4b71Sopenharmony_ci| callback             | AsyncCallback&lt;boolean&gt; |  Yes   | Callback used to return the result. The value **true** indicates that screen hopping is enabled, and the value **false** indicates the opposite.|
1143e41f4b71Sopenharmony_ci
1144e41f4b71Sopenharmony_ci**Error codes**
1145e41f4b71Sopenharmony_ci
1146e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
1147e41f4b71Sopenharmony_ci
1148e41f4b71Sopenharmony_ci| ID| Error Message         |
1149e41f4b71Sopenharmony_ci| -------- | ----------------- |
1150e41f4b71Sopenharmony_ci| 202 | Not system application. |
1151e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
1152e41f4b71Sopenharmony_ci
1153e41f4b71Sopenharmony_ci**Example**
1154e41f4b71Sopenharmony_ci
1155e41f4b71Sopenharmony_ci```ts
1156e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
1157e41f4b71Sopenharmony_cilet deviceDescriptor = "networkId";
1158e41f4b71Sopenharmony_citry {
1159e41f4b71Sopenharmony_ci  cooperate.getCrossingSwitchState(deviceDescriptor, (error: BusinessError, data: boolean) => {
1160e41f4b71Sopenharmony_ci    if (error) {
1161e41f4b71Sopenharmony_ci      console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
1162e41f4b71Sopenharmony_ci      return;
1163e41f4b71Sopenharmony_ci    }
1164e41f4b71Sopenharmony_ci    console.log(`Get the status success, data: ${JSON.stringify(data)}`);
1165e41f4b71Sopenharmony_ci  });
1166e41f4b71Sopenharmony_ci} catch (error) {
1167e41f4b71Sopenharmony_ci  console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
1168e41f4b71Sopenharmony_ci}
1169e41f4b71Sopenharmony_ci```
1170e41f4b71Sopenharmony_ci
1171e41f4b71Sopenharmony_ci## cooperate.getCrossingSwitchState<sup>(deprecated)</sup>
1172e41f4b71Sopenharmony_ci
1173e41f4b71Sopenharmony_cigetCrossingSwitchState(networkId: string): Promise&lt;boolean&gt;;
1174e41f4b71Sopenharmony_ci
1175e41f4b71Sopenharmony_ciObtains the screen hopping status of the target device. This API uses a promise to return the result.
1176e41f4b71Sopenharmony_ci
1177e41f4b71Sopenharmony_ci> **NOTE**
1178e41f4b71Sopenharmony_ci>
1179e41f4b71Sopenharmony_ci> This API is deprecated since API version 10. You are advised to use [cooperate.getCooperateSwitchState](#cooperategetcooperateswitchstate11-1).
1180e41f4b71Sopenharmony_ci
1181e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
1182e41f4b71Sopenharmony_ci
1183e41f4b71Sopenharmony_ci**Parameters**
1184e41f4b71Sopenharmony_ci
1185e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory  | Description                           |
1186e41f4b71Sopenharmony_ci| --------   | ---------  | ----  | ----------------------------    |
1187e41f4b71Sopenharmony_ci| networkId | string     |  Yes   | Descriptor of the target device for screen hopping.           |
1188e41f4b71Sopenharmony_ci
1189e41f4b71Sopenharmony_ci**Error codes**
1190e41f4b71Sopenharmony_ci
1191e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
1192e41f4b71Sopenharmony_ci
1193e41f4b71Sopenharmony_ci| ID| Error Message         |
1194e41f4b71Sopenharmony_ci| -------- | ----------------- |
1195e41f4b71Sopenharmony_ci| 202 | Not system application. |
1196e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
1197e41f4b71Sopenharmony_ci
1198e41f4b71Sopenharmony_ci**Return value**
1199e41f4b71Sopenharmony_ci
1200e41f4b71Sopenharmony_ci| Parameters                       | Description                    |
1201e41f4b71Sopenharmony_ci| -------------------        | ------------------------------- |
1202e41f4b71Sopenharmony_ci| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** indicates that screen hopping is enabled, and the value **false** indicates the opposite.|
1203e41f4b71Sopenharmony_ci
1204e41f4b71Sopenharmony_ci
1205e41f4b71Sopenharmony_ci
1206e41f4b71Sopenharmony_ci**Example**
1207e41f4b71Sopenharmony_ci
1208e41f4b71Sopenharmony_ci```ts
1209e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
1210e41f4b71Sopenharmony_cilet deviceDescriptor = "networkId";
1211e41f4b71Sopenharmony_citry {
1212e41f4b71Sopenharmony_ci  cooperate.getCrossingSwitchState(deviceDescriptor).then((data: boolean) => {
1213e41f4b71Sopenharmony_ci    console.log(`Get the status success, data: ${JSON.stringify(data)}`);
1214e41f4b71Sopenharmony_ci  }, (error: BusinessError) => {
1215e41f4b71Sopenharmony_ci    console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
1216e41f4b71Sopenharmony_ci  });
1217e41f4b71Sopenharmony_ci} catch (error) {
1218e41f4b71Sopenharmony_ci  console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
1219e41f4b71Sopenharmony_ci}
1220e41f4b71Sopenharmony_ci```
1221e41f4b71Sopenharmony_ci
1222e41f4b71Sopenharmony_ci
1223e41f4b71Sopenharmony_ci
1224e41f4b71Sopenharmony_ci## on('cooperate')<sup>(deprecated)</sup>
1225e41f4b71Sopenharmony_ci
1226e41f4b71Sopenharmony_cion(type: 'cooperate', callback: Callback&lt;{ networkId: string, msg: CooperateMsg }&gt;): void;
1227e41f4b71Sopenharmony_ci
1228e41f4b71Sopenharmony_ciEnables listening for screen hopping status change events.
1229e41f4b71Sopenharmony_ci
1230e41f4b71Sopenharmony_ci> **NOTE**
1231e41f4b71Sopenharmony_ci>
1232e41f4b71Sopenharmony_ci> This API is deprecated since API version 10. You are advised to use [on('cooperateMessage')](#oncooperatemessage11).
1233e41f4b71Sopenharmony_ci
1234e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
1235e41f4b71Sopenharmony_ci
1236e41f4b71Sopenharmony_ci**Parameters**
1237e41f4b71Sopenharmony_ci
1238e41f4b71Sopenharmony_ci| Name               | Type                                                            | Mandatory| Description                           |
1239e41f4b71Sopenharmony_ci| --------             | ----------------------------                                    | ---- | ----------------------------   |
1240e41f4b71Sopenharmony_ci| type                 | string                                                          |  Yes | Event type. The value is **cooperate**.|
1241e41f4b71Sopenharmony_ci| callback             | Callback&lt;{ networkId: string, msg: [CooperateMsg](#cooperatemsgdeprecated) }&gt; |  Yes | Callback used to return the result.|
1242e41f4b71Sopenharmony_ci
1243e41f4b71Sopenharmony_ci**Error codes**
1244e41f4b71Sopenharmony_ci
1245e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
1246e41f4b71Sopenharmony_ci
1247e41f4b71Sopenharmony_ci| ID| Error Message         |
1248e41f4b71Sopenharmony_ci| -------- | ----------------- |
1249e41f4b71Sopenharmony_ci| 202 | Not system application. |
1250e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
1251e41f4b71Sopenharmony_ci
1252e41f4b71Sopenharmony_ci**Example**
1253e41f4b71Sopenharmony_ci
1254e41f4b71Sopenharmony_ci```ts
1255e41f4b71Sopenharmony_cifunction callback(networkId: string, msg: cooperate.CooperateMsg) {
1256e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing event: ${JSON.stringify(networkId)}`);
1257e41f4b71Sopenharmony_ci  return false;
1258e41f4b71Sopenharmony_ci}
1259e41f4b71Sopenharmony_citry {
1260e41f4b71Sopenharmony_ci  cooperate.on('cooperate', callback);
1261e41f4b71Sopenharmony_ci} catch (error) {
1262e41f4b71Sopenharmony_ci  console.log(`Register failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
1263e41f4b71Sopenharmony_ci}
1264e41f4b71Sopenharmony_ci```
1265e41f4b71Sopenharmony_ci
1266e41f4b71Sopenharmony_ci
1267e41f4b71Sopenharmony_ci
1268e41f4b71Sopenharmony_ci## off('cooperate')<sup>(deprecated)</sup>
1269e41f4b71Sopenharmony_ci
1270e41f4b71Sopenharmony_cioff(type: 'cooperate', callback?: Callback&lt;void&gt;): void;
1271e41f4b71Sopenharmony_ci
1272e41f4b71Sopenharmony_ciDisables listening for screen hopping status change events.
1273e41f4b71Sopenharmony_ci
1274e41f4b71Sopenharmony_ci> **NOTE**
1275e41f4b71Sopenharmony_ci>
1276e41f4b71Sopenharmony_ci> This API is deprecated since API version 10. You are advised to use [off('cooperateMessage')](#offcooperatemessage11).
1277e41f4b71Sopenharmony_ci
1278e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
1279e41f4b71Sopenharmony_ci
1280e41f4b71Sopenharmony_ci**Parameters**
1281e41f4b71Sopenharmony_ci
1282e41f4b71Sopenharmony_ci| Name               | Type                                                             | Mandatory   | Description                          |
1283e41f4b71Sopenharmony_ci| --------             | ----------------------------                                     | ----   | ----------------------------   |
1284e41f4b71Sopenharmony_ci| type                 | string                                                           |  Yes   | Event type. The value is **cooperate**.|
1285e41f4b71Sopenharmony_ci| callback             | AsyncCallback&lt;void&gt; |  No | Callback to be unregistered. If this parameter is not specified, all callbacks registered by the current application will be unregistered.|
1286e41f4b71Sopenharmony_ci
1287e41f4b71Sopenharmony_ci**Error codes**
1288e41f4b71Sopenharmony_ci
1289e41f4b71Sopenharmony_ciFor details about the error codes, see [Screen Hopping Error Codes](errorcode-devicestatus.md).
1290e41f4b71Sopenharmony_ci
1291e41f4b71Sopenharmony_ci| ID| Error Message         |
1292e41f4b71Sopenharmony_ci| -------- | ----------------- |
1293e41f4b71Sopenharmony_ci| 202 | Not system application. |
1294e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
1295e41f4b71Sopenharmony_ci
1296e41f4b71Sopenharmony_ci**Example**
1297e41f4b71Sopenharmony_ci
1298e41f4b71Sopenharmony_ci```ts
1299e41f4b71Sopenharmony_ci// Unregister a single callback.
1300e41f4b71Sopenharmony_cifunction callbackOn(networkId: string, msg: cooperate.CooperateMsg) {
1301e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing event: ${JSON.stringify(networkId)}`);
1302e41f4b71Sopenharmony_ci  return false;
1303e41f4b71Sopenharmony_ci}
1304e41f4b71Sopenharmony_cifunction callbackOff() {
1305e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing event`);
1306e41f4b71Sopenharmony_ci  return false;
1307e41f4b71Sopenharmony_ci}
1308e41f4b71Sopenharmony_citry {
1309e41f4b71Sopenharmony_ci  cooperate.on('cooperate', callbackOn);
1310e41f4b71Sopenharmony_ci  cooperate.off('cooperate', callbackOff);
1311e41f4b71Sopenharmony_ci} catch (error) {
1312e41f4b71Sopenharmony_ci  console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
1313e41f4b71Sopenharmony_ci}
1314e41f4b71Sopenharmony_ci```
1315e41f4b71Sopenharmony_ci```ts
1316e41f4b71Sopenharmony_ci// Unregister all callbacks.
1317e41f4b71Sopenharmony_cifunction callbackOn(networkId: string, msg: cooperate.CooperateMsg) {
1318e41f4b71Sopenharmony_ci  console.log(`Keyboard mouse crossing event: ${JSON.stringify(networkId)}`);
1319e41f4b71Sopenharmony_ci  return false;
1320e41f4b71Sopenharmony_ci}
1321e41f4b71Sopenharmony_citry {
1322e41f4b71Sopenharmony_ci  cooperate.on('cooperate', callbackOn);
1323e41f4b71Sopenharmony_ci  cooperate.off('cooperate');
1324e41f4b71Sopenharmony_ci} catch (error) {
1325e41f4b71Sopenharmony_ci  console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
1326e41f4b71Sopenharmony_ci}
1327e41f4b71Sopenharmony_ci```
1328e41f4b71Sopenharmony_ci
1329e41f4b71Sopenharmony_ci
1330e41f4b71Sopenharmony_ci
1331e41f4b71Sopenharmony_ci##  CooperateMsg<sup>(deprecated)</sup>
1332e41f4b71Sopenharmony_ci
1333e41f4b71Sopenharmony_ciRepresents a screen hopping message notification.
1334e41f4b71Sopenharmony_ci
1335e41f4b71Sopenharmony_ci> **NOTE**
1336e41f4b71Sopenharmony_ci>
1337e41f4b71Sopenharmony_ci> This API is deprecated since API version 10. You are advised to use [CooperateMessage](#cooperatemessage11).
1338e41f4b71Sopenharmony_ci
1339e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Msdp.DeviceStatus.Cooperate
1340e41f4b71Sopenharmony_ci
1341e41f4b71Sopenharmony_ci| Name                      | Value                            | Description                             |
1342e41f4b71Sopenharmony_ci| --------                     |  -----------------               |  -----------------               |
1343e41f4b71Sopenharmony_ci| COOPERATE_PREPARE |  0    |  The preparation for screen hopping is finished.  |
1344e41f4b71Sopenharmony_ci| COOPERATE_UNPREPARE |  1  |  The preparation for screen hopping is cancelled. |
1345e41f4b71Sopenharmony_ci| COOPERATE_ACTIVATE |  2   |  Screen hopping starts. |
1346e41f4b71Sopenharmony_ci| COOPERATE_ACTIVATE_SUCCESS | 3 | Starting screen hopping succeeds.|
1347e41f4b71Sopenharmony_ci| COOPERATE_ACTIVATE_FAIL | 4 | Starting screen hopping fails.|
1348e41f4b71Sopenharmony_ci| COOPERATE_DEACTIVATE_SUCCESS | 5 | Stopping screen hopping succeeds.|
1349e41f4b71Sopenharmony_ci| COOPERATE_DEACTIVATE_FAIL | 6 | Stopping screen hopping fails.|
1350e41f4b71Sopenharmony_ci| COOPERATE_SESSION_DISCONNECTED | 7 | The screen hopping session is disconnected.|
1351