diff options
author | Vladimir Chtchetkine <vchtchetkine@google.com> | 2011-02-01 07:18:23 -0800 |
---|---|---|
committer | Android Code Review <code-review@android.com> | 2011-02-01 07:18:23 -0800 |
commit | f4d4ca164dea606cee27e1f68d4742a3c57b0954 (patch) | |
tree | 1d8d2bbc7d13742129a0faad57ea51931c2e0080 /android/protocol/ui-commands-impl.c | |
parent | a7880fe783781bbedf998916791ebd70fb252b88 (diff) | |
parent | 85276806ec6ac969d7befa2496c1de59adaaac74 (diff) | |
download | external_qemu-f4d4ca164dea606cee27e1f68d4742a3c57b0954.zip external_qemu-f4d4ca164dea606cee27e1f68d4742a3c57b0954.tar.gz external_qemu-f4d4ca164dea606cee27e1f68d4742a3c57b0954.tar.bz2 |
Merge "Refactor attach-UI service"
Diffstat (limited to 'android/protocol/ui-commands-impl.c')
-rw-r--r-- | android/protocol/ui-commands-impl.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/android/protocol/ui-commands-impl.c b/android/protocol/ui-commands-impl.c index 456c61e..30d5277 100644 --- a/android/protocol/ui-commands-impl.c +++ b/android/protocol/ui-commands-impl.c @@ -17,7 +17,6 @@ */ #include "console.h" -//#include "android/hw-control.h" #include "android/looper.h" #include "android/core-connection.h" #include "android/async-utils.h" @@ -73,25 +72,6 @@ static UICmdImpl _uiCmdImpl; static AndroidHwLightBrightnessCallback _brightness_change_callback = NULL; static void* _brightness_change_callback_param = NULL; -/* Destroys UICmdImpl instance. */ -static void -_uiCmdImpl_destroy() -{ - if (_uiCmdImpl.core_connection != NULL) { - // Disable I/O callbacks. - qemu_set_fd_handler(_uiCmdImpl.sock, NULL, NULL, NULL); - core_connection_close(_uiCmdImpl.core_connection); - core_connection_free(_uiCmdImpl.core_connection); - _uiCmdImpl.core_connection = NULL; - } - // Properly deallocate the reader buffer. - if (_uiCmdImpl.reader_buffer != NULL && - _uiCmdImpl.reader_buffer != (uint8_t*)&_uiCmdImpl.cmd_header) { - free(_uiCmdImpl.reader_buffer); - _uiCmdImpl.reader_buffer = (uint8_t*)&_uiCmdImpl.cmd_header; - } -} - /* Handles UI control command received from the core. * Param: * uicmd - UICmdImpl instance that received the command. @@ -146,7 +126,7 @@ _uiCmdImpl_io_read(void* opaque) if (status == 0) { /* Disconnection, meaning that the core process got termonated. */ fprintf(stderr, "core-ui-control service got disconnected\n"); - _uiCmdImpl_destroy(); + uiCmdImpl_destroy(); return; } if (status < 0) { @@ -227,7 +207,7 @@ uiCmdImpl_create(SockAddress* console_socket) &_uiCmdImpl)) { derror("Unable to set up UI _uiCmdImpl_io_read callback: %s\n", errno_str); - _uiCmdImpl_destroy(); + uiCmdImpl_destroy(); if (handshake != NULL) { free(handshake); } @@ -247,6 +227,24 @@ uiCmdImpl_create(SockAddress* console_socket) return 0; } +void +uiCmdImpl_destroy(void) +{ + if (_uiCmdImpl.core_connection != NULL) { + // Disable I/O callbacks. + qemu_set_fd_handler(_uiCmdImpl.sock, NULL, NULL, NULL); + core_connection_close(_uiCmdImpl.core_connection); + core_connection_free(_uiCmdImpl.core_connection); + _uiCmdImpl.core_connection = NULL; + } + // Properly deallocate the reader buffer. + if (_uiCmdImpl.reader_buffer != NULL && + _uiCmdImpl.reader_buffer != (uint8_t*)&_uiCmdImpl.cmd_header) { + free(_uiCmdImpl.reader_buffer); + _uiCmdImpl.reader_buffer = (uint8_t*)&_uiCmdImpl.cmd_header; + } +} + int uicmd_set_brightness_change_callback(AndroidHwLightBrightnessCallback callback, void* opaque) |