Merge "Remove useless Android.mk files."
diff --git a/audio/2.0/Android.bp b/audio/2.0/Android.bp
index ea3ea84..06299b6 100644
--- a/audio/2.0/Android.bp
+++ b/audio/2.0/Android.bp
@@ -186,6 +186,7 @@
 
 cc_test {
     name: "android.hardware.audio@2.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/audio/effect/2.0/Android.bp b/audio/effect/2.0/Android.bp
index e940296..e939ece 100644
--- a/audio/effect/2.0/Android.bp
+++ b/audio/effect/2.0/Android.bp
@@ -249,6 +249,7 @@
 
 cc_test {
     name: "android.hardware.audio.effect@2.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/automotive/evs/1.0/Android.bp b/automotive/evs/1.0/Android.bp
index be58711..da68c2a 100644
--- a/automotive/evs/1.0/Android.bp
+++ b/automotive/evs/1.0/Android.bp
@@ -155,6 +155,7 @@
 
 cc_test {
     name: "android.hardware.automotive.evs@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/automotive/vehicle/2.0/Android.bp b/automotive/vehicle/2.0/Android.bp
index ffc768e..0d0d28f 100644
--- a/automotive/vehicle/2.0/Android.bp
+++ b/automotive/vehicle/2.0/Android.bp
@@ -137,6 +137,7 @@
 
 cc_test {
     name: "android.hardware.automotive.vehicle@2.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/biometrics/fingerprint/2.1/Android.bp b/biometrics/fingerprint/2.1/Android.bp
index 719f47d..e6e4827 100644
--- a/biometrics/fingerprint/2.1/Android.bp
+++ b/biometrics/fingerprint/2.1/Android.bp
@@ -137,6 +137,7 @@
 
 cc_test {
     name: "android.hardware.biometrics.fingerprint@2.1-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/bluetooth/1.0/Android.bp b/bluetooth/1.0/Android.bp
index 5637aa4..9d2cf6e 100644
--- a/bluetooth/1.0/Android.bp
+++ b/bluetooth/1.0/Android.bp
@@ -137,6 +137,7 @@
 
 cc_test {
     name: "android.hardware.bluetooth@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/boot/1.0/Android.bp b/boot/1.0/Android.bp
index ad9cfc7..e15b2d0 100644
--- a/boot/1.0/Android.bp
+++ b/boot/1.0/Android.bp
@@ -128,6 +128,7 @@
 
 cc_test {
     name: "android.hardware.boot@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/boot/1.0/vts/Android.bp b/boot/1.0/vts/Android.bp
deleted file mode 100644
index 7aef46b..0000000
--- a/boot/1.0/vts/Android.bp
+++ /dev/null
@@ -1,3 +0,0 @@
-subdirs = [
-    "*"
-]
diff --git a/boot/Android.bp b/boot/Android.bp
index 67af5bb..33f70eb 100644
--- a/boot/Android.bp
+++ b/boot/Android.bp
@@ -1,6 +1,5 @@
 // This is an autogenerated file, do not edit.
 subdirs = [
     "1.0",
-    "1.0/vts",
     "1.0/vts/functional",
 ]
diff --git a/broadcastradio/1.0/Android.bp b/broadcastradio/1.0/Android.bp
index 9b8c5b3..b394fdc 100644
--- a/broadcastradio/1.0/Android.bp
+++ b/broadcastradio/1.0/Android.bp
@@ -155,6 +155,7 @@
 
 cc_test {
     name: "android.hardware.broadcastradio@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/broadcastradio/1.1/Android.bp b/broadcastradio/1.1/Android.bp
index 2111c16..fa1c3e9 100644
--- a/broadcastradio/1.1/Android.bp
+++ b/broadcastradio/1.1/Android.bp
@@ -161,6 +161,7 @@
 
 cc_test {
     name: "android.hardware.broadcastradio@1.1-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/camera/device/1.0/Android.bp b/camera/device/1.0/Android.bp
index dfc58c9..5b2d4c0 100644
--- a/camera/device/1.0/Android.bp
+++ b/camera/device/1.0/Android.bp
@@ -154,6 +154,7 @@
 
 cc_test {
     name: "android.hardware.camera.device@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/camera/device/3.2/Android.bp b/camera/device/3.2/Android.bp
index d770964..15a7dcd 100644
--- a/camera/device/3.2/Android.bp
+++ b/camera/device/3.2/Android.bp
@@ -154,6 +154,7 @@
 
 cc_test {
     name: "android.hardware.camera.device@3.2-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/camera/provider/2.4/Android.bp b/camera/provider/2.4/Android.bp
index 40f7594..15a31fc 100644
--- a/camera/provider/2.4/Android.bp
+++ b/camera/provider/2.4/Android.bp
@@ -153,6 +153,7 @@
 
 cc_test {
     name: "android.hardware.camera.provider@2.4-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/configstore/1.0/Android.bp b/configstore/1.0/Android.bp
index bd11112..3e9c200 100644
--- a/configstore/1.0/Android.bp
+++ b/configstore/1.0/Android.bp
@@ -128,6 +128,7 @@
 
 cc_test {
     name: "android.hardware.configstore@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/contexthub/1.0/Android.bp b/contexthub/1.0/Android.bp
index 74e028c..e8f7103 100644
--- a/contexthub/1.0/Android.bp
+++ b/contexthub/1.0/Android.bp
@@ -137,6 +137,7 @@
 
 cc_test {
     name: "android.hardware.contexthub@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/drm/1.0/Android.bp b/drm/1.0/Android.bp
index c5f814c..502d10e 100644
--- a/drm/1.0/Android.bp
+++ b/drm/1.0/Android.bp
@@ -164,6 +164,7 @@
 
 cc_test {
     name: "android.hardware.drm@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/dumpstate/1.0/Android.bp b/dumpstate/1.0/Android.bp
index 684ab35..5a028a5 100644
--- a/dumpstate/1.0/Android.bp
+++ b/dumpstate/1.0/Android.bp
@@ -124,6 +124,7 @@
 
 cc_test {
     name: "android.hardware.dumpstate@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/gatekeeper/1.0/Android.bp b/gatekeeper/1.0/Android.bp
index b3cd75e..5692bf1 100644
--- a/gatekeeper/1.0/Android.bp
+++ b/gatekeeper/1.0/Android.bp
@@ -128,6 +128,7 @@
 
 cc_test {
     name: "android.hardware.gatekeeper@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/gnss/1.0/Android.bp b/gnss/1.0/Android.bp
index f40e6e1..36b2095 100644
--- a/gnss/1.0/Android.bp
+++ b/gnss/1.0/Android.bp
@@ -299,6 +299,7 @@
 
 cc_test {
     name: "android.hardware.gnss@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/graphics/allocator/2.0/Android.bp b/graphics/allocator/2.0/Android.bp
index c24da12..6532065 100644
--- a/graphics/allocator/2.0/Android.bp
+++ b/graphics/allocator/2.0/Android.bp
@@ -135,6 +135,7 @@
 
 cc_test {
     name: "android.hardware.graphics.allocator@2.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/graphics/bufferqueue/1.0/Android.bp b/graphics/bufferqueue/1.0/Android.bp
index c96c3c3..44052c7 100644
--- a/graphics/bufferqueue/1.0/Android.bp
+++ b/graphics/bufferqueue/1.0/Android.bp
@@ -141,6 +141,7 @@
 
 cc_test {
     name: "android.hardware.graphics.bufferqueue@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/graphics/composer/2.1/Android.bp b/graphics/composer/2.1/Android.bp
index 9080781..3bdd0a6 100644
--- a/graphics/composer/2.1/Android.bp
+++ b/graphics/composer/2.1/Android.bp
@@ -150,6 +150,7 @@
 
 cc_test {
     name: "android.hardware.graphics.composer@2.1-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/graphics/mapper/2.0/Android.bp b/graphics/mapper/2.0/Android.bp
index f829840..6ab99b5 100644
--- a/graphics/mapper/2.0/Android.bp
+++ b/graphics/mapper/2.0/Android.bp
@@ -133,6 +133,7 @@
 
 cc_test {
     name: "android.hardware.graphics.mapper@2.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/health/1.0/Android.bp b/health/1.0/Android.bp
index 1b5661c..aff56a8 100644
--- a/health/1.0/Android.bp
+++ b/health/1.0/Android.bp
@@ -128,6 +128,7 @@
 
 cc_test {
     name: "android.hardware.health@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/health/2.0/Android.bp b/health/2.0/Android.bp
index d7e8dd0..f944471 100644
--- a/health/2.0/Android.bp
+++ b/health/2.0/Android.bp
@@ -143,6 +143,7 @@
 
 cc_test {
     name: "android.hardware.health@2.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/health/2.0/vts/functional/Android.bp b/health/2.0/vts/functional/Android.bp
new file mode 100644
index 0000000..4ad01b9
--- /dev/null
+++ b/health/2.0/vts/functional/Android.bp
@@ -0,0 +1,25 @@
+//
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_test {
+    name: "VtsHalHealthV2_0TargetTest",
+    defaults: ["VtsHalTargetTestDefaults"],
+    srcs: ["VtsHalHealthV2_0TargetTest.cpp"],
+    static_libs: [
+        "android.hardware.health@1.0",
+        "android.hardware.health@2.0",
+    ],
+}
diff --git a/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp b/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp
new file mode 100644
index 0000000..8abed0c
--- /dev/null
+++ b/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp
@@ -0,0 +1,248 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "mHealthhidl_hal_test"
+
+#include <mutex>
+
+#include <VtsHalHidlTargetTestBase.h>
+#include <android-base/logging.h>
+#include <android/hardware/health/2.0/IHealth.h>
+#include <android/hardware/health/2.0/types.h>
+
+using ::testing::AssertionFailure;
+using ::testing::AssertionResult;
+using ::testing::AssertionSuccess;
+using ::testing::VtsHalHidlTargetTestBase;
+using ::testing::VtsHalHidlTargetTestEnvBase;
+
+namespace android {
+namespace hardware {
+namespace health {
+namespace V2_0 {
+
+using V1_0::BatteryStatus;
+using V1_0::HealthInfo;
+
+// Test environment for graphics.composer
+class HealthHidlEnvironment : public VtsHalHidlTargetTestEnvBase {
+   public:
+    // get the test environment singleton
+    static HealthHidlEnvironment* Instance() {
+        static HealthHidlEnvironment* instance = new HealthHidlEnvironment;
+        return instance;
+    }
+
+    virtual void registerTestServices() override { registerTestService<IHealth>(); }
+
+   private:
+    HealthHidlEnvironment() {}
+
+    GTEST_DISALLOW_COPY_AND_ASSIGN_(HealthHidlEnvironment);
+};
+
+class HealthHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+   public:
+    virtual void SetUp() override {
+        std::string serviceName = HealthHidlEnvironment::Instance()->getServiceName<IHealth>();
+        LOG(INFO) << "get service with name:" << serviceName;
+        ASSERT_FALSE(serviceName.empty());
+        mHealth = ::testing::VtsHalHidlTargetTestBase::getService<IHealth>(serviceName);
+        ASSERT_NE(mHealth, nullptr);
+    }
+
+    sp<IHealth> mHealth;
+};
+
+class Callback : public IHealthInfoCallback {
+    using Function = std::function<void(const HealthInfo&)>;
+
+   public:
+    Callback(const Function& f) : mInternal(f) {}
+    Return<void> healthInfoChanged(const HealthInfo& info) override {
+        std::unique_lock<std::mutex> lock(mMutex);
+        if (mInternal) mInternal(info);
+        return Void();
+    }
+    void clear() {
+        std::unique_lock<std::mutex> lock(mMutex);
+        mInternal = nullptr;
+    }
+
+   private:
+    std::mutex mMutex;
+    Function mInternal;
+};
+
+#define ASSERT_OK(r) ASSERT_TRUE(isOk(r))
+#define EXPECT_OK(r) EXPECT_TRUE(isOk(r))
+template <typename T>
+AssertionResult isOk(const Return<T>& r) {
+    return r.isOk() ? AssertionSuccess() : (AssertionFailure() << r.description());
+}
+
+#define ASSERT_ALL_OK(r) ASSERT_TRUE(isAllOk(r))
+// Both isOk() and Result::SUCCESS
+AssertionResult isAllOk(const Return<Result>& r) {
+    if (!r.isOk()) {
+        return AssertionFailure() << r.description();
+    }
+    if (static_cast<Result>(r) != Result::SUCCESS) {
+        return AssertionFailure() << toString(static_cast<Result>(r));
+    }
+    return AssertionSuccess();
+}
+
+/**
+ * Test whether callbacks work. Tested functions are IHealth::registerCallback,
+ * unregisterCallback, and update.
+ */
+TEST_F(HealthHidlTest, Callbacks) {
+    using namespace std::chrono_literals;
+
+    std::mutex mutex;
+    std::condition_variable cv;
+    bool firstCallbackInvoked = false;
+    bool secondCallbackInvoked = false;
+
+    sp<Callback> firstCallback = new Callback([&](const auto&) {
+        std::unique_lock<std::mutex> lk(mutex);
+        firstCallbackInvoked = true;
+    });
+
+    sp<Callback> secondCallback = new Callback([&](const auto&) {
+        std::unique_lock<std::mutex> lk(mutex);
+        secondCallbackInvoked = true;
+        cv.notify_all();
+    });
+
+    ASSERT_ALL_OK(mHealth->registerCallback(firstCallback));
+    ASSERT_ALL_OK(mHealth->registerCallback(secondCallback));
+
+    // assert that the first callback is invoked when update is called.
+    {
+        std::unique_lock<std::mutex> lk(mutex);
+        firstCallbackInvoked = false;
+        secondCallbackInvoked = false;
+    }
+
+    ASSERT_ALL_OK(mHealth->update());
+
+    {
+        std::unique_lock<std::mutex> lk(mutex);
+        EXPECT_TRUE(cv.wait_for(lk, 1s, [&] {
+            return firstCallbackInvoked && secondCallbackInvoked;
+        })) << "Timeout.";
+        ASSERT_TRUE(firstCallbackInvoked);
+        ASSERT_TRUE(secondCallbackInvoked);
+    }
+
+    ASSERT_ALL_OK(mHealth->unregisterCallback(firstCallback));
+
+    // assert that the second callback is still invoked even though the first is unregistered.
+    {
+        std::unique_lock<std::mutex> lk(mutex);
+        firstCallbackInvoked = false;
+        secondCallbackInvoked = false;
+    }
+
+    ASSERT_ALL_OK(mHealth->update());
+
+    {
+        std::unique_lock<std::mutex> lk(mutex);
+        EXPECT_TRUE(cv.wait_for(lk, 1s, [&] { return secondCallbackInvoked; })) << "Timeout.";
+        ASSERT_FALSE(firstCallbackInvoked);
+        ASSERT_TRUE(secondCallbackInvoked);
+    }
+
+    ASSERT_ALL_OK(mHealth->unregisterCallback(secondCallback));
+
+    // avoid reference to lambda function that goes out of scope.
+    firstCallback->clear();
+    secondCallback->clear();
+}
+
+TEST_F(HealthHidlTest, UnregisterNonExistentCallback) {
+    sp<Callback> callback = new Callback([](const auto&) {});
+    auto ret = mHealth->unregisterCallback(callback);
+    ASSERT_OK(ret);
+    ASSERT_EQ(Result::NOT_FOUND, static_cast<Result>(ret)) << "Actual: " << toString(ret);
+}
+
+/**
+ * Pass the test if:
+ *  - Property is not supported (res == NOT_SUPPORTED)
+ *  - Result is success, and predicate is true
+ * @param res the Result value.
+ * @param valueStr the string representation for actual value (for error message)
+ * @param pred a predicate that test whether the value is valid
+ */
+#define EXPECT_VALID_OR_UNSUPPORTED_PROP(res, valueStr, pred) \
+    EXPECT_TRUE(isPropertyOk(res, valueStr, pred, #pred))
+
+AssertionResult isPropertyOk(Result res, const std::string& valueStr, bool pred,
+                             const std::string& predStr) {
+    if (res == Result::SUCCESS) {
+        if (pred) {
+            return AssertionSuccess();
+        }
+        return AssertionFailure() << "value doesn't match.\nActual: " << valueStr
+                                  << "\nExpected: " << predStr;
+    }
+    if (res == Result::NOT_SUPPORTED) {
+        return AssertionSuccess();
+    }
+    return AssertionFailure() << "Result is not SUCCESS or NOT_SUPPORTED: " << toString(res);
+}
+
+TEST_F(HealthHidlTest, Properties) {
+    EXPECT_OK(mHealth->getChargeCounter([](auto result, auto value) {
+        EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value > 0);
+    }));
+    EXPECT_OK(mHealth->getCurrentNow([](auto result, auto value) {
+        EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value != INT32_MIN);
+    }));
+    EXPECT_OK(mHealth->getCurrentAverage([](auto result, auto value) {
+        EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value != INT32_MIN);
+    }));
+    EXPECT_OK(mHealth->getCapacity([](auto result, auto value) {
+        EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), 0 <= value && value <= 100);
+    }));
+    EXPECT_OK(mHealth->getEnergyCounter([](auto result, auto value) {
+        EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value != INT64_MIN);
+    }));
+    EXPECT_OK(mHealth->getChargeStatus([](auto result, auto value) {
+        EXPECT_VALID_OR_UNSUPPORTED_PROP(
+            result, toString(value),
+            value == BatteryStatus::CHARGING || value == BatteryStatus::DISCHARGING ||
+                value == BatteryStatus::NOT_CHARGING || value == BatteryStatus::FULL);
+    }));
+}
+
+}  // namespace V2_0
+}  // namespace health
+}  // namespace hardware
+}  // namespace android
+
+int main(int argc, char** argv) {
+    using ::android::hardware::health::V2_0::HealthHidlEnvironment;
+    ::testing::AddGlobalTestEnvironment(HealthHidlEnvironment::Instance());
+    ::testing::InitGoogleTest(&argc, argv);
+    HealthHidlEnvironment::Instance()->init(&argc, argv);
+    int status = RUN_ALL_TESTS();
+    LOG(INFO) << "Test result = " << status;
+    return status;
+}
diff --git a/health/Android.bp b/health/Android.bp
index 31e042a..7797b35 100644
--- a/health/Android.bp
+++ b/health/Android.bp
@@ -3,4 +3,5 @@
     "1.0",
     "1.0/vts/functional",
     "2.0",
+    "2.0/vts/functional",
 ]
diff --git a/ir/1.0/Android.bp b/ir/1.0/Android.bp
index 6ca7701..e686d23 100644
--- a/ir/1.0/Android.bp
+++ b/ir/1.0/Android.bp
@@ -128,6 +128,7 @@
 
 cc_test {
     name: "android.hardware.ir@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/keymaster/3.0/Android.bp b/keymaster/3.0/Android.bp
index 9019739..0e55133 100644
--- a/keymaster/3.0/Android.bp
+++ b/keymaster/3.0/Android.bp
@@ -128,6 +128,7 @@
 
 cc_test {
     name: "android.hardware.keymaster@3.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/light/2.0/Android.bp b/light/2.0/Android.bp
index 3412fcc..f1ce520 100644
--- a/light/2.0/Android.bp
+++ b/light/2.0/Android.bp
@@ -128,6 +128,7 @@
 
 cc_test {
     name: "android.hardware.light@2.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/media/omx/1.0/Android.bp b/media/omx/1.0/Android.bp
index 378c18e..7367409 100644
--- a/media/omx/1.0/Android.bp
+++ b/media/omx/1.0/Android.bp
@@ -187,6 +187,7 @@
 
 cc_test {
     name: "android.hardware.media.omx@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/memtrack/1.0/Android.bp b/memtrack/1.0/Android.bp
index fc6aa9d..fe88d0f 100644
--- a/memtrack/1.0/Android.bp
+++ b/memtrack/1.0/Android.bp
@@ -128,6 +128,7 @@
 
 cc_test {
     name: "android.hardware.memtrack@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/nfc/1.0/Android.bp b/nfc/1.0/Android.bp
index ac02e44..ad84683 100644
--- a/nfc/1.0/Android.bp
+++ b/nfc/1.0/Android.bp
@@ -137,6 +137,7 @@
 
 cc_test {
     name: "android.hardware.nfc@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/power/1.0/Android.bp b/power/1.0/Android.bp
index 5cc4ae0..789fdcc 100644
--- a/power/1.0/Android.bp
+++ b/power/1.0/Android.bp
@@ -128,6 +128,7 @@
 
 cc_test {
     name: "android.hardware.power@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/radio/1.0/Android.bp b/radio/1.0/Android.bp
index 4485e74..da496e7 100644
--- a/radio/1.0/Android.bp
+++ b/radio/1.0/Android.bp
@@ -164,6 +164,7 @@
 
 cc_test {
     name: "android.hardware.radio@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/radio/1.1/Android.bp b/radio/1.1/Android.bp
index d89211b..462bd85 100644
--- a/radio/1.1/Android.bp
+++ b/radio/1.1/Android.bp
@@ -161,6 +161,7 @@
 
 cc_test {
     name: "android.hardware.radio@1.1-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/radio/deprecated/1.0/Android.bp b/radio/deprecated/1.0/Android.bp
index 82a7c8d..7b0c01e 100644
--- a/radio/deprecated/1.0/Android.bp
+++ b/radio/deprecated/1.0/Android.bp
@@ -148,6 +148,7 @@
 
 cc_test {
     name: "android.hardware.radio.deprecated@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/renderscript/1.0/Android.bp b/renderscript/1.0/Android.bp
index c687ea9..0fd5186 100644
--- a/renderscript/1.0/Android.bp
+++ b/renderscript/1.0/Android.bp
@@ -138,6 +138,7 @@
 
 cc_test {
     name: "android.hardware.renderscript@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/sensors/1.0/Android.bp b/sensors/1.0/Android.bp
index 8a91ee6..d3ec0be 100644
--- a/sensors/1.0/Android.bp
+++ b/sensors/1.0/Android.bp
@@ -128,6 +128,7 @@
 
 cc_test {
     name: "android.hardware.sensors@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/soundtrigger/2.0/Android.bp b/soundtrigger/2.0/Android.bp
index 173aa75..d902dd0 100644
--- a/soundtrigger/2.0/Android.bp
+++ b/soundtrigger/2.0/Android.bp
@@ -141,6 +141,7 @@
 
 cc_test {
     name: "android.hardware.soundtrigger@2.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tests/Android.bp b/tests/Android.bp
index 18fc473..0031637 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -6,6 +6,7 @@
     "baz/1.0/default",
     "expression/1.0",
     "extension/light/2.0",
+    "extension/light/2.0/default",
     "foo/1.0",
     "foo/1.0/default",
     "foo/1.0/default/lib",
diff --git a/tests/bar/1.0/Android.bp b/tests/bar/1.0/Android.bp
index ce4b4fc..b862c9b 100644
--- a/tests/bar/1.0/Android.bp
+++ b/tests/bar/1.0/Android.bp
@@ -167,6 +167,7 @@
 
 cc_test {
     name: "android.hardware.tests.bar@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tests/baz/1.0/Android.bp b/tests/baz/1.0/Android.bp
index 3a208a8..41b6ef2 100644
--- a/tests/baz/1.0/Android.bp
+++ b/tests/baz/1.0/Android.bp
@@ -152,6 +152,7 @@
 
 cc_test {
     name: "android.hardware.tests.baz@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tests/expression/1.0/Android.bp b/tests/expression/1.0/Android.bp
index a54538c..bbb6f33 100644
--- a/tests/expression/1.0/Android.bp
+++ b/tests/expression/1.0/Android.bp
@@ -130,6 +130,7 @@
 
 cc_test {
     name: "android.hardware.tests.expression@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tests/extension/light/2.0/Android.bp b/tests/extension/light/2.0/Android.bp
index 5220630..07dcea3 100644
--- a/tests/extension/light/2.0/Android.bp
+++ b/tests/extension/light/2.0/Android.bp
@@ -131,6 +131,7 @@
 
 cc_test {
     name: "android.hardware.tests.extension.light@2.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tests/extension/light/2.0/default/Android.bp b/tests/extension/light/2.0/default/Android.bp
new file mode 100644
index 0000000..365a34a
--- /dev/null
+++ b/tests/extension/light/2.0/default/Android.bp
@@ -0,0 +1,34 @@
+//
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_binary {
+    name: "android.hardware.tests.extension.light@2.0-service",
+    init_rc: ["android.hardware.tests.extension.light@2.0-service.rc"],
+    vendor: true,
+    relative_install_path: "hw",
+    srcs: [
+        "Light.cpp",
+        "service.cpp",
+    ],
+
+    shared_libs: [
+        "libhidlbase",
+        "libhidltransport",
+        "libutils",
+        "android.hardware.light@2.0",
+        "android.hardware.tests.extension.light@2.0",
+    ],
+}
diff --git a/tests/extension/light/2.0/default/Android.mk b/tests/extension/light/2.0/default/Android.mk
deleted file mode 100644
index b30d11c..0000000
--- a/tests/extension/light/2.0/default/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.extension.light@2.0-service
-LOCAL_INIT_RC := android.hardware.tests.extension.light@2.0-service.rc
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SRC_FILES := \
-    Light.cpp \
-    service.cpp
-
-LOCAL_SHARED_LIBRARIES := \
-    libhidlbase \
-    libhidltransport \
-    libutils \
-    android.hardware.light@2.0 \
-    android.hardware.tests.extension.light@2.0 \
-
-include $(BUILD_EXECUTABLE)
diff --git a/tests/foo/1.0/Android.bp b/tests/foo/1.0/Android.bp
index acf4fdd..51b5dc6 100644
--- a/tests/foo/1.0/Android.bp
+++ b/tests/foo/1.0/Android.bp
@@ -161,6 +161,7 @@
 
 cc_test {
     name: "android.hardware.tests.foo@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tests/hash/1.0/Android.bp b/tests/hash/1.0/Android.bp
index 3f7205e..ffff051 100644
--- a/tests/hash/1.0/Android.bp
+++ b/tests/hash/1.0/Android.bp
@@ -121,6 +121,7 @@
 
 cc_test {
     name: "android.hardware.tests.hash@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tests/inheritance/1.0/Android.bp b/tests/inheritance/1.0/Android.bp
index e693082..bd34512 100644
--- a/tests/inheritance/1.0/Android.bp
+++ b/tests/inheritance/1.0/Android.bp
@@ -148,6 +148,7 @@
 
 cc_test {
     name: "android.hardware.tests.inheritance@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tests/libhwbinder/1.0/Android.bp b/tests/libhwbinder/1.0/Android.bp
index 0a84abb..139aec5 100644
--- a/tests/libhwbinder/1.0/Android.bp
+++ b/tests/libhwbinder/1.0/Android.bp
@@ -130,6 +130,7 @@
 
 cc_test {
     name: "android.hardware.tests.libhwbinder@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tests/memory/1.0/Android.bp b/tests/memory/1.0/Android.bp
index 7a36c0e..5653e97 100644
--- a/tests/memory/1.0/Android.bp
+++ b/tests/memory/1.0/Android.bp
@@ -121,6 +121,7 @@
 
 cc_test {
     name: "android.hardware.tests.memory@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tests/msgq/1.0/Android.bp b/tests/msgq/1.0/Android.bp
index 0af5420..39a34cb 100644
--- a/tests/msgq/1.0/Android.bp
+++ b/tests/msgq/1.0/Android.bp
@@ -130,6 +130,7 @@
 
 cc_test {
     name: "android.hardware.tests.msgq@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tests/multithread/1.0/Android.bp b/tests/multithread/1.0/Android.bp
index df38695..98cbd5e 100644
--- a/tests/multithread/1.0/Android.bp
+++ b/tests/multithread/1.0/Android.bp
@@ -121,6 +121,7 @@
 
 cc_test {
     name: "android.hardware.tests.multithread@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tests/pointer/1.0/Android.bp b/tests/pointer/1.0/Android.bp
index 1644186..2c13cb1 100644
--- a/tests/pointer/1.0/Android.bp
+++ b/tests/pointer/1.0/Android.bp
@@ -130,6 +130,7 @@
 
 cc_test {
     name: "android.hardware.tests.pointer@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tests/trie/1.0/Android.bp b/tests/trie/1.0/Android.bp
index 27b5ea5..73f1b0b 100644
--- a/tests/trie/1.0/Android.bp
+++ b/tests/trie/1.0/Android.bp
@@ -125,6 +125,7 @@
 
 cc_test {
     name: "android.hardware.tests.trie@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tetheroffload/config/1.0/Android.bp b/tetheroffload/config/1.0/Android.bp
index 705253d..5cafb5d 100644
--- a/tetheroffload/config/1.0/Android.bp
+++ b/tetheroffload/config/1.0/Android.bp
@@ -124,6 +124,7 @@
 
 cc_test {
     name: "android.hardware.tetheroffload.config@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tetheroffload/control/1.0/Android.bp b/tetheroffload/control/1.0/Android.bp
index 75750f0..f4f120a 100644
--- a/tetheroffload/control/1.0/Android.bp
+++ b/tetheroffload/control/1.0/Android.bp
@@ -137,6 +137,7 @@
 
 cc_test {
     name: "android.hardware.tetheroffload.control@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/thermal/1.0/Android.bp b/thermal/1.0/Android.bp
index da1e641..199da79 100644
--- a/thermal/1.0/Android.bp
+++ b/thermal/1.0/Android.bp
@@ -128,6 +128,7 @@
 
 cc_test {
     name: "android.hardware.thermal@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tv/cec/1.0/Android.bp b/tv/cec/1.0/Android.bp
index 10902ef..f333777 100644
--- a/tv/cec/1.0/Android.bp
+++ b/tv/cec/1.0/Android.bp
@@ -137,6 +137,7 @@
 
 cc_test {
     name: "android.hardware.tv.cec@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/tv/input/1.0/Android.bp b/tv/input/1.0/Android.bp
index 36b2f13..b07b2c7 100644
--- a/tv/input/1.0/Android.bp
+++ b/tv/input/1.0/Android.bp
@@ -141,6 +141,7 @@
 
 cc_test {
     name: "android.hardware.tv.input@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/usb/1.0/Android.bp b/usb/1.0/Android.bp
index e97dbf9..ce4bc25 100644
--- a/usb/1.0/Android.bp
+++ b/usb/1.0/Android.bp
@@ -137,6 +137,7 @@
 
 cc_test {
     name: "android.hardware.usb@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/usb/1.0/default/Android.bp b/usb/1.0/default/Android.bp
new file mode 100644
index 0000000..2ebe61f
--- /dev/null
+++ b/usb/1.0/default/Android.bp
@@ -0,0 +1,34 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_binary {
+    name: "android.hardware.usb@1.0-service",
+    init_rc: ["android.hardware.usb@1.0-service.rc"],
+    relative_install_path: "hw",
+    vendor: true,
+    srcs: [
+        "service.cpp",
+        "Usb.cpp",
+    ],
+
+    shared_libs: [
+        "libcutils",
+        "libhidlbase",
+        "libhidltransport",
+        "liblog",
+        "libutils",
+        "libhardware",
+        "android.hardware.usb@1.0",
+    ],
+}
diff --git a/usb/1.0/default/Android.mk b/usb/1.0/default/Android.mk
deleted file mode 100644
index afd53cf..0000000
--- a/usb/1.0/default/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE := android.hardware.usb@1.0-service
-LOCAL_INIT_RC := android.hardware.usb@1.0-service.rc
-LOCAL_SRC_FILES := \
-    service.cpp \
-    Usb.cpp
-
-LOCAL_SHARED_LIBRARIES := \
-    libcutils \
-    libhidlbase \
-    libhidltransport \
-    liblog \
-    libutils \
-    libhardware \
-    android.hardware.usb@1.0 \
-
-include $(BUILD_EXECUTABLE)
diff --git a/usb/Android.bp b/usb/Android.bp
index 33f70eb..ed19a37 100644
--- a/usb/Android.bp
+++ b/usb/Android.bp
@@ -1,5 +1,6 @@
 // This is an autogenerated file, do not edit.
 subdirs = [
     "1.0",
+    "1.0/default",
     "1.0/vts/functional",
 ]
diff --git a/vibrator/1.0/Android.bp b/vibrator/1.0/Android.bp
index 0a48e00..9289657 100644
--- a/vibrator/1.0/Android.bp
+++ b/vibrator/1.0/Android.bp
@@ -128,6 +128,7 @@
 
 cc_test {
     name: "android.hardware.vibrator@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/vibrator/1.0/default/Android.bp b/vibrator/1.0/default/Android.bp
index d4200da..9170b39 100644
--- a/vibrator/1.0/default/Android.bp
+++ b/vibrator/1.0/default/Android.bp
@@ -16,7 +16,7 @@
 cc_library_shared {
     name: "android.hardware.vibrator@1.0-impl",
     defaults: ["hidl_defaults"],
-    proprietary: true,
+    vendor: true,
     relative_install_path: "hw",
     srcs: ["Vibrator.cpp"],
     shared_libs: [
@@ -28,3 +28,20 @@
         "android.hardware.vibrator@1.0",
     ],
 }
+
+cc_binary {
+    name: "android.hardware.vibrator@1.0-service",
+    init_rc: ["android.hardware.vibrator@1.0-service.rc"],
+    vendor: true,
+    relative_install_path: "hw",
+    srcs: ["service.cpp"],
+
+    shared_libs: [
+        "libhidlbase",
+        "libhidltransport",
+        "liblog",
+        "libutils",
+        "libhardware",
+        "android.hardware.vibrator@1.0",
+    ],
+}
diff --git a/vibrator/1.0/default/Android.mk b/vibrator/1.0/default/Android.mk
deleted file mode 100644
index af4a955..0000000
--- a/vibrator/1.0/default/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Copyright (C) 2016 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.vibrator@1.0-service
-LOCAL_INIT_RC := android.hardware.vibrator@1.0-service.rc
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SRC_FILES := \
-  service.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
-  libhidlbase \
-  libhidltransport \
-  liblog \
-  libutils \
-  libhardware \
-  android.hardware.vibrator@1.0
-
-include $(BUILD_EXECUTABLE)
diff --git a/vr/1.0/Android.bp b/vr/1.0/Android.bp
index 5da5857..6fda0e6 100644
--- a/vr/1.0/Android.bp
+++ b/vr/1.0/Android.bp
@@ -124,6 +124,7 @@
 
 cc_test {
     name: "android.hardware.vr@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/wifi/1.0/Android.bp b/wifi/1.0/Android.bp
index 088591a..c61d989 100644
--- a/wifi/1.0/Android.bp
+++ b/wifi/1.0/Android.bp
@@ -236,6 +236,7 @@
 
 cc_test {
     name: "android.hardware.wifi@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",
diff --git a/wifi/supplicant/1.0/Android.bp b/wifi/supplicant/1.0/Android.bp
index 4bf8e68..8a0b802 100644
--- a/wifi/supplicant/1.0/Android.bp
+++ b/wifi/supplicant/1.0/Android.bp
@@ -227,6 +227,7 @@
 
 cc_test {
     name: "android.hardware.wifi.supplicant@1.0-adapter",
+    defaults: ["hidl-module-defaults"],
     shared_libs: [
         "libhidladapter",
         "libhidlbase",