adb: win32: define UNICODE/_UNICODE, Unicode error messages, misc

Define the UNICODE and _UNICODE preprocessor symbols to make passing
char* to Ansi/Unicode-agnostic Windows and C Runtime APIs break the
build. The solution is to call wide Windows and C Runtime APIs and use
widen(utf8).c_str(). Most code was already calling wide APIs. Defining
these symbols makes a call to CreateEvent() (which previously mapped to
CreateEventA()) turn into a call to CreateEventW().

Make SystemErrorCodeToString() use Unicode.

Add various comments.

Change-Id: I9b212412348a29826718e897a486489e1f142d16
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
diff --git a/adb/Android.mk b/adb/Android.mk
index ec7f49c..e911bc3 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -22,6 +22,15 @@
     -Wno-missing-field-initializers \
     -DADB_REVISION='"$(adb_version)"' \
 
+# Define windows.h and tchar.h Unicode preprocessor symbols so that
+# CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
+# build if you accidentally pass char*. Fix by calling like:
+# CreateFileW(widen(utf8).c_str()).
+ADB_COMMON_windows_CFLAGS := \
+    -DUNICODE=1 -D_UNICODE=1 \
+
+ADB_COMMON_CFLAGS += $(ADB_COMMON_$(HOST_OS)_CFLAGS)
+
 # libadb
 # =========================================================