46 Star 173 Fork 4.7K

OpenHarmony/interface_sdk-js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
@ohos.driver.deviceManager.d.ts 19.85 KB
一键复制 编辑 原始数据 按行查看 历史
xiapan 提交于 29天前 . 0702 merge into master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
/*
* Copyright (c) 2023 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 DriverDevelopmentKit
*/
import type { AsyncCallback } from './@ohos.base';
import type rpc from './@ohos.rpc';
/**
* This module provides the capability of manage external device.
*
* @namespace deviceManager
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
declare namespace deviceManager {
/**
* Query the external device list.
*
* @permission ohos.permission.ACCESS_EXTENSIONAL_DEVICE_DRIVER
* @param { int } busType - The bus type of device to be queried.
* @returns { Array<Readonly<Device>> } External device list.
* @throws { BusinessError } 201 - The permission check failed.
* @throws { BusinessError } 22900001 - ExternalDeviceManager service exception or busType parameter error.
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
function queryDevices(busType?: int): Array<Readonly<Device>>;
/**
* Bind the device based on the device information returned by queryDevices().
*
* @permission ohos.permission.ACCESS_EXTENSIONAL_DEVICE_DRIVER
* @param { number } deviceId - Device id on the device list returned by queryDevices().
* @param { AsyncCallback<number> } onDisconnect - Callback is invoked when device is disconnected after bind
* success.
* @param { AsyncCallback<{deviceId: number; remote: rpc.IRemoteObject;}> } callback - Indicates the bind result
* including device ID and remote object.
* @throws { BusinessError } 201 - The permission check failed.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
* 3.Parameter verification failed.
* @throws { BusinessError } 22900001 - ExternalDeviceManager service exception.
* @syscap SystemCapability.Driver.ExternalDevice
* @since 10
* @deprecated since 18
* @useinstead ohos.driver.deviceManager/deviceManager#bindDriverWithDeviceId
*/
function bindDevice(deviceId: number, onDisconnect: AsyncCallback<number>,
callback: AsyncCallback<{deviceId: number; remote: rpc.IRemoteObject;}>): void;
/**
* Bind the device based on the device information returned by queryDevices().
*
* @permission ohos.permission.ACCESS_EXTENSIONAL_DEVICE_DRIVER
* @param { number } deviceId - Device id on the device list returned by queryDevices().
* @param { AsyncCallback<number> } onDisconnect - Callback is invoked when device is disconnected after bind
* success.
* @param { AsyncCallback<RemoteDeviceDriver> } callback - Indicates the bind result including device ID and
* remote object.
* @throws { BusinessError } 201 - The permission check failed.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
* 3.Parameter verification failed.
* @throws { BusinessError } 22900001 - ExternalDeviceManager service exception.
* @syscap SystemCapability.Driver.ExternalDevice
* @since 11
* @deprecated since 18
* @useinstead ohos.driver.deviceManager/deviceManager#bindDriverWithDeviceId
*/
function bindDeviceDriver(deviceId: number, onDisconnect: AsyncCallback<number>,
callback: AsyncCallback<RemoteDeviceDriver>): void;
/**
* Bind the device based on the device information returned by queryDevices().
*
* @permission ohos.permission.ACCESS_EXTENSIONAL_DEVICE_DRIVER
* @param { number } deviceId - Device id on the device list returned by queryDevices().
* @param { AsyncCallback<number> } onDisconnect - Callback is invoked when device is disconnected after bind
* success.
* @returns { Promise<{deviceId: number; remote: rpc.IRemoteObject;}> } Indicates the bind result including device
* ID and remote object.
* @throws { BusinessError } 201 - The permission check failed.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
* 3.Parameter verification failed.
* @throws { BusinessError } 22900001 - ExternalDeviceManager service exception.
* @syscap SystemCapability.Driver.ExternalDevice
* @since 10
* @deprecated since 18
* @useinstead ohos.driver.deviceManager/deviceManager#bindDriverWithDeviceId
*/
function bindDevice(deviceId: number, onDisconnect: AsyncCallback<number>): Promise<{deviceId: number;
remote: rpc.IRemoteObject;}>;
/**
* Bind the device based on the device information returned by queryDevices().
*
* @permission ohos.permission.ACCESS_EXTENSIONAL_DEVICE_DRIVER
* @param { number } deviceId - Device id on the device list returned by queryDevices().
* @param { AsyncCallback<number> } onDisconnect - Callback is invoked when device is disconnected after bind
* success.
* @returns { Promise<RemoteDeviceDriver> } Indicates the bind result including device ID and remote object.
* @throws { BusinessError } 201 - The permission check failed.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
* 3.Parameter verification failed.
* @throws { BusinessError } 22900001 - ExternalDeviceManager service exception.
* @syscap SystemCapability.Driver.ExternalDevice
* @since 11
* @deprecated since 18
* @useinstead ohos.driver.deviceManager/deviceManager#bindDriverWithDeviceId
*/
function bindDeviceDriver(deviceId: number, onDisconnect: AsyncCallback<number>): Promise<RemoteDeviceDriver>;
/**
* Unbind the device based on the device information returned by queryDevices().
*
* @permission ohos.permission.ACCESS_EXTENSIONAL_DEVICE_DRIVER
* @param { number } deviceId - Device id on the device list returned by queryDevices().
* @param { AsyncCallback<number> } callback - Indicates the unbind result invoked when unbind is finished.
* @throws { BusinessError } 201 - The permission check failed.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
* @throws { BusinessError } 22900001 - ExternalDeviceManager service exception.
* @syscap SystemCapability.Driver.ExternalDevice
* @since 10
* @deprecated since 18
* @useinstead ohos.driver.deviceManager/deviceManager#unbindDriverWithDeviceId
*/
function unbindDevice(deviceId: number, callback: AsyncCallback<number>): void;
/**
* Unbind the device based on the device information returned by queryDevices().
*
* @permission ohos.permission.ACCESS_EXTENSIONAL_DEVICE_DRIVER
* @param { number } deviceId - Device id on the device list returned by queryDevices().
* @returns { Promise<number> } - Indicates the unbind result invoked when unbind is finished.
* @throws { BusinessError } 201 - The permission check failed.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
* 3.Parameter verification failed.
* @throws { BusinessError } 22900001 - ExternalDeviceManager service exception.
* @syscap SystemCapability.Driver.ExternalDevice
* @since 10
* @deprecated since 18
* @useinstead ohos.driver.deviceManager/deviceManager#unbindDriverWithDeviceId
*/
function unbindDevice(deviceId: number): Promise<number>;
/**
* Queries external device information.
*
* @permission ohos.permission.ACCESS_EXTENSIONAL_DEVICE_DRIVER
* @param { long } deviceId - ID of device to query.
* @returns { Array<Readonly<DeviceInfo>> } Device information obtained.
* @throws { BusinessError } 201 - The permission check failed.
* @throws { BusinessError } 202 - Permission denied. A non-system application cannot call a system API.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types.
* @throws { BusinessError } 26300001 - ExternalDeviceManager service exception.
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
function queryDeviceInfo(deviceId?: long): Array<Readonly<DeviceInfo>>;
/**
* Queries driver information.
*
* @permission ohos.permission.ACCESS_EXTENSIONAL_DEVICE_DRIVER
* @param { string } driverUid - Unique identifier of driver query.
* @returns { Array<Readonly<DriverInfo>> } Driver information obtained.
* @throws { BusinessError } 201 - The permission check failed.
* @throws { BusinessError } 202 - Permission denied. A non-system application cannot call a system API.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types.
* @throws { BusinessError } 26300001 - ExternalDeviceManager service exception.
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
function queryDriverInfo(driverUid?: string): Array<Readonly<DriverInfo>>;
/**
* Bind the device based on the device information returned by queryDevices().
*
* @permission ohos.permission.ACCESS_DDK_DRIVERS
* @param { long } deviceId - Device id on the device list returned by queryDevices().
* @param { AsyncCallback<long> } onDisconnect - Callback is invoked when device is disconnected after bind
* success.
* @returns { Promise<RemoteDeviceDriver> } Indicates the bind result including device ID and remote object.
* @throws { BusinessError } 201 - The permission check failed.
* @throws { BusinessError } 26300001 - ExternalDeviceManager service exception.
* @throws { BusinessError } 26300002 - The driver service does not allow any client to bind.
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts{ '1.1':'19','1.2':'20'}
* @arkts 1.1&1.2
*/
function bindDriverWithDeviceId(deviceId: long, onDisconnect: AsyncCallback<long>): Promise<RemoteDeviceDriver>;
/**
* Unbind the device based on the device information returned by queryDevices().
*
* @permission ohos.permission.ACCESS_DDK_DRIVERS
* @param { long } deviceId - Device id on the device list returned by queryDevices().
* @returns { Promise<int> } - Indicates the unbind result invoked when unbind is finished.
* @throws { BusinessError } 201 - The permission check failed.
* @throws { BusinessError } 26300001 - ExternalDeviceManager service exception.
* @throws { BusinessError } 26300003 - There is no binding relationship.
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts{ '1.1':'19','1.2':'20'}
* @arkts 1.1&1.2
*/
function unbindDriverWithDeviceId(deviceId: long): Promise<int>;
/**
* Enumerates the bus types.
*
* @enum { int }
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
export enum BusType {
/**
* USB device type
*
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
USB = 1,
}
/**
* Represents a device.
*
* @typedef Device
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
interface Device {
/**
* Bus type of the device.
*
* @type { BusType }
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
busType: BusType;
/**
* Device ID.
*
* @type { long }
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
deviceId: long;
/**
* Description of the device.
*
* @type { string }
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
description: string;
}
/**
* Represents a USB device.
*
* @typedef USBDevice
* @extends Device
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
interface USBDevice extends Device {
/**
* Vendor ID.
*
* @type { int }
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
vendorId: int;
/**
* Product ID.
*
* @type { int }
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
productId: int;
}
/**
* Driver of the remote device bound with <b>deviceId</b>.
*
* @typedef RemoteDeviceDriver
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts {'1.1':'11', '1.2':'20'}
* @arkts 1.1&1.2
*/
interface RemoteDeviceDriver {
/**
* Device ID.
*
* @type { long }
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts {'1.1':'11', '1.2':'20'}
* @arkts 1.1&1.2
*/
deviceId: long;
/**
* Remote driver object.
*
* @type { rpc.IRemoteObject }
* @syscap SystemCapability.Driver.ExternalDevice
* @since arkts {'1.1':'11', '1.2':'20'}
* @arkts 1.1&1.2
*/
remote: rpc.IRemoteObject;
}
/**
* Represents information about a device interface descriptor.
*
* @typedef USBInterfaceDesc
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
interface USBInterfaceDesc {
/**
* Interface number.
*
* @type { int }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
bInterfaceNumber: int;
/**
* Interface class code.
*
* @type { int }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
bClass: int;
/**
* Interface subclass code.
*
* @type { int }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
bSubClass: int;
/**
* Interface protocol.
*
* @type { int }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
bProtocol: int;
}
/**
* Represents the device information.
*
* @typedef DeviceInfo
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
interface DeviceInfo {
/**
* Device ID.
*
* @type { long }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
deviceId: long;
/**
* Whether the device has a matched driver.
*
* @type { boolean }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
isDriverMatched: boolean;
/**
* Unique identifier of the driver.
*
* @type { ?string }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
driverUid?: string;
}
/**
* Represents the USB device information.
*
* @typedef USBDeviceInfo
* @extends DeviceInfo
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
interface USBDeviceInfo extends DeviceInfo {
/**
* Vendor ID.
*
* @type { int }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
vendorId: int;
/**
* Product ID.
*
* @type { int }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
productId: int;
/**
* List of USB interface descriptors.
*
* @type { Array<Readonly<USBInterfaceDesc>> }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
interfaceDescList: Array<Readonly<USBInterfaceDesc>>;
}
/**
* Represents the driver information.
*
* @typedef DriverInfo
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
interface DriverInfo {
/**
* Bus type of the device.
*
* @type { BusType }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
busType: BusType;
/**
* Unique identifier of the driver.
*
* @type { string }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
driverUid: string;
/**
* Driver name.
*
* @type { string }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
driverName: string;
/**
* Driver version.
*
* @type { string }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
driverVersion: string;
/**
* Driver size.
*
* @type { string }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
driverSize: string;
/**
* Driver description.
*
* @type { string }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
description: string;
}
/**
* Represents the USB driver information.
*
* @typedef USBDriverInfo
* @extends DriverInfo
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
interface USBDriverInfo extends DriverInfo {
/**
* IDs of supported products.
*
* @type { Array<int> }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
productIdList: Array<int>;
/**
* IDs of supported vendors.
*
* @type { Array<int> }
* @syscap SystemCapability.Driver.ExternalDevice
* @systemapi
* @since arkts {'1.1':'12', '1.2':'20'}
* @arkts 1.1&1.2
*/
vendorIdList: Array<int>;
}
}
export default deviceManager;
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

搜索帮助