Merge "Protect against null strings in hal wrapper implementation."
diff --git a/biometrics/fingerprint/2.1/vts/functional/Android.bp b/biometrics/fingerprint/2.1/vts/functional/Android.bp
index 7d2e83f..25f7cc0 100644
--- a/biometrics/fingerprint/2.1/vts/functional/Android.bp
+++ b/biometrics/fingerprint/2.1/vts/functional/Android.bp
@@ -30,12 +30,8 @@
     ],
     static_libs: ["libgtest"],
     cflags: [
-        "--coverage",
         "-O0",
         "-g",
-    ],
-    ldflags: [
-        "--coverage"
     ]
 }
 
diff --git a/boot/1.0/vts/functional/Android.bp b/boot/1.0/vts/functional/Android.bp
index 714a18b..6c28bf1 100644
--- a/boot/1.0/vts/functional/Android.bp
+++ b/boot/1.0/vts/functional/Android.bp
@@ -30,11 +30,7 @@
     ],
     static_libs: ["libgtest"],
     cflags: [
-        "--coverage",
         "-O0",
         "-g",
-    ],
-    ldflags: [
-        "--coverage"
     ]
 }
diff --git a/contexthub/1.0/vts/functional/Android.bp b/contexthub/1.0/vts/functional/Android.bp
index e78898e..1c011a0 100644
--- a/contexthub/1.0/vts/functional/Android.bp
+++ b/contexthub/1.0/vts/functional/Android.bp
@@ -27,12 +27,8 @@
     ],
     static_libs: ["libgtest"],
     cflags: [
-        "--coverage",
         "-O0",
         "-g",
-    ],
-    ldflags: [
-        "--coverage",
-    ],
+    ]
 }
 
diff --git a/example/Android.bp b/example/Android.bp
deleted file mode 100644
index ea6dbb5..0000000
--- a/example/Android.bp
+++ /dev/null
@@ -1,4 +0,0 @@
-// This is an autogenerated file, do not edit.
-subdirs = [
-    "extension/light/2.0",
-]
diff --git a/example/extension/light/2.0/Android.bp b/example/extension/light/2.0/Android.bp
deleted file mode 100644
index cf345da..0000000
--- a/example/extension/light/2.0/Android.bp
+++ /dev/null
@@ -1,62 +0,0 @@
-// This file is autogenerated by hidl-gen. Do not edit manually.
-
-filegroup {
-    name: "android.hardware.example.extension.light@2.0_hal",
-    srcs: [
-        "types.hal",
-        "IExtLight.hal",
-    ],
-}
-
-genrule {
-    name: "android.hardware.example.extension.light@2.0_genc++",
-    tools: ["hidl-gen"],
-    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.example.extension.light@2.0",
-    srcs: [
-        ":android.hardware.example.extension.light@2.0_hal",
-    ],
-    out: [
-        "android/hardware/example/extension/light/2.0/types.cpp",
-        "android/hardware/example/extension/light/2.0/ExtLightAll.cpp",
-    ],
-}
-
-genrule {
-    name: "android.hardware.example.extension.light@2.0_genc++_headers",
-    tools: ["hidl-gen"],
-    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.example.extension.light@2.0",
-    srcs: [
-        ":android.hardware.example.extension.light@2.0_hal",
-    ],
-    out: [
-        "android/hardware/example/extension/light/2.0/types.h",
-        "android/hardware/example/extension/light/2.0/IExtLight.h",
-        "android/hardware/example/extension/light/2.0/IHwExtLight.h",
-        "android/hardware/example/extension/light/2.0/BnHwExtLight.h",
-        "android/hardware/example/extension/light/2.0/BpHwExtLight.h",
-        "android/hardware/example/extension/light/2.0/BsExtLight.h",
-    ],
-}
-
-cc_library_shared {
-    name: "android.hardware.example.extension.light@2.0",
-    generated_sources: ["android.hardware.example.extension.light@2.0_genc++"],
-    generated_headers: ["android.hardware.example.extension.light@2.0_genc++_headers"],
-    export_generated_headers: ["android.hardware.example.extension.light@2.0_genc++_headers"],
-    shared_libs: [
-        "libhidlbase",
-        "libhidltransport",
-        "libhwbinder",
-        "liblog",
-        "libutils",
-        "libcutils",
-        "android.hardware.light@2.0",
-    ],
-    export_shared_lib_headers: [
-        "libhidlbase",
-        "libhidltransport",
-        "libhwbinder",
-        "libutils",
-        "android.hardware.light@2.0",
-    ],
-}
diff --git a/example/extension/light/2.0/default/Android.mk b/example/extension/light/2.0/default/Android.mk
deleted file mode 100644
index acd9638..0000000
--- a/example/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.example.extension.light@2.0-service
-LOCAL_INIT_RC := android.hardware.example.extension.light@2.0-service.rc
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SRC_FILES := \
-    Light.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
-    libhidlbase \
-    libhidltransport \
-    libhwbinder \
-    libutils \
-    android.hardware.light@2.0 \
-    android.hardware.example.extension.light@2.0 \
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/example/extension/light/2.0/default/android.hardware.example.extension.light@2.0-service.rc b/example/extension/light/2.0/default/android.hardware.example.extension.light@2.0-service.rc
deleted file mode 100644
index 7480a7e..0000000
--- a/example/extension/light/2.0/default/android.hardware.example.extension.light@2.0-service.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service light-ext-2-0 /vendor/bin/hw/android.hardware.example.extension.light@2.0-service
-    class hal
-    user system
-    group system readproc
\ No newline at end of file
diff --git a/gatekeeper/1.0/vts/functional/Android.bp b/gatekeeper/1.0/vts/functional/Android.bp
index e79e40e..70a85c6 100644
--- a/gatekeeper/1.0/vts/functional/Android.bp
+++ b/gatekeeper/1.0/vts/functional/Android.bp
@@ -31,11 +31,7 @@
     ],
     static_libs: ["libgtest"],
     cflags: [
-        "--coverage",
         "-O0",
         "-g",
-    ],
-    ldflags: [
-        "--coverage"
     ]
 }
