Home | History | Annotate | Download | only in client

Lines Matching refs:handle

51   rely on AdbWinApi.dll's handle validation and AdbCloseHandle(endpoint)'s
55 /// Handle to USB interface
58 /// Handle to USB read pipe (endpoint)
61 /// Handle to USB write pipe (endpoint)
83 /// Checks if there is opened usb handle in handle_list for this device.
86 /// Checks if there is opened usb handle in handle_list for this device.
90 /// Registers opened usb handle (adds it to handle_list).
91 int register_new_device(usb_handle* handle);
94 int recognized_device(usb_handle* handle);
113 /// Writes data to the opened usb handle
114 int usb_write(usb_handle* handle, const void* data, int len);
116 /// Reads data using the opened usb handle
117 int usb_read(usb_handle* handle, void* data, int len);
119 /// Cleans up opened usb handle
120 void usb_cleanup_handle(usb_handle* handle);
122 /// Cleans up (but don't close) opened usb handle
123 void usb_kick(usb_handle* handle);
125 /// Closes opened usb handle
126 int usb_close(usb_handle* handle);
153 int register_new_device(usb_handle* handle) {
154 if (NULL == handle) return 0;
159 if (known_device_locked(handle->interface_name)) {
163 // Not in the list. Add this handle to the list.
164 handle_list.push_back(handle);
260 // Allocate our handle
327 int usb_write(usb_handle* handle, const void* data, int len) {
333 if (NULL == handle) {
334 D("usb_write was passed NULL handle");
340 if (!AdbWriteEndpointSync(handle->adb_write_pipe, (void*)data, (unsigned long)len, &written,
358 if (handle->zero_mask && (len & handle->zero_mask) == 0) {
360 if (!AdbWriteEndpointSync(handle->adb_write_pipe, (void*)data, 0, &written, time_out)) {
373 if (NULL != handle) {
375 usb_kick(handle);
383 int usb_read(usb_handle* handle, void* data, int len) {
390 if (NULL == handle) {
391 D("usb_read was passed NULL handle");
397 if (!AdbReadEndpointSync(handle->adb_read_pipe, data, len, &read, time_out)) {
414 if (NULL != handle) {
416 usb_kick(handle);
432 void usb_cleanup_handle(usb_handle* handle) {
434 if (NULL != handle) {
435 if (NULL != handle->interface_name) free(handle->interface_name);
439 if (NULL != handle->adb_write_pipe) _adb_close_handle(handle->adb_write_pipe);
440 if (NULL != handle->adb_read_pipe) _adb_close_handle(handle->adb_read_pipe);
441 if (NULL != handle->adb_interface) _adb_close_handle(handle->adb_interface);
443 handle->interface_name = NULL;
444 handle->adb_write_pipe = NULL;
445 handle->adb_read_pipe = NULL;
446 handle->adb_interface = NULL;
450 static void usb_kick_locked(usb_handle* handle) {
453 usb_cleanup_handle(handle);
456 void usb_kick(usb_handle* handle) {
458 if (NULL != handle) {
460 usb_kick_locked(handle);
466 int usb_close(usb_handle* handle) {
469 if (NULL != handle) {
470 // Remove handle from the list
473 handle_list.erase(std::remove(handle_list.begin(), handle_list.end(), handle),
477 // Cleanup handle
478 usb_cleanup_handle(handle);
479 free(handle);
485 size_t usb_get_max_packet_size(usb_handle* handle) {
486 return handle->max_packet_size;
489 int recognized_device(usb_handle* handle) {
490 if (NULL == handle) return 0;
495 if (!AdbGetUsbDeviceDescriptor(handle->adb_interface, &device_desc)) {
504 if (!AdbGetUsbInterfaceDescriptor(handle->adb_interface, &interf_desc)) {
522 if (AdbGetEndpointInformation(handle->adb_interface, 0, &endpoint_info)) {
523 handle->max_packet_size = endpoint_info.max_packet_size;
524 handle->zero_mask = endpoint_info.max_packet_size - 1;
525 D("device zero_mask: 0x%x", handle->zero_mask);
535 usb_handle* handle = NULL;
553 handle = do_usb_open(next_interface->device_name);
554 if (NULL != handle) {
556 if (recognized_device(handle)) {
568 if (AdbGetSerialNumber(handle->adb_interface, serial_number, &serial_number_len,
571 if (register_new_device(handle)) {
572 register_usb_transport(handle, serial_number, NULL, 1);
575 usb_cleanup_handle(handle);
576 free(handle);
581 usb_cleanup_handle(handle);
582 free(handle);
585 usb_cleanup_handle(handle);
586 free(handle);