blob: e2ad129ca8d65f9d577276e7ba7d4d2efd107d6d [file] [log] [blame]
vchtchetkinedceaaa52009-07-22 13:34:53 -07001/*
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_ADBWINAPI_H__
18#define ANDROID_USB_API_ADBWINAPI_H__
vchtchetkine82675112009-07-24 11:30:41 -070019
vchtchetkinedceaaa52009-07-22 13:34:53 -070020/** \file
21 This file consists of declarations of routines exported by the API as well
22 as types, structures, and constants definitions used in the API.
23*/
24
25// Enables compillation for "straight" C
26#ifdef __cplusplus
27 #define EXTERN_C extern "C"
28#else
29 #define EXTERN_C extern
30 typedef int bool;
31 #define true 1
32 #define false 0
33#endif
34
35/** \brief Enumerates ADB endpoint types.
36
37 This enum is taken from WDF_USB_PIPE_TYPE enum found in WDK.
38*/
39typedef enum _AdbEndpointType {
40 /// Unknown (invalid, or not initialized) endpoint type.
41 AdbEndpointTypeInvalid = 0,
42
43 /// Endpoint is device control pipe.
44 AdbEndpointTypeControl,
45
46 /// Endpoint is isochronous r/w pipe.
47 AdbEndpointTypeIsochronous,
48
49 /// Endpoint is a bulk r/w pipe.
50 AdbEndpointTypeBulk,
51
52 /// Endpoint is an interrupt r/w pipe.
53 AdbEndpointTypeInterrupt,
54} AdbEndpointType;
55
56/** \brief Endpoint desriptor.
57
58 This structure is based on WDF_USB_PIPE_INFORMATION structure found in WDK.
59*/
60typedef struct _AdbEndpointInformation {
61 /// Maximum packet size this endpoint is capable of.
62 unsigned long max_packet_size;
63
64 /// Maximum size of one transfer which should be sent to the host controller.
65 unsigned long max_transfer_size;
66
67 /// ADB endpoint type.
68 AdbEndpointType endpoint_type;
69
70 /// Raw endpoint address on the device as described by its descriptor.
71 unsigned char endpoint_address;
72
73 /// Polling interval.
74 unsigned char polling_interval;
75
76 /// Which alternate setting this structure is relevant for.
77 unsigned char setting_index;
78} AdbEndpointInformation;
79
80/// Shortcut to default write bulk endpoint in zero-based endpoint index API.
81#define ADB_QUERY_BULK_WRITE_ENDPOINT_INDEX 0xFC
82
83/// Shortcut to default read bulk endpoint in zero-based endpoint index API.
84#define ADB_QUERY_BULK_READ_ENDPOINT_INDEX 0xFE
85
86// {F72FE0D4-CBCB-407d-8814-9ED673D0DD6B}
87/// Our USB class id that driver uses to register our device.
88#define ANDROID_USB_CLASS_ID \
89{0xf72fe0d4, 0xcbcb, 0x407d, {0x88, 0x14, 0x9e, 0xd6, 0x73, 0xd0, 0xdd, 0x6b}};
90
91/// Defines vendor ID for HCT devices.
92#define DEVICE_VENDOR_ID 0x0BB4
93
94/// Defines product ID for the device with single interface.
95#define DEVICE_SINGLE_PRODUCT_ID 0x0C01
96
97/// Defines product ID for the Dream composite device.
98#define DEVICE_COMPOSITE_PRODUCT_ID 0x0C02
99
100/// Defines product ID for the Magic composite device.
101#define DEVICE_MAGIC_COMPOSITE_PRODUCT_ID 0x0C03
102
103/// Defines interface ID for the device.
104#define DEVICE_INTERFACE_ID 0x01
105
106/// Defines vendor ID for the device
107#define DEVICE_EMULATOR_VENDOR_ID 0x18D1
108
109/// Defines product ID for a SoftUSB device simulator that is used to test
110/// the driver in isolation from hardware.
111#define DEVICE_EMULATOR_PROD_ID 0xDDDD
112
113// The following ifdef block is the standard way of creating macros which make
114// exporting from a DLL simpler. All files within this DLL are compiled with
115// the ADBWIN_EXPORTS symbol defined on the command line. this symbol should
116// not be defined on any project that uses this DLL. This way any other project
117// whose source files include this file see ADBWIN_API functions as being
118// imported from a DLL, whereas this DLL sees symbols defined with this macro
119// as being exported.
120#ifdef ADBWIN_EXPORTS
121#define ADBWIN_API EXTERN_C __declspec(dllexport)
122#else
123#define ADBWIN_API EXTERN_C __declspec(dllimport)
124#endif
125
126/** \brief Handle to an API object.
127
128 To access USB interface and its components clients must first obtain a
129 handle to the required object. API Objects that are represented by a
130 handle are:
131 1. Interface enumerator that provides access to a list of interfaces that
132 match certain criterias that were specified when interface enumerator
133 has been created. This handle is created in AdbEnumInterfaces routine.
134 2. Interface that is the major object this API deals with. In Windows
135 model of the USB stack each USB device (that is physical device,
136 attached to a USB port) exposes one or more interfaces that become the
137 major entities through which that device gets accessed. Each of these
138 interfaces are represented as Windows Device Objects on the USB stack.
139 So, to this extent, at least as this API is concerned, terms "interface"
140 and "device" are interchangeable, since each interface is represented by
141 a device object on the Windows USB stack. This handle is created in
142 either AdbCreateInterface or AdbCreateInterfaceByName routines.
143 3. Endpoint object (also called a pipe) represents an endpoint on interface
144 through which all I/O operations are performed. This handle is created in
145 one of these routines: AdbOpenEndpoint, AdbOpenDefaultBulkReadEndpoint,
146 or AdbOpenDefaultBulkWriteEndpoint.
147 4. I/O completion object that tracks completion information of asynchronous
148 I/O performed on an endpoint. When an endpoint object gets opened through
149 this API it is opened for asynchronous (or overlapped) I/O. And each time
150 an asynchronous I/O is performed by this API an I/O completion object is
151 created to track the result of that I/O when it gets completed. Clients
152 of the API can then use a handle to I/O completion object to query for
153 the status and result of asynchronous I/O as well as wait for this I/O
154 completion. This handle is created in one of these routines:
155 AdbReadEndpointAsync, or AdbWriteEndpointAsync.
156 After object is no longer needed by the client, its handle must be closed
157 using AdbCloseHandle routine.
158*/
159typedef void* ADBAPIHANDLE;
160
161/** \brief Defines access type with which an I/O object (endpoint)
162 should be opened.
163*/
164typedef enum _AdbOpenAccessType {
165 /// Opens for read and write access.
166 AdbOpenAccessTypeReadWrite,
167
168 /// Opens for read only access.
169 AdbOpenAccessTypeRead,
170
171 /// Opens for write only access.
172 AdbOpenAccessTypeWrite,
173
174 /// Opens for querying information.
175 AdbOpenAccessTypeQueryInfo,
176} AdbOpenAccessType;
177
178/** \brief Defines sharing mode with which an I/O object (endpoint)
179 should be opened.
180*/
181typedef enum _AdbOpenSharingMode {
182 /// Shares read and write.
183 AdbOpenSharingModeReadWrite,
184
185 /// Shares only read.
186 AdbOpenSharingModeRead,
187
188 /// Shares only write.
189 AdbOpenSharingModeWrite,
190
191 /// Opens exclusive.
192 AdbOpenSharingModeExclusive,
193} AdbOpenSharingMode;
194
195/** \brief Provides information about an interface.
196*/
197typedef struct _AdbInterfaceInfo {
198 /// Inteface's class id (see SP_DEVICE_INTERFACE_DATA for details)
199 GUID class_id;
200
201 /// Interface flags (see SP_DEVICE_INTERFACE_DATA for details)
202 unsigned long flags;
203
204 /// Device name for the interface (see SP_DEVICE_INTERFACE_DETAIL_DATA
205 /// for details)
206 wchar_t device_name[1];
207} AdbInterfaceInfo;
208
209/** \brief Creates USB interface enumerator
210
211 This routine enumerates all USB interfaces that match provided class ID.
212 This routine uses SetupDiGetClassDevs SDK routine to enumerate devices that
213 match class ID and then SetupDiEnumDeviceInterfaces SDK routine is called
214 to enumerate interfaces on the devices.
215 @param[in] class_id Device class ID, assigned by the driver.
216 @param[in] exclude_not_present If true enumation will include only those
217 devices that are currently present.
218 @param[in] exclude_removed If true interfaces with SPINT_REMOVED flag set
219 will be not included in the enumeration.
220 @param[in] active_only If true only active interfaces (with flag
221 SPINT_ACTIVE set) will be included in the enumeration.
222 @return Handle to the enumerator object or NULL on failure. If NULL is
223 returned GetLastError() provides extended error information.
224*/
225ADBWIN_API ADBAPIHANDLE __cdecl AdbEnumInterfaces(GUID class_id,
226 bool exclude_not_present,
227 bool exclude_removed,
228 bool active_only);
229
230/** \brief Gets next interface information
231
232 @param[in] adb_handle Handle to interface enumerator object obtained via
233 AdbEnumInterfaces call.
234 @param[out] info Upon successful completion will receive interface
235 information. Can be NULL. If it is NULL, upon return from this
236 routine size parameter will contain memory size required for the
237 next entry.
238 @param[in,out] size On the way in provides size of the memory buffer
239 addressed by info parameter. On the way out (only if buffer was not
240 big enough) will provide memory size required for the next entry.
241 @return true on success, false on error. If false is returned
242 GetLastError() provides extended error information.
243 ERROR_INSUFFICIENT_BUFFER indicates that buffer provided in info
244 parameter was not big enough and size parameter contains memory size
245 required for the next entry. ERROR_NO_MORE_ITEMS indicates that
246 enumeration is over and there are no more entries to return.
247*/
248ADBWIN_API bool __cdecl AdbNextInterface(ADBAPIHANDLE adb_handle,
249 AdbInterfaceInfo* info,
250 unsigned long* size);
251
252/** \brief Resets enumerator so next call to AdbNextInterface will start
253 from the beginning.
254
255 @param[in] adb_handle Handle to interface enumerator object obtained via
256 AdbEnumInterfaces call.
257 @return true on success, false on error. If false is returned GetLastError()
258 provides extended error information.
259*/
260ADBWIN_API bool __cdecl AdbResetInterfaceEnum(ADBAPIHANDLE adb_handle);
261
262/** \brief Creates USB interface object
263
264 This routine creates an object that represents a USB interface.
265 @param[in] interface_name Name of the interface.
266 @return Handle to the interface object or NULL on failure. If NULL is
267 returned GetLastError() provides extended error information.
268*/
269ADBWIN_API ADBAPIHANDLE __cdecl AdbCreateInterfaceByName(const wchar_t* interface_name);
270
271/** \brief Creates USB interface object based on vendor, product and
272 interface IDs.
273
274 This routine creates and object that represents a USB interface on our
275 device. It uses AdbCreateInterfaceByName to actually do the create.
276 @param[in] class_id Device class ID, assigned by the driver.
277 @param[in] vendor_id Device vendor ID
278 @param[in] product_id Device product ID
279 @param[in] interface_id Device interface ID. This parameter is optional.
280 Value 0xFF indicates that interface should be addressed by vendor
281 and product IDs only.
282 @return Handle to the interface object or NULL on failure. If NULL is
283 returned GetLastError() provides extended error information.
284*/
285ADBWIN_API ADBAPIHANDLE __cdecl AdbCreateInterface(GUID class_id,
286 unsigned short vendor_id,
287 unsigned short product_id,
288 unsigned char interface_id);
289
290/** \brief Gets interface name.
291
292 @param[in] adb_interface A handle to interface object created with
293 AdbCreateInterface call.
294 @param[out] buffer Buffer for the name. Can be NULL in which case
295 buffer_char_size will contain number of characters required for
296 the name.
297 @param[in,out] buffer_char_size On the way in supplies size (in characters)
298 of the buffer. On the way out, if method failed and GetLastError
299 reports ERROR_INSUFFICIENT_BUFFER, will contain number of characters
300 required for the name.
301 @param[in] ansi If true the name will be returned as single character
302 string. Otherwise name will be returned as wide character string.
303 @return true on success, false on failure. If false is returned
304 GetLastError() provides extended error information.
305*/
306ADBWIN_API bool __cdecl AdbGetInterfaceName(ADBAPIHANDLE adb_interface,
307 void* buffer,
308 unsigned long* buffer_char_size,
309 bool ansi);
310
311/** \brief Gets serial number for interface's device.
312
313 @param[in] adb_interface A handle to interface object created with
314 AdbCreateInterface call.
315 @param[out] buffer Buffer for the serail number string. Can be NULL in which
316 case buffer_char_size will contain number of characters required for
317 the string.
318 @param[in,out] buffer_char_size On the way in supplies size (in characters)
319 of the buffer. On the way out, if method failed and GetLastError
320 reports ERROR_INSUFFICIENT_BUFFER, will contain number of characters
321 required for the name.
322 @param[in] ansi If true the name will be returned as single character
323 string. Otherwise name will be returned as wide character string.
324 @return true on success, false on failure. If false is returned
325 GetLastError() provides extended error information.
326*/
327ADBWIN_API bool __cdecl AdbGetSerialNumber(ADBAPIHANDLE adb_interface,
328 void* buffer,
329 unsigned long* buffer_char_size,
330 bool ansi);
331
332/** \brief Gets device descriptor for the USB device associated with
333 the given interface.
334
335 @param[in] adb_interface A handle to interface object created with
336 AdbCreateInterface call.
337 @param[out] desc Upon successful completion will have usb device
338 descriptor.
339 @return true on success, false on failure. If false is returned
340 GetLastError() provides extended error information.
341*/
342ADBWIN_API bool __cdecl AdbGetUsbDeviceDescriptor(ADBAPIHANDLE adb_interface,
343 USB_DEVICE_DESCRIPTOR* desc);
344
345/** \brief Gets descriptor for the selected USB device configuration.
346
347 @param[in] adb_interface A handle to interface object created with
348 AdbCreateInterface call.
349 @param[out] desc Upon successful completion will have usb device
350 configuration descriptor.
351 @return true on success, false on failure. If false is returned
352 GetLastError() provides extended error information.
353*/
354ADBWIN_API bool __cdecl AdbGetUsbConfigurationDescriptor(
355 ADBAPIHANDLE adb_interface,
356 USB_CONFIGURATION_DESCRIPTOR* desc);
357
358/** \brief Gets descriptor for the given interface.
359
360 @param[in] adb_interface A handle to interface object created with
361 AdbCreateInterface call.
362 @param[out] desc Upon successful completion will have usb device
363 configuration descriptor.
364 @return true on success, false on failure. If false is returned
365 GetLastError() provides extended error information.
366*/
367ADBWIN_API bool __cdecl AdbGetUsbInterfaceDescriptor(ADBAPIHANDLE adb_interface,
368 USB_INTERFACE_DESCRIPTOR* desc);
369
370/** \brief Gets information about an endpoint on the given interface.
371
372 @param[in] adb_interface A handle to interface object created with
373 AdbCreateInterface call.
374 @param[in] endpoint_index Zero-based endpoint index. There are two
375 shortcuts for this parameter: ADB_QUERY_BULK_WRITE_ENDPOINT_INDEX
376 and ADB_QUERY_BULK_READ_ENDPOINT_INDEX that provide information
377 about bulk write and bulk read endpoints respectively.
378 @param[out] info Upon successful completion will have endpoint information.
379 @return true on success, false on failure. If false is returned
380 GetLastError() provides extended error information.
381*/
382ADBWIN_API bool __cdecl AdbGetEndpointInformation(ADBAPIHANDLE adb_interface,
383 unsigned char endpoint_index,
384 AdbEndpointInformation* info);
385
386/** \brief Gets information about default bulk read endpoint on the given
387 interface.
388
389 @param[in] adb_interface A handle to interface object created with
390 AdbCreateInterface call.
391 @param[out] info Upon successful completion will have endpoint information.
392 @return true on success, false on failure. If false is returned
393 GetLastError() provides extended error information.
394*/
395ADBWIN_API bool __cdecl AdbGetDefaultBulkReadEndpointInformation(
396 ADBAPIHANDLE adb_interface,
397 AdbEndpointInformation* info);
398
399/** \brief Gets information about default bulk write endpoint on the given
400 interface.
401
402 @param[in] adb_interface A handle to interface object created with
403 AdbCreateInterface call.
404 @param[out] info Upon successful completion will have endpoint information.
405 @return true on success, false on failure. If false is returned
406 GetLastError() provides extended error information.
407*/
408ADBWIN_API bool __cdecl AdbGetDefaultBulkWriteEndpointInformation(
409 ADBAPIHANDLE adb_interface,
410 AdbEndpointInformation* info);
411
412/** \brief Opens an endpoint on the given interface.
413
414 Endpoints are always opened for overlapped I/O.
415 @param[in] adb_interface A handle to interface object created with
416 AdbCreateInterface call.
417 @param[in] endpoint_index Zero-based endpoint index. There are two
418 shortcuts for this parameter: ADB_QUERY_BULK_WRITE_ENDPOINT_INDEX
419 and ADB_QUERY_BULK_READ_ENDPOINT_INDEX that provide information
420 about bulk write and bulk read endpoints respectively.
421 @param[in] access_type Desired access type. In the current implementation
422 this parameter has no effect on the way endpoint is opened. It's
423 always read / write access.
424 @param[in] sharing_mode Desired share mode. In the current implementation
425 this parameter has no effect on the way endpoint is opened. It's
426 always shared for read / write.
427 @return Handle to the opened endpoint object or NULL on failure. If NULL is
428 returned GetLastError() provides extended error information.
429*/
430ADBWIN_API ADBAPIHANDLE __cdecl AdbOpenEndpoint(ADBAPIHANDLE adb_interface,
431 unsigned char endpoint_index,
432 AdbOpenAccessType access_type,
433 AdbOpenSharingMode sharing_mode);
434
435/** \brief Opens default bulk read endpoint on the given interface.
436
437 Endpoints are always opened for overlapped I/O.
438 @param[in] adb_interface A handle to interface object created with
439 AdbCreateInterface call.
440 @param[in] access_type Desired access type. In the current implementation
441 this parameter has no effect on the way endpoint is opened. It's
442 always read / write access.
443 @param[in] sharing_mode Desired share mode. In the current implementation
444 this parameter has no effect on the way endpoint is opened. It's
445 always shared for read / write.
446 @return Handle to the opened endpoint object or NULL on failure. If NULL is
447 returned GetLastError() provides extended error information.
448*/
449ADBWIN_API ADBAPIHANDLE __cdecl AdbOpenDefaultBulkReadEndpoint(
450 ADBAPIHANDLE adb_interface,
451 AdbOpenAccessType access_type,
452 AdbOpenSharingMode sharing_mode);
453
454/** \brief Opens default bulk write endpoint on the given interface.
455
456 Endpoints are always opened for overlapped I/O.
457 @param[in] adb_interface A handle to interface object created with
458 AdbCreateInterface call.
459 @param[in] access_type Desired access type. In the current implementation
460 this parameter has no effect on the way endpoint is opened. It's
461 always read / write access.
462 @param[in] sharing_mode Desired share mode. In the current implementation
463 this parameter has no effect on the way endpoint is opened. It's
464 always shared for read / write.
465 @return Handle to the opened endpoint object or NULL on failure. If NULL is
466 returned GetLastError() provides extended error information.
467*/
468ADBWIN_API ADBAPIHANDLE __cdecl AdbOpenDefaultBulkWriteEndpoint(
469 ADBAPIHANDLE adb_interface,
470 AdbOpenAccessType access_type,
471 AdbOpenSharingMode sharing_mode);
472
473/** \brief Gets handle to interface object for the given endpoint
474
475 @param[in] adb_endpoint A handle to opened endpoint object, obtained via one
476 of the AdbOpenXxxEndpoint calls.
477 @return Handle to the interface for this endpoint or NULL on failure. If NULL
478 is returned GetLastError() provides extended error information.
479*/
480ADBWIN_API ADBAPIHANDLE __cdecl AdbGetEndpointInterface(ADBAPIHANDLE adb_endpoint);
481
482/** \brief Gets information about the given endpoint.
483
484 @param[in] adb_endpoint A handle to opened endpoint object, obtained via one
485 of the AdbOpenXxxEndpoint calls.
486 @param[out] info Upon successful completion will have endpoint information.
487 @return true on success, false on failure. If false is returned
488 GetLastError() provides extended error information.
489*/
490ADBWIN_API bool __cdecl AdbQueryInformationEndpoint(ADBAPIHANDLE adb_endpoint,
491 AdbEndpointInformation* info);
492
493/** \brief Asynchronously reads from the given endpoint.
494
495 @param[in] adb_endpoint A handle to opened endpoint object, obtained via one
496 of the AdbOpenXxxEndpoint calls.
497 @param[out] buffer Pointer to the buffer that receives the data.
498 @param[in] bytes_to_read Number of bytes to be read.
499 @param[out] bytes_read Number of bytes read. Can be NULL.
500 @param[in] event_handle Event handle that should be signaled when async I/O
501 completes. Can be NULL. If it's not NULL this handle will be used to
502 initialize OVERLAPPED structure for this I/O.
503 @param[in] time_out A timeout (in milliseconds) required for this I/O to
504 complete. Zero value for this parameter means that there is no
505 timeout for this I/O.
506 @return A handle to IO completion object or NULL on failure. If NULL is
507 returned GetLastError() provides extended error information.
508*/
509ADBWIN_API ADBAPIHANDLE __cdecl AdbReadEndpointAsync(ADBAPIHANDLE adb_endpoint,
510 void* buffer,
511 unsigned long bytes_to_read,
512 unsigned long* bytes_read,
513 unsigned long time_out,
514 HANDLE event_handle);
515
516/** \brief Asynchronously writes to the given endpoint.
517
518 @param[in] adb_endpoint A handle to opened endpoint object, obtained via one
519 of the AdbOpenXxxEndpoint calls.
520 @param[in] buffer Pointer to the buffer containing the data to be written.
521 @param[in] bytes_to_write Number of bytes to be written.
522 @param[out] bytes_written Number of bytes written. Can be NULL.
523 @param[in] event_handle Event handle that should be signaled when async I/O
524 completes. Can be NULL. If it's not NULL this handle will be used to
525 initialize OVERLAPPED structure for this I/O.
526 @param[in] time_out A timeout (in milliseconds) required for this I/O to
527 complete. Zero value for this parameter means that there is no
528 timeout for this I/O.
529 @return A handle to IO completion object or NULL on failure. If NULL is
530 returned GetLastError() provides extended error information.
531*/
532ADBWIN_API ADBAPIHANDLE __cdecl AdbWriteEndpointAsync(ADBAPIHANDLE adb_endpoint,
533 void* buffer,
534 unsigned long bytes_to_write,
535 unsigned long* bytes_written,
536 unsigned long time_out,
537 HANDLE event_handle);
538
539/** \brief Synchronously reads from the given endpoint.
540
541 @param[in] adb_endpoint A handle to opened endpoint object, obtained via one
542 of the AdbOpenXxxEndpoint calls.
543 @param[out] buffer Pointer to the buffer that receives the data.
544 @param[in] bytes_to_read Number of bytes to be read.
545 @param[out] bytes_read Number of bytes read. Can be NULL.
546 @param[in] time_out A timeout (in milliseconds) required for this I/O to
547 complete. Zero value for this parameter means that there is no
548 timeout for this I/O.
549 @return true on success and false on failure. If false is
550 returned GetLastError() provides extended error information.
551*/
552ADBWIN_API bool __cdecl AdbReadEndpointSync(ADBAPIHANDLE adb_endpoint,
553 void* buffer,
554 unsigned long bytes_to_read,
555 unsigned long* bytes_read,
556 unsigned long time_out);
557
558/** \brief Synchronously writes to the given endpoint.
559
560 @param[in] adb_endpoint A handle to opened endpoint object, obtained via one
561 of the AdbOpenXxxEndpoint calls.
562 @param[in] buffer Pointer to the buffer containing the data to be written.
563 @param[in] bytes_to_write Number of bytes to be written.
564 @param[out] bytes_written Number of bytes written. Can be NULL.
565 @param[in] time_out A timeout (in milliseconds) required for this I/O to
566 complete. Zero value for this parameter means that there is no
567 timeout for this I/O.
568 @return true on success and false on failure. If false is
569 returned GetLastError() provides extended error information.
570*/
571ADBWIN_API bool __cdecl AdbWriteEndpointSync(ADBAPIHANDLE adb_endpoint,
572 void* buffer,
573 unsigned long bytes_to_write,
574 unsigned long* bytes_written,
575 unsigned long time_out);
576
577/** \brief Gets overlapped I/O result for async I/O performed on the
578 given endpoint.
579
580 @param[in] adb_io_completion A handle to an I/O completion object returned
581 from AdbRead/WriteAsync routines.
582 @param[out] ovl_data Buffer for the copy of this object's OVERLAPPED
583 structure. Can be NULL.
584 @param[out] bytes_transferred Pointer to a variable that receives the
585 number of bytes that were actually transferred by a read or write
586 operation. See SDK doc on GetOvelappedResult for more information.
587 Unlike regular GetOvelappedResult call this parameter can be NULL.
588 @param[in] wait If this parameter is true, the method does not return
589 until the operation has been completed. If this parameter is false
590 and the operation is still pending, the method returns false and
591 the GetLastError function returns ERROR_IO_INCOMPLETE.
592 @return true if I/O has been completed or false on failure or if request
593 is not yet completed. If false is returned GetLastError() provides
594 extended error information. If GetLastError returns
595 ERROR_IO_INCOMPLETE it means that I/O is not yet completed.
596*/
597ADBWIN_API bool __cdecl AdbGetOvelappedIoResult(ADBAPIHANDLE adb_io_completion,
598 LPOVERLAPPED overlapped,
599 unsigned long* bytes_transferred,
600 bool wait);
601
602/** \brief Checks if overlapped I/O has been completed.
603
604 @param[in] adb_io_completion A handle to an I/O completion object returned
605 from AdbRead/WriteAsync routines.
606 @return true if I/O has been completed or false if it's still
607 incomplete. Regardless of the returned value, caller should
608 check GetLastError to validate that handle was OK.
609*/
610ADBWIN_API bool __cdecl AdbHasOvelappedIoComplated(ADBAPIHANDLE adb_io_completion);
611
612/** \brief Closes handle previously opened with one of the API calls
613
614 @param[in] adb_handle ADB handle previously opened with one of the API calls
615 @return true on success or false on failure. If false is returned
616 GetLastError() provides extended error information.
617*/
618ADBWIN_API bool __cdecl AdbCloseHandle(ADBAPIHANDLE adb_handle);
619
620#endif // ANDROID_USB_API_ADBWINAPI_H__