Make contexthubhal build with the VNDK.

When the vndk is enabled (BOARD_VNDK_VERSION=current),
vendor libraries must only link against vendor variants
in the build system. This means that they receive restricted
sets of headers and that automatic global headers are restricted.

Also renamed device side static library "libnanohub_common" which
only provided headers to libnanohub_common_headers and made it
a header library.

Test: build contexthubhal with BOARD_VNDK_VERSION=current
Test: build, boot, use sensors (such as photosphere)
Bug: 37342627
Change-Id: I9bdaff3dc27f0fc2f45b38987ee18d7200a23f6c
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..1e0d8c8
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,3 @@
+subdirs = [
+    "lib",
+]
diff --git a/contexthubhal/Android.mk b/contexthubhal/Android.mk
index 1600e1b..be27d47 100644
--- a/contexthubhal/Android.mk
+++ b/contexthubhal/Android.mk
@@ -14,7 +14,10 @@
 # Include target-specific files.
 LOCAL_SRC_FILES += nanohubhal_default.cpp
 
-LOCAL_STATIC_LIBRARIES += libnanohub_common
+LOCAL_HEADER_LIBRARIES := \
+    libhardware_headers \
+    libnanohub_common_headers \
+    libutils_headers
 
 LOCAL_MODULE := context_hub.default
 LOCAL_MODULE_TAGS := optional
diff --git a/contexthubhal/nanohubhal.cpp b/contexthubhal/nanohubhal.cpp
index 7764253..21b6374 100644
--- a/contexthubhal/nanohubhal.cpp
+++ b/contexthubhal/nanohubhal.cpp
@@ -26,8 +26,8 @@
 #include <hardware/context_hub.h>
 #include <hardware/hardware.h>
 
-#include <utils/Log.h>
 #include <cutils/properties.h>
+#include <log/log.h>
 
 #include <nanohub/nanohub.h>
 
diff --git a/contexthubhal/nanohubhal_default.cpp b/contexthubhal/nanohubhal_default.cpp
index 2645c61..fb5231e 100644
--- a/contexthubhal/nanohubhal_default.cpp
+++ b/contexthubhal/nanohubhal_default.cpp
@@ -18,7 +18,7 @@
 #include <hardware/context_hub.h>
 #include "nanohub_perdevice.h"
 #include "nanohubhal.h"
-#include <utils/Log.h>
+#include <log/log.h>
 
 namespace android {
 
diff --git a/contexthubhal/system_comms.cpp b/contexthubhal/system_comms.cpp
index c4e9b62..4a67a66 100644
--- a/contexthubhal/system_comms.cpp
+++ b/contexthubhal/system_comms.cpp
@@ -24,7 +24,7 @@
 
 #include <vector>
 
-#include <utils/Log.h>
+#include <log/log.h>
 
 #include <endian.h>
 
diff --git a/contexthubhal/test/main.cpp b/contexthubhal/test/main.cpp
index fe21e99..f8399ce 100644
--- a/contexthubhal/test/main.cpp
+++ b/contexthubhal/test/main.cpp
@@ -16,8 +16,8 @@
 #include <signal.h>
 #include <unistd.h>
 
+#include <log/log.h>
 #include <sys/endian.h>
-#include <utils/Log.h>
 
 #include <hardware/hardware.h>
 #include <hardware/context_hub.h>
diff --git a/lib/Android.bp b/lib/Android.bp
new file mode 100644
index 0000000..828d29e
--- /dev/null
+++ b/lib/Android.bp
@@ -0,0 +1,5 @@
+cc_library_headers {
+    name: "libnanohub_common_headers",
+    vendor_available: true,
+    export_include_dirs: ["include"],
+}
diff --git a/lib/Android.mk b/lib/Android.mk
index e88b975..0caa123 100644
--- a/lib/Android.mk
+++ b/lib/Android.mk
@@ -58,20 +58,6 @@
 
 include $(BUILD_HOST_STATIC_LIBRARY)
 
-include $(CLEAR_VARS)
-
-# now-empty static library to export include files for other projects
-LOCAL_MODULE := libnanohub_common
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_C_INCLUDES := \
-    $(src_includes)
-
-LOCAL_EXPORT_C_INCLUDE_DIRS := \
-    $(src_includes)
-
-include $(BUILD_STATIC_LIBRARY)
-
 include $(call first-makefiles-under, $(LOCAL_PATH))
 
 src_files :=