46 Star 173 Fork 4.7K

OpenHarmony/interface_sdk-js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
@ohos.distributedDeviceManager.d.ts 53.67 KB
一键复制 编辑 原始数据 按行查看 历史
guoyi 提交于 3个月前 . 添加错误码说明
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279
/*
* Copyright (c) 2023-2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @kit DistributedServiceKit
*/
import type { AsyncCallback, Callback } from './@ohos.base';
/**
* Providers interfaces to create a {@link deviceManager} instances.
*
* @namespace distributedDeviceManager
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
declare namespace distributedDeviceManager {
/**
* Basic description information of a distributed device.
* @interface DeviceBasicInfo
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
interface DeviceBasicInfo {
/**
* Device identifier. The actual value is udid-hash confused with appid and salt value based on sha256.
* This id remains unchanged after application installation. If the application is uninstalled and reinstalled,
* the obtained ID will change.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
deviceId: string;
/**
* Device name.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
deviceName: string;
/**
* Obtains the device type represented by a string,
* which can be {@code phone}, {@code tablet}, {@code tv}, {@code smartVision}, {@code car}.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
deviceType: string;
/**
* Device network id.
* @type { ?string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
networkId?: string;
}
/**
* The state of the nearby devices.
* @enum { number }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
enum DeviceStateChange {
/**
* This state indicates the device is online but the state is unknown,The distributed function cannot used until
* state changes to AVAILABLE.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
UNKNOWN = 0,
/**
* This state indicates the device has been synchronized to the database, Now the distributed function can be used.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
AVAILABLE = 1,
/**
* This state indicates the device is offline.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
UNAVAILABLE = 2,
}
/**
* Device profile information filter options.
* @interface DeviceProfileInfoFilterOptions
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
interface DeviceProfileInfoFilterOptions {
/**
* Whether to request data from the cloud.
* @type { boolean }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
isCloud : boolean,
/**
* Device ID list.
* @type { Array<string> }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
deviceIdList?: Array<string>;
}
/**
* Service profile information.
* @interface ServiceProfileInfo
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
interface ServiceProfileInfo {
/**
* Device ID.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
deviceId: string;
/**
* Service ID.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
serviceId: string;
/**
* Service Type.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
serviceType: string;
/**
* Service data.
* @type { ?string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
data?: string;
}
/**
* Device profile information.
* @interface DeviceProfileInfo
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
interface DeviceProfileInfo {
/**
* Device ID.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
deviceId: string;
/**
* Device SerialNumber.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
deviceSn: string;
/**
* MAC address.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
mac: string;
/**
* Device model.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
model: string;
/**
* Device type.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
deviceType: string;
/**
* Manufacturer.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
manufacturer: string;
/**
* Device name.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
deviceName: string;
/**
* Product ID.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
productId: string;
/**
* Product sub ID.
* @type { ?string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
subProductId?: string;
/**
* Sdk version.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
sdkVersion: string;
/**
* Bluetooth BLE MAC address.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
bleMac: string;
/**
* Bluetooth BR MAC address.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
brMac: string;
/**
* Starflash MAC address.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
sleMac: string;
/**
* Firmware version.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
firmwareVersion: string;
/**
* Hardware version.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
hardwareVersion: string;
/**
* Software version.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
softwareVersion: string;
/**
* Protocol type.
* @type { number }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
protocolType: number;
/**
* Setup type.
* @type { number }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
setupType: number;
/**
* Wise device ID.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
wiseDeviceId: string;
/**
* Wise user ID.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
wiseUserId: string;
/**
* Register time.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
registerTime: string;
/**
* Modify time.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
modifyTime: string;
/**
* Share time.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
shareTime: string;
/**
* Whether the device is a local device.
* @type { boolean }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
isLocalDevice: boolean;
/**
* Service profile information list.
* @type { Array<ServiceProfileInfo> }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
services?: Array<ServiceProfileInfo>;
/**
* Name of the product to which the device belongs.
* @type { ?string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
productName?: string;
/**
* Internal model of the product to which the device belongs.
* @type { ?string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
internalModel?: string;
}
/**
* Device icon information filter options.
* @interface DeviceIconInfoFilterOptions
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
interface DeviceIconInfoFilterOptions {
/**
* Product ID.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
productId: string;
/**
* Product sub ID.
* @type { ?string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
subProductId?: string;
/**
* Image type.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
imageType: string;
/**
* Spec name.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
specName: string;
/**
* Internal model of the product to which the device belongs.
* @type { ?string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
internalModel?: string;
}
/**
* Device icon information.
* @interface DeviceIconInfo
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
interface DeviceIconInfo {
/**
* Product ID.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
productId: string;
/**
* Product sub ID.
* @type { ?string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
subProductId?: string;
/**
* Image type.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
imageType: string;
/**
* Spec name.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
specName: string;
/**
* Uniform resoure locator.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
url: string;
/**
* Icon.
* @type { ArrayBuffer }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
icon: ArrayBuffer;
/**
* Internal model of the product to which the device belongs.
* @type { ?string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
internalModel?: string;
}
/**
* Heartbeat policy.
* @enum {number}
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
enum StrategyForHeartbeat {
/**
* Temporarily stop heartbeat, which automatically recovers after timeout.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
TEMP_STOP_HEARTBEAT = 100,
/**
* Start heartbeat.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
START_HEARTBEAT = 101,
}
/**
* Device network id query filter options.
* @interface NetworkIdQueryFilter
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
interface NetworkIdQueryFilter {
/**
* Get device network id list by wiseDevice ID.
* @type { string }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
wiseDeviceId : string;
/**
* Get device network id list by online status.
* @type { number }
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
onlineStatus : number,
}
/**
* Creates an {@code DeviceManager} instance.
*
* To manage devices, you must first call this method to obtain a {@code DeviceManager} instance and then
* use this instance to call other device management methods.
*
* @param { string } bundleName - Indicates the bundle name of the application.
* @returns { DeviceManager } - Return the DeviceManager object.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
function createDeviceManager(bundleName: string): DeviceManager;
/**
* Releases the {@code DeviceManager} instance that is no longer used.
*
* @param { DeviceManager } deviceManager - Indicates the {@code DeviceManager} instance.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter types;
* 3. Parameter verification failed.
* @throws { BusinessError } 11600101 - Failed to execute the function.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
function releaseDeviceManager(deviceManager: DeviceManager): void;
/**
* Provides methods for managing devices.
*
* @interface DeviceManager
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
interface DeviceManager {
/**
* Get a list of available devices. This interface query all authorized and connectable devices.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @returns { Array<DeviceBasicInfo> } - Returns a list of available devices.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 11600101 - Failed to execute the function.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
getAvailableDeviceListSync(): Array<DeviceBasicInfo>;
/**
* Get a list of available devices. This interface query all authorized and connectable devices.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { AsyncCallback<Array<DeviceBasicInfo>> } callback - Indicates the callback to be
* invoked upon getAvailableDeviceList.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 11600101 - Failed to execute the function.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
getAvailableDeviceList(callback: AsyncCallback<Array<DeviceBasicInfo>>): void;
/**
* Get a list of available devices. This interface query all authorized and connectable devices.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @returns { Promise<Array<DeviceBasicInfo>> } - Returns a list of available devices.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 11600101 - Failed to execute the function.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
getAvailableDeviceList(): Promise<Array<DeviceBasicInfo>>;
/**
* Get the network id of the local device.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @returns { string } - Returns local device network id.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 11600101 - Failed to execute the function.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
getLocalDeviceNetworkId(): string;
/**
* Get the device name of the local device.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @returns { string } - Returns local device name.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 11600101 - Failed to execute the function.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
getLocalDeviceName(): string;
/**
* Get the device type of the local device.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @returns { number } - Returns local device type.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 11600101 - Failed to execute the function.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
getLocalDeviceType(): number;
/**
* Get the device id of the local device.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @returns { string } - Device identifier. The actual value is udid-hash confused with appid and salt value based on sha256.
* This id remains unchanged after application installation. If the application is uninstalled and reinstalled,
* the obtained ID will change.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 11600101 - Failed to execute the function.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
getLocalDeviceId(): string;
/**
* Get the device name by network id.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { string } networkId - Device network id.
* @returns { string } - Returns device name.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified networkId is greater than 255.
* @throws { BusinessError } 11600101 - Failed to execute the function.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
getDeviceName(networkId: string): string;
/**
* Get the device type by network id.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { string } networkId - Device network id.
* @returns { number } - Returns device type.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified networkId is greater than 255.
* @throws { BusinessError } 11600101 - Failed to execute the function.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
getDeviceType(networkId: string): number;
/**
* Start to discover nearby devices.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { object } discoverParam - Identifies the type of target discovered:
* discoverTargetType : 1 - Discovery target as a device by default, the value is 1.
* @param { object } filterOptions - FilterOptions to filter discovery device.
* The type of filterOptions is map. The map are as follows:
* availableStatus: 0-1 - Discover devices only are credible, The value is 0 indicates device isn't credible;
* 0: Devices are offline, client need to bind the device by calling bindTarget() and then connect to it.
* 1: Devices already online, client can make connection.
* discoverDistance: 0-100 - Discover devices within a certain distance from the local, the unit is cm.
* authenticationStatus: 0-1 - Discover devices based on different authentication status:
* 0: Devices not authenticated.
1: Devices already authenticated.
* The value is 1 indicates device is trust.
* authorizationType: 0-2 - Discover devices based on different authorization type:
* 0: Devices authenticated based on temporary negotiated session key.
* 1: Devices authenticated based on the same account credential key.
* 2: Devices authenticated based on different account credential keys.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 11600104 - Discovery unavailable.
* @throws { BusinessError } 11600101 - Failed to execute the function.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
startDiscovering(discoverParam: { [key: string]: Object; }, filterOptions?: { [key: string]: Object; }): void;
/**
* Stop discovering nearby devices.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 11600101 - Failed to execute the function.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
stopDiscovering(): void;
/**
* Bind the specified target.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { string } deviceId - id of device to bind.
* @param { object } bindParam - parameters of device to bind, The parameter type is map,such as:
* "bindType" : 1, - This value is type of bind, the values are as follows:
* 1 - The bind type is pin code .
* "targetPkgName" : "xxxx", - The package name of binding target.
* "appName" : "xxxx", - The app name that try to bind the target.
* "appOperation" : "xxxx" - The reason why the app want to bind the target package.
* "customDescription" : "xxxx" - The detail description of the operation.
* @param { AsyncCallback<{deviceId: string;}> } callback - indicates the callback to be invoked upon bindDevice.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified deviceId is greater than 255.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 11600101 - Failed to execute the function.
* @throws { BusinessError } 11600103 - Authentication unavailable.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
bindTarget(deviceId: string, bindParam: { [key: string]: Object; }, callback: AsyncCallback<{deviceId: string;}>): void;
/**
* Unbind the specified target.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { string } deviceId - id of device to unbind
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified deviceId is greater than 255.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 11600101 - Failed to execute the function.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
unbindTarget(deviceId: string): void;
/**
* The reply of ui operation from pin-code window, this interface can only be used by pin-code-hap of devicemanager.
*
* @permission ohos.permission.ACCESS_SERVICE_DM
* @param { number } action - The reply action of user operation.
* @param { string } actionResult - Indicates the user operation result.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified actionResult is greater than 255.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi this method can be used only by system applications.
* @since 10
*/
replyUiAction(action: number, actionResult: string): void;
/**
* Register a device state callback so that the application can be notified upon device state changes based on
* the application bundle name.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { 'deviceStateChange' } type - Device state change.
* @param { Callback<{ action: DeviceStateChange; device: DeviceBasicInfo; }> } callback
* Indicates the device state callback to register.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified type is greater than 255.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChange; device: DeviceBasicInfo; }>): void;
/**
* UnRegister device state callback based on the application bundle name.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { 'deviceStateChange' } type - Device state change.
* @param { Callback<{ action: DeviceStateChange; device: DeviceBasicInfo; }> } callback
* Indicates the device state callback to unregister.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified type is greater than 255.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChange; device: DeviceBasicInfo; }>): void;
/**
* Register a device discovery result callback so that the application can be notified when discovery success.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { 'discoverSuccess' } type - Successfully discovered device.
* @param { Callback<{ device: DeviceBasicInfo; }> } callback - Indicates the device discovery callback to register.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified type is greater than 255.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
on(type: 'discoverSuccess', callback: Callback<{ device: DeviceBasicInfo; }>): void;
/**
* UnRegister the device discovery result callback.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { 'discoverSuccess' } type - Successfully discovered device.
* @param { Callback<{ device: DeviceBasicInfo; }> } callback - Indicates the device discovery callback to unregister.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified type is greater than 255.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
off(type: 'discoverSuccess', callback?: Callback<{ device: DeviceBasicInfo; }>): void;
/**
* Register a device name change callback so that the application can be notified when discovery success.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { 'deviceNameChange' } type - Changed device name.
* @param { Callback<{ deviceName: string; }> } callback - Indicates the device name change callback to register.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified type is greater than 255.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
on(type: 'deviceNameChange', callback: Callback<{ deviceName: string; }>): void;
/**
* UnRegister the device name change result callback.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { 'deviceNameChange' } type - Changed device name.
* @param { Callback<{ deviceName: string; }> } callback - Indicates the device name change callback to unregister.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified type is greater than 255.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
off(type: 'deviceNameChange', callback?: Callback<{ deviceName: string; }>): void;
/**
* Register a device discovery result callback so that the application can be notified when discover failed.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { 'discoverFailure' } type - Discovery Device Failure.
* @param { Callback<{ reason: number; }> } callback
* Indicates the device found result callback to register.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified type is greater than 255.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
on(type: 'discoverFailure', callback: Callback<{ reason: number; }>): void;
/**
* UnRegister the device discovery result callback.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { 'discoverFailure' } type - Discovery Device Failure.
* @param { Callback<{ reason: number; }> } callback
* Indicates the device found result callback to unregister.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified type is greater than 255.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
off(type: 'discoverFailure', callback?: Callback<{ reason: number; }>): void;
/**
* Register a serviceError callback so that the application can be notified when devicemanager service died
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { 'serviceDie' } type - Service death.
* @param { Callback<{}> } callback - Indicates the service error callback to register.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified type is greater than 255.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
on(type: 'serviceDie', callback?: Callback<{}>): void;
/**
* UnRegister the service error callback.
*
* @permission ohos.permission.DISTRIBUTED_DATASYNC
* @param { 'serviceDie' } type - Service death.
* @param { Callback<{}> } callback - Indicates the service error callback to unregister.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified type is greater than 255.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @since 10
*/
off(type: 'serviceDie', callback?: Callback<{}>): void;
/**
* Register a callback from deviceManager service so that the devicemanager ui can be notified when uiStateChanges.
*
* @permission ohos.permission.ACCESS_SERVICE_DM
* @param { 'replyResult' } type - Ui reply result to register.
* @param { Callback<{ param: string; }> } callback - Indicates the devicemanager ui state to register.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified type is greater than 255.
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi this method can be used only by system applications.
* @since 10
*/
on(type: 'replyResult', callback: Callback<{ param: string; }>): void;
/**
* Unregister uiStateChange, this interface can only be used by devicemanager ui.
*
* @permission ohos.permission.ACCESS_SERVICE_DM
* @param { 'replyResult' } type - Ui reply result to unregister.
* @param { Callback<{ param: string; }> } callback - Indicates the devicemanager ui state to unregister.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified type is greater than 255.
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi this method can be used only by system applications.
* @since 10
*/
off(type: 'replyResult', callback?: Callback<{ param: string; }>): void;
/**
* Get the device list under the same account.
*
* @permission ohos.permission.ACCESS_SERVICE_DM
* @param { DeviceProfileInfoFilterOptions } filterOptions - parameter for querying the device list, The parameter type is map,such as:
* "isCloud" : false, - false - Get from the cahce of device side.
* true - Get from the cloud.
* "deviceIdList" : [], - Get by specified device ids.
* @returns { Promise<Array<DeviceProfileInfo>> } - Returns a list of devices.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified type is greater than 500.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
* @throws { BusinessError } 11600102 - Failed to obtain service.
* @throws { BusinessError } 11600106 - Get data from cloud fail.
* @throws { BusinessError } 11600107 - A login account is required.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
getDeviceProfileInfoList(filterOptions: DeviceProfileInfoFilterOptions): Promise<Array<DeviceProfileInfo>>;
/**
* Put the device list under the same account.
*
* @permission ohos.permission.ACCESS_SERVICE_DM
* @param { Array<DeviceProfileInfo> } deviceProfileInfoList - parameter for querying the device list for put,
* @returns { Promise<number> } - Returns operation result.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* 4. The size of specified type is greater than 500.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
* @throws { BusinessError } 11600102 - Failed to obtain service.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
putDeviceProfileInfoList(deviceProfileInfoList: Array<DeviceProfileInfo>): Promise<number>;
/**
* Get a DeviceIconInfo.
*
* @permission ohos.permission.ACCESS_SERVICE_DM
* @param { DeviceIconInfoFilterOptions } filterOptions - parameter for querying the device list, The parameter type is map,such as:
* "productId" : "xxx", - product id of device
* "subProductId" : "xxx", - subproduct id of device
* "imageType" : "xxx", - image type, such as: ID、ID_Headset_L、ID_Headset_R、ID_Headset_B、ID_Headset_LB、ID_Headset_RB
* "specName" : "xxx", - image size specification name, such as: sm/lg
* @returns { Promise<DeviceIconInfo> } - Returns a DeviceIconInfo.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
* @throws { BusinessError } 11600102 - Failed to obtain service.
* @throws { BusinessError } 11600106 - Get data from cloud fail.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
getDeviceIconInfo(filterOptions: DeviceIconInfoFilterOptions): Promise<DeviceIconInfo>;
/**
* Get display name of local device.
*
* @permission ohos.permission.ACCESS_SERVICE_DM
* @param { number } maxNameLength - the max number of bytes of the local device display name
*
* @returns { Promise<string> } - Returns device display name.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
* @throws { BusinessError } 11600102 - Failed to obtain service.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
getLocalDisplayDeviceName(maxNameLength: number): Promise<string>;
/**
* Set local device name.
*
* @permission ohos.permission.ACCESS_SERVICE_DM
* @param { string } deviceName - local device name
* @returns { Promise<number> } - Returns operation result.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
* @throws { BusinessError } 11600102 - Failed to obtain service.
* @throws { BusinessError } 11600106 - Failed to get data from the cloud.
* @throws { BusinessError } 11600107 - A login account is required.
* @throws { BusinessError } 11600108 - The device name contains non-compliant content.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
setLocalDeviceName(deviceName: string): Promise<number>;
/**
* Set remote device name.
*
* @permission ohos.permission.ACCESS_SERVICE_DM
* @param { string } deviceId - remote device id
* @param { string } deviceName - remote device name
* @returns { Promise<number> } - Returns operation result.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter type;
* 3. Parameter verification failed;
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
* @throws { BusinessError } 11600102 - Failed to obtain service.
* @throws { BusinessError } 11600106 - Failed to get data from the cloud.
* @throws { BusinessError } 11600107 - A login account is required.
* @throws { BusinessError } 11600108 - The device name contains non-compliant content.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
setRemoteDeviceName(deviceId: string, deviceName: string): Promise<number>;
/**
* Set heartbeat policy.
*
* @permission ohos.permission.ACCESS_SERVICE_DM
* @param { StrategyForHeartbeat } policy - Heartbeat policy.
* @param { number } delayTime - Indicates the duration for disable heartbeat.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter types;
* 3. Parameter verification failed.
* @throws { BusinessError } 11600102 - Failed to obtain service.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 15
*/
setHeartbeatPolicy(policy: StrategyForHeartbeat, delayTime: number): void;
/**
* Restores local device name.
*
* @permission ohos.permission.ACCESS_SERVICE_DM
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
* @throws { BusinessError } 11600102 - Failed to obtain the service.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
restoreLocalDeivceName(): void;
/**
* Get the device network id list by conditions.
*
* @permission ohos.permission.ACCESS_SERVICE_DM
* @param { NetworkIdQueryFilter } filterOptions - parameter for querying the device network id list,
* The parameter type is map, such as:
* "wiseDeviceId" : xx-xxxxx - Get device network id list by wiseDevice id.
* "onlineStatus" : 1, - Get device network id list by online status.
* 0 - indicates that the device is offline.
* 1 - indicates that the device is online.
* @returns { Promise<Array<string>> } - Returns a list of device network id.
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission
* required to call the API.
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Parameter verification failed;
* @throws { BusinessError } 11600102 - Failed to obtain service.
* @throws { BusinessError } 11600107 - A login account is required.
* @syscap SystemCapability.DistributedHardware.DeviceManager
* @systemapi
* @since 18
*/
getDeviceNetworkIdList(filterOptions: NetworkIdQueryFilter): Promise<Array<string>>;
}
}
export default distributedDeviceManager;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/interface_sdk-js.git
git@gitee.com:openharmony/interface_sdk-js.git
openharmony
interface_sdk-js
interface_sdk-js
master

搜索帮助