adb_helper_routines.h revision dceaaa52cec11631c72cfea5fb74ee607602ecde
1/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_USB_API_ADB_HELPER_ROUTINES_H__
18#define ANDROID_USB_API_ADB_HELPER_ROUTINES_H__
19/** \file
20  This file consists of declarations of helper routines used
21  in the API.
22*/
23
24#include "adb_api_private_defines.h"
25
26/** \brief Given the hardware device information enumerates interfaces for
27  this device.
28
29  @param[in] hardware_dev_info A handle to hardware device information obtained
30         from PnP manager via SetupDiGetClassDevs()
31  @param[in] class_id Device class ID how it is specified by our USB driver.
32  @param[in] exclude_removed If true interfaces with SPINT_REMOVED flag set
33         will be not included in the enumeration.
34  @param[in] active_only If true only active interfaces (with flag
35         SPINT_ACTIVE set) will be included in the enumeration.
36  @param[out] interfaces Upon successfull completion will consist of array of
37         all interfaces found for this device (matching all filters).
38  @return True on success, false on failure, in which case GetLastError()
39          provides extended information about the error that occurred.
40*/
41bool EnumerateDeviceInterfaces(HDEVINFO hardware_dev_info,
42                               GUID class_id,
43                               bool exclude_removed,
44                               bool active_only,
45                               AdbEnumInterfaceArray* interfaces);
46
47/** \brief Enumerates all interfaces for our device class.
48
49  This routine uses SetupDiGetClassDevs to get our device info and calls
50  EnumerateDeviceInterfaces to perform the enumeration.
51  @param[in] class_id Device class ID how it is specified by our USB driver
52  @param[in] flags Flags to pass to SetupDiGetClassDevs to filter devices. See
53         SetupDiGetClassDevs() in SDK for more info on these flags.
54  @param[in] exclude_removed If true interfaces with SPINT_REMOVED flag set
55         will be not included in the enumeration.
56  @param[in] active_only If true only active interfaces (with flag
57         SPINT_ACTIVE set) will be included in the enumeration.
58  @param[out] interfaces Upon successfull completion will consist of array of
59         all interfaces found for this device (matching all filters).
60  @return True on success, false on failure, in which case GetLastError()
61          provides extended information about the error that occurred.
62*/
63bool EnumerateDeviceInterfaces(GUID class_id,
64                               ULONG flags,
65                               bool exclude_removed,
66                               bool active_only,
67                               AdbEnumInterfaceArray* interfaces);
68
69/** \brief Given the hardware device information and data gets data details.
70
71  Given the hardware_dev_info, representing a handle to the plug and
72  play information, and dev_info_data, representing a specific usb device,
73  gets detailed data about the device (interface).
74  @param[in] hardware_dev_info A handle to hardware device information obtained
75         from PnP manager via SetupDiGetClassDevs()
76  @param[in] dev_info_data Device information data obtained via call to
77         SetupDiEnumDeviceInterfaces()
78  @param[out] dev_info_detail_data Upon successfull completion will consist of
79         the detailed data about device interface. This routine always
80         allocates memory for the output structure so content of this pointer
81         doesn't matter and will be overwritten by this routine. The caller
82         of this method is responsible for freeing allocated data using free()
83         routine.
84  @return True on success, false on failure, in which case GetLastError()
85          provides extended information about the error that occurred.
86*/
87bool GetUsbDeviceDetails(HDEVINFO hardware_dev_info,
88                       PSP_DEVICE_INTERFACE_DATA dev_info_data,
89                       PSP_DEVICE_INTERFACE_DETAIL_DATA* dev_info_detail_data);
90
91/** \brief Given the hardware device information and data gets device name.
92
93  Given the hardware_dev_info, representing a handle to the plug and
94  play information, and dev_info_data, representing a specific usb device,
95  gets device name. This routine uses GetUsbDeviceDetails to extract device
96  name.
97  @param[in] hardware_dev_info A handle to hardware device information obtained
98         from PnP manager via SetupDiGetClassDevs()
99  @param[in] dev_info_data Device information data obtained via call to
100         SetupDiEnumDeviceInterfaces()
101  @param[out] name Upon successfull completion will have name for the device.
102  @return True on success, false on failure, in which case GetLastError()
103          provides extended information about the error that occurred.
104*/
105bool GetUsbDeviceName(HDEVINFO hardware_dev_info,
106                      PSP_DEVICE_INTERFACE_DATA dev_info_data,
107                      std::wstring* name);
108
109#endif  // ANDROID_USB_API_ADB_HELPER_ROUTINES_H__
110