diff --git a/graphics/allocator/2.0/vts/functional/Android.bp b/graphics/allocator/2.0/vts/functional/Android.bp
index 194b228..2f58836 100644
--- a/graphics/allocator/2.0/vts/functional/Android.bp
+++ b/graphics/allocator/2.0/vts/functional/Android.bp
@@ -31,11 +31,7 @@
     ],
     static_libs: ["libgtest"],
     cflags: [
-        "--coverage",
         "-O0",
         "-g",
-    ],
-    ldflags: [
-        "--coverage",
-    ],
+    ]
 }
diff --git a/graphics/composer/2.1/vts/functional/Android.bp b/graphics/composer/2.1/vts/functional/Android.bp
index c3f7636..aa2eae3 100644
--- a/graphics/composer/2.1/vts/functional/Android.bp
+++ b/graphics/composer/2.1/vts/functional/Android.bp
@@ -35,11 +35,7 @@
     ],
     static_libs: ["libgtest", "libhwcomposer-command-buffer"],
     cflags: [
-        "--coverage",
         "-O0",
         "-g",
-    ],
-    ldflags: [
-        "--coverage",
-    ],
+    ]
 }
diff --git a/graphics/mapper/2.0/vts/functional/Android.bp b/graphics/mapper/2.0/vts/functional/Android.bp
index 27ea350..efb868b 100644
--- a/graphics/mapper/2.0/vts/functional/Android.bp
+++ b/graphics/mapper/2.0/vts/functional/Android.bp
@@ -34,11 +34,7 @@
     ],
     static_libs: ["libgtest"],
     cflags: [
-        "--coverage",
         "-O0",
         "-g",
-    ],
-    ldflags: [
-        "--coverage",
-    ],
+    ]
 }
diff --git a/light/2.0/vts/functional/Android.bp b/light/2.0/vts/functional/Android.bp
index 889457f..53f5d7f 100644
--- a/light/2.0/vts/functional/Android.bp
+++ b/light/2.0/vts/functional/Android.bp
@@ -27,12 +27,8 @@
     ],
     static_libs: ["libgtest"],
     cflags: [
-        "--coverage",
         "-O0",
         "-g",
-    ],
-    ldflags: [
-        "--coverage"
     ]
 }
 
diff --git a/media/omx/1.0/IOmxBufferProducer.hal b/media/omx/1.0/IOmxBufferProducer.hal
index d4cf5f7..7e2172b 100644
--- a/media/omx/1.0/IOmxBufferProducer.hal
+++ b/media/omx/1.0/IOmxBufferProducer.hal
@@ -72,12 +72,27 @@
     };
 
     /**
+     * Ref: frameworks/native/include/gui/FrameTimestamp.h: CompositorTiming
+     *
+     * The most recent compositor timing info sent from consumer to producer
+     * through a HIDL interface.
+     */
+    struct CompositorTiming {
+        int64_t deadlineNs;
+        int64_t intervalNs;
+        int64_t presentLatencyNs;
+    };
+
+    /**
      * Ref: frameworks/native/include/gui/FrameTimestamp.h: FrameEventHistoryDelta
      *
      * A collection of updates from consumer to producer that can be sent
      * through a HIDL interface.
      */
