• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023-2025 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 type { AsyncCallback, Callback } from './@ohos.base';
22
23/**
24 * Providers interfaces to create a {@link deviceManager} instances.
25 *
26 * @namespace distributedDeviceManager
27 * @syscap SystemCapability.DistributedHardware.DeviceManager
28 * @since 10
29 */
30
31declare namespace distributedDeviceManager {
32
33  /**
34   * Basic description information of a distributed device.
35   * @interface DeviceBasicInfo
36   * @syscap SystemCapability.DistributedHardware.DeviceManager
37   * @since 10
38   */
39  interface DeviceBasicInfo {
40    /**
41     * Device identifier. The actual value is udid-hash confused with appid and salt value based on sha256.
42     * This id remains unchanged after application installation. If the application is uninstalled and reinstalled,
43     * the obtained ID will change.
44     * @type { string }
45     * @syscap SystemCapability.DistributedHardware.DeviceManager
46     * @since 10
47     */
48    deviceId: string;
49
50    /**
51     * Device name.
52     * @type { string }
53     * @syscap SystemCapability.DistributedHardware.DeviceManager
54     * @since 10
55     */
56    deviceName: string;
57
58    /**
59     * Obtains the device type represented by a string,
60     * which can be {@code phone}, {@code tablet}, {@code tv}, {@code smartVision}, {@code car}.
61     * @type { string }
62     * @syscap SystemCapability.DistributedHardware.DeviceManager
63     * @since 10
64     */
65    deviceType: string;
66
67    /**
68     * Device network id.
69     * @type { ?string }
70     * @syscap SystemCapability.DistributedHardware.DeviceManager
71     * @since 10
72     */
73    networkId?: string;
74  }
75
76  /**
77   * The state of the nearby devices.
78   * @enum { number }
79   * @syscap SystemCapability.DistributedHardware.DeviceManager
80   * @since 10
81   */
82  enum DeviceStateChange {
83    /**
84     * This state indicates the device is online but the state is unknown,The distributed function cannot used until
85     * state changes to AVAILABLE.
86     * @syscap SystemCapability.DistributedHardware.DeviceManager
87     * @since 10
88     */
89    UNKNOWN = 0,
90
91    /**
92     * This state indicates the device has been synchronized to the database, Now the distributed function can be used.
93     * @syscap SystemCapability.DistributedHardware.DeviceManager
94     * @since 10
95     */
96    AVAILABLE = 1,
97
98    /**
99     * This state indicates the device is offline.
100     * @syscap SystemCapability.DistributedHardware.DeviceManager
101     * @since 10
102     */
103    UNAVAILABLE = 2,
104  }
105
106  /**
107   * Device profile information filter options.
108   * @interface DeviceProfileInfoFilterOptions
109   * @syscap SystemCapability.DistributedHardware.DeviceManager
110   * @systemapi
111   * @since 15
112   */
113  interface DeviceProfileInfoFilterOptions {
114    /**
115     * Whether to request data from the cloud.
116     * @type { boolean }
117     * @syscap SystemCapability.DistributedHardware.DeviceManager
118     * @systemapi
119     * @since 15
120     */
121    isCloud : boolean,
122    /**
123     * Device ID list.
124     * @type { Array<string> }
125     * @syscap SystemCapability.DistributedHardware.DeviceManager
126     * @systemapi
127     * @since 15
128     */
129    deviceIdList?: Array<string>;
130  }
131
132  /**
133   * Service profile information.
134   * @interface ServiceProfileInfo
135   * @syscap SystemCapability.DistributedHardware.DeviceManager
136   * @systemapi
137   * @since 15
138   */
139  interface ServiceProfileInfo {
140    /**
141     * Device ID.
142     * @type { string }
143     * @syscap SystemCapability.DistributedHardware.DeviceManager
144     * @systemapi
145     * @since 15
146     */
147    deviceId: string;
148
149    /**
150     * Service ID.
151     * @type { string }
152     * @syscap SystemCapability.DistributedHardware.DeviceManager
153     * @systemapi
154     * @since 15
155     */
156    serviceId: string;
157
158    /**
159     * Service Type.
160     * @type { string }
161     * @syscap SystemCapability.DistributedHardware.DeviceManager
162     * @systemapi
163     * @since 15
164     */
165    serviceType: string;
166
167    /**
168     * Service data.
169     * @type { ?string }
170     * @syscap SystemCapability.DistributedHardware.DeviceManager
171     * @systemapi
172     * @since 15
173     */
174    data?: string;
175  }
176
177  /**
178   * Device profile information.
179   * @interface DeviceProfileInfo
180   * @syscap SystemCapability.DistributedHardware.DeviceManager
181   * @systemapi
182   * @since 15
183   */
184  interface DeviceProfileInfo {
185    /**
186     * Device ID.
187     * @type { string }
188     * @syscap SystemCapability.DistributedHardware.DeviceManager
189     * @systemapi
190     * @since 15
191     */
192    deviceId: string;
193
194    /**
195     * Device SerialNumber.
196     * @type { string }
197     * @syscap SystemCapability.DistributedHardware.DeviceManager
198     * @systemapi
199     * @since 15
200     */
201    deviceSn: string;
202
203    /**
204     * MAC address.
205     * @type { string }
206     * @syscap SystemCapability.DistributedHardware.DeviceManager
207     * @systemapi
208     * @since 15
209     */
210    mac: string;
211
212    /**
213     * Device model.
214     * @type { string }
215     * @syscap SystemCapability.DistributedHardware.DeviceManager
216     * @systemapi
217     * @since 15
218     */
219    model: string;
220
221    /**
222     * Device type.
223     * @type { string }
224     * @syscap SystemCapability.DistributedHardware.DeviceManager
225     * @systemapi
226     * @since 15
227     */
228    deviceType: string;
229
230    /**
231     * Manufacturer.
232     * @type { string }
233     * @syscap SystemCapability.DistributedHardware.DeviceManager
234     * @systemapi
235     * @since 15
236     */
237    manufacturer: string;
238
239    /**
240     * Device name.
241     * @type { string }
242     * @syscap SystemCapability.DistributedHardware.DeviceManager
243     * @systemapi
244     * @since 15
245     */
246    deviceName: string;
247
248    /**
249     * Product ID.
250     * @type { string }
251     * @syscap SystemCapability.DistributedHardware.DeviceManager
252     * @systemapi
253     * @since 15
254     */
255    productId: string;
256
257    /**
258     * Product sub ID.
259     * @type { ?string }
260     * @syscap SystemCapability.DistributedHardware.DeviceManager
261     * @systemapi
262     * @since 15
263     */
264    subProductId?: string;
265
266    /**
267     * Sdk version.
268     * @type { string }
269     * @syscap SystemCapability.DistributedHardware.DeviceManager
270     * @systemapi
271     * @since 15
272     */
273    sdkVersion: string;
274
275    /**
276     * Bluetooth BLE MAC address.
277     * @type { string }
278     * @syscap SystemCapability.DistributedHardware.DeviceManager
279     * @systemapi
280     * @since 15
281     */
282    bleMac: string;
283
284    /**
285     * Bluetooth BR MAC address.
286     * @type { string }
287     * @syscap SystemCapability.DistributedHardware.DeviceManager
288     * @systemapi
289     * @since 15
290     */
291    brMac: string;
292
293    /**
294     * Starflash MAC address.
295     * @type { string }
296     * @syscap SystemCapability.DistributedHardware.DeviceManager
297     * @systemapi
298     * @since 15
299     */
300    sleMac: string;
301
302    /**
303     * Firmware version.
304     * @type { string }
305     * @syscap SystemCapability.DistributedHardware.DeviceManager
306     * @systemapi
307     * @since 15
308     */
309    firmwareVersion: string;
310
311    /**
312     * Hardware version.
313     * @type { string }
314     * @syscap SystemCapability.DistributedHardware.DeviceManager
315     * @systemapi
316     * @since 15
317     */
318    hardwareVersion: string;
319
320    /**
321     * Software version.
322     * @type { string }
323     * @syscap SystemCapability.DistributedHardware.DeviceManager
324     * @systemapi
325     * @since 15
326     */
327    softwareVersion: string;
328
329    /**
330     * Protocol type.
331     * @type { number }
332     * @syscap SystemCapability.DistributedHardware.DeviceManager
333     * @systemapi
334     * @since 15
335     */
336    protocolType: number;
337
338    /**
339     * Setup type.
340     * @type { number }
341     * @syscap SystemCapability.DistributedHardware.DeviceManager
342     * @systemapi
343     * @since 15
344     */
345    setupType: number;
346
347    /**
348     * Wise device ID.
349     * @type { string }
350     * @syscap SystemCapability.DistributedHardware.DeviceManager
351     * @systemapi
352     * @since 15
353     */
354    wiseDeviceId: string;
355
356    /**
357     * Wise user ID.
358     * @type { string }
359     * @syscap SystemCapability.DistributedHardware.DeviceManager
360     * @systemapi
361     * @since 15
362     */
363    wiseUserId: string;
364
365    /**
366     * Register time.
367     * @type { string }
368     * @syscap SystemCapability.DistributedHardware.DeviceManager
369     * @systemapi
370     * @since 15
371     */
372    registerTime: string;
373
374    /**
375     * Modify time.
376     * @type { string }
377     * @syscap SystemCapability.DistributedHardware.DeviceManager
378     * @systemapi
379     * @since 15
380     */
381    modifyTime: string;
382
383    /**
384     * Share time.
385     * @type { string }
386     * @syscap SystemCapability.DistributedHardware.DeviceManager
387     * @systemapi
388     * @since 15
389     */
390    shareTime: string;
391
392    /**
393    * Whether the device is a local device.
394    * @type { boolean }
395    * @syscap SystemCapability.DistributedHardware.DeviceManager
396    * @systemapi
397    * @since 15
398    */
399    isLocalDevice: boolean;
400
401    /**
402     * Service profile information list.
403     * @type { Array<ServiceProfileInfo> }
404     * @syscap SystemCapability.DistributedHardware.DeviceManager
405     * @systemapi
406     * @since 15
407     */
408    services?: Array<ServiceProfileInfo>;
409  }
410
411  /**
412   * Heartbeat policy.
413   * @enum {number}
414   * @syscap SystemCapability.DistributedHardware.DeviceManager
415   * @systemapi
416   * @since 15
417   */
418  enum StrategyForHeartbeat {
419    /**
420     * Temporarily stop heartbeat, which automatically recovers after timeout.
421     * @syscap SystemCapability.DistributedHardware.DeviceManager
422     * @systemapi
423     * @since 15
424     */
425    TEMP_STOP_HEARTBEAT = 100,
426    /**
427     * Start heartbeat.
428     * @syscap SystemCapability.DistributedHardware.DeviceManager
429     * @systemapi
430     * @since 15
431     */
432    START_HEARTBEAT = 101,
433  }
434
435  /**
436   * Creates an {@code DeviceManager} instance.
437   *
438   * To manage devices, you must first call this method to obtain a {@code DeviceManager} instance and then
439   * use this instance to call other device management methods.
440   *
441   * @param { string } bundleName - Indicates the bundle name of the application.
442   * @returns { DeviceManager } - Return the DeviceManager object.
443   * @throws { BusinessError } 401 - Parameter error. Possible causes:
444   *                                                  1. Mandatory parameters are left unspecified;
445   *                                                  2. Incorrect parameter type;
446   *                                                  3. Parameter verification failed.
447   * @syscap SystemCapability.DistributedHardware.DeviceManager
448   * @since 10
449   */
450  function createDeviceManager(bundleName: string): DeviceManager;
451
452  /**
453   * Releases the {@code DeviceManager} instance that is no longer used.
454   *
455   * @permission ohos.permission.DISTRIBUTED_DATASYNC
456   * @param { DeviceManager } deviceManager - Indicates the {@code DeviceManager} instance.
457   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
458   * @throws { BusinessError } 401 - Parameter error. Possible causes:
459   *                                                  1. Mandatory parameters are left unspecified;
460   *                                                  2. Incorrect parameter types;
461   *                                                  3. Parameter verification failed.
462   * @throws { BusinessError } 11600101 - Failed to execute the function.
463   * @syscap SystemCapability.DistributedHardware.DeviceManager
464   * @since 10
465   */
466  function releaseDeviceManager(deviceManager: DeviceManager): void;
467
468  /**
469   * Provides methods for managing devices.
470   *
471   * @interface DeviceManager
472   * @syscap SystemCapability.DistributedHardware.DeviceManager
473   * @since 10
474   */
475  interface DeviceManager {
476
477    /**
478     * Get a list of available devices. This interface query all authorized and connectable devices.
479     *
480     * @permission ohos.permission.DISTRIBUTED_DATASYNC
481     * @returns { Array<DeviceBasicInfo> } - Returns a list of available devices.
482     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
483     * @throws { BusinessError } 401 - Parameter error. Possible causes:
484     *                                                  1. Mandatory parameters are left unspecified;
485     *                                                  2. Incorrect parameter types;
486     *                                                  3. Parameter verification failed.
487     * @throws { BusinessError } 11600101 - Failed to execute the function.
488     * @syscap SystemCapability.DistributedHardware.DeviceManager
489     * @since 10
490     */
491    getAvailableDeviceListSync(): Array<DeviceBasicInfo>;
492
493    /**
494     * Get a list of available devices. This interface query all authorized and connectable devices.
495     *
496     * @permission ohos.permission.DISTRIBUTED_DATASYNC
497     * @param { AsyncCallback<Array<DeviceBasicInfo>> } callback - Indicates the callback to be
498     * invoked upon getAvailableDeviceList.
499     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
500     * @throws { BusinessError } 11600101 - Failed to execute the function.
501     * @syscap SystemCapability.DistributedHardware.DeviceManager
502     * @since 10
503     */
504    getAvailableDeviceList(callback: AsyncCallback<Array<DeviceBasicInfo>>): void;
505
506    /**
507     * Get a list of available devices. This interface query all authorized and connectable devices.
508     *
509     * @permission ohos.permission.DISTRIBUTED_DATASYNC
510     * @returns { Promise<Array<DeviceBasicInfo>> } - Returns a list of available devices.
511     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
512     * @throws { BusinessError } 11600101 - Failed to execute the function.
513     * @syscap SystemCapability.DistributedHardware.DeviceManager
514     * @since 10
515     */
516    getAvailableDeviceList(): Promise<Array<DeviceBasicInfo>>;
517
518    /**
519     * Get the network id of the local device.
520     *
521     * @permission ohos.permission.DISTRIBUTED_DATASYNC
522     * @returns { string } - Returns local device network id.
523     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
524     * @throws { BusinessError } 11600101 - Failed to execute the function.
525     * @syscap SystemCapability.DistributedHardware.DeviceManager
526     * @since 10
527     */
528    getLocalDeviceNetworkId(): string;
529
530    /**
531     * Get the device name of the local device.
532     *
533     * @permission ohos.permission.DISTRIBUTED_DATASYNC
534     * @returns { string } - Returns local device name.
535     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
536     * @throws { BusinessError } 11600101 - Failed to execute the function.
537     * @syscap SystemCapability.DistributedHardware.DeviceManager
538     * @since 10
539     */
540    getLocalDeviceName(): string;
541
542    /**
543     * Get the device type of the local device.
544     *
545     * @permission ohos.permission.DISTRIBUTED_DATASYNC
546     * @returns { number } - Returns local device type.
547     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
548     * @throws { BusinessError } 11600101 - Failed to execute the function.
549     * @syscap SystemCapability.DistributedHardware.DeviceManager
550     * @since 10
551     */
552    getLocalDeviceType(): number;
553
554    /**
555     * Get the device id of the local device.
556     *
557     * @permission ohos.permission.DISTRIBUTED_DATASYNC
558     * @returns { string } - Device identifier. The actual value is udid-hash confused with appid and salt value based on sha256.
559     * This id remains unchanged after application installation. If the application is uninstalled and reinstalled,
560     * the obtained ID will change.
561     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
562     * @throws { BusinessError } 11600101 - Failed to execute the function.
563     * @syscap SystemCapability.DistributedHardware.DeviceManager
564     * @since 10
565     */
566    getLocalDeviceId(): string;
567
568    /**
569     * Get the device name by network id.
570     *
571     * @permission ohos.permission.DISTRIBUTED_DATASYNC
572     * @param { string } networkId - Device network id.
573     * @returns { string } - Returns device name.
574     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
575     * @throws { BusinessError } 401 - Parameter error. Possible causes:
576     *                                                  1. Mandatory parameters are left unspecified;
577     *                                                  2. Incorrect parameter type;
578     *                                                  3. Parameter verification failed;
579     *                                                  4. The size of specified networkId is greater than 255.
580     * @throws { BusinessError } 11600101 - Failed to execute the function.
581     * @syscap SystemCapability.DistributedHardware.DeviceManager
582     * @since 10
583     */
584    getDeviceName(networkId: string): string;
585
586    /**
587     * Get the device type by network id.
588     *
589     * @permission ohos.permission.DISTRIBUTED_DATASYNC
590     * @param { string } networkId - Device network id.
591     * @returns { number } - Returns device type.
592     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
593     * @throws { BusinessError } 401 - Parameter error. Possible causes:
594     *                                                  1. Mandatory parameters are left unspecified;
595     *                                                  2. Incorrect parameter type;
596     *                                                  3. Parameter verification failed;
597     *                                                  4. The size of specified networkId is greater than 255.
598     * @throws { BusinessError } 11600101 - Failed to execute the function.
599     * @syscap SystemCapability.DistributedHardware.DeviceManager
600     * @since 10
601     */
602    getDeviceType(networkId: string): number;
603
604    /**
605     * Start to discover nearby devices.
606     *
607     * @permission ohos.permission.DISTRIBUTED_DATASYNC
608     * @param { object } discoverParam - Identifies the type of target discovered:
609     *       discoverTargetType : 1     - Discovery target as a device by default, the value is 1.
610     * @param { object } filterOptions - FilterOptions to filter discovery device.
611     * The type of filterOptions is map. The map are as follows:
612     *       availableStatus: 0-1       - Discover devices only are credible, The value is 0 indicates device isn't credible;
613     *                                      0: Devices are offline, client need to bind the device by calling bindTarget() and then connect to it.
614     *                                      1: Devices already online, client can make connection.
615     *       discoverDistance: 0-100    - Discover devices within a certain distance from the local, the unit is cm.
616     *       authenticationStatus: 0-1  - Discover devices based on different authentication status:
617     *                                      0: Devices not authenticated.
618                                            1: Devices already authenticated.
619     *                                The value is 1 indicates device is trust.
620     *       authorizationType: 0-2     - Discover devices based on different authorization type:
621     *                                      0: Devices authenticated based on temporary negotiated session key.
622     *                                      1: Devices authenticated based on the same account credential key.
623     *                                      2: Devices authenticated based on different account credential keys.
624     * @throws { BusinessError } 401 - Parameter error. Possible causes:
625     *                                                  1. Mandatory parameters are left unspecified;
626     *                                                  2. Incorrect parameter type;
627     *                                                  3. Parameter verification failed.
628     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
629     * @throws { BusinessError } 11600104 - Discovery unavailable.
630     * @throws { BusinessError } 11600101 - Failed to execute the function.
631     * @syscap SystemCapability.DistributedHardware.DeviceManager
632     * @since 10
633     */
634    startDiscovering(discoverParam: { [key: string]: Object; }, filterOptions?: { [key: string]: Object; }): void;
635
636    /**
637     * Stop discovering nearby devices.
638     *
639     * @permission ohos.permission.DISTRIBUTED_DATASYNC
640     * @throws { BusinessError } 401 - Parameter error. Possible causes:
641     *                                                  1. Mandatory parameters are left unspecified;
642     *                                                  2. Incorrect parameter type;
643     *                                                  3. Parameter verification failed.
644     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
645     * @throws { BusinessError } 11600104 - Discovery unavailable.
646     * @throws { BusinessError } 11600101 - Failed to execute the function.
647     * @syscap SystemCapability.DistributedHardware.DeviceManager
648     * @since 10
649     */
650    stopDiscovering(): void;
651
652    /**
653     * Bind the specified target.
654     *
655     * @permission ohos.permission.DISTRIBUTED_DATASYNC
656     * @param { string } deviceId - id of device to bind.
657     * @param { object } bindParam - parameters of device to bind, The parameter type is map,such as:
658     *      "bindType" : 1,           - This value is type of bind, the values are as follows:
659     *                                  1 - The bind type is pin code .
660
661     *      "targetPkgName" : "xxxx", - The package name of binding target.
662     *      "appName" : "xxxx",       - The app name that try to bind the target.
663     *      "appOperation" : "xxxx"   - The reason why the app want to bind the target package.
664     *      "customDescription" : "xxxx" - The detail description of the operation.
665     * @param { AsyncCallback<{deviceId: string;}> } callback - indicates the callback to be invoked upon bindDevice.
666     * @throws { BusinessError } 401 - Parameter error. Possible causes:
667     *                                                  1. Mandatory parameters are left unspecified;
668     *                                                  2. Incorrect parameter type;
669     *                                                  3. Parameter verification failed;
670     *                                                  4. The size of specified deviceId is greater than 255.
671     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
672     * @throws { BusinessError } 11600101 - Failed to execute the function.
673     * @throws { BusinessError } 11600103 - Authentication unavailable.
674     * @syscap SystemCapability.DistributedHardware.DeviceManager
675     * @since 10
676     */
677    bindTarget(deviceId: string, bindParam: { [key: string]: Object; }, callback: AsyncCallback<{deviceId: string;}>): void;
678
679    /**
680     * Unbind the specified target.
681     *
682     * @permission ohos.permission.DISTRIBUTED_DATASYNC
683     * @param { string } deviceId - id of device to unbind
684     * @throws { BusinessError } 401 - Parameter error. Possible causes:
685     *                                                  1. Mandatory parameters are left unspecified;
686     *                                                  2. Incorrect parameter type;
687     *                                                  3. Parameter verification failed;
688     *                                                  4. The size of specified deviceId is greater than 255.
689     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
690     * @throws { BusinessError } 11600101 - Failed to execute the function.
691     * @syscap SystemCapability.DistributedHardware.DeviceManager
692     * @since 10
693     */
694    unbindTarget(deviceId: string): void;
695
696    /**
697     * The reply of ui operation from pin-code window, this interface can only be used by pin-code-hap of devicemanager.
698     *
699     * @permission ohos.permission.ACCESS_SERVICE_DM
700     * @param { number } action - The reply action of user operation.
701     * @param { string } actionResult - Indicates the user operation result.
702     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
703     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
704     * @throws { BusinessError } 401 - Parameter error. Possible causes:
705     *                                                  1. Mandatory parameters are left unspecified;
706     *                                                  2. Incorrect parameter type;
707     *                                                  3. Parameter verification failed;
708     *                                                  4. The size of specified actionResult is greater than 255.
709     * @syscap SystemCapability.DistributedHardware.DeviceManager
710     * @systemapi this method can be used only by system applications.
711     * @since 10
712     */
713    replyUiAction(action: number, actionResult: string): void;
714
715    /**
716     * Register a device state callback so that the application can be notified upon device state changes based on
717     * the application bundle name.
718     *
719     * @permission ohos.permission.DISTRIBUTED_DATASYNC
720     * @param { 'deviceStateChange' } type - Device state change.
721     * @param { Callback<{ action: DeviceStateChange; device: DeviceBasicInfo; }> } callback
722     * Indicates the device state callback to register.
723     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
724     * @throws { BusinessError } 401 - Parameter error. Possible causes:
725     *                                                  1. Mandatory parameters are left unspecified;
726     *                                                  2. Incorrect parameter type;
727     *                                                  3. Parameter verification failed;
728     *                                                  4. The size of specified type is greater than 255.
729     * @syscap SystemCapability.DistributedHardware.DeviceManager
730     * @since 10
731     */
732    on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChange; device: DeviceBasicInfo; }>): void;
733
734    /**
735     * UnRegister device state callback based on the application bundle name.
736     *
737     * @permission ohos.permission.DISTRIBUTED_DATASYNC
738     * @param { 'deviceStateChange' } type - Device state change.
739     * @param { Callback<{ action: DeviceStateChange; device: DeviceBasicInfo; }> } callback
740     * Indicates the device state callback to unregister.
741     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
742     * @throws { BusinessError } 401 - Parameter error. Possible causes:
743     *                                                  1. Mandatory parameters are left unspecified;
744     *                                                  2. Incorrect parameter type;
745     *                                                  3. Parameter verification failed;
746     *                                                  4. The size of specified type is greater than 255.
747     * @syscap SystemCapability.DistributedHardware.DeviceManager
748     * @since 10
749     */
750    off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChange; device: DeviceBasicInfo; }>): void;
751
752    /**
753     * Register a device discovery result callback so that the application can be notified when discovery success.
754     *
755     * @permission ohos.permission.DISTRIBUTED_DATASYNC
756     * @param { 'discoverSuccess' } type - Successfully discovered device.
757     * @param { Callback<{ device: DeviceBasicInfo; }> } callback - Indicates the device discovery callback to register.
758     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
759     * @throws { BusinessError } 401 - Parameter error. Possible causes:
760     *                                                  1. Mandatory parameters are left unspecified;
761     *                                                  2. Incorrect parameter type;
762     *                                                  3. Parameter verification failed;
763     *                                                  4. The size of specified type is greater than 255.
764     * @syscap SystemCapability.DistributedHardware.DeviceManager
765     * @since 10
766     */
767    on(type: 'discoverSuccess', callback: Callback<{ device: DeviceBasicInfo; }>): void;
768
769    /**
770     * UnRegister the device discovery result callback.
771     *
772     * @permission ohos.permission.DISTRIBUTED_DATASYNC
773     * @param { 'discoverSuccess' } type - Successfully discovered device.
774     * @param { Callback<{ device: DeviceBasicInfo; }> } callback - Indicates the device discovery callback to unregister.
775     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
776     * @throws { BusinessError } 401 - Parameter error. Possible causes:
777     *                                                  1. Mandatory parameters are left unspecified;
778     *                                                  2. Incorrect parameter type;
779     *                                                  3. Parameter verification failed;
780     *                                                  4. The size of specified type is greater than 255.
781     * @syscap SystemCapability.DistributedHardware.DeviceManager
782     * @since 10
783     */
784    off(type: 'discoverSuccess', callback?: Callback<{ device: DeviceBasicInfo; }>): void;
785
786    /**
787     * Register a device name change callback so that the application can be notified when discovery success.
788     *
789     * @permission ohos.permission.DISTRIBUTED_DATASYNC
790     * @param { 'deviceNameChange' } type - Changed device name.
791     * @param { Callback<{ deviceName: string; }> } callback - Indicates the device name change callback to register.
792     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
793     * @throws { BusinessError } 401 - Parameter error. Possible causes:
794     *                                                  1. Mandatory parameters are left unspecified;
795     *                                                  2. Incorrect parameter type;
796     *                                                  3. Parameter verification failed;
797     *                                                  4. The size of specified type is greater than 255.
798     * @syscap SystemCapability.DistributedHardware.DeviceManager
799     * @since 10
800     */
801    on(type: 'deviceNameChange', callback: Callback<{ deviceName: string; }>): void;
802
803    /**
804     * UnRegister the device name change result callback.
805     *
806     * @permission ohos.permission.DISTRIBUTED_DATASYNC
807     * @param { 'deviceNameChange' } type - Changed device name.
808     * @param { Callback<{ deviceName: string; }> } callback - Indicates the device name change callback to unregister.
809     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
810     * @throws { BusinessError } 401 - Parameter error. Possible causes:
811     *                                                  1. Mandatory parameters are left unspecified;
812     *                                                  2. Incorrect parameter type;
813     *                                                  3. Parameter verification failed;
814     *                                                  4. The size of specified type is greater than 255.
815     * @syscap SystemCapability.DistributedHardware.DeviceManager
816     * @since 10
817     */
818    off(type: 'deviceNameChange', callback?: Callback<{ deviceName: string; }>): void;
819
820    /**
821     * Register a device discovery result callback so that the application can be notified when discover failed.
822     *
823     * @permission ohos.permission.DISTRIBUTED_DATASYNC
824     * @param { 'discoverFailure' } type - Discovery Device Failure.
825     * @param { Callback<{ reason: number; }> } callback
826     * Indicates the device found result callback to register.
827     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
828     * @throws { BusinessError } 401 - Parameter error. Possible causes:
829     *                                                  1. Mandatory parameters are left unspecified;
830     *                                                  2. Incorrect parameter type;
831     *                                                  3. Parameter verification failed;
832     *                                                  4. The size of specified type is greater than 255.
833     * @syscap SystemCapability.DistributedHardware.DeviceManager
834     * @since 10
835     */
836    on(type: 'discoverFailure', callback: Callback<{ reason: number; }>): void;
837
838    /**
839     * UnRegister the device discovery result callback.
840     *
841     * @permission ohos.permission.DISTRIBUTED_DATASYNC
842     * @param { 'discoverFailure' } type - Discovery Device Failure.
843     * @param { Callback<{ reason: number; }> } callback
844     * Indicates the device found result callback to unregister.
845     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
846     * @throws { BusinessError } 401 - Parameter error. Possible causes:
847     *                                                  1. Mandatory parameters are left unspecified;
848     *                                                  2. Incorrect parameter type;
849     *                                                  3. Parameter verification failed;
850     *                                                  4. The size of specified type is greater than 255.
851     * @syscap SystemCapability.DistributedHardware.DeviceManager
852     * @since 10
853     */
854    off(type: 'discoverFailure', callback?: Callback<{ reason: number; }>): void;
855
856    /**
857     * Register a serviceError callback so that the application can be notified when devicemanager service died
858     *
859     * @permission ohos.permission.DISTRIBUTED_DATASYNC
860     * @param { 'serviceDie' } type - Service death.
861     * @param { Callback<{}> } callback - Indicates the service error callback to register.
862     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
863     * @throws { BusinessError } 401 - Parameter error. Possible causes:
864     *                                                  1. Mandatory parameters are left unspecified;
865     *                                                  2. Incorrect parameter type;
866     *                                                  3. Parameter verification failed;
867     *                                                  4. The size of specified type is greater than 255.
868     * @syscap SystemCapability.DistributedHardware.DeviceManager
869     * @since 10
870     */
871    on(type: 'serviceDie', callback?: Callback<{}>): void;
872
873    /**
874     * UnRegister the service error callback.
875     *
876     * @permission ohos.permission.DISTRIBUTED_DATASYNC
877     * @param { 'serviceDie' } type - Service death.
878     * @param { Callback<{}> } callback - Indicates the service error callback to unregister.
879     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
880     * @throws { BusinessError } 401 - Parameter error. Possible causes:
881     *                                                  1. Mandatory parameters are left unspecified;
882     *                                                  2. Incorrect parameter type;
883     *                                                  3. Parameter verification failed;
884     *                                                  4. The size of specified type is greater than 255.
885     * @syscap SystemCapability.DistributedHardware.DeviceManager
886     * @since 10
887     */
888    off(type: 'serviceDie', callback?: Callback<{}>): void;
889
890    /**
891     * Register a callback from deviceManager service so that the devicemanager ui can be notified when uiStateChanges.
892     *
893     * @permission ohos.permission.ACCESS_SERVICE_DM
894     * @param { 'replyResult' } type - Ui reply result to register.
895     * @param { Callback<{ param: string; }> } callback - Indicates the devicemanager ui state to register.
896     * @throws { BusinessError } 401 - Parameter error. Possible causes:
897     *                                                  1. Mandatory parameters are left unspecified;
898     *                                                  2. Incorrect parameter type;
899     *                                                  3. Parameter verification failed;
900     *                                                  4. The size of specified type is greater than 255.
901     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
902     * @syscap SystemCapability.DistributedHardware.DeviceManager
903     * @systemapi this method can be used only by system applications.
904     * @since 10
905     */
906    on(type: 'replyResult', callback: Callback<{ param: string; }>): void;
907
908    /**
909      * Unregister uiStateChange, this interface can only be used by devicemanager ui.
910      *
911      * @permission ohos.permission.ACCESS_SERVICE_DM
912      * @param { 'replyResult' } type - Ui reply result to unregister.
913      * @param { Callback<{ param: string; }> } callback - Indicates the devicemanager ui state to unregister.
914      * @throws { BusinessError } 401 - Parameter error. Possible causes:
915      *                                                  1. Mandatory parameters are left unspecified;
916      *                                                  2. Incorrect parameter type;
917      *                                                  3. Parameter verification failed;
918      *                                                  4. The size of specified type is greater than 255.
919      * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
920      * @syscap SystemCapability.DistributedHardware.DeviceManager
921      * @systemapi this method can be used only by system applications.
922      * @since 10
923      */
924    off(type: 'replyResult', callback?: Callback<{ param: string; }>): void;
925
926    /**
927     * Get the device list under the same account.
928     *
929     * @permission ohos.permission.ACCESS_SERVICE_DM
930     * @param { DeviceProfileInfoFilterOptions } filterOptions - parameter for querying the device list, The parameter type is map,such as:
931     *      "isCloud" : false,           -  false - Get from the cahce of device side.
932     *                                      true  - Get from the cloud.
933     *      "deviceIdList" : [],         - Get by specified device ids.
934     * @returns { Promise<Array<DeviceProfileInfo>> } - Returns a list of devices.
935     * @throws { BusinessError } 401 - Parameter error. Possible causes:
936     *                                                  1. Mandatory parameters are left unspecified;
937     *                                                  2. Incorrect parameter type;
938     *                                                  3. Parameter verification failed;
939     *                                                  4. The size of specified type is greater than 500.
940     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
941     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
942     * @throws { BusinessError } 11600102 - Failed to obtain service.
943     * @throws { BusinessError } 11600106 - Get data from cloud fail.
944     * @throws { BusinessError } 11600107 - A login account is required.
945     * @syscap SystemCapability.DistributedHardware.DeviceManager
946     * @systemapi
947     * @since 15
948     */
949    getDeviceProfileInfoList(filterOptions: DeviceProfileInfoFilterOptions): Promise<Array<DeviceProfileInfo>>;
950
951    /**
952     * Set heartbeat policy.
953     *
954     * @permission ohos.permission.ACCESS_SERVICE_DM
955     * @param { StrategyForHeartbeat } policy  - Heartbeat policy.
956     * @param { number } delayTime  - Indicates the duration for disable heartbeat.
957     * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
958     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
959     * @throws { BusinessError } 401 - Parameter error. Possible causes:
960     *                                                  1. Mandatory parameters are left unspecified;
961     *                                                  2. Incorrect parameter types;
962     *                                                  3. Parameter verification failed.
963     * @throws { BusinessError } 11600102 - Failed to obtain service.
964     * @syscap SystemCapability.DistributedHardware.DeviceManager
965     * @systemapi
966     * @since 15
967     */
968    setHeartbeatPolicy(policy: StrategyForHeartbeat, delayTime: number): void;
969  }
970}
971
972export default distributedDeviceManager;