Merge "Update Light extension example to match docs."
diff --git a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
index 90fec01..838aca2 100644
--- a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -26,6 +26,9 @@
 #include <type_traits>
 #include <vector>
 
+#include <fcntl.h>
+#include <unistd.h>
+
 #include <VtsHalHidlTargetTestBase.h>
 
 #include <android-base/logging.h>
@@ -527,19 +530,23 @@
 
 template <class DebugDump>
 static void testDebugDump(DebugDump debugDump) {
-    // Dump in a temporary file
-    // Note that SELinux must be deactivate for this test to work
-    FILE* file = tmpfile();
-    ASSERT_NE(nullptr, file) << errno;
+    // File descriptors to our pipe. fds[0] corresponds to the read end and
+    // fds[1] to the write end.
+    int fds[2];
+    ASSERT_EQ(0, pipe2(fds, O_NONBLOCK)) << errno;
+
+    // Make sure that the pipe is at least 1 MB in size. The test process runs
+    // in su domain, so it should be safe to make this call.
+    fcntl(fds[0], F_SETPIPE_SZ, 1 << 20);
 
     // Wrap the temporary file file descriptor in a native handle
     auto* nativeHandle = native_handle_create(1, 0);
     ASSERT_NE(nullptr, nativeHandle);
-    nativeHandle->data[0] = fileno(file);
+    nativeHandle->data[0] = fds[1];
 
     // Wrap this native handle in a hidl handle
     hidl_handle handle;
-    handle.setTo(nativeHandle, true /*take ownership*/);
+    handle.setTo(nativeHandle, false /*take ownership*/);
 
     ASSERT_OK(debugDump(handle));
 
@@ -547,12 +554,12 @@
     // TODO: debugDump does not return a Result.
     // This mean that the hal can not report that it not implementing the
     // function.
-    rewind(file);  // can not fail
     char buff;
-    if (fread(&buff, sizeof(buff), 1, file) != 1) {
+    if (read(fds[0], &buff, 1) != 1) {
         doc::note("debugDump does not seem implemented");
     }
-    EXPECT_EQ(0, fclose(file)) << errno;
+    EXPECT_EQ(0, close(fds[0])) << errno;
+    EXPECT_EQ(0, close(fds[1])) << errno;
 }
 
 TEST_F(AudioPrimaryHidlTest, DebugDump) {
diff --git a/biometrics/fingerprint/2.1/vts/functional/VtsHalBiometricsFingerprintV2_1TargetTest.cpp b/biometrics/fingerprint/2.1/vts/functional/VtsHalBiometricsFingerprintV2_1TargetTest.cpp
index 29776b4..638af9f 100644
--- a/biometrics/fingerprint/2.1/vts/functional/VtsHalBiometricsFingerprintV2_1TargetTest.cpp
+++ b/biometrics/fingerprint/2.1/vts/functional/VtsHalBiometricsFingerprintV2_1TargetTest.cpp
@@ -43,7 +43,7 @@
 static const uint32_t kTimeout = 3;
 static const std::chrono::seconds kTimeoutInSeconds = std::chrono::seconds(kTimeout);
 static const uint32_t kGroupId = 99;
-static const std::string kTmpDir = "/data/system/";
+static const std::string kTmpDir = "/data/system/users/0/fpdata/";
 static const uint32_t kIterations = 1000;
 
 // Wait for a callback to occur (signaled by the given future) up to the
@@ -186,7 +186,7 @@
     ASSERT_FALSE(mService == nullptr);
 
     // Create an active group
-    // FP service can only write to /data/system due to
+    // FP service can only write to /data/system/users/*/fpdata/ due to
     // SELinux Policy and Linux Dir Permissions
     Return<RequestStatus> res = mService->setActiveGroup(kGroupId, kTmpDir);
     ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
diff --git a/health/2.0/Android.bp b/health/2.0/Android.bp
index f944471..8281a84 100644
--- a/health/2.0/Android.bp
+++ b/health/2.0/Android.bp
@@ -75,6 +75,36 @@
 }
 
 genrule {
+    name: "android.hardware.health-V2.0-java_gen_java",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Ljava -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.health@2.0",
+    srcs: [
+        ":android.hardware.health@2.0_hal",
+    ],
+    out: [
+        "android/hardware/health/V2_0/HealthInfo.java",
+        "android/hardware/health/V2_0/Result.java",
+        "android/hardware/health/V2_0/IHealth.java",
+        "android/hardware/health/V2_0/IHealthInfoCallback.java",
+    ],
+}
+
+java_library {
+    name: "android.hardware.health-V2.0-java",
+    no_framework_libs: true,
+    defaults: ["hidl-java-module-defaults"],
+    srcs: [":android.hardware.health-V2.0-java_gen_java"],
+    libs: [
+        "hwbinder",
+        "android.hardware.health-V1.0-java",
+        "android.hidl.base-V1.0-java",
+    ]
+}
+
+// This package does not export any types. Not creating java constants export.
+
+
+genrule {
     name: "android.hardware.health@2.0-adapter-helper_genc++",
     tools: ["hidl-gen"],
     cmd: "$(location hidl-gen) -o $(genDir) -Lc++-adapter-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.health@2.0",
@@ -100,7 +130,6 @@
     ],
 }
 