-    typedef vec<FrameEventsDelta> FrameEventHistoryDelta;
+    struct FrameEventHistoryDelta {
+        vec<FrameEventsDelta> deltas;
+        CompositorTiming compositorTiming;
+    };
 
     /**
      * Modes for disconnection.
diff --git a/memtrack/1.0/vts/functional/Android.bp b/memtrack/1.0/vts/functional/Android.bp
index b3e560a..0f57adc 100644
--- a/memtrack/1.0/vts/functional/Android.bp
+++ b/memtrack/1.0/vts/functional/Android.bp
@@ -30,11 +30,7 @@
     ],
     static_libs: ["libgtest"],
     cflags: [
-        "--coverage",
         "-O0",
         "-g",
-    ],
-    ldflags: [
-        "--coverage"
     ]
 }
diff --git a/power/1.0/vts/functional/Android.bp b/power/1.0/vts/functional/Android.bp
index 81dc316..7aa2611 100644
--- a/power/1.0/vts/functional/Android.bp
+++ b/power/1.0/vts/functional/Android.bp
@@ -31,11 +31,7 @@
     ],
     static_libs: ["libgtest"],
     cflags: [
-        "--coverage",
         "-O0",
         "-g",
-    ],
-    ldflags: [
-        "--coverage"
     ]
 }
diff --git a/tests/Android.bp b/tests/Android.bp
index 337e4f4..040a6fb 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -4,6 +4,7 @@
     "bar/1.0/default",
     "baz/1.0",
     "expression/1.0",
+    "extension/light/2.0",
     "foo/1.0",
     "foo/1.0/default",
     "foo/1.0/default/lib",
diff --git a/tests/extension/light/2.0/Android.bp b/tests/extension/light/2.0/Android.bp
new file mode 100644
index 0000000..5203da6
--- /dev/null
+++ b/tests/extension/light/2.0/Android.bp
@@ -0,0 +1,62 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+    name: "android.hardware.tests.extension.light@2.0_hal",
+    srcs: [
+        "types.hal",
+        "IExtLight.hal",
+    ],
+}
+
+genrule {
+    name: "android.hardware.tests.extension.light@2.0_genc++",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.tests.extension.light@2.0",
+    srcs: [
+        ":android.hardware.tests.extension.light@2.0_hal",
+    ],
+    out: [
+        "android/hardware/tests/extension/light/2.0/types.cpp",
+        "android/hardware/tests/extension/light/2.0/ExtLightAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.tests.extension.light@2.0_genc++_headers",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.tests.extension.light@2.0",
+    srcs: [
+        ":android.hardware.tests.extension.light@2.0_hal",
+    ],
+    out: [
+        "android/hardware/tests/extension/light/2.0/types.h",
+        "android/hardware/tests/extension/light/2.0/IExtLight.h",
+        "android/hardware/tests/extension/light/2.0/IHwExtLight.h",
+        "android/hardware/tests/extension/light/2.0/BnHwExtLight.h",
+        "android/hardware/tests/extension/light/2.0/BpHwExtLight.h",
+        "android/hardware/tests/extension/light/2.0/BsExtLight.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.tests.extension.light@2.0",
+    generated_sources: ["android.hardware.tests.extension.light@2.0_genc++"],
+    generated_headers: ["android.hardware.tests.extension.light@2.0_genc++_headers"],
+    export_generated_headers: ["android.hardware.tests.extension.light@2.0_genc++_headers"],
+    shared_libs: [
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "liblog",
+        "libutils",
+        "libcutils",
+        "android.hardware.light@2.0",
+    ],
+    export_shared_lib_headers: [
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "libutils",
+        "android.hardware.light@2.0",
+    ],
+}
diff --git a/example/extension/light/2.0/Android.mk b/tests/extension/light/2.0/Android.mk
similarity index 77%
rename from example/extension/light/2.0/Android.mk
rename to tests/extension/light/2.0/Android.mk
index 0b79747..16424a3 100644
--- a/example/extension/light/2.0/Android.mk
+++ b/tests/extension/light/2.0/Android.mk
@@ -5,7 +5,7 @@
 ################################################################################
 
 include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.example.extension.light@2.0-java
+LOCAL_MODULE := android.hardware.tests.extension.light@2.0-java
 LOCAL_MODULE_CLASS := JAVA_LIBRARIES
 
 intermediates := $(call local-generated-sources-dir, COMMON)
@@ -20,7 +20,7 @@
 #
 # Build types.hal (Default)
 #
-GEN := $(intermediates)/android/hardware/example/extension/light/V2_0/Default.java
+GEN := $(intermediates)/android/hardware/tests/extension/light/V2_0/Default.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -30,7 +30,7 @@
         -Ljava \
         -randroid.hardware:hardware/interfaces \
         -randroid.hidl:system/libhidl/transport \
-        android.hardware.example.extension.light@2.0::types.Default
+        android.hardware.tests.extension.light@2.0::types.Default
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
@@ -39,7 +39,7 @@
 #
 # Build types.hal (ExtBrightness)
 #
-GEN := $(intermediates)/android/hardware/example/extension/light/V2_0/ExtBrightness.java
+GEN := $(intermediates)/android/hardware/tests/extension/light/V2_0/ExtBrightness.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -49,7 +49,7 @@
         -Ljava \
         -randroid.hardware:hardware/interfaces \
         -randroid.hidl:system/libhidl/transport \
-        android.hardware.example.extension.light@2.0::types.ExtBrightness
+        android.hardware.tests.extension.light@2.0::types.ExtBrightness
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
@@ -58,7 +58,7 @@
 #
 # Build types.hal (ExtLightState)
 #
-GEN := $(intermediates)/android/hardware/example/extension/light/V2_0/ExtLightState.java
+GEN := $(intermediates)/android/hardware/tests/extension/light/V2_0/ExtLightState.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -68,7 +68,7 @@
         -Ljava \
         -randroid.hardware:hardware/interfaces \
         -randroid.hidl:system/libhidl/transport \
-        android.hardware.example.extension.light@2.0::types.ExtLightState
+        android.hardware.tests.extension.light@2.0::types.ExtLightState
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
@@ -77,7 +77,7 @@
 #
 # Build IExtLight.hal
 #
-GEN := $(intermediates)/android/hardware/example/extension/light/V2_0/IExtLight.java
+GEN := $(intermediates)/android/hardware/tests/extension/light/V2_0/IExtLight.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IExtLight.hal
@@ -89,7 +89,7 @@
         -Ljava \
         -randroid.hardware:hardware/interfaces \
         -randroid.hidl:system/libhidl/transport \
-        android.hardware.example.extension.light@2.0::IExtLight
+        android.hardware.tests.extension.light@2.0::IExtLight
 
 $(GEN): $(LOCAL_PATH)/IExtLight.hal
 	$(transform-generated-source)
@@ -100,7 +100,7 @@
 ################################################################################
 
 include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.example.extension.light@2.0-java-static
+LOCAL_MODULE := android.hardware.tests.extension.light@2.0-java-static
 LOCAL_MODULE_CLASS := JAVA_LIBRARIES
 
 intermediates := $(call local-generated-sources-dir, COMMON)
@@ -115,7 +115,7 @@
 #
 # Build types.hal (Default)
 #
-GEN := $(intermediates)/android/hardware/example/extension/light/V2_0/Default.java
+GEN := $(intermediates)/android/hardware/tests/extension/light/V2_0/Default.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -125,7 +125,7 @@
         -Ljava \
         -randroid.hardware:hardware/interfaces \
         -randroid.hidl:system/libhidl/transport \
-        android.hardware.example.extension.light@2.0::types.Default
+        android.hardware.tests.extension.light@2.0::types.Default
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
@@ -134,7 +134,7 @@
 #
 # Build types.hal (ExtBrightness)
 #
-GEN := $(intermediates)/android/hardware/example/extension/light/V2_0/ExtBrightness.java
+GEN := $(intermediates)/android/hardware/tests/extension/light/V2_0/ExtBrightness.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -144,7 +144,7 @@
         -Ljava \
         -randroid.hardware:hardware/interfaces \
         -randroid.hidl:system/libhidl/transport \
-        android.hardware.example.extension.light@2.0::types.ExtBrightness
+        android.hardware.tests.extension.light@2.0::types.ExtBrightness
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
@@ -153,7 +153,7 @@
 #
 # Build types.hal (ExtLightState)
 #
-GEN := $(intermediates)/android/hardware/example/extension/light/V2_0/ExtLightState.java
+GEN := $(intermediates)/android/hardware/tests/extension/light/V2_0/ExtLightState.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -163,7 +163,7 @@
         -Ljava \
         -randroid.hardware:hardware/interfaces \
         -randroid.hidl:system/libhidl/transport \
-        android.hardware.example.extension.light@2.0::types.ExtLightState
+        android.hardware.tests.extension.light@2.0::types.ExtLightState
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
@@ -172,7 +172,7 @@
 #
 # Build IExtLight.hal
 #
-GEN := $(intermediates)/android/hardware/example/extension/light/V2_0/IExtLight.java
+GEN := $(intermediates)/android/hardware/tests/extension/light/V2_0/IExtLight.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IExtLight.hal
@@ -184,7 +184,7 @@
         -Ljava \
         -randroid.hardware:hardware/interfaces \
         -randroid.hidl:system/libhidl/transport \
-        android.hardware.example.extension.light@2.0::IExtLight
+        android.hardware.tests.extension.light@2.0::IExtLight
 
 $(GEN): $(LOCAL_PATH)/IExtLight.hal
 	$(transform-generated-source)
diff --git a/example/extension/light/2.0/IExtLight.hal b/tests/extension/light/2.0/IExtLight.hal
similarity index 95%
rename from example/extension/light/2.0/IExtLight.hal
rename to tests/extension/light/2.0/IExtLight.hal
index f12a272..1515b86 100644
--- a/example/extension/light/2.0/IExtLight.hal
+++ b/tests/extension/light/2.0/IExtLight.hal
@@ -17,7 +17,7 @@
 // Would normally be 'vendor.example.extension.light@2.0' however, this is
 // a google extension example. A vendor extension should also live in the
 // vendor partition.
-package android.hardware.example.extension.light@2.0;
+package android.hardware.tests.extension.light@2.0;
 
 import android.hardware.light@2.0;
 
diff --git a/tests/extension/light/2.0/default/Android.mk b/tests/extension/light/2.0/default/Android.mk
new file mode 100644
index 0000000..4dee3ee
--- /dev/null
+++ b/tests/extension/light/2.0/default/Android.mk
@@ -0,0 +1,20 @@
+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 \
+    libhwbinder \
+    libutils \
+    android.hardware.light@2.0 \
+    android.hardware.tests.extension.light@2.0 \
+
+include $(BUILD_EXECUTABLE)
diff --git a/example/extension/light/2.0/default/Light.cpp b/tests/extension/light/2.0/default/Light.cpp
similarity index 97%
rename from example/extension/light/2.0/default/Light.cpp
rename to tests/extension/light/2.0/default/Light.cpp
index 2e56319..d941e73 100644
--- a/example/extension/light/2.0/default/Light.cpp
+++ b/tests/extension/light/2.0/default/Light.cpp
@@ -17,7 +17,7 @@
 
 namespace android {
 namespace hardware {
-namespace example {
+namespace tests {
 namespace extension {
 namespace light {
 namespace V2_0 {
@@ -66,6 +66,6 @@
 }  // namespace V2_0
 }  // namespace light
 }  // namespace extension
-}  // namespace example
+}  // namespace tests
 }  // namespace hardware
 }  // namespace android
diff --git a/example/extension/light/2.0/default/Light.h b/tests/extension/light/2.0/default/Light.h
similarity index 79%
rename from example/extension/light/2.0/default/Light.h
rename to tests/extension/light/2.0/default/Light.h
index e3b60df..dc2c5dd 100644
--- a/example/extension/light/2.0/default/Light.h
+++ b/tests/extension/light/2.0/default/Light.h
@@ -13,23 +13,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef ANDROID_HARDWARE_EXAMPLE_EXTENSION_LIGHT_V2_0_LIGHT_H
-#define ANDROID_HARDWARE_EXAMPLE_EXTENSION_LIGHT_V2_0_LIGHT_H
+#ifndef ANDROID_HARDWARE_TESTS_EXTENSION_LIGHT_V2_0_LIGHT_H
+#define ANDROID_HARDWARE_TESTS_EXTENSION_LIGHT_V2_0_LIGHT_H
 
-#include <android/hardware/example/extension/light/2.0/IExtLight.h>
+#include <android/hardware/tests/extension/light/2.0/IExtLight.h>
 #include <hidl/Status.h>
 
 #include <hidl/MQDescriptor.h>
 namespace android {
 namespace hardware {
-namespace example {
+namespace tests {
 namespace extension {
 namespace light {
 namespace V2_0 {
 namespace implementation {
 
-using ::android::hardware::example::extension::light::V2_0::ExtLightState;
-using ::android::hardware::example::extension::light::V2_0::IExtLight;
+using ::android::hardware::tests::extension::light::V2_0::ExtLightState;
+using ::android::hardware::tests::extension::light::V2_0::IExtLight;
 using ::android::hardware::light::V2_0::ILight;
 using ::android::hardware::light::V2_0::LightState;
 using ::android::hardware::light::V2_0::Status;
@@ -54,8 +54,8 @@
 }  // namespace V2_0
 }  // namespace light
 }  // namespace extension
-}  // namespace example
+}  // namespace tests
 }  // namespace hardware
 }  // namespace android
 
-#endif  // ANDROID_HARDWARE_EXAMPLE_EXTENSION_LIGHT_V2_0_LIGHT_H
+#endif  // ANDROID_HARDWARE_TESTS_EXTENSION_LIGHT_V2_0_LIGHT_H
diff --git a/tests/extension/light/2.0/default/android.hardware.tests.extension.light@2.0-service.rc b/tests/extension/light/2.0/default/android.hardware.tests.extension.light@2.0-service.rc
new file mode 100644
index 0000000..8f379ee
--- /dev/null
+++ b/tests/extension/light/2.0/default/android.hardware.tests.extension.light@2.0-service.rc
@@ -0,0 +1,4 @@
+service light-ext-2-0 /vendor/bin/hw/android.hardware.tests.extension.light@2.0-service
+    class hal
+    user system
+    group system
\ No newline at end of file
diff --git a/example/extension/light/2.0/default/service.cpp b/tests/extension/light/2.0/default/service.cpp
similarity index 87%
rename from example/extension/light/2.0/default/service.cpp
rename to tests/extension/light/2.0/default/service.cpp
index 07afe79..4d839b2 100644
--- a/example/extension/light/2.0/default/service.cpp
+++ b/tests/extension/light/2.0/default/service.cpp
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#define LOG_TAG "android.hardware.light@2.0-service"
+#define LOG_TAG "android.hardware.tests.extension.light@2.0-service"
 
 #include <android/log.h>
 #include <hidl/HidlTransportSupport.h>
@@ -24,8 +24,8 @@
 using android::hardware::joinRpcThreadpool;
 using android::sp;
 
-// Generated HIDL files
 using android::hardware::light::V2_0::ILight;
+using android::hardware::tests::extension::light::V2_0::implementation::Light;
 
 int main() {
     android::sp<ILight> service = new Light();
diff --git a/example/extension/light/2.0/types.hal b/tests/extension/light/2.0/types.hal
similarity index 97%
rename from example/extension/light/2.0/types.hal
rename to tests/extension/light/2.0/types.hal
index 5be41bb..1b09479 100644
--- a/example/extension/light/2.0/types.hal
+++ b/tests/extension/light/2.0/types.hal
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.example.extension.light@2.0;
+package android.hardware.tests.extension.light@2.0;
 
 import android.hardware.light@2.0;
 
diff --git a/tests/msgq/1.0/ITestMsgQ.hal b/tests/msgq/1.0/ITestMsgQ.hal
index 3ed1b37..dfb9be4 100644
--- a/tests/msgq/1.0/ITestMsgQ.hal
+++ b/tests/msgq/1.0/ITestMsgQ.hal
@@ -34,15 +34,19 @@
         generates(bool ret, fmq_sync<uint16_t> mqDesc);
 
     /*
-     * This method requests the service to set up an unsynchronized write
-     * wait-free FMQ with the client as reader.
+     * This method requests the service to return an MQDescriptor to
+     * an unsynchronized FMQ set up by the server. If 'configureFmq' is
+     * true, then the server sets up a new unsynchronized FMQ. This
+     * method is to be used to test multiple reader processes.
      *
-     * @return ret True if the setup is successful.
-     * @return mqDesc This structure describes the FMQ that was
+     * @param configureFmq The server sets up a new unsynchronized FMQ if
+     * this parameter is true.
+     *
+     * @return ret True if successful.
+     * @return mqDesc This structure describes the unsynchronized FMQ that was
      * set up by the service. Client can use it to set up the FMQ at its end.
      */
