Build emulator hal modules with BOARD_VNDK_VERSION

Bug: 64704866
Test: BOARD_VNDK_VERSION=current mm -j under
/device/generic/goldfish/audio, fingerprint, keymaster, power, sensors,
gatekeeper, hwcomposer (keymaster is still unsuccessful due to the
dependency to libgoldfishkeymaster and libkeystore_binder)

Change-Id: I3a46c338f204379604c27ff99f2e1e11a81363ba
diff --git a/audio/Android.mk b/audio/Android.mk
index b60ff14..b8d45e2 100644
--- a/audio/Android.mk
+++ b/audio/Android.mk
@@ -34,6 +34,7 @@
 			libtinyalsa
 
 LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_HEADER_LIBRARIES := libhardware_headers
 
 include $(BUILD_SHARED_LIBRARY)
 
@@ -52,5 +53,6 @@
 			libdl
 
 LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_HEADER_LIBRARIES := libhardware_headers
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 781c18f..30b76d5 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -25,8 +25,9 @@
 #include <sys/time.h>
 #include <dlfcn.h>
 #include <fcntl.h>
+#include <unistd.h>
 
-#include <cutils/log.h>
+#include <log/log.h>
 #include <cutils/str_parms.h>
 
 #include <hardware/hardware.h>
diff --git a/audio/audio_hw_legacy.c b/audio/audio_hw_legacy.c
index 5f167b5..3d6a253 100644
--- a/audio/audio_hw_legacy.c
+++ b/audio/audio_hw_legacy.c
@@ -23,8 +23,9 @@
 #include <stdlib.h>
 #include <sys/time.h>
 #include <fcntl.h>
+#include <unistd.h>
 
-#include <cutils/log.h>
+#include <log/log.h>
 #include <cutils/str_parms.h>
 
 #include <hardware/hardware.h>
diff --git a/camera/jpeg-stub/Android.mk b/camera/jpeg-stub/Android.mk
index e017ac1..f92260e 100644
--- a/camera/jpeg-stub/Android.mk
+++ b/camera/jpeg-stub/Android.mk
@@ -33,7 +33,7 @@
     libexif \
     libjpeg \
     liblog \
-    libandroid_runtime
+
 jpeg_c_includes := external/libjpeg-turbo \
                    external/libexif \
                    frameworks/native/include
diff --git a/fingerprint/Android.mk b/fingerprint/Android.mk
index 55e513c..e282578 100644
--- a/fingerprint/Android.mk
+++ b/fingerprint/Android.mk
@@ -21,7 +21,8 @@
 LOCAL_MODULE_RELATIVE_PATH := hw
 LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
 LOCAL_SRC_FILES := fingerprint.c
-LOCAL_SHARED_LIBRARIES := liblog
+LOCAL_SHARED_LIBRARIES := liblog libcutils
+LOCAL_HEADER_LIBRARIES := libhardware_headers
 
 include $(BUILD_SHARED_LIBRARY)
 
@@ -32,6 +33,7 @@
 LOCAL_MODULE_RELATIVE_PATH := hw
 LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
 LOCAL_SRC_FILES := fingerprint.c
-LOCAL_SHARED_LIBRARIES := liblog
+LOCAL_SHARED_LIBRARIES := liblog libcutils
+LOCAL_HEADER_LIBRARIES := libhardware_headers
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/fingerprint/fingerprint.c b/fingerprint/fingerprint.c
index dd37770..0c63ff8 100644
--- a/fingerprint/fingerprint.c
+++ b/fingerprint/fingerprint.c
@@ -32,7 +32,7 @@
 #include <inttypes.h>
 #include <malloc.h>
 #include <string.h>
-#include <cutils/log.h>
+#include <log/log.h>
 #include <hardware/hardware.h>
 #include <hardware/fingerprint.h>
 #include "qemud.h"
diff --git a/gatekeeper/SoftGateKeeper.h b/gatekeeper/SoftGateKeeper.h
index cb02a6f..2f4f4d7 100644
--- a/gatekeeper/SoftGateKeeper.h
+++ b/gatekeeper/SoftGateKeeper.h
@@ -26,11 +26,11 @@
 }
 
 #include <android-base/memory.h>
-#include <UniquePtr.h>
 #include <gatekeeper/gatekeeper.h>
 
 #include <iostream>
 #include <unordered_map>
+#include <memory>
 
 namespace gatekeeper {
 
@@ -173,7 +173,7 @@
     typedef std::unordered_map<uint32_t, failure_record_t> FailureRecordMap;
     typedef std::unordered_map<uint64_t, fast_hash_t> FastHashMap;
 
-    UniquePtr<uint8_t[]> key_;
+    std::unique_ptr<uint8_t[]> key_;
     FailureRecordMap failure_map_;
     FastHashMap fast_hash_map_;
 };
diff --git a/gatekeeper/SoftGateKeeperDevice.h b/gatekeeper/SoftGateKeeperDevice.h
index 60ed44d..af3a1bc 100644
--- a/gatekeeper/SoftGateKeeperDevice.h
+++ b/gatekeeper/SoftGateKeeperDevice.h
@@ -19,7 +19,7 @@
 
 #include "SoftGateKeeper.h"
 
-#include <UniquePtr.h>
+#include <memory>
 
 using namespace gatekeeper;
 
