• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit DistributedServiceKit
19 */
20
21import { AsyncCallback } from './@ohos.base';
22import { Callback } from './@ohos.base';
23
24/**
25 * Implements screen hopping operation management.
26 *
27 * @namespace cooperate
28 * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
29 * @systemapi Hide this for inner system use.
30 * @since 10
31 */
32declare namespace cooperate {
33  /**
34   * Enumerates screen hopping message notifications.
35   *
36   * @enum { number }
37   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
38   * @systemapi Hide this for inner system use.
39   * @since 10
40   * @deprecated since 11
41   * @useinstead cooperate#CooperateState
42   */
43  enum CooperateMsg {
44    /**
45     * Preparing for screen hopping.
46     *
47     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
48     * @systemapi Hide this for inner system use.
49     * @since 10
50     * @deprecated since 11
51     * @useinstead cooperate.CooperateState#COOPERATE_PREPARE
52     */
53    COOPERATE_PREPARE = 0,
54
55    /**
56     * Canceling the preparation for screen hopping.
57     *
58     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
59     * @systemapi Hide this for inner system use.
60     * @since 10
61     * @deprecated since 11
62     * @useinstead cooperate.CooperateState#COOPERATE_UNPREPARE
63     */
64    COOPERATE_UNPREPARE = 1,
65
66    /**
67     * Starting screen hopping.
68     *
69     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
70     * @systemapi Hide this for inner system use.
71     * @since 10
72     * @deprecated since 11
73     * @useinstead cooperate.CooperateState#COOPERATE_ACTIVATE
74     */
75    COOPERATE_ACTIVATE = 2,
76
77    /**
78     * Success in starting screen hopping.
79     *
80     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
81     * @systemapi Hide this for inner system use.
82     * @since 10
83     * @deprecated since 11
84     * @useinstead cooperate.CooperateState#COOPERATE_ACTIVATE_SUCCESS
85     */
86    COOPERATE_ACTIVATE_SUCCESS = 3,
87
88    /**
89     * Failure to start screen hopping.
90     *
91     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
92     * @systemapi Hide this for inner system use.
93     * @since 10
94     * @deprecated since 11
95     * @useinstead cooperate.CooperateState#COOPERATE_ACTIVATE_FAILURE
96     */
97    COOPERATE_ACTIVATE_FAIL = 4,
98
99    /**
100     * Success in stopping screen hopping.
101     *
102     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
103     * @systemapi Hide this for inner system use.
104     * @since 10
105     * @deprecated since 11
106     * @useinstead cooperate.CooperateState#COOPERATE_DEACTIVATE_SUCCESS
107     */
108    COOPERATE_DEACTIVATE_SUCCESS = 5,
109
110    /**
111     * Failure to stop screen hopping.
112     *
113     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
114     * @systemapi Hide this for inner system use.
115     * @since 10
116     * @deprecated since 11
117     * @useinstead cooperate.CooperateState#COOPERATE_DEACTIVATE_FAILURE
118     */
119    COOPERATE_DEACTIVATE_FAIL = 6,
120
121    /**
122     * Inter-device session disconnected.
123     *
124     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
125     * @systemapi Hide this for inner system use.
126     * @since 10
127     * @deprecated since 11
128     * @useinstead cooperate.CooperateState#COOPERATE_SESSION_DISCONNECTED
129     */
130    COOPERATE_SESSION_DISCONNECTED = 7,
131  }
132
133  /**
134   * Enumerates the screen hopping states.
135   *
136   * @enum { number }
137   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
138   * @systemapi Hide this for inner system use.
139   * @since 11
140   */
141  enum CooperateState {
142    /**
143     * Preparing for screen hopping.
144     *
145     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
146     * @systemapi Hide this for inner system use.
147     * @since 11
148     */
149    COOPERATE_PREPARE = 0,
150
151    /**
152     * Canceling the preparation for screen hopping.
153     *
154     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
155     * @systemapi Hide this for inner system use.
156     * @since 11
157     */
158    COOPERATE_UNPREPARE = 1,
159
160    /**
161     * Starting screen hopping.
162     *
163     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
164     * @systemapi Hide this for inner system use.
165     * @since 11
166     */
167    COOPERATE_ACTIVATE = 2,
168
169    /**
170     * Success in starting screen hopping.
171     *
172     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
173     * @systemapi Hide this for inner system use.
174     * @since 11
175     */
176    COOPERATE_ACTIVATE_SUCCESS = 3,
177
178    /**
179     * Failure to start screen hopping.
180     *
181     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
182     * @systemapi Hide this for inner system use.
183     * @since 11
184     */
185    COOPERATE_ACTIVATE_FAILURE = 4,
186
187    /**
188     * Success in stopping screen hopping.
189     *
190     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
191     * @systemapi Hide this for inner system use.
192     * @since 11
193     */
194    COOPERATE_DEACTIVATE_SUCCESS = 5,
195
196    /**
197     * Failure to stop screen hopping.
198     *
199     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
200     * @systemapi Hide this for inner system use.
201     * @since 11
202     */
203    COOPERATE_DEACTIVATE_FAILURE = 6,
204
205    /**
206     * Inter-device session disconnected.
207     *
208     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
209     * @systemapi Hide this for inner system use.
210     * @since 11
211     */
212    COOPERATE_SESSION_DISCONNECTED = 7,
213  }
214
215  /**
216   * Defines a screen hopping message.
217   *
218   * @interface CooperateMessage
219   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
220   * @systemapi Hide this for inner system use.
221   * @since 11
222   */
223  interface CooperateMessage {
224    /**
225     * Descriptor of the target device for screen hopping.
226     *
227     * @type { string }
228     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
229     * @systemapi Hide this for inner system use.
230     * @since 11
231     */
232    networkId: string;
233
234    /**
235     * Screen hopping state.
236     *
237     * @type { CooperateState }
238     * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
239     * @systemapi Hide this for inner system use.
240     * @since 11
241     */
242    state: CooperateState;
243  }
244
245  /**
246   * Prepares for screen hopping.
247   *
248   * @param { AsyncCallback<void> } callback Asynchronous callback used to return the operation result.
249   * @throws {BusinessError} 401 - Parameter error.
250   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
251   * @systemapi Hide this for inner system use.
252   * @since 10
253   * @deprecated since 11
254   * @useinstead cooperate#prepareCooperate
255   */
256  function prepare(callback: AsyncCallback<void>): void;
257
258  /**
259   * Prepares for screen hopping.
260   *
261   * @returns { Promise<void> } the promise returned by the function.
262   * @throws {BusinessError} 401 - Parameter error.
263   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
264   * @systemapi Hide this for inner system use.
265   * @since 10
266   * @deprecated since 11
267   * @useinstead cooperate#prepareCooperate
268   */
269  function prepare(): Promise<void>;
270
271  /**
272   * Prepares for screen hopping.
273   *
274   * @permission ohos.permission.COOPERATE_MANAGER
275   * @param { AsyncCallback<void> } callback - Asynchronous callback used to return the operation result.
276   * @throws {BusinessError} 201 - Permission denied.
277   * @throws {BusinessError} 202 - Not system application.
278   * @throws {BusinessError} 401 - Parameter error.
279   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
280   * @systemapi Hide this for inner system use.
281   * @since 11
282   */
283  function prepareCooperate(callback: AsyncCallback<void>): void;
284
285  /**
286   * Prepares for screen hopping.
287   *
288   * @permission ohos.permission.COOPERATE_MANAGER
289   * @returns { Promise<void> } the promise returned by the function.
290   * @throws {BusinessError} 201 - Permission denied.
291   * @throws {BusinessError} 202 - Not system application.
292   * @throws {BusinessError} 401 - Parameter error.
293   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
294   * @systemapi Hide this for inner system use.
295   * @since 11
296   */
297  function prepareCooperate(): Promise<void>;
298
299  /**
300   * Cancels the preparation for screen hopping.
301   *
302   * @param { AsyncCallback<void> } callback Asynchronous callback used to return the operation result.
303   * @throws {BusinessError} 401 - Parameter error.
304   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
305   * @systemapi Hide this for inner system use.
306   * @since 10
307   * @deprecated since 11
308   * @useinstead cooperate#unprepareCooperate
309   */
310  function unprepare(callback: AsyncCallback<void>): void;
311
312  /**
313   * Cancels the preparation for screen hopping.
314   *
315   * @returns { Promise<void> } the promise returned by the function.
316   * @throws {BusinessError} 401 - Parameter error.
317   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
318   * @systemapi Hide this for inner system use.
319   * @since 10
320   * @deprecated since 11
321   * @useinstead cooperate#unprepareCooperate
322   */
323  function unprepare(): Promise<void>;
324
325  /**
326   * Cancels the preparation for screen hopping.
327   *
328   * @permission ohos.permission.COOPERATE_MANAGER
329   * @param { AsyncCallback<void> } callback - Asynchronous callback used to return the operation result.
330   * @throws {BusinessError} 201 - Permission denied.
331   * @throws {BusinessError} 202 - Not system application.
332   * @throws {BusinessError} 401 - Parameter error.
333   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
334   * @systemapi Hide this for inner system use.
335   * @since 11
336   */
337  function unprepareCooperate(callback: AsyncCallback<void>): void;
338
339  /**
340   * Cancels the preparation for screen hopping.
341   *
342   * @permission ohos.permission.COOPERATE_MANAGER
343   * @returns { Promise<void> } the promise returned by the function.
344   * @throws {BusinessError} 201 - Permission denied.
345   * @throws {BusinessError} 202 - Not system application.
346   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
347   * @systemapi Hide this for inner system use.
348   * @since 11
349   */
350  function unprepareCooperate(): Promise<void>;
351
352  /**
353   * Starts screen hopping.
354   *
355   * @param { string } targetNetworkId Descriptor of the target device for screen hopping.
356   * @param { number } inputDeviceId Identifier of the input device for screen hopping.
357   * @param { AsyncCallback<void> } callback Asynchronous callback used to return the operation result.
358   * @throws {BusinessError} 401 - Parameter error.
359   * @throws {BusinessError} 20900001 - Operation failed.
360   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
361   * @systemapi Hide this for inner system use.
362   * @since 10
363   * @deprecated since 11
364   * @useinstead cooperate#activateCooperate
365   */
366  function activate(targetNetworkId: string, inputDeviceId: number, callback: AsyncCallback<void>): void;
367
368  /**
369   * Starts screen hopping.
370   *
371   * @param { string } targetNetworkId Descriptor of the target device for screen hopping.
372   * @param { number }inputDeviceId Identifier of the input device for screen hopping.
373   * @returns { Promise<void> } the promise returned by the function.
374   * @throws {BusinessError} 401 - Parameter error.
375   * @throws {BusinessError} 20900001 - Operation failed.
376   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
377   * @systemapi Hide this for inner system use.
378   * @since 10
379   * @deprecated since 11
380   * @useinstead cooperate#activateCooperate
381   */
382  function activate(targetNetworkId: string, inputDeviceId: number): Promise<void>;
383
384  /**
385   * Starts screen hopping.
386   *
387   * @permission ohos.permission.COOPERATE_MANAGER
388   * @param { string } targetNetworkId - Descriptor of the target device for screen hopping.
389   * @param { number } inputDeviceId - Identifier of the input device for screen hopping.
390   * @param { AsyncCallback<void> } callback - Asynchronous callback used to return the operation result.
391   * @throws {BusinessError} 201 - Permission denied.
392   * @throws {BusinessError} 202 - Not system application.
393   * @throws {BusinessError} 401 - Parameter error.
394   * @throws {BusinessError} 20900001 - Operation failed.
395   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
396   * @systemapi Hide this for inner system use.
397   * @since 11
398   */
399  function activateCooperate(targetNetworkId: string, inputDeviceId: number, callback: AsyncCallback<void>): void;
400
401  /**
402   * Starts screen hopping.
403   *
404   * @permission ohos.permission.COOPERATE_MANAGER
405   * @param { string } targetNetworkId - Descriptor of the target device for screen hopping.
406   * @param { number }inputDeviceId - Identifier of the input device for screen hopping.
407   * @returns { Promise<void> } the promise returned by the function.
408   * @throws {BusinessError} 201 - Permission denied.
409   * @throws {BusinessError} 202 - Not system application.
410   * @throws {BusinessError} 401 - Parameter error.
411   * @throws {BusinessError} 20900001 - Operation failed.
412   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
413   * @systemapi Hide this for inner system use.
414   * @since 11
415   */
416  function activateCooperate(targetNetworkId: string, inputDeviceId: number): Promise<void>;
417
418  /**
419   * Stops screen hopping.
420   *
421   * @param { boolean } isUnchained Whether the cross-device link is unchained.
422   * @param { AsyncCallback<void> } callback Asynchronous callback used to return the operation result.
423   * @throws {BusinessError} 401 - Parameter error.
424   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
425   * @systemapi Hide this for inner system use.
426   * @since 10
427   * @deprecated since 11
428   * @useinstead cooperate#deactivateCooperate
429   */
430  function deactivate(isUnchained: boolean, callback: AsyncCallback<void>): void;
431
432  /**
433   * Stops screen hopping.
434   *
435   * @param { boolean } isUnchained Whether the cross-device link is unchained.
436   * @returns { Promise<void> } the promise returned by the function.
437   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
438   * @systemapi Hide this for inner system use.
439   * @since 10
440   * @deprecated since 11
441   * @useinstead cooperate#deactivateCooperate
442   */
443  function deactivate(isUnchained: boolean): Promise<void>;
444
445  /**
446   * Stops screen hopping.
447   *
448   * @permission ohos.permission.COOPERATE_MANAGER
449   * @param { boolean } isUnchained - Whether the cross-device link is unchained.
450   * @param { AsyncCallback<void> } callback - Asynchronous callback used to return the operation result.
451   * @throws {BusinessError} 201 - Permission denied.
452   * @throws {BusinessError} 202 - Not system application.
453   * @throws {BusinessError} 401 - Parameter error.
454   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
455   * @systemapi Hide this for inner system use.
456   * @since 11
457   */
458  function deactivateCooperate(isUnchained: boolean, callback: AsyncCallback<void>): void;
459
460  /**
461   * Stops screen hopping.
462   *
463   * @permission ohos.permission.COOPERATE_MANAGER
464   * @param { boolean } isUnchained - Whether the cross-device link is unchained.
465   * @returns { Promise<void> } the promise returned by the function.
466   * @throws {BusinessError} 201 - Permission denied.
467   * @throws {BusinessError} 202 - Not system application.
468   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
469   * @systemapi Hide this for inner system use.
470   * @since 11
471   */
472  function deactivateCooperate(isUnchained: boolean): Promise<void>;
473
474  /**
475   * Obtains the screen hopping status.
476   *
477   * @param { string } networkId Descriptor of the target device for screen hopping.
478   * @param { AsyncCallback<boolean> } callback Asynchronous callback used to return the screen hopping status.
479   * @throws {BusinessError} 401 - Parameter error.
480   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
481   * @systemapi Hide this for inner system use.
482   * @since 10
483   * @deprecated since 11
484   * @useinstead cooperate#getCooperateSwitchState
485   */
486  function getCrossingSwitchState(networkId: string, callback: AsyncCallback<boolean>): void;
487
488  /**
489   * Obtains the status of the screen hopping switch.
490   *
491   * @param { string } networkId Descriptor of the target device for screen hopping.
492   * @returns { Promise<boolean> } Returns {@code true} the screen hopping status;
493   *                               returns {@code false} otherwise.
494   * @throws {BusinessError} 401 - Parameter error.
495   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
496   * @systemapi Hide this for inner system use.
497   * @since 10
498   * @deprecated since 11
499   * @useinstead cooperate#getCooperateSwitchState
500   */
501  function getCrossingSwitchState(networkId: string): Promise<boolean>;
502
503
504  /**
505   * Obtains the screen hopping status.
506   *
507   * @permission ohos.permission.COOPERATE_MANAGER
508   * @param { string } networkId - Descriptor of the target device for screen hopping.
509   * @param { AsyncCallback<boolean> } callback - Asynchronous callback used to return the screen hopping status.
510   * @throws {BusinessError} 201 - Permission denied.
511   * @throws {BusinessError} 202 - Not system application.
512   * @throws {BusinessError} 401 - Parameter error.
513   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
514   * @systemapi Hide this for inner system use.
515   * @since 11
516   */
517  function getCooperateSwitchState(networkId: string, callback: AsyncCallback<boolean>): void;
518
519  /**
520   * Obtains the status of the screen hopping switch.
521   *
522   * @permission ohos.permission.COOPERATE_MANAGER
523   * @param { string } networkId - Descriptor of the target device for screen hopping.
524   * @returns { Promise<boolean> } Returns {@code true} the screen hopping status;
525   *                               returns {@code false} otherwise.
526   * @throws {BusinessError} 201 - Permission denied.
527   * @throws {BusinessError} 202 - Not system application.
528   * @throws {BusinessError} 401 - Parameter error.
529   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
530   * @systemapi Hide this for inner system use.
531   * @since 11
532   */
533  function getCooperateSwitchState(networkId: string): Promise<boolean>;
534
535  /**
536   * Enables listening for screen hopping status change events.
537   *
538   * @param { 'cooperate' } type Change type.
539   * @param { Callback<{ networkId: string, msg: CooperateMsg }> } callback Asynchronous callback used to
540   * return the screen hopping status change event.
541   * @throws {BusinessError} 401 - Parameter error.
542   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
543   * @systemapi Hide this for inner system use.
544   * @since 10
545   * @deprecated since 11
546   * @useinstead cooperate#on
547   */
548  function on(type: 'cooperate', callback: Callback<{ networkId: string, msg: CooperateMsg }>): void;
549
550  /**
551   * Disables listening for screen hopping status change events.
552   *
553   * @param { 'cooperate' } type Change type.
554   * @param { Callback<void> } callback Callback for which listening
555   * is disabled. If this parameter is not specified, listening will be disabled for all registered callbacks.
556   * @throws {BusinessError} 401 - Parameter error.
557   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
558   * @systemapi Hide this for inner system use.
559   * @since 10
560   * @deprecated since 11
561   * @useinstead cooperate#on
562   */
563  function off(type: 'cooperate', callback?: Callback<void>): void;
564
565  /**
566   * Enables listening for screen hopping status change events.
567   *
568   * @permission ohos.permission.COOPERATE_MANAGER
569   * @param { 'cooperateMessage' } type - Change type.
570   * @param { Callback<CooperateMessage> } callback - Asynchronous callback used to
571   * return the screen hopping status change event.
572   * @throws {BusinessError} 201 - Permission denied.
573   * @throws {BusinessError} 202 - Not system application.
574   * @throws {BusinessError} 401 - Parameter error.
575   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
576   * @systemapi Hide this for inner system use.
577   * @since 11
578   */
579  function on(type: 'cooperateMessage', callback: Callback<CooperateMessage>): void;
580
581  /**
582   * Disables listening for screen hopping status change events.
583   *
584   * @permission ohos.permission.COOPERATE_MANAGER
585   * @param { 'cooperateMessage' } type - Change type.
586   * @param { Callback<CooperateMessage> } [callback] - Callback for which listening
587   * is disabled. If this parameter is not specified, listening will be disabled for all registered callbacks.
588   * @throws {BusinessError} 201 - Permission denied.
589   * @throws {BusinessError} 202 - Not system application.
590   * @throws {BusinessError} 401 - Parameter error.
591   * @syscap SystemCapability.Msdp.DeviceStatus.Cooperate
592   * @systemapi Hide this for inner system use.
593   * @since 11
594   */
595  function off(type: 'cooperateMessage', callback?: Callback<CooperateMessage>): void;
596}
597
598export default cooperate;
599