-    configureFmqUnsyncWrite()
-        generates(bool ret, fmq_unsync<uint16_t> mqDesc);
+    getFmqUnsyncWrite(bool configureFmq) generates(bool ret, fmq_unsync<uint16_t> mqDesc);
 
     /*
      * This method request the service to write into the synchronized read/write
diff --git a/thermal/1.0/vts/functional/Android.bp b/thermal/1.0/vts/functional/Android.bp
index bef7bc2..fedb760 100644
--- a/thermal/1.0/vts/functional/Android.bp
+++ b/thermal/1.0/vts/functional/Android.bp
@@ -31,12 +31,8 @@
     ],
     static_libs: ["libgtest"],
     cflags: [
-        "--coverage",
         "-O0",
         "-g",
     ],
-    ldflags: [
-        "--coverage"
-    ]
 }
 
diff --git a/tv/input/1.0/vts/functional/Android.bp b/tv/input/1.0/vts/functional/Android.bp
index 979eb99..c327733 100644
--- a/tv/input/1.0/vts/functional/Android.bp
+++ b/tv/input/1.0/vts/functional/Android.bp
@@ -31,13 +31,8 @@
     ],
     static_libs: ["libgtest"],
     cflags: [
-// TODO: add --coverage when the segfault issue is fixed.
-//        "--coverage",
         "-O0",
         "-g",
-    ],
-//    ldflags: [
-//        "--coverage"
-//    ]
+    ]
 }
 
diff --git a/vr/1.0/vts/functional/Android.bp b/vr/1.0/vts/functional/Android.bp
index 551f27c..529f92d 100644
--- a/vr/1.0/vts/functional/Android.bp
+++ b/vr/1.0/vts/functional/Android.bp
@@ -26,11 +26,7 @@
     ],
     static_libs: ["libgtest"],
     cflags: [
-       "--coverage",
        "-O0",
         "-g",
-    ],
-    ldflags: [
-        "--coverage"
     ]
 }
diff --git a/wifi/.clang-format b/wifi/.clang-format
new file mode 100644
index 0000000..25ed932
--- /dev/null
+++ b/wifi/.clang-format
@@ -0,0 +1,2 @@
+BasedOnStyle: Google
+IndentWidth: 4
\ No newline at end of file
diff --git a/wifi/1.0/vts/functional/Android.bp b/wifi/1.0/vts/functional/Android.bp
index e2cd7b1..8a5d7e0 100644
--- a/wifi/1.0/vts/functional/Android.bp
+++ b/wifi/1.0/vts/functional/Android.bp
@@ -21,6 +21,7 @@
         "main.cpp",
         "wifi_ap_iface_hidl_test.cpp",
         "wifi_chip_hidl_test.cpp",
+        "wifi_hidl_call_util_selftest.cpp",
         "wifi_hidl_test.cpp",
         "wifi_hidl_test_utils.cpp",
         "wifi_nan_iface_hidl_test.cpp",
diff --git a/wifi/1.0/vts/functional/wifi_hidl_call_util.h b/wifi/1.0/vts/functional/wifi_hidl_call_util.h
new file mode 100644
index 0000000..03200a0
--- /dev/null
+++ b/wifi/1.0/vts/functional/wifi_hidl_call_util.h
@@ -0,0 +1,123 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <functional>
+#include <tuple>
+#include <type_traits>
+#include <utility>
+
+#include <gtest/gtest.h>
+
+namespace {
+namespace detail {
+template <typename>
+struct functionArgSaver;
+
+// Provides a std::function that takes one argument, and a buffer
+// wherein the function will store its argument. The buffer has
+// the same type as the argument, but with const and reference
+// modifiers removed.
+template <typename ArgT>
+struct functionArgSaver<std::function<void(ArgT)>> final {
+    using StorageT = typename std::remove_const<
+        typename std::remove_reference<ArgT>::type>::type;
+
+    std::function<void(ArgT)> saveArgs = [this](ArgT arg) {
+        this->saved_values = arg;
+    };
+
+    StorageT saved_values;
+};
+
+// Provides a std::function that takes two arguments, and a buffer
+// wherein the function will store its arguments. The buffer is a
+// std::pair, whose elements have the same types as the arguments
+// (but with const and reference modifiers removed).
+template <typename Arg1T, typename Arg2T>
+struct functionArgSaver<std::function<void(Arg1T, Arg2T)>> final {
+    using StorageT =
+        std::pair<typename std::remove_const<
+                      typename std::remove_reference<Arg1T>::type>::type,
+                  typename std::remove_const<
+                      typename std::remove_reference<Arg2T>::type>::type>;
+
+    std::function<void(Arg1T, Arg2T)> saveArgs = [this](Arg1T arg1,
+                                                        Arg2T arg2) {
+        this->saved_values = {arg1, arg2};
+    };
+
+    StorageT saved_values;
+};
+
+// Provides a std::function that takes three or more arguments, and a
+// buffer wherein the function will store its arguments. The buffer is a
+// std::tuple whose elements have the same types as the arguments (but
+// with const and reference modifiers removed).
+template <typename... ArgT>
+struct functionArgSaver<std::function<void(ArgT...)>> final {
+    using StorageT = std::tuple<typename std::remove_const<
+        typename std::remove_reference<ArgT>::type>::type...>;
+
+    std::function<void(ArgT...)> saveArgs = [this](ArgT... arg) {
+        this->saved_values = {arg...};
+    };
+
+    StorageT saved_values;
+};
+
+// Invokes |method| on |object|, providing |method| a CallbackT as the
+// final argument. Returns a copy of the parameters that |method| provided
+// to CallbackT. (The parameters are returned by value.)
+template <typename CallbackT, typename MethodT, typename ObjectT,
+          typename... ArgT>
+typename functionArgSaver<CallbackT>::StorageT invokeMethod(
+    MethodT method, ObjectT object, ArgT&&... methodArg) {
+    functionArgSaver<CallbackT> result_buffer;
+    const auto& res = ((*object).*method)(std::forward<ArgT>(methodArg)...,
+                                          result_buffer.saveArgs);
+    EXPECT_TRUE(res.isOk());
+    return result_buffer.saved_values;
+}
+}  // namespace detail
+}  // namespace
+
+// Invokes |method| on |strong_pointer|, passing provided arguments through to
+// |method|.
+//
+// Returns either:
+// - A copy of the result callback parameter (for callbacks with a single
+//   parameter), OR
+// - A pair containing a copy of the result callback parameters (for callbacks
+//   with two parameters), OR
+// - A tuple containing a copy of the result callback paramters (for callbacks
+//   with three or more parameters).
+//
+// Example usage:
+//   EXPECT_EQ(WifiStatusCode::SUCCESS,
+//       HIDL_INVOKE(strong_pointer, methodReturningWifiStatus).code);
+//   EXPECT_EQ(WifiStatusCode::SUCCESS,
+//       HIDL_INVOKE(strong_pointer, methodReturningWifiStatusAndOneMore)
+//         .first.code);
+//   EXPECT_EQ(WifiStatusCode::SUCCESS, std::get<0>(
+//       HIDL_INVOKE(strong_pointer, methodReturningWifiStatusAndTwoMore))
+//         .code);
+#define HIDL_INVOKE(strong_pointer, method, ...)                              \
+    (detail::invokeMethod<                                                    \
+        std::remove_reference<decltype(*strong_pointer)>::type::method##_cb>( \
+        &std::remove_reference<decltype(*strong_pointer)>::type::method,      \
+        strong_pointer, ##__VA_ARGS__))
diff --git a/wifi/1.0/vts/functional/wifi_hidl_call_util_selftest.cpp b/wifi/1.0/vts/functional/wifi_hidl_call_util_selftest.cpp
new file mode 100644
index 0000000..129bdb2
--- /dev/null
+++ b/wifi/1.0/vts/functional/wifi_hidl_call_util_selftest.cpp
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ */
+
+#include <functional>
+#include <type_traits>
+
+#include <hidl/Status.h>
+#include <utils/RefBase.h>
+#include <utils/StrongPointer.h>
+
+#include "wifi_hidl_call_util.h"
+
+namespace {
+/*
+ * Example of a user-defined data-type.
+ *
+ * Used to verify that, within the internals of HIDL_INVOKE,
+ * reference parameters are stored by copy.
+ */
+class Dummy {};
+
+/*
+ * Example of what a HIDL-generated proxy might look like.
+ */
+class IExample : public ::android::RefBase {
+   public:
+    // The callback type, for a method called startWithCallbackCopy, which
+    // has a callback that takes an |int|. Both the name, and the value,
+    // must match what would appear in HIDL-generated code.
+    using startWithCallbackCopy_cb = std::function<void(int)>;
+
+    // The callback type, for a method called startWithCallbackReference, which
+    // has a callback that takes an |int|. Both the name, and the value,
+    // must match what would appear in HIDL-generated code.
+    using startWithCallbackReference_cb = std::function<void(int)>;
+
+    // Constants which allow tests to verify that the proxy methods can
+    // correctly return a value. We use different values for by-copy and
+    // by-reference, to double-check that a call was dispatched properly.
+    static constexpr int kByCopyResult = 42;
+    static constexpr int kByReferenceResult = 420;
+
+    // Example of what a no-arg method would look like, if the callback
+    // is passed by-value.
+    ::android::hardware::Return<void> startWithCallbackCopy(
+        startWithCallbackCopy_cb _hidl_cb) {
+        _hidl_cb(kByCopyResult);
+        return ::android::hardware::Void();
+    }
+    // Example of what a no-arg method would look like, if the callback
+    // is passed by const-reference.
+    ::android::hardware::Return<void> startWithCallbackReference(
+        const startWithCallbackReference_cb& _hidl_cb) {
+        _hidl_cb(kByReferenceResult);
+        return ::android::hardware::Void();
+    }
+};
+
+constexpr int IExample::kByCopyResult;
+constexpr int IExample::kByReferenceResult;
+}  // namespace
+
+static_assert(std::is_same<int, detail::functionArgSaver<
+                                    std::function<void(int)>>::StorageT>::value,
+              "Single-arg result should be stored directly.");
+
+static_assert(
+    std::is_same<std::pair<int, long>, detail::functionArgSaver<std::function<
+                                           void(int, long)>>::StorageT>::value,
+    "Two-arg result should be stored as a pair.");
+
+static_assert(
+    std::is_same<std::tuple<char, int, long>,
+                 detail::functionArgSaver<
+                     std::function<void(char, int, long)>>::StorageT>::value,
+    "Three-arg result should be stored as a tuple.");
+
+static_assert(std::is_same<Dummy, detail::functionArgSaver<std::function<
+                                      void(const Dummy&)>>::StorageT>::value,
+              "Reference should be stored by copy.");
+
+/*
+ * Verifies that HIDL_INVOKE can be used with methods that take the result
+ * callback as a by-value parameter. (This reflects the current implementation
+ * of HIDL-generated code.)
+ */
+TEST(HidlInvokeTest, WorksWithMethodThatTakesResultCallbackByValue) {
+    ::android::sp<IExample> sp = new IExample();
+    EXPECT_EQ(IExample::kByCopyResult, HIDL_INVOKE(sp, startWithCallbackCopy));
+}
+
+/*
+ * Verifies that HIDL_INVOKE can be used with methods that take the result
+ * callback as a const-reference parameter. (This ensures that HIDL_INVOKE will
+ * continue to work, if the HIDL-generated code switches to const-ref.)
+ */
+TEST(HidlInvokeTest, WorksWithMethodThatTakesResultCallbackByConstReference) {
+    ::android::sp<IExample> sp = new IExample();
+    EXPECT_EQ(IExample::kByReferenceResult,
+              HIDL_INVOKE(sp, startWithCallbackReference));
+}
diff --git a/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp b/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp
index 050bba3..8f34a88 100644
--- a/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp
+++ b/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp
@@ -16,6 +16,7 @@
 
 #include <gtest/gtest.h>
 
