diff options
author | David Pursell <dpursell@google.com> | 2015-10-30 11:22:01 -0700 |
---|---|---|
committer | David Pursell <dpursell@google.com> | 2015-11-16 09:31:07 -0800 |
commit | 0b156638307db890e5539b52521fd24beb3440cb (patch) | |
tree | 42feda4e66833b368f6c6b7c6a63562baa0db084 /fastboot/engine.cpp | |
parent | 942f8ea84f3f96c2e2556fe90ebba0ec76730553 (diff) |
fastboot: create Transport object (take 2).
(Second upload of this CL; original upload had the wrong version of
usb_windows.cpp that caused a compilation error. Fixed error and
re-tested.)
This CL creates a Transport object to provide a generic interface for
various transports. Specifically this is designed to be able to add UDP
support to fastboot in an upcoming CL without changing the main program
logic.
Also includes some minor code style fixes and replaces malloc/free
in the USB implementation files with smart pointers and std::string.
Bug: http://b/22029765
Change-Id: I1175bbce08690fbd15f51e68166be9b3e9973ea0
Diffstat (limited to 'fastboot/engine.cpp')
-rw-r--r-- | fastboot/engine.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/fastboot/engine.cpp b/fastboot/engine.cpp index d4be63b73..ac5a17a06 100644 --- a/fastboot/engine.cpp +++ b/fastboot/engine.cpp @@ -75,13 +75,13 @@ static Action *action_last = 0; -bool fb_getvar(usb_handle* usb, const std::string& key, std::string* value) { +bool fb_getvar(Transport* transport, const std::string& key, std::string* value) { std::string cmd = "getvar:"; cmd += key; char buf[FB_RESPONSE_SZ + 1]; memset(buf, 0, sizeof(buf)); - if (fb_command_response(usb, cmd.c_str(), buf)) { + if (fb_command_response(transport, cmd.c_str(), buf)) { return false; } *value = buf; @@ -330,7 +330,7 @@ void fb_queue_wait_for_disconnect(void) queue_action(OP_WAIT_FOR_DISCONNECT, ""); } -int fb_execute_queue(usb_handle *usb) +int fb_execute_queue(Transport* transport) { Action *a; char resp[FB_RESPONSE_SZ+1]; @@ -350,25 +350,25 @@ int fb_execute_queue(usb_handle *usb) fprintf(stderr,"%s...\n",a->msg); } if (a->op == OP_DOWNLOAD) { - status = fb_download_data(usb, a->data, a->size); + status = fb_download_data(transport, a->data, a->size); status = a->func(a, status, status ? fb_get_error() : ""); if (status) break; } else if (a->op == OP_COMMAND) { - status = fb_command(usb, a->cmd); + status = fb_command(transport, a->cmd); status = a->func(a, status, status ? fb_get_error() : ""); if (status) break; } else if (a->op == OP_QUERY) { - status = fb_command_response(usb, a->cmd, resp); + status = fb_command_response(transport, a->cmd, resp); status = a->func(a, status, status ? fb_get_error() : resp); if (status) break; } else if (a->op == OP_NOTICE) { fprintf(stderr,"%s\n",(char*)a->data); } else if (a->op == OP_DOWNLOAD_SPARSE) { - status = fb_download_data_sparse(usb, reinterpret_cast<sparse_file*>(a->data)); + status = fb_download_data_sparse(transport, reinterpret_cast<sparse_file*>(a->data)); status = a->func(a, status, status ? fb_get_error() : ""); if (status) break; } else if (a->op == OP_WAIT_FOR_DISCONNECT) { - usb_wait_for_disconnect(usb); + transport->WaitForDisconnect(); } else { die("bogus action"); } |