-
 cc_library {
     name: "android.hardware.health@2.0-adapter-helper",
     defaults: ["hidl-module-defaults"],
diff --git a/health/2.0/Android.mk b/health/2.0/Android.mk
deleted file mode 100644
index 344c963..0000000
--- a/health/2.0/Android.mk
+++ /dev/null
@@ -1,86 +0,0 @@
-# This file is autogenerated by hidl-gen. Do not edit manually.
-
-LOCAL_PATH := $(call my-dir)
-
-################################################################################
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.health-V2.0-java
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-
-intermediates := $(call local-generated-sources-dir, COMMON)
-
-HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
-
-LOCAL_JAVA_LIBRARIES := \
-    android.hardware.health-V1.0-java \
-    android.hidl.base-V1.0-java \
-
-LOCAL_NO_STANDARD_LIBRARIES := true
-LOCAL_JAVA_LIBRARIES += core-oj hwbinder
-
-#
-# Build types.hal (Result)
-#
-GEN := $(intermediates)/android/hardware/health/V2_0/Result.java
-$(GEN): $(HIDL)
-$(GEN): PRIVATE_HIDL := $(HIDL)
-$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
-$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
-$(GEN): PRIVATE_CUSTOM_TOOL = \
-        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-        -Ljava \
-        -randroid.hardware:hardware/interfaces \
-        -randroid.hidl:system/libhidl/transport \
-        android.hardware.health@2.0::types.Result
-
-$(GEN): $(LOCAL_PATH)/types.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-#
-# Build IHealth.hal
-#
-GEN := $(intermediates)/android/hardware/health/V2_0/IHealth.java
-$(GEN): $(HIDL)
-$(GEN): PRIVATE_HIDL := $(HIDL)
-$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IHealth.hal
-$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IHealthInfoCallback.hal
-$(GEN): $(LOCAL_PATH)/IHealthInfoCallback.hal
-$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
-$(GEN): $(LOCAL_PATH)/types.hal
-$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
-$(GEN): PRIVATE_CUSTOM_TOOL = \
-        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-        -Ljava \
-        -randroid.hardware:hardware/interfaces \
-        -randroid.hidl:system/libhidl/transport \
-        android.hardware.health@2.0::IHealth
-
-$(GEN): $(LOCAL_PATH)/IHealth.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-#
-# Build IHealthInfoCallback.hal
-#
-GEN := $(intermediates)/android/hardware/health/V2_0/IHealthInfoCallback.java
-$(GEN): $(HIDL)
-$(GEN): PRIVATE_HIDL := $(HIDL)
-$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IHealthInfoCallback.hal
-$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
-$(GEN): PRIVATE_CUSTOM_TOOL = \
-        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-        -Ljava \
-        -randroid.hardware:hardware/interfaces \
-        -randroid.hidl:system/libhidl/transport \
-        android.hardware.health@2.0::IHealthInfoCallback
-
-$(GEN): $(LOCAL_PATH)/IHealthInfoCallback.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-include $(BUILD_JAVA_LIBRARY)
-
-
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/health/2.0/IHealthInfoCallback.hal b/health/2.0/IHealthInfoCallback.hal
index 8e17bb9..15352ee 100644
--- a/health/2.0/IHealthInfoCallback.hal
+++ b/health/2.0/IHealthInfoCallback.hal
@@ -16,8 +16,6 @@
 
 package android.hardware.health@2.0;
 
-import @1.0::HealthInfo;
-
 /**
  * IHealthInfoCallback is the callback interface to
  * {@link IHealthInfoBus.registerCallback}.
diff --git a/health/2.0/types.hal b/health/2.0/types.hal
index 89ea444..0d17f9f 100644
--- a/health/2.0/types.hal
+++ b/health/2.0/types.hal
@@ -16,6 +16,7 @@
 
 package android.hardware.health@2.0;
 
+import @1.0::HealthInfo;
 import @1.0::Result;
 
 /**
@@ -25,3 +26,40 @@
     NOT_FOUND,
     CALLBACK_DIED,
 };
+
+struct HealthInfo {
+    /**
+     * Legacy information from 1.0 HAL.
+     *
+     * If a value is not available, it must be set to 0, UNKNOWN, or empty
+     * string.
+     */
+    @1.0::HealthInfo legacy;
+
+    /**
+     * Average battery current in microamperes. Positive
+     * values indicate net current entering the battery from a charge source,
+     * negative values indicate net current discharging from the battery.
+     * The time period over which the average is computed may depend on the
+     * fuel gauge hardware and its configuration.
+     *
+     * If this value is not available, it must be set to 0.
+     */
+    int32_t batteryCurrentAverage;
+
+    /**
+     * Remaining battery capacity percentage of total capacity
+     * (with no fractional part). This value must be in the range 0-100
+     * (inclusive).
+     *
+     * If this value is not available, it must be set to 0.
+     */
+    int32_t batteryCapacity;
+
+    /**
+     * Battery remaining energy in nanowatt-hours.
+     *
+     * If this value is not available, it must be set to 0.
+     */
+    int64_t energyCounter;
+};
\ No newline at end of file
diff --git a/keymaster/3.0/default/Android.mk b/keymaster/3.0/default/Android.mk
index 9df5bf8..87ad245 100644
--- a/keymaster/3.0/default/Android.mk
+++ b/keymaster/3.0/default/Android.mk
@@ -11,7 +11,8 @@
     liblog \
     libsoftkeymasterdevice \
     libcrypto \