+#include "wifi_hidl_call_util.h"
 #include "wifi_hidl_test_utils.h"
 
 using ::android::hardware::wifi::V1_0::IWifi;
@@ -52,41 +53,23 @@
         return nullptr;
     }
 
-    bool operation_failed = false;
-    wifi->start([&](WifiStatus status) {
-        if (status.code != WifiStatusCode::SUCCESS) {
-            operation_failed = true;
-        }
-    });
-    if (operation_failed) {
+    if (HIDL_INVOKE(wifi, start).code != WifiStatusCode::SUCCESS) {
         return nullptr;
     }
 
-    std::vector<ChipId> wifi_chip_ids;
-    wifi->getChipIds(
-        [&](const WifiStatus& status, const hidl_vec<ChipId>& chip_ids) {
-            if (status.code != WifiStatusCode::SUCCESS) {
-                operation_failed = true;
-            }
-            wifi_chip_ids = chip_ids;
-        });
-    // We don't expect more than 1 chip currently.
-    if (operation_failed || wifi_chip_ids.size() != 1) {
+    const auto& status_and_chip_ids = HIDL_INVOKE(wifi, getChipIds);
+    const auto& chip_ids = status_and_chip_ids.second;
+    if (status_and_chip_ids.first.code != WifiStatusCode::SUCCESS ||
+        chip_ids.size() != 1) {
         return nullptr;
     }
 
-    sp<IWifiChip> wifi_chip;
-    wifi->getChip(wifi_chip_ids[0],
-                  [&](const WifiStatus& status, const sp<IWifiChip>& chip) {
-                      if (status.code != WifiStatusCode::SUCCESS) {
-                          operation_failed = true;
-                      }
-                      wifi_chip = chip;
-                  });
-    if (operation_failed) {
+    const auto& status_and_chip = HIDL_INVOKE(wifi, getChip, chip_ids[0]);
+    if (status_and_chip.first.code != WifiStatusCode::SUCCESS) {
         return nullptr;
     }
-    return wifi_chip;
+
+    return status_and_chip.second;
 }
 
 // Since we currently only support one iface of each type. Just iterate thru the
@@ -116,30 +99,18 @@
 
 bool configureChipToSupportIfaceType(const sp<IWifiChip>& wifi_chip,
                                      IfaceType type) {
-    bool operation_failed = false;
-    std::vector<IWifiChip::ChipMode> chip_modes;
-    wifi_chip->getAvailableModes(
-        [&](WifiStatus status, const hidl_vec<IWifiChip::ChipMode>& modes) {
-            if (status.code != WifiStatusCode::SUCCESS) {
-                operation_failed = true;
-            }
-            chip_modes = modes;
-        });
-    if (operation_failed) {
+    const auto& status_and_modes = HIDL_INVOKE(wifi_chip, getAvailableModes);
+    if (status_and_modes.first.code != WifiStatusCode::SUCCESS) {
         return false;
     }
 
     ChipModeId mode_id;
-    if (!findModeToSupportIfaceType(type, chip_modes, &mode_id)) {
+    if (!findModeToSupportIfaceType(type, status_and_modes.second, &mode_id)) {
         return false;
     }
 
-    wifi_chip->configureChip(mode_id, [&](WifiStatus status) {
-        if (status.code != WifiStatusCode::SUCCESS) {
-            operation_failed = true;
-        }
-    });
-    if (operation_failed) {
+    if (HIDL_INVOKE(wifi_chip, configureChip, mode_id).code !=
+        WifiStatusCode::SUCCESS) {
         return false;
     }
     return true;
@@ -154,19 +125,11 @@
         return nullptr;
     }
 
-    bool operation_failed = false;
-    sp<IWifiApIface> wifi_ap_iface;
-    wifi_chip->createApIface(
-        [&](const WifiStatus& status, const sp<IWifiApIface>& iface) {
-            if (status.code != WifiStatusCode::SUCCESS) {
-                operation_failed = true;
-            }
-            wifi_ap_iface = iface;
-        });
-    if (operation_failed) {
+    const auto& status_and_iface = HIDL_INVOKE(wifi_chip, createApIface);
+    if (status_and_iface.first.code != WifiStatusCode::SUCCESS) {
         return nullptr;
     }
-    return wifi_ap_iface;
+    return status_and_iface.second;
 }
 
 sp<IWifiNanIface> getWifiNanIface() {
@@ -178,19 +141,11 @@
         return nullptr;
     }
 
-    bool operation_failed = false;
-    sp<IWifiNanIface> wifi_nan_iface;
-    wifi_chip->createNanIface(
-        [&](const WifiStatus& status, const sp<IWifiNanIface>& iface) {
-            if (status.code != WifiStatusCode::SUCCESS) {
-                operation_failed = true;
-            }
-            wifi_nan_iface = iface;
-        });
-    if (operation_failed) {
+    const auto& status_and_iface = HIDL_INVOKE(wifi_chip, createNanIface);
+    if (status_and_iface.first.code != WifiStatusCode::SUCCESS) {
         return nullptr;
     }
-    return wifi_nan_iface;
+    return status_and_iface.second;
 }
 
 sp<IWifiP2pIface> getWifiP2pIface() {
@@ -202,19 +157,11 @@
         return nullptr;
     }
 
-    bool operation_failed = false;
-    sp<IWifiP2pIface> wifi_p2p_iface;
-    wifi_chip->createP2pIface(
-        [&](const WifiStatus& status, const sp<IWifiP2pIface>& iface) {
-            if (status.code != WifiStatusCode::SUCCESS) {
-                operation_failed = true;
-            }
-            wifi_p2p_iface = iface;
-        });
-    if (operation_failed) {
+    const auto& status_and_iface = HIDL_INVOKE(wifi_chip, createP2pIface);
+    if (status_and_iface.first.code != WifiStatusCode::SUCCESS) {
         return nullptr;
     }
-    return wifi_p2p_iface;
+    return status_and_iface.second;
 }
 
 sp<IWifiStaIface> getWifiStaIface() {
@@ -226,19 +173,11 @@
         return nullptr;
     }
 
-    bool operation_failed = false;
-    sp<IWifiStaIface> wifi_sta_iface;
-    wifi_chip->createStaIface(
-        [&](const WifiStatus& status, const sp<IWifiStaIface>& iface) {
-            if (status.code != WifiStatusCode::SUCCESS) {
-                operation_failed = true;
-            }
-            wifi_sta_iface = iface;
-        });
-    if (operation_failed) {
+    const auto& status_and_iface = HIDL_INVOKE(wifi_chip, createStaIface);
+    if (status_and_iface.first.code != WifiStatusCode::SUCCESS) {
         return nullptr;
     }
-    return wifi_sta_iface;
+    return status_and_iface.second;
 }
 
 sp<IWifiRttController> getWifiRttController() {
@@ -251,26 +190,16 @@
         return nullptr;
     }
 
-    bool operation_failed = false;
-    sp<IWifiRttController> wifi_rtt_controller;
-    wifi_chip->createRttController(
-        wifi_sta_iface, [&](const WifiStatus& status,
-                            const sp<IWifiRttController>& controller) {
-            if (status.code != WifiStatusCode::SUCCESS) {
-                operation_failed = true;
-            }
-            wifi_rtt_controller = controller;
-        });
-    if (operation_failed) {
+    const auto& status_and_controller =
+        HIDL_INVOKE(wifi_chip, createRttController, wifi_sta_iface);
+    if (status_and_controller.first.code != WifiStatusCode::SUCCESS) {
         return nullptr;
     }
-    return wifi_rtt_controller;
+    return status_and_controller.second;
 }
 
 void stopWifi() {
     sp<IWifi> wifi = getWifi();
     ASSERT_NE(wifi, nullptr);
-    wifi->stop([](const WifiStatus& status) {
-        ASSERT_EQ(status.code, WifiStatusCode::SUCCESS);
-    });
+    ASSERT_EQ(HIDL_INVOKE(wifi, stop).code, WifiStatusCode::SUCCESS);
 }