Update makefiles for vndk enabled.
am: f58aaeba02
Change-Id: I0bbde3b2d347b9bc648ef86d361ba5715f3c9355
diff --git a/base/HidlInternal.cpp b/base/HidlInternal.cpp
index b0d867f..5fae1c4 100644
--- a/base/HidlInternal.cpp
+++ b/base/HidlInternal.cpp
@@ -25,13 +25,16 @@
#include <dirent.h>
#include <dlfcn.h>
#include <regex>
+#include <utils/misc.h>
+
+extern "C" __attribute__((weak)) void __sanitizer_cov_dump();
#endif
namespace android {
namespace hardware {
namespace details {
-void logAlwaysFatal(const char *message) {
+void logAlwaysFatal(const char* message) {
LOG(FATAL) << message;
}
@@ -42,9 +45,21 @@
mInstrumentationLibPackage(package),
mInterfaceName(interface) {
configureInstrumentation(false);
+#ifdef LIBHIDL_TARGET_DEBUGGABLE
+ if (__sanitizer_cov_dump != nullptr) {
+ ::android::add_sysprop_change_callback(
+ []() {
+ bool enableCoverage = property_get_bool("hal.coverage.enable", false);
+ if (enableCoverage) {
+ __sanitizer_cov_dump();
+ }
+ },
+ 0);
+ }
+#endif
}
-HidlInstrumentor:: ~HidlInstrumentor() {}
+HidlInstrumentor::~HidlInstrumentor() {}
void HidlInstrumentor::configureInstrumentation(bool log) {
bool enableInstrumentation = property_get_bool(
diff --git a/base/include/hidl/HidlInternal.h b/base/include/hidl/HidlInternal.h
index 6c0d8df..d81dd9c 100644
--- a/base/include/hidl/HidlInternal.h
+++ b/base/include/hidl/HidlInternal.h
@@ -28,6 +28,18 @@
namespace hardware {
namespace details {
+// tag for pure interfaces (e.x. IFoo)
+struct i_tag {};
+
+// tag for server interfaces (e.x. BnHwFoo)
+struct bnhw_tag {};
+
+// tag for proxy interfaces (e.x. BpHwFoo)
+struct bphw_tag {};
+
+// tag for passthrough interfaces (e.x. BsFoo)
+struct bs_tag {};
+
//Templated classes can use the below method
//to avoid creating dependencies on liblog.
void logAlwaysFatal(const char *message);
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index f25cdc4..6e37229 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -172,15 +172,16 @@
void moveFrom(hidl_string &&);
};
+// Use NOLINT to suppress missing parentheses warnings around OP.
#define HIDL_STRING_OPERATOR(OP) \
inline bool operator OP(const hidl_string &hs1, const hidl_string &hs2) { \
- return strcmp(hs1.c_str(), hs2.c_str()) OP 0; \
+ return strcmp(hs1.c_str(), hs2.c_str()) OP 0; /* NOLINT */ \
} \
inline bool operator OP(const hidl_string &hs, const char *s) { \
- return strcmp(hs.c_str(), s) OP 0; \
+ return strcmp(hs.c_str(), s) OP 0; /* NOLINT */ \
} \
inline bool operator OP(const char *s, const hidl_string &hs) { \
- return strcmp(hs.c_str(), s) OP 0; \
+ return strcmp(hs.c_str(), s) OP 0; /* NOLINT */ \
}
HIDL_STRING_OPERATOR(==)
diff --git a/test_main.cpp b/test_main.cpp
index 1f2f845..b265607 100644
--- a/test_main.cpp
+++ b/test_main.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "LibHidlTest"
#include <android-base/logging.h>
+#include <condition_variable>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <hidl/HidlSupport.h>
@@ -296,16 +297,23 @@
TEST_F(LibHidlTest, TaskRunnerTest) {
using android::hardware::details::TaskRunner;
+ using namespace std::chrono_literals;
+
+ std::condition_variable cv;
+ std::mutex m;
+
TaskRunner tr;
tr.start(1 /* limit */);
bool flag = false;
tr.push([&] {
- usleep(1000);
flag = true;
+ cv.notify_all();
});
- usleep(500);
- EXPECT_FALSE(flag);
- usleep(1000);
+
+ std::unique_lock<std::mutex> lock(m);
+
+ // 1s so this doesn't deadlock. This isn't a performance test.
+ EXPECT_TRUE(cv.wait_for(lock, 1s, [&]{return flag;}));
EXPECT_TRUE(flag);
}
diff --git a/transport/base/1.0/Android.mk b/transport/base/1.0/Android.mk
index 2031a92..a044b9b 100644
--- a/transport/base/1.0/Android.mk
+++ b/transport/base/1.0/Android.mk
@@ -11,6 +11,8 @@
intermediates := $(call local-generated-sources-dir, COMMON)
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+LOCAL_NO_STANDARD_LIBRARIES := true
+LOCAL_JAVA_LIBRARIES := core-oj hwbinder
#
# Build types.hal (DebugInfo)
@@ -61,6 +63,8 @@
intermediates := $(call local-generated-sources-dir, COMMON)
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+LOCAL_NO_STANDARD_LIBRARIES := true
+LOCAL_JAVA_LIBRARIES := core-oj hwbinder
#
# Build types.hal (DebugInfo)
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index 47ff581..fc834b9 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -306,7 +306,8 @@
// Otherwise, the smallest possible BnChild is found where IChild is a subclass of IType
// and iface is of class IChild. BnChild will be used to wrapped the given iface.
// Return nullptr if iface is null or any failure.
-template <typename IType>
+template <typename IType,
+ typename = std::enable_if_t<std::is_same<details::i_tag, typename IType::_hidl_tag>::value>>
sp<IBinder> toBinder(sp<IType> iface) {
IType *ifacePtr = iface.get();
if (ifacePtr == nullptr) {
diff --git a/transport/include/hidl/HidlTransportSupport.h b/transport/include/hidl/HidlTransportSupport.h
index d116598..18a4036 100644
--- a/transport/include/hidl/HidlTransportSupport.h
+++ b/transport/include/hidl/HidlTransportSupport.h
@@ -62,7 +62,10 @@
bool setMinSchedulerPolicy(const sp<::android::hidl::base::V1_0::IBase>& service,
int policy, int priority);
-template <typename ILeft, typename IRight>
+template <typename ILeft,
+ typename IRight,
+ typename = std::enable_if_t<std::is_same<details::i_tag, typename ILeft::_hidl_tag>::value>,
+ typename = std::enable_if_t<std::is_same<details::i_tag, typename IRight::_hidl_tag>::value>>
bool interfacesEqual(sp<ILeft> left, sp<IRight> right) {
if (left == nullptr || right == nullptr || !left->isRemote() || !right->isRemote()) {
return left == right;
diff --git a/transport/manager/1.0/Android.mk b/transport/manager/1.0/Android.mk
index 8b20827..50ddee6 100644
--- a/transport/manager/1.0/Android.mk
+++ b/transport/manager/1.0/Android.mk
@@ -15,6 +15,8 @@
LOCAL_JAVA_LIBRARIES := \
android.hidl.base-V1.0-java \
+LOCAL_NO_STANDARD_LIBRARIES := true
+LOCAL_JAVA_LIBRARIES += core-oj hwbinder
#
# Build IServiceManager.hal
@@ -69,6 +71,8 @@
LOCAL_STATIC_JAVA_LIBRARIES := \
android.hidl.base-V1.0-java-static \
+LOCAL_NO_STANDARD_LIBRARIES := true
+LOCAL_JAVA_LIBRARIES := core-oj hwbinder
#
# Build IServiceManager.hal
diff --git a/transport/manager/1.1/Android.mk b/transport/manager/1.1/Android.mk
index 20c9504..ae8dc70 100644
--- a/transport/manager/1.1/Android.mk
+++ b/transport/manager/1.1/Android.mk
@@ -16,6 +16,8 @@
android.hidl.base-V1.0-java \
android.hidl.manager-V1.0-java \
+LOCAL_NO_STANDARD_LIBRARIES := true
+LOCAL_JAVA_LIBRARIES += core-oj hwbinder
#
# Build IServiceManager.hal
@@ -51,6 +53,8 @@
android.hidl.base-V1.0-java-static \
android.hidl.manager-V1.0-java-static \
+LOCAL_NO_STANDARD_LIBRARIES := true
+LOCAL_JAVA_LIBRARIES := core-oj hwbinder
#
# Build IServiceManager.hal
diff --git a/transport/token/1.0/Android.mk b/transport/token/1.0/Android.mk
index ea86d57..c355c12 100644
--- a/transport/token/1.0/Android.mk
+++ b/transport/token/1.0/Android.mk
@@ -15,6 +15,8 @@
LOCAL_JAVA_LIBRARIES := \
android.hidl.base-V1.0-java \
+LOCAL_NO_STANDARD_LIBRARIES := true
+LOCAL_JAVA_LIBRARIES += core-oj hwbinder
#
# Build ITokenManager.hal
@@ -49,6 +51,8 @@
LOCAL_STATIC_JAVA_LIBRARIES := \
android.hidl.base-V1.0-java-static \
+LOCAL_NO_STANDARD_LIBRARIES := true
+LOCAL_JAVA_LIBRARIES := core-oj hwbinder
#
# Build ITokenManager.hal