-    libkeymaster1 \
+    libkeymaster_portable \
+    libkeymaster_staging \
     libhidlbase \
     libhidltransport \
     libutils \
diff --git a/keymaster/3.0/default/KeymasterDevice.cpp b/keymaster/3.0/default/KeymasterDevice.cpp
index fcdd329..d83963f 100644
--- a/keymaster/3.0/default/KeymasterDevice.cpp
+++ b/keymaster/3.0/default/KeymasterDevice.cpp
@@ -64,7 +64,7 @@
     assert(mod->module_api_version < KEYMASTER_MODULE_API_VERSION_1_0);
     ALOGI("Found keymaster0 module %s, version %x", mod->name, mod->module_api_version);
 
-    UniquePtr<SoftKeymasterDevice> soft_keymaster(new SoftKeymasterDevice);
+    std::unique_ptr<SoftKeymasterDevice> soft_keymaster(new SoftKeymasterDevice);
     keymaster0_device_t* km0_device = NULL;
     keymaster_error_t error = KM_ERROR_OK;
 
@@ -107,7 +107,7 @@
     assert(mod->module_api_version >= KEYMASTER_MODULE_API_VERSION_1_0);
     ALOGI("Found keymaster1 module %s, version %x", mod->name, mod->module_api_version);
 
-    UniquePtr<SoftKeymasterDevice> soft_keymaster(new SoftKeymasterDevice);
+    std::unique_ptr<SoftKeymasterDevice> soft_keymaster(new SoftKeymasterDevice);
     keymaster1_device_t* km1_device = nullptr;
     keymaster_error_t error = KM_ERROR_OK;
 
diff --git a/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp b/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp
index 3448494..a3eb54c 100644
--- a/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp
+++ b/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp
@@ -17,7 +17,6 @@
 #include <radio_hidl_hal_utils_v1_0.h>
 
 int main(int argc, char** argv) {
-    ::testing::AddGlobalTestEnvironment(new RadioHidlEnvironment);
     ::testing::InitGoogleTest(&argc, argv);
 
     // setup seed for rand function
diff --git a/radio/1.0/vts/functional/VtsHalSapV1_0TargetTest.cpp b/radio/1.0/vts/functional/VtsHalSapV1_0TargetTest.cpp
index 5e5c50c..84b67c9 100644
--- a/radio/1.0/vts/functional/VtsHalSapV1_0TargetTest.cpp
+++ b/radio/1.0/vts/functional/VtsHalSapV1_0TargetTest.cpp
@@ -17,8 +17,6 @@
 #include <sap_hidl_hal_utils.h>
 
 int main(int argc, char** argv) {
-    // Add Sim-access Profile Hidl Environment
-    ::testing::AddGlobalTestEnvironment(new SapHidlEnvironment);
     ::testing::InitGoogleTest(&argc, argv);
 
     // setup seed for rand function
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_utils_v1_0.h b/radio/1.0/vts/functional/radio_hidl_hal_utils_v1_0.h
index b0d67da..b60887c 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_utils_v1_0.h
+++ b/radio/1.0/vts/functional/radio_hidl_hal_utils_v1_0.h
@@ -538,11 +538,4 @@
     sp<IRadio> radio;
     sp<RadioResponse> radioRsp;
     sp<RadioIndication> radioInd;
-};
-
-// A class for test environment setup
-class RadioHidlEnvironment : public ::testing::Environment {
-   public:
-    virtual void SetUp() {}
-    virtual void TearDown() {}
 };
\ No newline at end of file
diff --git a/radio/1.0/vts/functional/sap_hidl_hal_utils.h b/radio/1.0/vts/functional/sap_hidl_hal_utils.h
index 7126b06..fb142b7 100644
--- a/radio/1.0/vts/functional/sap_hidl_hal_utils.h
+++ b/radio/1.0/vts/functional/sap_hidl_hal_utils.h
@@ -102,11 +102,4 @@
 
     /* Sap Callback object */
     sp<SapCallback> sapCb;
-};
-
-// A class for test environment setup
-class SapHidlEnvironment : public ::testing::Environment {
-   public:
-    virtual void SetUp() {}
-    virtual void TearDown() {}
-};
+};
\ No newline at end of file
diff --git a/radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp b/radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp
index 09351c8..107a9e0 100644
--- a/radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp
+++ b/radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp
@@ -17,7 +17,6 @@
 #include <radio_hidl_hal_utils_v1_1.h>
 
 int main(int argc, char** argv) {
-    ::testing::AddGlobalTestEnvironment(new RadioHidlEnvironment);
     ::testing::InitGoogleTest(&argc, argv);
 
     int status = RUN_ALL_TESTS();
diff --git a/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h b/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h
index dd4f1ef..fc102a5 100644
--- a/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h
+++ b/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h
@@ -561,10 +561,3 @@
     sp<RadioResponse_v1_1> radioRsp_v1_1;
     sp<RadioIndication_v1_1> radioInd_v1_1;
 };
