1/* 2 * Copyright (c) 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@!sts_inject_into_module("import type { AsyncCallback } from '@ohos.base';") 17@!sts_inject_into_module("import type rpc from '@ohos.rpc';") 18 19@!namespace("@ohos.driver.deviceManager", "deviceManager") 20 21@!sts_inject(""" 22static { loadLibrary("device_manager_taihe_native.z") } 23""") 24 25function queryDevices(busType: Optional<i32>): Array<DeviceUnion>; 26 27function queryDeviceInfo(deviceId: Optional<u64>): Array<DeviceInfoUnion>; 28 29function queryDriverInfo(driverUid: Optional<String>): Array<DriverInfoUnion>; 30 31@!sts_inject("export native function bindDriverWithDeviceId(deviceId: long, onDisconnect: AsyncCallback<long>): Promise<RemoteDeviceDriver>;") 32@gen_promise("unbindDriverWithDeviceId") 33function UnbindDriverWithDeviceIdSync(deviceId: u64): i32; 34 35enum BusType : i32 { 36 USB = 1, 37} 38 39struct Device { 40 busType: BusType; 41 deviceId: u64; 42 description: String; 43} 44 45struct USBDevice { 46 @extends base: Device; 47 vendorId: i32; 48 productId: i32; 49} 50 51union DeviceUnion { 52 t1: USBDevice; 53 t: Device; 54} 55 56struct RemoteDeviceDriver { 57 deviceId: u64; 58 remote: @sts_type("rpc.IRemoteObject") Opaque; 59} 60 61struct USBInterfaceDesc { 62 bInterfaceNumber: i32; 63 bClass: i32; 64 bSubClass: i32; 65 bProtocol: i32; 66} 67 68struct DeviceInfo { 69 deviceId: u64; 70 isDriverMatched: bool; 71 driverUid: Optional<String>; 72} 73 74struct USBDeviceInfo { 75 @extends base: DeviceInfo; 76 vendorId: i32; 77 productId: i32; 78 interfaceDescList: Array<USBInterfaceDesc>; 79} 80 81union DeviceInfoUnion { 82 t1: USBDeviceInfo; 83 t: DeviceInfo; 84} 85 86struct DriverInfo { 87 busType: BusType; 88 driverUid: String; 89 driverName: String; 90 driverVersion: String; 91 driverSize: String; 92 description: String; 93} 94 95struct USBDriverInfo { 96 @extends base: DriverInfo; 97 productIdList: Array<i32>; 98 vendorIdList: Array<i32>; 99} 100 101union DriverInfoUnion { 102 t1: USBDriverInfo; 103 t: DriverInfo; 104} 105