Port server core to Android

 * Android libutils locks and threads
 * Add Android.mk for building with AOSP
 * Add logger sink for Android
 * Regenerate Android.mk when CMake is run
diff --git a/common/os/Mutex.cxx b/common/os/Mutex.cxx
index 13013cf..4794568 100644
--- a/common/os/Mutex.cxx
+++ b/common/os/Mutex.cxx
@@ -18,6 +18,10 @@
 
 #ifdef WIN32
 #include <windows.h>
+#elif defined(__ANDROID__)
+#include <utils/Errors.h>
+#include <utils/Mutex.h>
+#include <utils/Condition.h>
 #else
 #include <pthread.h>
 #endif
@@ -33,6 +37,8 @@
 #ifdef WIN32
   systemMutex = new CRITICAL_SECTION;
   InitializeCriticalSection((CRITICAL_SECTION*)systemMutex);
+#elif defined(__ANDROID__)
+  systemMutex = new ::android::Mutex;
 #else
   int ret;
 
@@ -48,6 +54,8 @@
 #ifdef WIN32
   DeleteCriticalSection((CRITICAL_SECTION*)systemMutex);
   delete (CRITICAL_SECTION*)systemMutex;
+#elif defined(__ANDROID__)
+  delete (::android::Mutex*)systemMutex;
 #else
   pthread_mutex_destroy((pthread_mutex_t*)systemMutex);
   delete (pthread_mutex_t*)systemMutex;
@@ -58,6 +66,12 @@
 {
 #ifdef WIN32
   EnterCriticalSection((CRITICAL_SECTION*)systemMutex);
+#elif defined(__ANDROID__)
+  android::status_t ret;
+
+  ret = ((::android::Mutex*)systemMutex)->lock();
+  if (ret != android::NO_ERROR)
+    throw rdr::SystemException("Failed to lock mutex", ret);
 #else
   int ret;
 
@@ -71,6 +85,8 @@
 {
 #ifdef WIN32
   LeaveCriticalSection((CRITICAL_SECTION*)systemMutex);
+#elif defined(__ANDROID__)
+  ((::android::Mutex*)systemMutex)->unlock();
 #else
   int ret;
 
@@ -87,6 +103,8 @@
 #ifdef WIN32
   systemCondition = new CONDITION_VARIABLE;
   InitializeConditionVariable((CONDITION_VARIABLE*)systemCondition);
+#elif defined(__ANDROID__)
+  systemCondition = new ::android::Condition;
 #else
   int ret;
 
@@ -101,6 +119,8 @@
 {
 #ifdef WIN32
   delete (CONDITION_VARIABLE*)systemCondition;
+#elif defined(__ANDROID__)
+  delete (::android::Condition*)systemCondition;
 #else
   pthread_cond_destroy((pthread_cond_t*)systemCondition);
   delete (pthread_cond_t*)systemCondition;
@@ -117,6 +137,12 @@
                                  INFINITE);
   if (!ret)
     throw rdr::SystemException("Failed to wait on condition variable", GetLastError());
+#elif defined(__ANDROID__)
+  android::status_t ret;
+
+  ret = ((::android::Condition*)systemCondition)->wait(*(::android::Mutex*)mutex->systemMutex);
+  if (ret != android::NO_ERROR)
+    throw rdr::SystemException("Failed to wait on condition variable", ret);
 #else
   int ret;
 
@@ -131,6 +157,8 @@
 {
 #ifdef WIN32
   WakeConditionVariable((CONDITION_VARIABLE*)systemCondition);
+#elif defined(__ANDROID__)
+  ((::android::Condition*)systemCondition)->signal();
 #else
   int ret;
 
@@ -144,6 +172,8 @@
 {
 #ifdef WIN32
   WakeAllConditionVariable((CONDITION_VARIABLE*)systemCondition);
+#elif defined(__ANDROID__)
+  ((::android::Condition*)systemCondition)->broadcast();
 #else
   int ret;
 
diff --git a/common/os/Thread.cxx b/common/os/Thread.cxx
index 2b08dbf..f3e5b73 100644
--- a/common/os/Thread.cxx
+++ b/common/os/Thread.cxx
@@ -18,6 +18,9 @@
 
 #ifdef WIN32
 #include <windows.h>
+#elif defined(__ANDROID__)
+#include <functional>
+#include <utils/Thread.h>
 #else
 #include <pthread.h>
 #include <signal.h>
@@ -31,12 +34,33 @@
 
 using namespace os;
 
+#if defined(__ANDROID__)
+namespace os {
+class AndroidThread : public ::android::Thread {
+public:
+  AndroidThread(std::function<void()> worker) : mWorker(worker) {}
+
+  virtual bool threadLoop() {
+    try {
+        mWorker();
+    } catch(...) {
+    }
+    return false;
+  }
+private:
+  std::function<void()> mWorker;
+};
+};
+#endif
+
 Thread::Thread() : running(false), threadId(NULL)
 {
   mutex = new Mutex;
 
 #ifdef WIN32
   threadId = new HANDLE;
+#elif defined(__ANDROID__)
+  threadId = new AndroidThread(std::bind(&Thread::worker, this));
 #else
   threadId = new pthread_t;
 #endif
@@ -46,6 +70,9 @@
 {
 #ifdef WIN32
   delete (HANDLE*)threadId;
+#elif defined(__ANDROID__)
+  ((AndroidThread*)threadId)->requestExit();
+  delete (::android::Thread*)threadId;
 #else
   if (isRunning())
     pthread_cancel(*(pthread_t*)threadId);
@@ -63,6 +90,8 @@
   *(HANDLE*)threadId = CreateThread(NULL, 0, startRoutine, this, 0, NULL);
   if (*(HANDLE*)threadId == NULL)
     throw rdr::SystemException("Failed to create thread", GetLastError());
+#elif defined(__ANDROID__)
+  ((AndroidThread*)threadId)->run(NULL);
 #else
   int ret;
   sigset_t all, old;
@@ -96,6 +125,12 @@
   ret = WaitForSingleObject(*(HANDLE*)threadId, INFINITE);
   if (ret != WAIT_OBJECT_0)
     throw rdr::SystemException("Failed to join thread", GetLastError());
+#elif defined(__ANDROID__)
+  ::android::status_t ret;
+
+  ret = ((AndroidThread*)threadId)->join();
+  if (ret != ::android::NO_ERROR)
+    throw rdr::SystemException("Failed to join thread", ret);
 #else
   int ret;
 
@@ -107,9 +142,13 @@
 
 bool Thread::isRunning()
 {
+#if defined(__ANDROID__)
+  return ((::android::Thread*)threadId)->isRunning();
+#else
   AutoMutex a(mutex);
 
   return running;
+#endif
 }
 
 size_t Thread::getSystemCPUCount()