• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2020-2022 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
16import { AsyncCallback, Callback } from './@ohos.base';
17
18/**
19 * Providers interfaces to create a {@link deviceManager} instances.
20 *
21 * @namespace deviceManager
22 * @syscap SystemCapability.DistributedHardware.DeviceManager
23 * @since 7
24 */
25declare namespace deviceManager {
26  /**
27   * DeviceInfo
28   *
29   * @interface DeviceInfo
30   * @syscap SystemCapability.DistributedHardware.DeviceManager
31   * @systemapi this method can be used only by system applications.
32   * @since 7
33   */
34  interface DeviceInfo {
35    /**
36     * DeviceId ID.
37     *
38     * @syscap SystemCapability.DistributedHardware.DeviceManager
39     * @systemapi this method can be used only by system applications.
40     * @since 7
41     */
42    deviceId: string;
43
44    /**
45     * Device name of the device.
46     *
47     * @syscap SystemCapability.DistributedHardware.DeviceManager
48     * @systemapi this method can be used only by system applications.
49     * @since 7
50     */
51    deviceName: string;
52
53    /**
54     * Device type of the device.
55     *
56     * @syscap SystemCapability.DistributedHardware.DeviceManager
57     * @systemapi this method can be used only by system applications.
58     * @since 7
59     */
60    deviceType: DeviceType;
61
62    /**
63     * NetworkId of the device.
64     *
65     * @syscap SystemCapability.DistributedHardware.DeviceManager
66     * @systemapi this method can be used only by system applications.
67     * @since 8
68     */
69    networkId: string;
70
71    /**
72     * @syscap SystemCapability.DistributedHardware.DeviceManager
73     * @systemapi this method can be used only by system applications.
74     * @since 9
75     * The distance of discovered device, in centimeter(cm).
76     */
77    range: number;
78
79    /**
80     * Indicates the device's trusted type
81     *
82     * @syscap SystemCapability.DistributedHardware.DeviceManager
83     * @systemapi this method can be used only by system applications.
84     * @since 10
85     */
86    authForm: AuthForm;
87  }
88
89  /**
90   * Device trusted type definitions
91   *
92   * @enum { number }
93   * @syscap SystemCapability.DistributedHardware.DeviceManager
94   * @systemapi this method can be used only by system applications.
95   * @since 10
96   */
97  enum AuthForm {
98    /**
99     * Indicates invalid trusted device type.
100     *
101     * @syscap SystemCapability.DistributedHardware.DeviceManager
102     * @systemapi this method can be used only by system applications.
103     * @since 10
104     */
105    INVALID_TYPE = -1,
106
107    /**
108     * Indicates peer to peer trusted device type without account.
109     *
110     * @syscap SystemCapability.DistributedHardware.DeviceManager
111     * @systemapi this method can be used only by system applications.
112     * @since 10
113     */
114    PEER_TO_PEER = 0,
115
116    /**
117     * Indicates identical account trusted device type.
118     *
119     * @syscap SystemCapability.DistributedHardware.DeviceManager
120     * @systemapi this method can be used only by system applications.
121     * @since 10
122     */
123    IDENTICAL_ACCOUNT = 1,
124
125    /**
126     * Indicates across account trusted device type.
127     *
128     * @syscap SystemCapability.DistributedHardware.DeviceManager
129     * @systemapi this method can be used only by system applications.
130     * @since 10
131     */
132    ACROSS_ACCOUNT = 2
133  }
134
135  /**
136   * Device Type definitions
137   *
138   * @enum { number }
139   * @syscap SystemCapability.DistributedHardware.DeviceManager
140   * @systemapi this method can be used only by system applications.
141   * @since 7
142   */
143  enum DeviceType {
144    /**
145     * Indicates an unknown device type.
146     *
147     * @syscap SystemCapability.DistributedHardware.DeviceManager
148     * @systemapi this method can be used only by system applications.
149     * @since 7
150     */
151    UNKNOWN_TYPE = 0,
152
153    /**
154     * Indicates a speaker.
155     *
156     * @syscap SystemCapability.DistributedHardware.DeviceManager
157     * @systemapi this method can be used only by system applications.
158     * @since 7
159     */
160    SPEAKER = 0x0A,
161
162    /**
163     * Indicates a smartphone.
164     *
165     * @syscap SystemCapability.DistributedHardware.DeviceManager
166     * @systemapi this method can be used only by system applications.
167     * @since 7
168     */
169    PHONE = 0x0E,
170
171    /**
172     * Indicates a tablet.
173     *
174     * @syscap SystemCapability.DistributedHardware.DeviceManager
175     * @systemapi this method can be used only by system applications.
176     * @since 7
177     */
178    TABLET = 0x11,
179
180    /**
181     * Indicates a smart watch.
182     *
183     * @syscap SystemCapability.DistributedHardware.DeviceManager
184     * @systemapi this method can be used only by system applications.
185     * @since 7
186     */
187    WEARABLE = 0x6D,
188
189    /**
190     * Indicates a car.
191     *
192     * @syscap SystemCapability.DistributedHardware.DeviceManager
193     * @systemapi this method can be used only by system applications.
194     * @since 7
195     */
196    CAR = 0x83,
197
198    /**
199     * Indicates a smart TV.
200     *
201     * @syscap SystemCapability.DistributedHardware.DeviceManager
202     * @systemapi this method can be used only by system applications.
203     * @since 7
204     */
205    TV = 0x9C
206  }
207
208  /**
209   * Device state change event definition
210   *
211   * @enum { number }
212   * @syscap SystemCapability.DistributedHardware.DeviceManager
213   * @systemapi this method can be used only by system applications.
214   * @since 7
215   */
216  enum DeviceStateChangeAction {
217    /**
218     * Device online action, which indicates the device is physically online
219     *
220     * @syscap SystemCapability.DistributedHardware.DeviceManager
221     * @systemapi this method can be used only by system applications.
222     * @since 7
223     */
224    ONLINE = 0,
225
226    /**
227     * Device ready action, which indicates the information between devices has been synchronized in the Distributed Data Service (DDS) module,
228     * and the device is ready for running distributed services
229     *
230     * @syscap SystemCapability.DistributedHardware.DeviceManager
231     * @systemapi this method can be used only by system applications.
232     * @since 7
233     */
234    READY = 1,
235
236    /**
237     * Device offline action, which Indicates the device is physically offline
238     *
239     * @syscap SystemCapability.DistributedHardware.DeviceManager
240     * @systemapi this method can be used only by system applications.
241     * @since 7
242     */
243    OFFLINE = 2,
244
245    /**
246     * Device change action
247     *
248     * @syscap SystemCapability.DistributedHardware.DeviceManager
249     * @systemapi this method can be used only by system applications.
250     * @since 7
251     */
252    CHANGE = 3
253  }
254
255  /**
256   * Service subscribe info for device discover
257   *
258   * @interface SubscribeInfo
259   * @syscap SystemCapability.DistributedHardware.DeviceManager
260   * @systemapi this method can be used only by system applications.
261   * @since 7
262   */
263  interface SubscribeInfo {
264    /**
265     * Service subscribe ID, the value is in scope [0, 65535], should be unique for each discover process
266     *
267     * @syscap SystemCapability.DistributedHardware.DeviceManager
268     * @systemapi this method can be used only by system applications.
269     * @since 7
270     */
271    subscribeId: number;
272
273    /**
274     * Discovery mode for service subscription.
275     *
276     * @syscap SystemCapability.DistributedHardware.DeviceManager
277     * @systemapi this method can be used only by system applications.
278     * @since 7
279     */
280    mode: DiscoverMode;
281
282    /**
283     * Service subscription medium.
284     *
285     * @syscap SystemCapability.DistributedHardware.DeviceManager
286     * @systemapi this method can be used only by system applications.
287     * @since 7
288     */
289    medium: ExchangeMedium;
290
291    /**
292     * Service subscription frequency.
293     *
294     * @syscap SystemCapability.DistributedHardware.DeviceManager
295     * @systemapi this method can be used only by system applications.
296     * @since 7
297     */
298    freq: ExchangeFreq;
299
300    /**
301     * only find the device with the same account.
302     *
303     * @syscap SystemCapability.DistributedHardware.DeviceManager
304     * @systemapi this method can be used only by system applications.
305     * @since 7
306     */
307    isSameAccount: boolean;
308
309    /**
310     * find the sleeping devices.
311     *
312     * @syscap SystemCapability.DistributedHardware.DeviceManager
313     * @systemapi this method can be used only by system applications.
314     * @since 7
315     */
316    isWakeRemote: boolean;
317
318    /**
319     * Subscribe capability.
320     *
321     * @syscap SystemCapability.DistributedHardware.DeviceManager
322     * @systemapi this method can be used only by system applications.
323     * @since 7
324     */
325    capability: SubscribeCap;
326  }
327
328  /**
329   * Service publish info for device discover
330   *
331   * @interface PublishInfo
332   * @syscap SystemCapability.DistributedHardware.DeviceManager
333   * @systemapi this method can be used only by system applications.
334   * @since 9
335   */
336  interface PublishInfo {
337    /**
338     * Service publish ID, the value is in scope [0, 65535], should be unique for each publish process
339     *
340     * @syscap SystemCapability.DistributedHardware.DeviceManager
341     * @systemapi this method can be used only by system applications.
342     * @since 9
343     */
344    publishId: number;
345
346    /**
347     * Discovery mode for service subscription.
348     *
349     * @syscap SystemCapability.DistributedHardware.DeviceManager
350     * @systemapi this method can be used only by system applications.
351     * @since 9
352     */
353    mode: DiscoverMode;
354
355    /**
356     * Service subscription frequency.
357     *
358     * @syscap SystemCapability.DistributedHardware.DeviceManager
359     * @systemapi this method can be used only by system applications.
360     * @since 9
361     */
362    freq: ExchangeFreq;
363
364    /**
365     *  Whether the device should be ranged by discoverer.
366     *
367     * @syscap SystemCapability.DistributedHardware.DeviceManager
368     * @systemapi this method can be used only by system applications.
369     * @since 9
370     */
371    ranging: boolean;
372  }
373
374  /**
375   * device discover mode
376   *
377   * @enum { number }
378   * @syscap SystemCapability.DistributedHardware.DeviceManager
379   * @systemapi this method can be used only by system applications.
380   * @since 7
381   */
382  enum DiscoverMode {
383    /**
384     * when using this key at client side, it means discovering for available nearby devices by
385     * calling @startDeviceDiscovery function, while using this key at server side indicating that
386     * a device publication or advertisement by calling @publishDeviceDiscovery.
387     *
388     * @syscap SystemCapability.DistributedHardware.DeviceManager
389     * @systemapi this method can be used only by system applications.
390     * @since 7
391     */
392    DISCOVER_MODE_PASSIVE = 0x55,
393
394    /**
395     * when using this key at server side, it means discovering for available nearby devices by
396     * calling @startDeviceDiscovery function, while using this key at client side indicating that
397     * a device publication or advertisement by calling @publishDeviceDiscovery.
398     *
399     * @syscap SystemCapability.DistributedHardware.DeviceManager
400     * @systemapi this method can be used only by system applications.
401     * @since 7
402     */
403    DISCOVER_MODE_ACTIVE = 0xAA
404  }
405
406  /**
407   * device discover medium
408   *
409   * @enum { number }
410   * @syscap SystemCapability.DistributedHardware.DeviceManager
411   * @systemapi this method can be used only by system applications.
412   * @since 7
413   */
414  enum ExchangeMedium {
415    /**
416     * Automatic medium selection
417     *
418     * @syscap SystemCapability.DistributedHardware.DeviceManager
419     * @systemapi this method can be used only by system applications.
420     * @since 7
421     */
422    AUTO = 0,
423
424    /**
425     * Bluetooth
426     *
427     * @syscap SystemCapability.DistributedHardware.DeviceManager
428     * @systemapi this method can be used only by system applications.
429     * @since 7
430     */
431    BLE = 1,
432
433    /**
434     * Wi-Fi
435     *
436     * @syscap SystemCapability.DistributedHardware.DeviceManager
437     * @systemapi this method can be used only by system applications.
438     * @since 7
439     */
440    COAP = 2,
441
442    /**
443     * USB
444     *
445     * @syscap SystemCapability.DistributedHardware.DeviceManager
446     * @systemapi this method can be used only by system applications.
447     * @since 7
448     */
449    USB = 3
450  }
451
452  /**
453   * device discover freq
454   *
455   * @enum { number }
456   * @syscap SystemCapability.DistributedHardware.DeviceManager
457   * @systemapi this method can be used only by system applications.
458   * @since 7
459   */
460  enum ExchangeFreq {
461    /**
462     * Low
463     *
464     * @syscap SystemCapability.DistributedHardware.DeviceManager
465     * @systemapi this method can be used only by system applications.
466     * @since 7
467     */
468    LOW = 0,
469
470    /**
471     * Medium
472     *
473     * @syscap SystemCapability.DistributedHardware.DeviceManager
474     * @systemapi this method can be used only by system applications.
475     * @since 7
476     */
477    MID = 1,
478
479    /**
480     * High
481     *
482     * @syscap SystemCapability.DistributedHardware.DeviceManager
483     * @systemapi this method can be used only by system applications.
484     * @since 7
485     */
486    HIGH = 2,
487
488    /**
489     * Super-high
490     *
491     * @syscap SystemCapability.DistributedHardware.DeviceManager
492     * @systemapi this method can be used only by system applications.
493     * @since 7
494     */
495    SUPER_HIGH = 3
496  }
497
498  /**
499   * device discover capability
500   *
501   * @enum { number }
502   * @syscap SystemCapability.DistributedHardware.DeviceManager
503   * @systemapi this method can be used only by system applications.
504   * @since 7
505   */
506  enum SubscribeCap {
507    /**
508     * ddmpCapability, will be discarded later. Currently, it will be converted to OSD capability inner.
509     *
510     * @syscap SystemCapability.DistributedHardware.DeviceManager
511     * @systemapi this method can be used only by system applications.
512     * @since 7
513     */
514    SUBSCRIBE_CAPABILITY_DDMP = 0,
515
516    /**
517     * One Super Device Capability
518     *
519     * @syscap SystemCapability.DistributedHardware.DeviceManager
520     * @systemapi this method can be used only by system applications.
521     * @since 7
522     */
523    SUBSCRIBE_CAPABILITY_OSD = 1
524  }
525
526  /**
527   * Device Authentication param
528   *
529   * @interface AuthParam
530   * @syscap SystemCapability.DistributedHardware.DeviceManager
531   * @systemapi this method can be used only by system applications
532   * @since 7
533   */
534  interface AuthParam {
535    /**
536     * Authentication type, 1 for pin code.
537     *
538     * @syscap SystemCapability.DistributedHardware.DeviceManager
539     * @systemapi this method can be used only by system applications
540     * @since 7
541     */
542    authType: number;
543
544    /**
545     * Authentication extra infos.
546     *
547     * @syscap SystemCapability.DistributedHardware.DeviceManager
548     * @systemapi this method can be used only by system applications
549     * @since 7
550     */
551    extraInfo: { [key: string]: any };
552  }
553
554  /**
555   * Device auth info.
556   *
557   * @interface AuthInfo
558   * @syscap SystemCapability.DistributedHardware.DeviceManager
559   * @systemapi this method can be used only by system applications
560   * @since 7
561   */
562  interface AuthInfo {
563    /**
564     * Authentication type, 1 for pin code.
565     *
566     * @syscap SystemCapability.DistributedHardware.DeviceManager
567     * @systemapi this method can be used only by system applications
568     * @since 7
569     */
570    authType: number;
571
572    /**
573     * the token used for this authentication.
574     *
575     * @syscap SystemCapability.DistributedHardware.DeviceManager
576     * @systemapi this method can be used only by system applications
577     * @since 7
578     */
579    token: number;
580
581    /**
582     * Authentication extra infos.
583     *
584     * @syscap SystemCapability.DistributedHardware.DeviceManager
585     * @systemapi this method can be used only by system applications
586     * @since 7
587     */
588    extraInfo: { [key: string]: any };
589  }
590
591  /**
592   * Creates a {@code DeviceManager} instance.
593   * <p>To manage devices, you must first call this method to obtain a {@code DeviceManager} instance and then
594   * use this instance to call other device management methods.
595   *
596   * @param { string } bundleName Indicates the bundle name of the application.
597   * @param { AsyncCallback<DeviceManager> } callback Indicates the callback to be invoked upon {@code DeviceManager} instance creation.
598   * @throws { BusinessError } 401 - Input parameter error.
599   * @throws { BusinessError } 202 - The caller is not a system application.
600   * @syscap SystemCapability.DistributedHardware.DeviceManager
601   * @systemapi this method can be used only by system applications.
602   * @since 7
603   */
604  function createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager>): void;
605
606  /**
607   * Provides methods for managing devices.
608   *
609   * @interface DeviceManager
610   * @syscap SystemCapability.DistributedHardware.DeviceManager
611   * @since 7
612   */
613  interface DeviceManager {
614    /**
615     * Releases the {@code DeviceManager} instance after the methods for device management are no longer used.
616     *
617     * @permission ohos.permission.ACCESS_SERVICE_DM
618     * @throws { BusinessError } 202 - The caller is not a system application.
619     * @throws { BusinessError } 201 - Permission verify failed.
620     * @throws { BusinessError } 11600101 - Failed to execute the function.
621     * @syscap SystemCapability.DistributedHardware.DeviceManager
622     * @systemapi this method can be used only by system applications.
623     * @since 7
624     */
625    release(): void;
626
627    /**
628     * Obtains a list of trusted devices.
629     *
630     * @permission ohos.permission.ACCESS_SERVICE_DM
631     * @returns { Array<DeviceInfo> } returns a list of trusted devices.
632     * @throws { BusinessError } 202 - The caller is not a system application.
633     * @throws { BusinessError } 201 - Permission verify failed.
634     * @throws { BusinessError } 11600101 - Failed to execute the function.
635     * @syscap SystemCapability.DistributedHardware.DeviceManager
636     * @systemapi this method can be used only by system applications.
637     * @since 7
638     */
639    getTrustedDeviceListSync(): Array<DeviceInfo>;
640
641    /**
642     * Obtains a list of trusted devices.
643     *
644     * @permission ohos.permission.ACCESS_SERVICE_DM
645     * @param { boolean } isRefresh Refresh the online device list to quickly bring nearby trusted devices online.
646     * @returns { Array<DeviceInfo> } Returns a list of trusted devices.
647     * @throws { BusinessError } 202 - The caller is not a system application.
648     * @throws { BusinessError } 201 - Permission verify failed.
649     * @throws { BusinessError } 401 - Input parameter error.
650     * @throws { BusinessError } 11600101 - Failed to execute the function.
651     * @syscap SystemCapability.DistributedHardware.DeviceManager
652     * @systemapi this method can be used only by system applications.
653     * @since 10
654     */
655    getTrustedDeviceListSync(isRefresh: boolean): Array<DeviceInfo>;
656
657    /**
658     * Obtains a list of trusted devices.
659     *
660     * @permission ohos.permission.ACCESS_SERVICE_DM
661     * @param { AsyncCallback<Array<DeviceInfo>> } callback Indicates the callback to be invoked upon getTrustedDeviceList
662     * @throws { BusinessError } 202 - The caller is not a system application.
663     * @throws { BusinessError } 401 - Input parameter error.
664     * @syscap SystemCapability.DistributedHardware.DeviceManager
665     * @systemapi this method can be used only by system applications.
666     * @since 8
667     */
668    getTrustedDeviceList(callback: AsyncCallback<Array<DeviceInfo>>): void;
669
670    /**
671     * Obtains a list of trusted devices.
672     *
673     * @permission ohos.permission.ACCESS_SERVICE_DM
674     * @returns { Promise<Array<DeviceInfo>> } Returns a list of trusted devices.
675     * @throws { BusinessError } 202 - The caller is not a system application.
676     * @syscap SystemCapability.DistributedHardware.DeviceManager
677     * @systemapi this method can be used only by system applications.
678     * @since 8
679     */
680    getTrustedDeviceList(): Promise<Array<DeviceInfo>>;
681
682    /**
683     * Obtains local device info
684     *
685     * @permission ohos.permission.ACCESS_SERVICE_DM
686     * @returns { DeviceInfo } Returns local device info.
687     * @throws { BusinessError } 202 - The caller is not a system application.
688     * @throws { BusinessError } 201 - Permission verify failed.
689     * @throws { BusinessError } 11600101 - Failed to execute the function.
690     * @syscap SystemCapability.DistributedHardware.DeviceManager
691     * @systemapi this method can be used only by system applications.
692     * @since 8
693     */
694    getLocalDeviceInfoSync(): DeviceInfo;
695
696    /**
697     * Obtains local device info
698     *
699     * @permission ohos.permission.ACCESS_SERVICE_DM
700     * @param { AsyncCallback<DeviceInfo> } callback Indicates the callback to be invoked upon getLocalDeviceInfo
701     * @throws { BusinessError } 401 - Input parameter error.
702     * @throws { BusinessError } 202 - The caller is not a system application.
703     * @syscap SystemCapability.DistributedHardware.DeviceManager
704     * @systemapi this method can be used only by system applications.
705     * @since 8
706     */
707    getLocalDeviceInfo(callback: AsyncCallback<DeviceInfo>): void;
708
709    /**
710     * Obtains local device info
711     *
712     * @permission ohos.permission.ACCESS_SERVICE_DM
713     * @returns { Promise<DeviceInfo> } Returns local device info.
714     * @throws { BusinessError } 202 - The caller is not a system application.
715     * @syscap SystemCapability.DistributedHardware.DeviceManager
716     * @systemapi this method can be used only by system applications.
717     * @since 8
718     */
719    getLocalDeviceInfo(): Promise<DeviceInfo>;
720
721    /**
722     * Obtains device info
723     *
724     * @permission ohos.permission.ACCESS_SERVICE_DM
725     * @param { string } networkId - device network id.
726     * @param { AsyncCallback<DeviceInfo> } callback - Indicates the callback to be invoked upon getDeviceInfo.
727     * @throws { BusinessError } 401 - Input parameter error.
728     * @throws { BusinessError } 202 - The caller is not a system application.
729     * @syscap SystemCapability.DistributedHardware.DeviceManager
730     * @systemapi this method can be used only by system applications.
731     * @since 10
732     */
733    getDeviceInfo(networkId: string, callback: AsyncCallback<DeviceInfo>): void;
734
735    /**
736     * Obtains device info
737     *
738     * @permission ohos.permission.ACCESS_SERVICE_DM
739     * @param { string } networkId - device network id.
740     * @returns { Promise<DeviceInfo> } Returns device info.
741     * @throws { BusinessError } 401 - Input parameter error.
742     * @throws { BusinessError } 202 - The caller is not a system application.
743     * @syscap SystemCapability.DistributedHardware.DeviceManager
744     * @systemapi this method can be used only by system applications.
745     * @since 10
746     */
747    getDeviceInfo(networkId: string): Promise<DeviceInfo>;
748
749    /**
750     * Start to discover device.
751     *
752     * @permission ohos.permission.ACCESS_SERVICE_DM
753     * @param { SubscribeInfo } subscribeInfo subscribe info to discovery device
754     * @throws { BusinessError } 401 - Input parameter error.
755     * @throws { BusinessError } 202 - The caller is not a system application.
756     * @throws { BusinessError } 201 - Permission verify failed.
757     * @throws { BusinessError } 11600104 - Discovery invalid.
758     * @throws { BusinessError } 11600101 - Failed to execute the function.
759     * @syscap SystemCapability.DistributedHardware.DeviceManager
760     * @systemapi this method can be used only by system applications.
761     * @since 8
762     */
763    startDeviceDiscovery(subscribeInfo: SubscribeInfo): void;
764
765    /**
766     * Start to discover device.
767     *
768     * @permission ohos.permission.ACCESS_SERVICE_DM
769     * @param { SubscribeInfo } subscribeInfo subscribe info to discovery device
770     * @param { string } filterOptions filterOptions to filter discovery device
771     * @throws { BusinessError } 401 - Input parameter error.
772     * @throws { BusinessError } 202 - The caller is not a system application.
773     * @throws { BusinessError } 201 - Permission verify failed.
774     * @throws { BusinessError } 11600104 - Discovery invalid.
775     * @throws { BusinessError } 11600101 - Failed to execute the function.
776     * @syscap SystemCapability.DistributedHardware.DeviceManager
777     * @systemapi this method can be used only by system applications.
778     * @since 9
779     */
780    startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void;
781
782    /**
783     * Stop to discover device.
784     *
785     * @permission ohos.permission.ACCESS_SERVICE_DM
786     * @param { number } subscribeId Service subscribe ID
787     * @throws { BusinessError } 401 - Input parameter error.
788     * @throws { BusinessError } 202 - The caller is not a system application.
789     * @throws { BusinessError } 201 - Permission verify failed.
790     * @throws { BusinessError } 11600101 - Failed to execute the function.
791     * @syscap SystemCapability.DistributedHardware.DeviceManager
792     * @systemapi this method can be used only by system applications.
793     * @since 7
794     */
795    stopDeviceDiscovery(subscribeId: number): void;
796
797    /**
798     * Publish discover device.
799     *
800     * @permission ohos.permission.ACCESS_SERVICE_DM
801     * @param { PublishInfo } publishInfo publish info to Publish discovery device
802     * @throws { BusinessError } 401 - Input parameter error.
803     * @throws { BusinessError } 202 - The caller is not a system application.
804     * @throws { BusinessError } 201 - Permission verify failed.
805     * @throws { BusinessError } 11600105 - Publish invalid.
806     * @throws { BusinessError } 11600101 - Failed to execute the function.
807     * @syscap SystemCapability.DistributedHardware.DeviceManager
808     * @systemapi this method can be used only by system applications.
809     * @since 9
810     */
811    publishDeviceDiscovery(publishInfo: PublishInfo): void;
812
813    /**
814     * UnPublish discover device.
815     *
816     * @permission ohos.permission.ACCESS_SERVICE_DM
817     * @param { number } publishId Service publish ID, identify a publish operation, should be a unique id in package range
818     * @throws { BusinessError } 401 - Input parameter error.
819     * @throws { BusinessError } 202 - The caller is not a system application.
820     * @throws { BusinessError } 201 - Permission verify failed.
821     * @throws { BusinessError } 11600101 - Failed to execute the function.
822     * @syscap SystemCapability.DistributedHardware.DeviceManager
823     * @systemapi this method can be used only by system applications.
824     * @since 9
825     */
826    unPublishDeviceDiscovery(publishId: number): void;
827
828    /**
829     * Authenticate the specified device.
830     *
831     * @permission ohos.permission.ACCESS_SERVICE_DM
832     * @param { DeviceInfo } deviceInfo deviceInfo of device to authenticate
833     * @param { AuthParam } authParam authParam of device to authenticate
834     * @param { AsyncCallback<{ deviceId: string, pinToken?: number }> } callback Indicates the callback to be invoked upon authenticateDevice
835     * @throws { BusinessError } 401 - Input parameter error.
836     * @throws { BusinessError } 202 - The caller is not a system application.
837     * @syscap SystemCapability.DistributedHardware.DeviceManager
838     * @systemapi this method can be used only by system applications.
839     * @since 7
840     */
841    authenticateDevice(
842      deviceInfo: DeviceInfo,
843      authParam: AuthParam,
844      callback: AsyncCallback<{ deviceId: string, pinToken?: number }>
845    ): void;
846
847    /**
848     * unAuthenticate the specified device.
849     *
850     * @permission ohos.permission.ACCESS_SERVICE_DM
851     * @param { DeviceInfo } deviceInfo deviceInfo of device to unAuthenticate
852     * @throws { BusinessError } 401 - Input parameter error.
853     * @throws { BusinessError } 202 - The caller is not a system application.
854     * @throws { BusinessError } 201 - Permission verify failed.
855     * @throws { BusinessError } 11600101 - Failed to execute the function.
856     * @syscap SystemCapability.DistributedHardware.DeviceManager
857     * @systemapi this method can be used only by system applications.
858     * @since 8
859     */
860    unAuthenticateDevice(deviceInfo: DeviceInfo): void;
861
862    /**
863     * verify auth info, such as pin code.
864     *
865     * @permission ohos.permission.ACCESS_SERVICE_DM
866     * @param { AuthInfo } authInfo device auth info o verify
867     * @param { AsyncCallback<{ deviceId: string, level: number }> } callback Indicates the callback to be invoked upon verifyAuthInfo
868     * @throws { BusinessError } 401 - Input parameter error.
869     * @throws { BusinessError } 202 - The caller is not a system application.
870     * @syscap SystemCapability.DistributedHardware.DeviceManager
871     * @systemapi this method can be used only by system applications.
872     * @since 7
873     */
874    verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{ deviceId: string, level: number }>): void;
875
876    /**
877     * Set user Operation from devicemanager Sea, this interface can only be used by devicemanager Sea.
878     *
879     * @permission ohos.permission.ACCESS_SERVICE_DM
880     * @param { number } operateAction User Operation Actions.
881     * @param { string } params Indicates the input param of the user.
882     * @throws { BusinessError } 401 - Input parameter error.
883     * @throws { BusinessError } 202 - The caller is not a system application.
884     * @throws { BusinessError } 201 - Permission verify failed.
885     * @syscap SystemCapability.DistributedHardware.DeviceManager
886     * @systemapi this method can be used only by system applications.
887     * @since 9
888     */
889    setUserOperation(operateAction: number, params: string): void;
890
891    /**
892     * Request credential information.
893     *
894     * @permission ohos.permission.ACCESS_SERVICE_DM
895     * @param { string } requestInfo - Request credential params, the params is json string, it includes version and userId.
896     * @param { AsyncCallback<{ registerInfo: string }> } callback Indicates the callback to be invoked upon requestCredential
897     * @throws { BusinessError } 401 - Input parameter error.
898     * @throws { BusinessError } 202 - The caller is not a system application.
899     * @syscap SystemCapability.DistributedHardware.DeviceManager
900     * @systemapi this method can be used only by system applications.
901     * @since 10
902     */
903    requestCredentialRegisterInfo(requestInfo: string, callback: AsyncCallback<{ registerInfo: string }>): void;
904
905    /**
906     * Import credential information.
907     *
908     * @permission ohos.permission.ACCESS_SERVICE_DM
909     * @param { string } credentialInfo - Import credential params, the params is json string, it includes processType, authType,
910     * userId, deviceId, version, devicePk and credentialData, the credentialData is array, each array element
911     * include credentialType, credentialId, serverPk, pkInfoSignature, pkInfo, authCode, peerDeviceId.
912     * @param { AsyncCallback<{ resultInfo: string }> } callback Indicates the callback to be invoked upon importCredential.
913     * @throws { BusinessError } 401 - Input parameter error.
914     * @throws { BusinessError } 202 - The caller is not a system application.
915     * @syscap SystemCapability.DistributedHardware.DeviceManager
916     * @systemapi this method can be used only by system applications.
917     * @since 10
918     */
919    importCredential(credentialInfo: string, callback: AsyncCallback<{ resultInfo: string }>): void;
920
921    /**
922     * delete credential information.
923     *
924     * @permission ohos.permission.ACCESS_SERVICE_DM
925     * @param { string } queryInfo - delete credential params. the params is json string, it includes processType, authType, userId.
926     * @param { AsyncCallback<{ resultInfo: string }> } callback Indicates the callback to be invoked upon deleteCredential
927     * @throws { BusinessError } 401 - Input parameter error.
928     * @throws { BusinessError } 202 - The caller is not a system application.
929     * @syscap SystemCapability.DistributedHardware.DeviceManager
930     * @systemapi this method can be used only by system applications.
931     * @since 10
932     */
933    deleteCredential(queryInfo: string, callback: AsyncCallback<{ resultInfo: string }>): void;
934
935    /**
936     * Register a callback from deviceManager service so that the devicemanager ui can be notified when ui statue
937     * changes.
938     *
939     * @permission ohos.permission.ACCESS_SERVICE_DM
940     * @param { 'uiStateChange' } type Ui state to unregister.
941     * @param { Callback<{ param: string }> } callback Indicates the devicemanager ui state to register.
942     * @throws { BusinessError } 401 - Input parameter error.
943     * @throws { BusinessError } 202 - The caller is not a system application.
944     * @syscap SystemCapability.DistributedHardware.DeviceManager
945     * @systemapi this method can be used only by system applications.
946     * @since 9
947     */
948    on(type: 'uiStateChange', callback: Callback<{ param: string }>): void;
949
950    /**
951     * Unregister uiStatueChange, this interface can only be used by devicemanager ui.
952     *ui state change
953     *
954     * @permission ohos.permission.ACCESS_SERVICE_DM
955     * @param { 'uiStateChange' } type Ui state to unregister.
956     * @param { Callback<{ param: string }> } callback Indicates the devicemanager ui state to unregister.
957     * @throws { BusinessError } 401 - Input parameter error.
958     * @throws { BusinessError } 202 - The caller is not a system application.
959     * @syscap SystemCapability.DistributedHardware.DeviceManager
960     * @systemapi this method can be used only by system applications.
961     * @since 9
962     */
963    off(type: 'uiStateChange', callback?: Callback<{ param: string }>): void;
964
965    /**
966     * Register a device state callback so that the application can be notified upon device state changes based on
967     * the application bundle name.
968     *
969     * @permission ohos.permission.ACCESS_SERVICE_DM
970     * @param { 'deviceStateChange' } type Device status change.
971     * @param { Callback<{ action: DeviceStateChangeAction, device: DeviceInfo }> } callback
972     *          Indicates the device state callback to register.
973     * @throws { BusinessError } 401 - Input parameter error.
974     * @throws { BusinessError } 202 - The caller is not a system application.
975     * @syscap SystemCapability.DistributedHardware.DeviceManager
976     * @systemapi this method can be used only by system applications.
977     * @since 7
978     */
979    on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChangeAction, device: DeviceInfo }>): void;
980
981    /**
982     * UnRegister device state callback based on the application bundle name.
983     *
984     * @permission ohos.permission.ACCESS_SERVICE_DM
985     * @param { 'deviceStateChange' } type Device status change.
986     * @param { Callback<{ action: DeviceStateChangeAction, device: DeviceInfo }> } callback Indicates the device state callback to register.
987     * @throws { BusinessError } 401 - Input parameter error.
988     * @throws { BusinessError } 202 - The caller is not a system application.
989     * @syscap SystemCapability.DistributedHardware.DeviceManager
990     * @systemapi this method can be used only by system applications.
991     * @since 7
992     */
993    off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChangeAction, device: DeviceInfo }>): void;
994
995    /**
996     * Register a device found callback so that the application can be notified when the device was found
997     *
998     * @permission ohos.permission.ACCESS_SERVICE_DM
999     * @param { 'deviceFound' } type Successfully discovered device.
1000     * @param { Callback<{ subscribeId: number, device: DeviceInfo }> } callback Indicates the device found callback to register.
1001     * @throws { BusinessError } 401 - Input parameter error.
1002     * @throws { BusinessError } 202 - The caller is not a system application.
1003     * @syscap SystemCapability.DistributedHardware.DeviceManager
1004     * @systemapi this method can be used only by system applications.
1005     * @since 7
1006     */
1007    on(type: 'deviceFound', callback: Callback<{ subscribeId: number, device: DeviceInfo }>): void;
1008
1009    /**
1010     * UnRegister a device found callback so that the application can be notified when the device was found
1011     *
1012     * @permission ohos.permission.ACCESS_SERVICE_DM
1013     * @param { 'deviceFound' } type Successfully discovered device.
1014     * @param { Callback<{ subscribeId: number, device: DeviceInfo }> } callback Indicates the device found callback to register.
1015     * @throws { BusinessError } 401 - Input parameter error.
1016     * @throws { BusinessError } 202 - The caller is not a system application.
1017     * @syscap SystemCapability.DistributedHardware.DeviceManager
1018     * @systemapi this method can be used only by system applications.
1019     * @since 7
1020     */
1021    off(type: 'deviceFound', callback?: Callback<{ subscribeId: number, device: DeviceInfo }>): void;
1022
1023    /**
1024     * Register a device found result callback so that the application can be notified when the device discover was failed
1025     *
1026     * @permission ohos.permission.ACCESS_SERVICE_DM
1027     * @param { 'discoverFail' } type Discovery Device Failure.
1028     * @param { Callback<{ subscribeId: number, reason: number }> } callback Indicates the device found result callback to register.
1029     * @throws { BusinessError } 401 - Input parameter error.
1030     * @throws { BusinessError } 202 - The caller is not a system application.
1031     * @syscap SystemCapability.DistributedHardware.DeviceManager
1032     * @systemapi this method can be used only by system applications.
1033     * @since 7
1034     */
1035    on(type: 'discoverFail', callback: Callback<{ subscribeId: number, reason: number }>): void;
1036
1037    /**
1038     * UnRegister a device found result callback so that the application can be notified when the device discover was failed
1039     *
1040     * @permission ohos.permission.ACCESS_SERVICE_DM
1041     * @param { 'discoverFail' } type Discovery Device Failure.
1042     * @param { Callback<{ subscribeId: number, reason: number }> } callback Indicates the device found result callback to register.
1043     * @throws { BusinessError } 401 - Input parameter error.
1044     * @throws { BusinessError } 202 - The caller is not a system application.
1045     * @syscap SystemCapability.DistributedHardware.DeviceManager
1046     * @systemapi this method can be used only by system applications.
1047     * @since 7
1048     */
1049    off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: number }>): void;
1050
1051    /**
1052     * Register a device publish result callback so that the application can be notified when the device publish success
1053     *
1054     * @permission ohos.permission.ACCESS_SERVICE_DM
1055     * @param { 'publishSuccess' } type Successfully published device.
1056     * @param { Callback<{ publishId: number }> } callback Indicates the device publish result callback to register.
1057     * @throws { BusinessError } 401 - Input parameter error.
1058     * @throws { BusinessError } 202 - The caller is not a system application.
1059     * @syscap SystemCapability.DistributedHardware.DeviceManager
1060     * @systemapi this method can be used only by system applications.
1061     * @since 9
1062     */
1063    on(type: 'publishSuccess', callback: Callback<{ publishId: number }>): void;
1064
1065    /**
1066     * UnRegister a device publish result callback so that the application can be notified when the device publish was failed
1067     *
1068     * @permission ohos.permission.ACCESS_SERVICE_DM
1069     * @param { 'publishSuccess' } type Successfully published device.
1070     * @param { Callback<{ publishId: number }> } callback Indicates the device publish result callback to register.
1071     * @throws { BusinessError } 401 - Input parameter error.
1072     * @throws { BusinessError } 202 - The caller is not a system application.
1073     * @syscap SystemCapability.DistributedHardware.DeviceManager
1074     * @systemapi this method can be used only by system applications.
1075     * @since 9
1076     */
1077    off(type: 'publishSuccess', callback?: Callback<{ publishId: number }>): void;
1078
1079    /**
1080     * Register a device publish result callback so that the application can be notified when the device publish was failed
1081     *
1082     * @permission ohos.permission.ACCESS_SERVICE_DM
1083     * @param { 'publishFail' } type Failed to publish device.
1084     * @param { Callback<{ publishId: number, reason: number }> } callback Indicates the device publish result callback to register.
1085     * @throws { BusinessError } 401 - Input parameter error.
1086     * @throws { BusinessError } 202 - The caller is not a system application.
1087     * @syscap SystemCapability.DistributedHardware.DeviceManager
1088     * @systemapi this method can be used only by system applications.
1089     * @since 9
1090     */
1091    on(type: 'publishFail', callback: Callback<{ publishId: number, reason: number }>): void;
1092
1093    /**
1094     * UnRegister a device publish result callback so that the application can be notified when the device publish was failed
1095     *
1096     * @permission ohos.permission.ACCESS_SERVICE_DM
1097     * @param { 'publishFail' } type Failed to publish device.
1098     * @param { Callback<{ publishId: number, reason: number }> } callback Indicates the device publish result callback to register.
1099     * @throws { BusinessError } 401 - Input parameter error.
1100     * @throws { BusinessError } 202 - The caller is not a system application.
1101     * @syscap SystemCapability.DistributedHardware.DeviceManager
1102     * @systemapi this method can be used only by system applications.
1103     * @since 9
1104     */
1105    off(type: 'publishFail', callback?: Callback<{ publishId: number, reason: number }>): void;
1106
1107    /**
1108     * Register a serviceError callback so that the application can be notified when devicemanager service died
1109     *
1110     * @permission ohos.permission.ACCESS_SERVICE_DM
1111     * @param { 'serviceDie' } type Service death.
1112     * @param { function } callback Indicates the service error callback to register.
1113     * @throws { BusinessError } 401 - Input parameter error.
1114     * @throws { BusinessError } 202 - The caller is not a system application.
1115     * @syscap SystemCapability.DistributedHardware.DeviceManager
1116     * @systemapi this method can be used only by system applications.
1117     * @since 7
1118     */
1119    on(type: 'serviceDie', callback: () => void): void;
1120
1121    /**
1122     * UnRegister a serviceError callback so that the application can be notified when devicemanager service died
1123     *
1124     * @permission ohos.permission.ACCESS_SERVICE_DM
1125     * @param { 'serviceDie' } type Service death.
1126     * @param { function } callback Indicates the service error callback to register.
1127     * @throws { BusinessError } 401 - Input parameter error.
1128     * @throws { BusinessError } 202 - The caller is not a system application.
1129     * @syscap SystemCapability.DistributedHardware.DeviceManager
1130     * @systemapi this method can be used only by system applications.
1131     * @since 7
1132     */
1133    off(type: 'serviceDie', callback?: () => void): void;
1134  }
1135}
1136
1137export default deviceManager;
1138