Refactor attach-UI service

Change-Id: Ia68ceb57ee5b5a66fa76b837fe3b990eb12e7188
diff --git a/vl-android-ui.c b/vl-android-ui.c
index c1ef7ae..e818159 100644
--- a/vl-android-ui.c
+++ b/vl-android-ui.c
@@ -42,7 +42,11 @@
 #include "android/utils/bufprint.h"
 #include "android/utils/system.h"
 #include "android/core-connection.h"
+#include "android/protocol/attach-ui-impl.h"
 #include "android/protocol/fb-updates-impl.h"
+#include "android/protocol/user-events-proxy.h"
+#include "android/protocol/core-commands-proxy.h"
+#include "android/protocol/ui-commands-impl.h"
 
 #ifdef CONFIG_MEMCHECK
 #include "memcheck/memcheck.h"
@@ -204,9 +208,6 @@
 
 extern void  dprint( const char* format, ... );
 
-/* Instance of the "attach UI" Emulator's core console client. */
-extern CoreConnection*   attach_client;
-
 #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
 
 /* compute with 96 bit intermediate result: (a*b)/c */
@@ -595,13 +596,11 @@
 
     main_loop();
 
-    if (attach_client != NULL) {
-        core_connection_detach(attach_client);
-        core_connection_close(attach_client);
-        core_connection_free(attach_client);
-    }
-
     implFb_destroy();
+    userEventsProxy_destroy();
+    coreCmdProxy_destroy();
+    uiCmdImpl_destroy();
+    attachUiImpl_destroy();
 
     quit_timers();
     return 0;