-
-// A class for test environment setup
-class RadioHidlEnvironment : public ::testing::Environment {
-   public:
-    virtual void SetUp() {}
-    virtual void TearDown() {}
-};
\ No newline at end of file
diff --git a/radio/1.2/Android.bp b/radio/1.2/Android.bp
new file mode 100644
index 0000000..d6535f5
--- /dev/null
+++ b/radio/1.2/Android.bp
@@ -0,0 +1,197 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+    name: "android.hardware.radio@1.2_hal",
+    srcs: [
+        "types.hal",
+        "IRadio.hal",
+        "ISap.hal",
+    ],
+}
+
+genrule {
+    name: "android.hardware.radio@1.2_genc++",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.radio@1.2",
+    srcs: [
+        ":android.hardware.radio@1.2_hal",
+    ],
+    out: [
+        "android/hardware/radio/1.2/types.cpp",
+        "android/hardware/radio/1.2/RadioAll.cpp",
+        "android/hardware/radio/1.2/SapAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.radio@1.2_genc++_headers",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.radio@1.2",
+    srcs: [
+        ":android.hardware.radio@1.2_hal",
+    ],
+    out: [
+        "android/hardware/radio/1.2/types.h",
+        "android/hardware/radio/1.2/hwtypes.h",
+        "android/hardware/radio/1.2/IRadio.h",
+        "android/hardware/radio/1.2/IHwRadio.h",
+        "android/hardware/radio/1.2/BnHwRadio.h",
+        "android/hardware/radio/1.2/BpHwRadio.h",
+        "android/hardware/radio/1.2/BsRadio.h",
+        "android/hardware/radio/1.2/ISap.h",
+        "android/hardware/radio/1.2/IHwSap.h",
+        "android/hardware/radio/1.2/BnHwSap.h",
+        "android/hardware/radio/1.2/BpHwSap.h",
+        "android/hardware/radio/1.2/BsSap.h",
+    ],
+}
+
+cc_library {
+    name: "android.hardware.radio@1.2",
+    defaults: ["hidl-module-defaults"],
+    generated_sources: ["android.hardware.radio@1.2_genc++"],
+    generated_headers: ["android.hardware.radio@1.2_genc++_headers"],
+    export_generated_headers: ["android.hardware.radio@1.2_genc++_headers"],
+    vendor_available: true,
+    vndk: {
+        enabled: true,
+    },
+    shared_libs: [
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "liblog",
+        "libutils",
+        "libcutils",
+        "android.hardware.radio@1.0",
+        "android.hardware.radio@1.1",
+    ],
+    export_shared_lib_headers: [
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "libutils",
+        "android.hardware.radio@1.0",
+        "android.hardware.radio@1.1",
+    ],
+}
+
+genrule {
+    name: "android.hardware.radio-V1.2-java_gen_java",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Ljava -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.radio@1.2",
+    srcs: [
+        ":android.hardware.radio@1.2_hal",
+    ],
+    out: [
+        "android/hardware/radio/V1_2/IncrementalResultsPeriodicityRange.java",
+        "android/hardware/radio/V1_2/MaxSearchTimeRange.java",
+        "android/hardware/radio/V1_2/NetworkScanRequest.java",
+        "android/hardware/radio/V1_2/RadioConst.java",
+        "android/hardware/radio/V1_2/ScanIntervalRange.java",
+        "android/hardware/radio/V1_2/IRadio.java",
+        "android/hardware/radio/V1_2/ISap.java",
+    ],
+}
+
+java_library {
+    name: "android.hardware.radio-V1.2-java",
+    no_framework_libs: true,
+    defaults: ["hidl-java-module-defaults"],
+    srcs: [":android.hardware.radio-V1.2-java_gen_java"],
+    libs: [
+        "hwbinder",
+        "android.hardware.radio-V1.0-java",
+        "android.hardware.radio-V1.1-java",
+        "android.hidl.base-V1.0-java",
+    ]
+}
+
+// This package does not export any types. Not creating java constants export.
+
+
+genrule {
+    name: "android.hardware.radio@1.2-adapter-helper_genc++",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++-adapter-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.radio@1.2",
+    srcs: [
+        ":android.hardware.radio@1.2_hal",
+    ],
+    out: [
+        "android/hardware/radio/1.2/ARadio.cpp",
+        "android/hardware/radio/1.2/ASap.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.radio@1.2-adapter-helper_genc++_headers",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++-adapter-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.radio@1.2",
+    srcs: [
+        ":android.hardware.radio@1.2_hal",
+    ],
+    out: [
+        "android/hardware/radio/1.2/ARadio.h",
+        "android/hardware/radio/1.2/ASap.h",
+    ],
+}
+
+cc_library {
+    name: "android.hardware.radio@1.2-adapter-helper",
+    defaults: ["hidl-module-defaults"],
+    generated_sources: ["android.hardware.radio@1.2-adapter-helper_genc++"],
+    generated_headers: ["android.hardware.radio@1.2-adapter-helper_genc++_headers"],
+    export_generated_headers: ["android.hardware.radio@1.2-adapter-helper_genc++_headers"],
+    vendor_available: true,
+    shared_libs: [
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "liblog",
+        "libutils",
+        "libcutils",
+        "libhidladapter",
+        "android.hardware.radio@1.0",
+        "android.hardware.radio@1.1",
+        "android.hardware.radio@1.2",
+        "android.hardware.radio@1.0-adapter-helper",
+        "android.hardware.radio@1.1-adapter-helper",
+        "android.hidl.base@1.0-adapter-helper",
+    ],
+    export_shared_lib_headers: [
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "libutils",
+        "libhidladapter",
+        "android.hardware.radio@1.0",
+        "android.hardware.radio@1.1",
+        "android.hardware.radio@1.2",
+        "android.hardware.radio@1.0-adapter-helper",
+        "android.hardware.radio@1.1-adapter-helper",
+        "android.hidl.base@1.0-adapter-helper",
+    ],
+}
+
+genrule {
+    name: "android.hardware.radio@1.2-adapter_genc++",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++-adapter-main -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.radio@1.2",
+    out: ["main.cpp"]
+}
+
+cc_test {
+    name: "android.hardware.radio@1.2-adapter",
+    defaults: ["hidl-module-defaults"],
+    shared_libs: [
+        "libhidladapter",
+        "libhidlbase",
+        "libhidltransport",
+        "libutils",
+        "android.hardware.radio@1.0",
+        "android.hardware.radio@1.1",
+        "android.hardware.radio@1.2",
+        "android.hardware.radio@1.2-adapter-helper",
+    ],
+    generated_sources: ["android.hardware.radio@1.2-adapter_genc++"],
+}
diff --git a/radio/1.2/IRadio.hal b/radio/1.2/IRadio.hal
new file mode 100644
index 0000000..6ae78a0
--- /dev/null
+++ b/radio/1.2/IRadio.hal
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+package android.hardware.radio@1.2;
+
+import @1.1::IRadio;
+
+/**
+ * This interface is used by telephony and telecom to talk to cellular radio.
+ * All the functions have minimum one parameter:
+ * serial: which corresponds to serial no. of request. Serial numbers must only be memorized for the
+ * duration of a method call. If clients provide colliding serials (including passing the same
+ * serial to different methods), multiple responses (one for each method call) must still be served.
+ * setResponseFunctions must work with @1.1::IRadioResponse and @1.1::IRadioIndication.
+ */
+interface IRadio extends @1.1::IRadio {
+
+    /**
+     * Starts a network scan
+     *
+     * @param serial Serial number of request.
+     * @param request Defines the radio networks/bands/channels which need to be scanned.
+     *
+     * Response function is IRadioResponse.startNetworkScanResponse()
+     */
+    oneway startNetworkScan_1_2(int32_t serial, NetworkScanRequest request);
+};
diff --git a/radio/1.2/ISap.hal b/radio/1.2/ISap.hal
new file mode 100644
index 0000000..757027c
--- /dev/null
+++ b/radio/1.2/ISap.hal
@@ -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.
+ */
+
+package android.hardware.radio@1.2;
+
+import @1.1::ISap;
+
+interface ISap extends @1.1::ISap {
+    /**
+     * Empty top level interface.
+     */
+};
diff --git a/radio/1.2/types.hal b/radio/1.2/types.hal
new file mode 100644
index 0000000..381eb85
--- /dev/null
+++ b/radio/1.2/types.hal
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+
+package android.hardware.radio@1.2;
+
+import @1.0::RadioConst;
+import @1.1::RadioAccessSpecifier;
+import @1.1::ScanType;
+
+enum RadioConst : @1.0::RadioConst {
+    RADIO_ACCESS_SPEFICIER_MAX_SIZE = 8,
+};
+
+/**
+ * values are in seconds
+ */
+enum ScanIntervalRange : int32_t {
+    MIN = 5,
+    MAX = 300,
+};
+
+/**
+ * value are in seconds
+ */
+enum MaxSearchTimeRange : int32_t {
+    MIN = 60,
+    MAX = 3600,
+};
+
+/**
+ * values are in seconds
+ */
+enum IncrementalResultsPeriodicityRange : int32_t {
+    MIN = 1,
+    MAX = 10,
+};
+
+struct NetworkScanRequest {
+    ScanType type;
+
+    /**
+     * Time interval in seconds between periodic scans, only valid when type = PERIODIC
+     * Range: ScanIntervalRange:MIN to ScanIntervalRange:MAX
+     */
+    int32_t interval;
+
+    /**
+     * Networks with bands/channels to scan
+     * Maximum length of the vector is
+     * RadioConst:RADIO_ACCESS_SPEFICIER_MAX_SIZE
+     */
+    vec<RadioAccessSpecifier> specifiers;
+
+    /**
+     * Maximum duration of the periodic search (in seconds).
+     * Expected range for the input is [MaxSearchTimeRange:MIN - MaxSearchTimeRange:MAX]
+     * If the search lasts maxSearchTime, it must be terminated.
+     */
+    int32_t maxSearchTime;
+
+    /**
+     * Indicates whether the modem must report incremental results of the network scan
+     * to the client.
+     * FALSE – Incremental results must not be reported.
+     * TRUE  – Incremental must be reported.
+     */
+    bool incrementalResults;
+
+    /**
+     * Indicates the periodicity with which the modem must report incremental results to
+     * the client (in seconds).
+     * Expected range for the input is
+     * [IncrementalResultsPeriodicityRange:MIN - IncrementalResultsPeriodicityRange:MAX]
+     * This value must be less than or equal to maxSearchTime.
+     */
+    int32_t incrementalResultsPeriodicity;
+
+    /**
+     * Describes the List of PLMN ids (MCC-MNC)
+     * If any PLMN of this list is found, search must end at that point and results with all
+     * PLMN found until that point should be sent as response.
+     * If the list is not sent, search to be completed until end and all PLMNs found to be
+     * reported.
+     */
+    vec<string> mccMncs;
+};
diff --git a/radio/Android.bp b/radio/Android.bp
index 0acb2ee..a209d9d 100644
--- a/radio/Android.bp
+++ b/radio/Android.bp
@@ -4,5 +4,6 @@
     "1.0/vts/functional",
     "1.1",
     "1.1/vts/functional",
+    "1.2",
     "deprecated/1.0",
 ]
diff --git a/tests/bar/1.0/default/Android.bp b/tests/bar/1.0/default/Android.bp
index 82d34a9..8aa6135 100644
--- a/tests/bar/1.0/default/Android.bp
+++ b/tests/bar/1.0/default/Android.bp
@@ -1,6 +1,6 @@
 
 
-cc_library_shared {
+cc_library {
     name: "android.hardware.tests.bar@1.0-impl",
     defaults: ["hidl_defaults"],
     relative_install_path: "hw",
@@ -14,10 +14,15 @@
         "libcutils",
         "libhidlbase",
         "libhidltransport",
+        "libhwbinder",
         "liblog",
         "libutils",
+    ],
+
+    // These are static libs only for testing purposes and portability. Shared
+    // libs should be used on device.
+    static_libs: [
         "android.hardware.tests.foo@1.0",
         "android.hardware.tests.bar@1.0",
     ],
-
 }
diff --git a/tests/baz/1.0/IBaz.hal b/tests/baz/1.0/IBaz.hal
index e4eb145..8c6a9a4 100644
--- a/tests/baz/1.0/IBaz.hal
+++ b/tests/baz/1.0/IBaz.hal
@@ -68,7 +68,6 @@
         bitfield<BitField> bf;
     };
 
