Home | History | Annotate | Download | only in adb

Lines Matching refs:handle

40   /// Handle to USB interface
43 /// Handle to USB read pipe (endpoint)
46 /// Handle to USB write pipe (endpoint)
68 /// Checks if there is opened usb handle in handle_list for this device.
71 /// Checks if there is opened usb handle in handle_list for this device.
75 /// Registers opened usb handle (adds it to handle_list).
76 int register_new_device(usb_handle* handle);
79 int recognized_device(usb_handle* handle);
98 /// Writes data to the opened usb handle
99 int usb_write(usb_handle* handle, const void* data, int len);
101 /// Reads data using the opened usb handle
102 int usb_read(usb_handle *handle, void* data, int len);
104 /// Cleans up opened usb handle
105 void usb_cleanup_handle(usb_handle* handle);
107 /// Cleans up (but don't close) opened usb handle
108 void usb_kick(usb_handle* handle);
110 /// Closes opened usb handle
111 int usb_close(usb_handle* handle);
113 /// Gets interface (device) name for an opened usb handle
114 const char *usb_name(usb_handle* handle);
145 int register_new_device(usb_handle* handle) {
146 if (NULL == handle)
152 if (known_device_locked(handle->interface_name)) {
157 // Not in the list. Add this handle to the list.
158 handle->next = &handle_list;
159 handle->prev = handle_list.prev;
160 handle->prev->next = handle;
161 handle->next->prev = handle;
191 // Allocate our handle
196 // Set linkers back to the handle
257 int usb_write(usb_handle* handle, const void* data, int len) {
263 if (NULL != handle) {
265 ret = AdbWriteEndpointSync(handle->adb_write_pipe,
276 if(handle->zero_mask && (len & handle->zero_mask) == 0) {
278 AdbWriteEndpointSync(handle->adb_write_pipe,
289 usb_kick(handle);
293 D("usb_write NULL handle\n");
302 int usb_read(usb_handle *handle, void* data, int len) {
308 if (NULL != handle) {
312 ret = AdbReadEndpointSync(handle->adb_read_pipe,
328 usb_kick(handle);
334 D("usb_read NULL handle\n");
343 void usb_cleanup_handle(usb_handle* handle) {
344 if (NULL != handle) {
345 if (NULL != handle->interface_name)
346 free(handle->interface_name);
347 if (NULL != handle->adb_write_pipe)
348 AdbCloseHandle(handle->adb_write_pipe);
349 if (NULL != handle->adb_read_pipe)
350 AdbCloseHandle(handle->adb_read_pipe);
351 if (NULL != handle->adb_interface)
352 AdbCloseHandle(handle->adb_interface);
354 handle->interface_name = NULL;
355 handle->adb_write_pipe = NULL;
356 handle->adb_read_pipe = NULL;
357 handle->adb_interface = NULL;
361 void usb_kick(usb_handle* handle) {
362 if (NULL != handle) {
365 usb_cleanup_handle(handle);
374 int usb_close(usb_handle* handle) {
377 if (NULL != handle) {
378 // Remove handle from the list
381 if ((handle->next != handle) && (handle->prev != handle)) {
382 handle->next->prev = handle->prev;
383 handle->prev->next = handle->next;
384 handle->prev = handle;
385 handle->next = handle;
390 // Cleanup handle
391 usb_cleanup_handle(handle);
392 free(handle);
398 const char *usb_name(usb_handle* handle) {
399 if (NULL == handle) {
405 return (const char*)handle->interface_name;
408 int recognized_device(usb_handle* handle) {
409 if (NULL == handle)
415 if (!AdbGetUsbDeviceDescriptor(handle->adb_interface,
423 if (!AdbGetUsbInterfaceDescriptor(handle->adb_interface,
439 if (AdbGetEndpointInformation(handle->adb_interface, 0, &endpoint_info)) {
440 handle->zero_mask = endpoint_info.max_packet_size - 1;
451 usb_handle* handle = NULL;
480 handle = do_usb_open(next_interface->device_name);
481 if (NULL != handle) {
483 if (recognized_device(handle)) {
487 if (AdbGetSerialNumber(handle->adb_interface,
492 if (register_new_device(handle)) {
493 register_usb_transport(handle, serial_number, NULL, 1);
496 usb_cleanup_handle(handle);
497 free(handle);
501 usb_cleanup_handle(handle);
502 free(handle);
505 usb_cleanup_handle(handle);
506 free(handle);