adb: win32: fix adb emu command

The adb emu command was never working because the socket connection to
the emulator was closed without reading all of the data that the
emulator sent. On Windows, this caused the emulator's recv() call to
error-out, so it never got the command that was sent.

Before settling on this fix, I also experimented changing the arguments
to the socket shutdown() call and that didn't seem to help. I also tried
removing the call to shutdown() and that didn't help. So that should
rule out shutdown() as the problem. One experiment that helped was
delaying before calling adb_close(), but that is of course fragile and
doesn't address the real issue, which is not closing the socket until
the commands have been read.

https://code.google.com/p/android/issues/detail?id=21021

Change-Id: I8fa4d740a2faa2c9922ec50792e16564a94f6eed
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
diff --git a/Android.mk b/Android.mk
index 7d6238c..1aed2cb 100644
--- a/Android.mk
+++ b/Android.mk
@@ -96,6 +96,9 @@
 
 ifeq ($(HOST_OS),windows)
     LOCAL_C_INCLUDES += development/host/windows/usb/api/
+    # Windows.h defines an awful ERROR macro that collides with base/logging.h.
+    # Suppress it with NOGDI.
+    LOCAL_CFLAGS += -DNOGDI
 endif
 
 include $(BUILD_HOST_STATIC_LIBRARY)
@@ -152,18 +155,21 @@
 include $(CLEAR_VARS)
 
 ifeq ($(HOST_OS),linux)
-  LOCAL_LDLIBS += -lrt -ldl -lpthread
-  LOCAL_CFLAGS += -DWORKAROUND_BUG6558362
+    LOCAL_LDLIBS += -lrt -ldl -lpthread
+    LOCAL_CFLAGS += -DWORKAROUND_BUG6558362
 endif
 
 ifeq ($(HOST_OS),darwin)
-  LOCAL_LDLIBS += -lpthread -framework CoreFoundation -framework IOKit -framework Carbon
-  LOCAL_CFLAGS += -Wno-sizeof-pointer-memaccess -Wno-unused-parameter
+    LOCAL_LDLIBS += -lpthread -framework CoreFoundation -framework IOKit -framework Carbon
+    LOCAL_CFLAGS += -Wno-sizeof-pointer-memaccess -Wno-unused-parameter
 endif
 
 ifeq ($(HOST_OS),windows)
-  LOCAL_LDLIBS += -lws2_32 -lgdi32
-  EXTRA_STATIC_LIBS := AdbWinApi
+    # Windows.h defines an awful ERROR macro that collides with base/logging.h.
+    # Suppress it with NOGDI.
+    LOCAL_CFLAGS += -DNOGDI
+    LOCAL_LDLIBS += -lws2_32 -lgdi32
+    EXTRA_STATIC_LIBS := AdbWinApi
 endif
 
 LOCAL_CLANG := $(adb_host_clang)