@@ -68,7 +68,7 @@
             const uint8_t *provided_password, uint32_t provided_password_length,
             uint8_t **auth_token, uint32_t *auth_token_length, bool *request_reenroll);
 private:
-    UniquePtr<SoftGateKeeper> impl_;
+    std::unique_ptr<SoftGateKeeper> impl_;
 };
 
 } // namespace gatekeeper
diff --git a/hwcomposer/hwcomposer.cpp b/hwcomposer/hwcomposer.cpp
index 61a3c46..c29d388 100644
--- a/hwcomposer/hwcomposer.cpp
+++ b/hwcomposer/hwcomposer.cpp
@@ -17,8 +17,9 @@
 #include <stdlib.h>
 #include <sys/time.h>
 #include <sys/resource.h>
+#include <unistd.h>
 
-#include <cutils/log.h>
+#include <log/log.h>
 #include <hardware/hwcomposer.h>
 #include <sync/sync.h>
 
diff --git a/keymaster/Android.mk b/keymaster/Android.mk
index 600e32d..de8a44c 100644
--- a/keymaster/Android.mk
+++ b/keymaster/Android.mk
@@ -25,6 +25,7 @@
                     $(LOCAL_PATH)/../include
 LOCAL_CFLAGS = -fvisibility=hidden -Wall -Werror
 LOCAL_SHARED_LIBRARIES := libcrypto liblog libkeystore_binder
+LOCAL_HEADER_LIBRARIES := libhardware_headers
 LOCAL_MODULE_TAGS := optional
 LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
@@ -43,5 +44,6 @@
 LOCAL_C_INCLUDES := system/security/keystore
 LOCAL_CFLAGS = -fvisibility=hidden -Wall -Werror
 LOCAL_SHARED_LIBRARIES := libcrypto liblog libkeystore_binder libgoldfishkeymaster
+LOCAL_HEADER_LIBRARIES := libhardware_headers
 LOCAL_MODULE_TAGS := optional
 include $(BUILD_SHARED_LIBRARY)
diff --git a/keymaster/keymaster_openssl.c b/keymaster/keymaster_openssl.c
index 69c9572..1cd5251 100644
--- a/keymaster/keymaster_openssl.c
+++ b/keymaster/keymaster_openssl.c
@@ -22,7 +22,7 @@
 #include <string.h>
 
 #define LOG_TAG "OpenSSLKeyMaster"
-#include <cutils/log.h>
+#include <log/log.h>
 
 #ifdef DEBUG
 #   define D(...)   ALOGD(__VA_ARGS__)
diff --git a/power/Android.mk b/power/Android.mk
index a4d4a2c..e3d07a5 100644
--- a/power/Android.mk
+++ b/power/Android.mk
@@ -23,6 +23,7 @@
 LOCAL_MODULE_RELATIVE_PATH := hw
 LOCAL_CFLAGS += -DQEMU_HARDWARE
 LOCAL_SHARED_LIBRARIES := liblog libcutils
+LOCAL_HEADER_LIBRARIES := libutils_headers libhardware_headers
 LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
 LOCAL_SRC_FILES := power_qemu.c
 LOCAL_MODULE := power.goldfish
@@ -35,6 +36,7 @@
 LOCAL_MODULE_RELATIVE_PATH := hw
 LOCAL_CFLAGS += -DQEMU_HARDWARE
 LOCAL_SHARED_LIBRARIES := liblog libcutils
+LOCAL_HEADER_LIBRARIES := libutils_headers libhardware_headers
 LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
 LOCAL_SRC_FILES := power_qemu.c
 LOCAL_MODULE := power.ranchu
diff --git a/sensors/Android.mk b/sensors/Android.mk
index 7a57bec..ad319e9 100644
--- a/sensors/Android.mk
+++ b/sensors/Android.mk
@@ -22,6 +22,7 @@
 LOCAL_VENDOR_MODULE := true
 LOCAL_MODULE_RELATIVE_PATH := hw
 LOCAL_SHARED_LIBRARIES := liblog libcutils
+LOCAL_HEADER_LIBRARIES := libhardware_headers
 LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
 LOCAL_SRC_FILES := sensors_qemu.c
 LOCAL_MODULE := sensors.ranchu
diff --git a/sensors/sensors_qemu.c b/sensors/sensors_qemu.c
index 7954cf5..3665ec7 100644
--- a/sensors/sensors_qemu.c
+++ b/sensors/sensors_qemu.c
@@ -33,7 +33,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <string.h>
-#include <cutils/log.h>
+#include <log/log.h>
 #include <cutils/sockets.h>
 #include <hardware/sensors.h>
 
diff --git a/vndk/Android.mk b/vndk/Android.mk
index da89575..25765ee 100644
--- a/vndk/Android.mk
+++ b/vndk/Android.mk
@@ -2,6 +2,7 @@
 
 LOCAL_PATH := $(call my-dir)
 
+ifndef BOARD_VNDK_VERSION
 VNDK_SP_LIBRARIES := \
     android.hardware.renderscript@1.0\
     android.hardware.graphics.allocator@2.0\
@@ -25,7 +26,8 @@
     libcompiler_rt\
     libbacktrace\
     libunwind\
-    liblzma\
+    liblzma
+endif
 
 define add-vndk-sp-lib
 include $$(CLEAR_VARS)