-    @Fragile @NoReally(very="yes", array={"a","b","c"})
     oneway doThis(float param);
 
     doThatAndReturnSomething(int64_t param) generates (int32_t result);
diff --git a/tests/baz/1.0/default/Android.bp b/tests/baz/1.0/default/Android.bp
index f247b83..492e0b4 100644
--- a/tests/baz/1.0/default/Android.bp
+++ b/tests/baz/1.0/default/Android.bp
@@ -1,4 +1,4 @@
-cc_library_shared {
+cc_library {
     name: "android.hardware.tests.baz@1.0-impl",
     defaults: ["hidl_defaults"],
     relative_install_path: "hw",
@@ -7,9 +7,15 @@
     ],
     shared_libs: [
         "libbase",
+        "libcutils",
         "libhidlbase",
         "libhidltransport",
+        "libhwbinder",
+        "liblog",
         "libutils",
-        "android.hardware.tests.baz@1.0",
     ],
+
+    // These are static libs only for testing purposes and portability. Shared
+    // libs should be used on device.
+    static_libs: ["android.hardware.tests.baz@1.0"],
 }
diff --git a/tests/extension/light/2.0/default/Android.bp b/tests/extension/light/2.0/default/Android.bp
index 365a34a..dcac97c 100644
--- a/tests/extension/light/2.0/default/Android.bp
+++ b/tests/extension/light/2.0/default/Android.bp
@@ -16,6 +16,7 @@
 
 cc_binary {
     name: "android.hardware.tests.extension.light@2.0-service",
+    defaults: ["hidl_defaults"],
     init_rc: ["android.hardware.tests.extension.light@2.0-service.rc"],
     vendor: true,
     relative_install_path: "hw",
diff --git a/tests/extension/light/2.0/default/service.cpp b/tests/extension/light/2.0/default/service.cpp
index 4d839b2..af287e9 100644
--- a/tests/extension/light/2.0/default/service.cpp
+++ b/tests/extension/light/2.0/default/service.cpp
@@ -30,6 +30,8 @@
 int main() {
     android::sp<ILight> service = new Light();
     configureRpcThreadpool(1, true /*callerWillJoin*/);
-    service->registerAsService();
+    if (service->registerAsService() != android::OK) {
+        exit(1);
+    }
     joinRpcThreadpool();
 }
diff --git a/tests/foo/1.0/default/Android.bp b/tests/foo/1.0/default/Android.bp
index 0e1d34d..d9dfc69 100644
--- a/tests/foo/1.0/default/Android.bp
+++ b/tests/foo/1.0/default/Android.bp
@@ -1,6 +1,6 @@
 
 
-cc_library_shared {
+cc_library {
     name: "android.hardware.tests.foo@1.0-impl",
     defaults: ["hidl_defaults"],
     relative_install_path: "hw",
@@ -11,12 +11,16 @@
     shared_libs: [
         "libbase",
         "libcutils",
+        "libfootest",
         "libhidlbase",
         "libhidltransport",
-        "libfootest",
+        "libhwbinder",
         "liblog",
         "libutils",
-        "android.hardware.tests.foo@1.0",
     ],
 
+    // These are static libs only for testing purposes and portability. Shared
+    // libs should be used on device.
+    static_libs: ["android.hardware.tests.foo@1.0"],
+
 }
diff --git a/tests/foo/1.0/default/lib/Android.bp b/tests/foo/1.0/default/lib/Android.bp
index 895582c..2cc96c5 100644
--- a/tests/foo/1.0/default/lib/Android.bp
+++ b/tests/foo/1.0/default/lib/Android.bp
@@ -1,4 +1,4 @@
-cc_library_shared {
+cc_library {
     name: "libfootest",
     defaults: ["hidl_defaults"],
     srcs: [
@@ -6,10 +6,14 @@
     ],
 
     shared_libs: [
+        "libcutils",
         "libhidlbase",
         "libhidltransport",
-        "android.hardware.tests.foo@1.0",
+        "libhwbinder",
+        "liblog",
     ],
+    static_libs: ["android.hardware.tests.foo@1.0"],
+
     local_include_dirs: ["include/hidl-test"],
     export_include_dirs: ["include"],
 
diff --git a/tests/hash/1.0/default/Android.bp b/tests/hash/1.0/default/Android.bp
index 67f9097..6e6d6a8 100644
--- a/tests/hash/1.0/default/Android.bp
+++ b/tests/hash/1.0/default/Android.bp
@@ -1,4 +1,4 @@
-cc_library_shared {
+cc_library {
     name: "android.hardware.tests.hash@1.0-impl",
     defaults: ["hidl_defaults"],
     relative_install_path: "hw",
@@ -6,9 +6,15 @@
         "Hash.cpp",
     ],
     shared_libs: [
+        "libcutils",
         "libhidlbase",
         "libhidltransport",
+        "libhwbinder",
+        "liblog",
         "libutils",
-        "android.hardware.tests.hash@1.0",
     ],
+
+    // These are static libs only for testing purposes and portability. Shared
+    // libs should be used on device.
+    static_libs: ["android.hardware.tests.hash@1.0"],
 }
diff --git a/tests/inheritance/1.0/default/Android.bp b/tests/inheritance/1.0/default/Android.bp
index 158da4b..891355b 100644
--- a/tests/inheritance/1.0/default/Android.bp
+++ b/tests/inheritance/1.0/default/Android.bp
@@ -1,6 +1,6 @@
 
 
-cc_library_shared {
+cc_library {
     name: "android.hardware.tests.inheritance@1.0-impl",
     defaults: ["hidl_defaults"],
     relative_install_path: "hw",
@@ -12,11 +12,16 @@
 
     shared_libs: [
         "libbase",
+        "libcutils",
         "libhidlbase",
         "libhidltransport",
+        "libhwbinder",
         "liblog",
         "libutils",
-        "android.hardware.tests.inheritance@1.0",
     ],
 
+    // These are static libs only for testing purposes and portability. Shared
+    // libs should be used on device.
+    static_libs: ["android.hardware.tests.inheritance@1.0"],
+
 }
diff --git a/tests/memory/1.0/default/Android.bp b/tests/memory/1.0/default/Android.bp
index efd4165..985183b 100644
--- a/tests/memory/1.0/default/Android.bp
+++ b/tests/memory/1.0/default/Android.bp
@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-cc_library_shared {
+cc_library {
     name: "android.hardware.tests.memory@1.0-impl",
     defaults: ["hidl_defaults"],
     relative_install_path: "hw",
@@ -20,12 +20,17 @@
         "MemoryTest.cpp",
     ],
     shared_libs: [
+        "libcutils",
         "libhidlbase",
         "libhidltransport",
         "libhidlmemory",
+        "libhwbinder",
         "liblog",
         "libutils",
-        "android.hardware.tests.memory@1.0",
         "android.hidl.memory@1.0",
     ],
+
+    // These are static libs only for testing purposes and portability. Shared
+    // libs should be used on device.
+    static_libs: ["android.hardware.tests.memory@1.0"],
 }
\ No newline at end of file
diff --git a/tests/msgq/1.0/default/Android.bp b/tests/msgq/1.0/default/Android.bp
index be4fe94..6bbca24 100644
--- a/tests/msgq/1.0/default/Android.bp
+++ b/tests/msgq/1.0/default/Android.bp
@@ -13,7 +13,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-cc_library_shared {
+cc_library {
     name: "android.hardware.tests.msgq@1.0-impl",
     defaults: ["hidl_defaults"],
     relative_install_path: "hw",
@@ -27,10 +27,16 @@
         "libfmq",
         "libhidlbase",
         "libhidltransport",
+        "libhwbinder",
         "liblog",
         "libutils",
-        "android.hardware.tests.msgq@1.0",
     ],
+
+    // These are static libs only for testing purposes and portability. Shared
+    // libs should be used on device.
+    static_libs: [
+        "android.hardware.tests.msgq@1.0",
+    ]
 }
 
 cc_test {
@@ -59,10 +65,19 @@
     shared_libs: [
         "libbase",
         "libcutils",
+        "libfmq",
         "libhidlbase",
         "libhidltransport",
+        "libhwbinder",
         "liblog",
         "libutils",
-        "android.hardware.tests.msgq@1.0"
     ],
+
+    // Allow dlsym'ing self for statically linked passthrough implementations
+    ldflags: ["-rdynamic"],
+
+    // These are static libs only for testing purposes and portability. Shared
+    // libs should be used on device.
+    static_libs: ["android.hardware.tests.msgq@1.0"],
+    whole_static_libs: ["android.hardware.tests.msgq@1.0-impl"],
 }
diff --git a/tests/multithread/1.0/default/Android.bp b/tests/multithread/1.0/default/Android.bp
index a7a750a..a94ee3e 100644
--- a/tests/multithread/1.0/default/Android.bp
+++ b/tests/multithread/1.0/default/Android.bp
@@ -1,4 +1,4 @@
-cc_library_shared {
+cc_library {
     name: "android.hardware.tests.multithread@1.0-impl",
     defaults: ["hidl_defaults"],
     relative_install_path: "hw",
@@ -7,10 +7,15 @@
     ],
     shared_libs: [
         "libbase",
+        "libcutils",
         "libhidlbase",
         "libhidltransport",
+        "libhwbinder",
         "liblog",
         "libutils",
-        "android.hardware.tests.multithread@1.0",
     ],
+
+    // These are static libs only for testing purposes and portability. Shared
+    // libs should be used on device.
+    static_libs: ["android.hardware.tests.multithread@1.0"],
 }
diff --git a/tests/pointer/1.0/default/Android.bp b/tests/pointer/1.0/default/Android.bp
index 0c91edb..4825ac7 100644
--- a/tests/pointer/1.0/default/Android.bp
+++ b/tests/pointer/1.0/default/Android.bp
@@ -1,6 +1,6 @@
 
 
-cc_library_shared {
+cc_library {
     name: "android.hardware.tests.pointer@1.0-impl",
     defaults: ["hidl_defaults"],
     relative_install_path: "hw",
@@ -11,12 +11,17 @@
 
     shared_libs: [
         "libbase",
+        "libcutils",
         "libhidlbase",
         "libhidltransport",
+        "libhwbinder",
         "libpointertest",
         "liblog",
         "libutils",
-        "android.hardware.tests.pointer@1.0",
     ],
 
+    // These are static libs only for testing purposes and portability. Shared
+    // libs should be used on device.
+    static_libs: ["android.hardware.tests.pointer@1.0"],
+
 }
diff --git a/tests/pointer/1.0/default/lib/Android.bp b/tests/pointer/1.0/default/lib/Android.bp
index ae07b04..180906b 100644
--- a/tests/pointer/1.0/default/lib/Android.bp
+++ b/tests/pointer/1.0/default/lib/Android.bp
@@ -1,4 +1,4 @@
-cc_library_shared {
+cc_library {
     name: "libpointertest",
     defaults: ["hidl_defaults"],
     srcs: [
@@ -10,8 +10,9 @@
         "libhidlbase",
         "libhidltransport",
         "liblog",
-        "android.hardware.tests.pointer@1.0",
     ],
+    static_libs: ["android.hardware.tests.pointer@1.0"],
+
     local_include_dirs: ["include/hidl-test"],
     export_include_dirs: ["include"],
 
diff --git a/tests/trie/1.0/default/Android.bp b/tests/trie/1.0/default/Android.bp
index 315c8bb..948a8cb 100644
--- a/tests/trie/1.0/default/Android.bp
+++ b/tests/trie/1.0/default/Android.bp
@@ -1,4 +1,4 @@
-cc_library_shared {
+cc_library {
     name: "android.hardware.tests.trie@1.0-impl",
     defaults: ["hidl_defaults"],
     relative_install_path: "hw",
@@ -7,10 +7,15 @@
     ],
     shared_libs: [
         "libbase",
+        "libcutils",
         "libhidlbase",
         "libhidltransport",
+        "libhwbinder",
         "liblog",
         "libutils",
-        "android.hardware.tests.trie@1.0",
     ],
+
+    // These are static libs only for testing purposes and portability. Shared
+    // libs should be used on device.
+    static_libs: ["android.hardware.tests.trie@1.0"],
 }
diff --git a/usb/1.0/default/Android.bp b/usb/1.0/default/Android.bp
index 2ebe61f..64de821 100644
--- a/usb/1.0/default/Android.bp
+++ b/usb/1.0/default/Android.bp
@@ -14,6 +14,7 @@
 
 cc_binary {
     name: "android.hardware.usb@1.0-service",
+    defaults: ["hidl_defaults"],
     init_rc: ["android.hardware.usb@1.0-service.rc"],
     relative_install_path: "hw",
     vendor: true,
diff --git a/vibrator/1.0/default/Android.bp b/vibrator/1.0/default/Android.bp
index 9170b39..0c7d155 100644
--- a/vibrator/1.0/default/Android.bp
+++ b/vibrator/1.0/default/Android.bp
@@ -31,6 +31,7 @@
 
 cc_binary {
     name: "android.hardware.vibrator@1.0-service",
+    defaults: ["hidl_defaults"],
     init_rc: ["android.hardware.vibrator@1.0-service.rc"],
     vendor: true,
     relative_install_path: "hw",