diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
index 95ca37b..545de39 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
@@ -28,9 +28,9 @@
 
 namespace impl {
 
-const VehicleProperty kHvacPowerProperties[] = {
-    VehicleProperty::HVAC_FAN_SPEED,
-    VehicleProperty::HVAC_FAN_DIRECTION,
+const int32_t kHvacPowerProperties[] = {
+    toInt(VehicleProperty::HVAC_FAN_SPEED),
+    toInt(VehicleProperty::HVAC_FAN_DIRECTION),
 };
 
 const VehiclePropConfig kVehicleProperties[] = {
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp
index 808aafb..e6a3e56 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp
@@ -503,16 +503,15 @@
     StatusCode status;
     switch (propId) {
         default:
-            if (mHvacPowerProps.find(VehicleProperty(propId)) !=
-                    mHvacPowerProps.end()) {
-                auto prop = mProps.find(
-                    std::make_pair(toInt(VehicleProperty::HVAC_POWER_ON), 0));
-                if (prop != mProps.end()) {
-                    if (prop->second->value.int32Values.size() == 1 &&
-                        prop->second->value.int32Values[0] == 0) {
-                        status = StatusCode::NOT_AVAILABLE;
-                        break;
-                    }
+            if (mHvacPowerProps.count(propId)) {
+                std::lock_guard<std::mutex> lock(mPropsMutex);
+                auto hvacPowerOn = getVehiclePropValueLocked(toInt(VehicleProperty::HVAC_POWER_ON),
+                                                             toInt(VehicleAreaZone::ROW_1));
+
+                if (hvacPowerOn && hvacPowerOn->value.int32Values.size() == 1
+                        && hvacPowerOn->value.int32Values[0] == 0) {
+                    status = StatusCode::NOT_AVAILABLE;
+                    break;
                 }
             }
             status = updateProperty(propValue);
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.h
index 98eef27..2efe05c 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.h
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.h
@@ -108,7 +108,7 @@
         std::pair<int32_t /*VehicleProperty*/, int32_t /*areaId*/>,
         std::unique_ptr<VehiclePropValue>> mProps;
     std::atomic<int> mExit;
-    std::unordered_set<VehicleProperty> mHvacPowerProps;
+    std::unordered_set<int32_t> mHvacPowerProps;
     std::mutex mPropsMutex;
     std::thread mThread;
     std::unique_ptr<CommBase> mComm{nullptr};
diff --git a/bluetooth/1.0/default/vendor_interface.cc b/bluetooth/1.0/default/vendor_interface.cc
index 26f52f7..e6575b0 100644
--- a/bluetooth/1.0/default/vendor_interface.cc
+++ b/bluetooth/1.0/default/vendor_interface.cc
@@ -248,10 +248,9 @@
         new hci::MctProtocol(fd_list, intercept_events, acl_cb);
     fd_watcher_.WatchFdForNonBlockingReads(
         fd_list[CH_EVT], [mct_hci](int fd) { mct_hci->OnEventDataReady(fd); });
-    if (fd_count >= CH_ACL_IN)
-      fd_watcher_.WatchFdForNonBlockingReads(
-          fd_list[CH_ACL_IN],
-          [mct_hci](int fd) { mct_hci->OnAclDataReady(fd); });
+    fd_watcher_.WatchFdForNonBlockingReads(
+        fd_list[CH_ACL_IN],
+        [mct_hci](int fd) { mct_hci->OnAclDataReady(fd); });
     hci_ = mct_hci;
   }
 
diff --git a/configstore/1.0/ISurfaceFlingerConfigs.hal b/configstore/1.0/ISurfaceFlingerConfigs.hal
index f9a49ce..58cb9f1 100644
--- a/configstore/1.0/ISurfaceFlingerConfigs.hal
+++ b/configstore/1.0/ISurfaceFlingerConfigs.hal
@@ -70,4 +70,10 @@
      * TARGET_HAS_HDR_DISPLAY to true in BoardConfig.mk
      */
     hasHDRDisplay() generates (OptionalBool value);
+
+    /*
+     * Specify the offset in nanoseconds to add to vsync time when timestamping
+     * present fences.
+     */
+    presentTimeOffsetFromVSyncNs() generates(OptionalInt64 value);
 };
diff --git a/configstore/1.0/default/SurfaceFlingerConfigs.cpp b/configstore/1.0/default/SurfaceFlingerConfigs.cpp
index 035479c..86e9b35 100644
--- a/configstore/1.0/default/SurfaceFlingerConfigs.cpp
+++ b/configstore/1.0/default/SurfaceFlingerConfigs.cpp
@@ -69,6 +69,16 @@
     return Void();
 }
 
+Return<void> SurfaceFlingerConfigs::presentTimeOffsetFromVSyncNs(presentTimeOffsetFromVSyncNs_cb _hidl_cb) {
+#ifdef PRESENT_TIME_OFFSET_FROM_VSYNC_NS
+      _hidl_cb({true, PRESENT_TIME_OFFSET_FROM_VSYNC_NS});
+      LOG(INFO) << "SurfaceFlinger presentTimeStampOffsetNs =  " << PRESENT_TIME_OFFSET_FROM_VSYNC_NS;
+#else
+      _hidl_cb({false, 0});
+#endif
+      return Void();
+}
+
 // Methods from ::android::hidl::base::V1_0::IBase follow.
 
 ISurfaceFlingerConfigs* HIDL_FETCH_ISurfaceFlingerConfigs(const char* /* name */) {
diff --git a/configstore/1.0/default/SurfaceFlingerConfigs.h b/configstore/1.0/default/SurfaceFlingerConfigs.h
index aa7fb8b..8378383 100644
--- a/configstore/1.0/default/SurfaceFlingerConfigs.h
+++ b/configstore/1.0/default/SurfaceFlingerConfigs.h
@@ -30,6 +30,7 @@
     Return<void> useContextPriority(useContextPriority_cb _hidl_cb) override;
     Return<void> hasWideColorDisplay(hasWideColorDisplay_cb _hidl_cb) override;
     Return<void> hasHDRDisplay(hasHDRDisplay_cb _hidl_cb) override;
+    Return<void> presentTimeOffsetFromVSyncNs(presentTimeOffsetFromVSyncNs_cb _hidl_cb) override;
 
     // Methods from ::android::hidl::base::V1_0::IBase follow.
 
diff --git a/configstore/1.0/default/surfaceflinger.mk b/configstore/1.0/default/surfaceflinger.mk
index 8ee3686..d824072 100644
--- a/configstore/1.0/default/surfaceflinger.mk
+++ b/configstore/1.0/default/surfaceflinger.mk
@@ -29,3 +29,8 @@
     LOCAL_CFLAGS += -DHAS_HDR_DISPLAY
 endif
 
+ifneq ($(PRESENT_TIME_OFFSET_FROM_VSYNC_NS),)
+    LOCAL_CFLAGS += -DPRESENT_TIME_OFFSET_FROM_VSYNC_NS=$(PRESENT_TIME_OFFSET_FROM_VSYNC_NS)
+else
+    LOCAL_CFLAGS += -DPRESENT_TIME_OFFSET_FROM_VSYNC_NS=0
+endif
diff --git a/graphics/Android.bp b/graphics/Android.bp
index eaa47ae..f4f7db4 100644
--- a/graphics/Android.bp
+++ b/graphics/Android.bp
@@ -3,6 +3,7 @@
     "allocator/2.0",
     "allocator/2.0/default",
     "allocator/2.0/vts/functional",
+    "bufferqueue/1.0",
     "common/1.0",
     "composer/2.1",
     "composer/2.1/default",
diff --git a/graphics/bufferqueue/1.0/Android.bp b/graphics/bufferqueue/1.0/Android.bp
new file mode 100644
index 0000000..4ba764f
--- /dev/null
+++ b/graphics/bufferqueue/1.0/Android.bp
@@ -0,0 +1,70 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+    name: "android.hardware.graphics.bufferqueue@1.0_hal",
+    srcs: [
+        "IGraphicBufferProducer.hal",
+        "IProducerListener.hal",
+    ],
+}
+
+genrule {
+    name: "android.hardware.graphics.bufferqueue@1.0_genc++",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.graphics.bufferqueue@1.0",
+    srcs: [
+        ":android.hardware.graphics.bufferqueue@1.0_hal",
+    ],
+    out: [
+        "android/hardware/graphics/bufferqueue/1.0/GraphicBufferProducerAll.cpp",
+        "android/hardware/graphics/bufferqueue/1.0/ProducerListenerAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.graphics.bufferqueue@1.0_genc++_headers",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.graphics.bufferqueue@1.0",
+    srcs: [
+        ":android.hardware.graphics.bufferqueue@1.0_hal",
+    ],
+    out: [
+        "android/hardware/graphics/bufferqueue/1.0/IGraphicBufferProducer.h",
+        "android/hardware/graphics/bufferqueue/1.0/IHwGraphicBufferProducer.h",
+        "android/hardware/graphics/bufferqueue/1.0/BnHwGraphicBufferProducer.h",
+        "android/hardware/graphics/bufferqueue/1.0/BpHwGraphicBufferProducer.h",
+        "android/hardware/graphics/bufferqueue/1.0/BsGraphicBufferProducer.h",
+        "android/hardware/graphics/bufferqueue/1.0/IProducerListener.h",
+        "android/hardware/graphics/bufferqueue/1.0/IHwProducerListener.h",
+        "android/hardware/graphics/bufferqueue/1.0/BnHwProducerListener.h",
+        "android/hardware/graphics/bufferqueue/1.0/BpHwProducerListener.h",
+        "android/hardware/graphics/bufferqueue/1.0/BsProducerListener.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.graphics.bufferqueue@1.0",
+    generated_sources: ["android.hardware.graphics.bufferqueue@1.0_genc++"],
+    generated_headers: ["android.hardware.graphics.bufferqueue@1.0_genc++_headers"],
+    export_generated_headers: ["android.hardware.graphics.bufferqueue@1.0_genc++_headers"],
+    shared_libs: [
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "liblog",
+        "libutils",
+        "libcutils",
+        "android.hardware.graphics.common@1.0",
+        "android.hardware.media@1.0",
+        "android.hidl.base@1.0",
+    ],
+    export_shared_lib_headers: [
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "libutils",
+        "android.hardware.graphics.common@1.0",
+        "android.hardware.media@1.0",
+        "android.hidl.base@1.0",
+    ],
+}
diff --git a/media/omx/1.0/IOmxBufferProducer.hal b/graphics/bufferqueue/1.0/IGraphicBufferProducer.hal
similarity index 95%
rename from media/omx/1.0/IOmxBufferProducer.hal
rename to graphics/bufferqueue/1.0/IGraphicBufferProducer.hal
index 7e2172b..c59a16c 100644
--- a/media/omx/1.0/IOmxBufferProducer.hal
+++ b/graphics/bufferqueue/1.0/IGraphicBufferProducer.hal
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * 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.
@@ -14,20 +14,29 @@
  * limitations under the License.
  */
 
-package android.hardware.media.omx@1.0;
+package android.hardware.graphics.bufferqueue@1.0;
+
+import android.hardware.media@1.0::Fence;
+import android.hardware.media@1.0::AnwBuffer;
+import android.hardware.media@1.0::Rect;
+import android.hardware.media@1.0::Region;
 
 import android.hardware.graphics.common@1.0::Dataspace;
 import android.hardware.graphics.common@1.0::PixelFormat;
 
-import android.hardware.media@1.0::types;
-import IOmxProducerListener;
+import IProducerListener;
 
 /**
  * Ref: frameworks/native/include/gui/IGraphicBufferProducer.h:
  *      IGraphicBufferProducer
  * This is a wrapper/wrapped HAL interface for the actual binder interface.
  */
-interface IOmxBufferProducer {
+interface IGraphicBufferProducer {
+
+    /**
+     * Type for return values of functions in IGraphicBufferProducer.
+     */
+    typedef int32_t Status;
 
     /**
      * Ref: frameworks/native/include/ui/FenceTime.h: FenceTime::Snapshot
@@ -142,7 +151,7 @@
 
     /**
      * requestBuffer requests a new buffer for the given index. The server (i.e.
-     * the IOmxBufferProducer implementation) assigns the newly created
+     * the IProducerListener implementation) assigns the newly created
      * buffer to the given slot index, and the client is expected to mirror the
      * slot->buffer mapping so that it's not necessary to transfer an
      * AnwBuffer for every dequeue operation.
@@ -466,12 +475,12 @@
         );
 
     /**
-     * connect attempts to connect a client API to the IOmxBufferProducer.
-     * This must be called before any other IOmxBufferProducer methods are
+     * connect attempts to connect a client API to the IGraphicBufferProducer.
+     * This must be called before any other IGraphicBufferProducer methods are
      * called except for getAllocator. A consumer must be already connected.
      *
      * This method will fail if the connect was previously called on the
-     * IOmxBufferProducer and no corresponding disconnect call was made.
+     * IGraphicBufferProducer and no corresponding disconnect call was made.
      *
      * The listener is an optional binder callback object that can be used if
      * the producer wants to be notified when the consumer releases a buffer
@@ -506,7 +515,7 @@
      * should be treated as opaque fatal unrecoverable errors.
      */
     connect(
-            IOmxProducerListener listener,
+            IProducerListener listener,
             int32_t api,
             bool producerControlledByApp
         ) generates (
@@ -516,8 +525,8 @@
 
     /**
      * disconnect attempts to disconnect a client API from the
-     * IOmxBufferProducer.  Calling this method will cause any subsequent
-     * calls to other IOmxBufferProducer methods to fail except for
+     * IGraphicBufferProducer.  Calling this method will cause any subsequent
+     * calls to other IGraphicBufferProducer methods to fail except for
      * getAllocator and connect.  Successfully calling connect after this will
      * allow the other methods to succeed again.
      *
@@ -526,7 +535,7 @@
      * Alternatively if mode is AllLocal, then the API value is ignored, and any API
      * connected from the same PID calling disconnect will be disconnected.
      *
-     * Disconnecting from an abandoned IOmxBufferProducer is legal and
+     * Disconnecting from an abandoned IGraphicBufferProducer is legal and
      * is considered a no-op.
      *
      * Return of a value other than NO_ERROR means an error has occurred:
@@ -543,7 +552,7 @@
         );
 
     /**
-     * Attaches a sideband buffer stream to the IOmxBufferProducer.
+     * Attaches a sideband buffer stream to the IGraphicBufferProducer.
      *
      * A sideband stream is a device-specific mechanism for passing buffers
      * from the producer to the consumer without using dequeueBuffer/
diff --git a/media/omx/1.0/IOmxProducerListener.hal b/graphics/bufferqueue/1.0/IProducerListener.hal
similarity index 91%
rename from media/omx/1.0/IOmxProducerListener.hal
rename to graphics/bufferqueue/1.0/IProducerListener.hal
index 7fde93b..206a500 100644
--- a/media/omx/1.0/IOmxProducerListener.hal
+++ b/graphics/bufferqueue/1.0/IProducerListener.hal
@@ -14,13 +14,13 @@
  * limitations under the License.
  */
 
-package android.hardware.media.omx@1.0;
+package android.hardware.graphics.bufferqueue@1.0;
 
 /**
  * Ref: frameworks/native/include/gui/IProducerListener.h: IProducerListener
  * This is a wrapper/wrapped HAL interface for the actual binder interface.
  */
-interface IOmxProducerListener {
+interface IProducerListener {
     oneway onBufferReleased();
     needsReleaseNotify() generates (bool result);
 };
diff --git a/media/omx/1.0/Android.bp b/media/omx/1.0/Android.bp
index 85d15ae..81dd617 100644
--- a/media/omx/1.0/Android.bp
+++ b/media/omx/1.0/Android.bp
@@ -6,11 +6,9 @@
         "types.hal",
         "IGraphicBufferSource.hal",
         "IOmx.hal",
-        "IOmxBufferProducer.hal",
         "IOmxBufferSource.hal",
         "IOmxNode.hal",
         "IOmxObserver.hal",
-        "IOmxProducerListener.hal",
     ],
 }
 
@@ -25,11 +23,9 @@
         "android/hardware/media/omx/1.0/types.cpp",
         "android/hardware/media/omx/1.0/GraphicBufferSourceAll.cpp",
         "android/hardware/media/omx/1.0/OmxAll.cpp",
-        "android/hardware/media/omx/1.0/OmxBufferProducerAll.cpp",
         "android/hardware/media/omx/1.0/OmxBufferSourceAll.cpp",
         "android/hardware/media/omx/1.0/OmxNodeAll.cpp",
         "android/hardware/media/omx/1.0/OmxObserverAll.cpp",
-        "android/hardware/media/omx/1.0/OmxProducerListenerAll.cpp",
     ],
 }
 
@@ -52,11 +48,6 @@
         "android/hardware/media/omx/1.0/BnHwOmx.h",
         "android/hardware/media/omx/1.0/BpHwOmx.h",
         "android/hardware/media/omx/1.0/BsOmx.h",
-        "android/hardware/media/omx/1.0/IOmxBufferProducer.h",
-        "android/hardware/media/omx/1.0/IHwOmxBufferProducer.h",
-        "android/hardware/media/omx/1.0/BnHwOmxBufferProducer.h",
-        "android/hardware/media/omx/1.0/BpHwOmxBufferProducer.h",
-        "android/hardware/media/omx/1.0/BsOmxBufferProducer.h",
         "android/hardware/media/omx/1.0/IOmxBufferSource.h",
         "android/hardware/media/omx/1.0/IHwOmxBufferSource.h",
         "android/hardware/media/omx/1.0/BnHwOmxBufferSource.h",
@@ -72,11 +63,6 @@
         "android/hardware/media/omx/1.0/BnHwOmxObserver.h",
         "android/hardware/media/omx/1.0/BpHwOmxObserver.h",
         "android/hardware/media/omx/1.0/BsOmxObserver.h",
-        "android/hardware/media/omx/1.0/IOmxProducerListener.h",
-        "android/hardware/media/omx/1.0/IHwOmxProducerListener.h",
-        "android/hardware/media/omx/1.0/BnHwOmxProducerListener.h",
-        "android/hardware/media/omx/1.0/BpHwOmxProducerListener.h",
-        "android/hardware/media/omx/1.0/BsOmxProducerListener.h",
     ],
 }
 
@@ -92,6 +78,7 @@
         "liblog",
         "libutils",
         "libcutils",
+        "android.hardware.graphics.bufferqueue@1.0",
         "android.hardware.graphics.common@1.0",
         "android.hardware.media@1.0",
         "android.hidl.base@1.0",
@@ -101,6 +88,7 @@
         "libhidltransport",
         "libhwbinder",
         "libutils",
+        "android.hardware.graphics.bufferqueue@1.0",
         "android.hardware.graphics.common@1.0",
         "android.hardware.media@1.0",
         "android.hidl.base@1.0",
diff --git a/media/omx/1.0/IOmx.hal b/media/omx/1.0/IOmx.hal
index acb1aae..78d4b32 100644
--- a/media/omx/1.0/IOmx.hal
+++ b/media/omx/1.0/IOmx.hal
@@ -16,11 +16,11 @@
 
 package android.hardware.media.omx@1.0;
 
+import android.hardware.graphics.bufferqueue@1.0::IGraphicBufferProducer;
 import android.hardware.media@1.0::types;
 
 import IOmxNode;
 import IOmxObserver;
-import IOmxBufferProducer;
 import IGraphicBufferSource;
 
 /**
@@ -76,7 +76,7 @@
     createInputSurface(
         ) generates (
             Status status,
-            IOmxBufferProducer producer,
+            IGraphicBufferProducer producer,
             IGraphicBufferSource source
         );
 };
diff --git a/radio/1.0/IRadio.hal b/radio/1.0/IRadio.hal
index b3e3e98..0b1bf40 100644
--- a/radio/1.0/IRadio.hal
+++ b/radio/1.0/IRadio.hal
@@ -630,7 +630,6 @@
 
     /*
      * Scans for available networks
-     * This request must not respond until the new operator is selected and registered.
      *
      * @param serial Serial number of request.
      *
diff --git a/radio/1.0/IRadioResponse.hal b/radio/1.0/IRadioResponse.hal
index cd0899a..bf50792 100644
--- a/radio/1.0/IRadioResponse.hal
+++ b/radio/1.0/IRadioResponse.hal
@@ -787,10 +787,13 @@
      *
      * Valid errors returned:
      *   RadioError:NONE
-     *   RadioError:INVALID_ARGUMENTS
      *   RadioError:RADIO_NOT_AVAILABLE
      *   RadioError:OPERATION_NOT_ALLOWED
-     *   RadioError:GENERIC_FAILURE
+     *   RadioError:ABORTED
+     *   RadioError:DEVICE_IN_USE
+     *   RadioError:INTERNAL_ERR
+     *   RadioError:NO_MEMORY
+     *   RadioError:MODEM_ERR
      */
     oneway getAvailableNetworksResponse(RadioResponseInfo info,
             vec<OperatorInfo> networkInfos);
diff --git a/radio/1.0/types.hal b/radio/1.0/types.hal
index 7c1d143..9b904a5 100644
--- a/radio/1.0/types.hal
+++ b/radio/1.0/types.hal
@@ -86,9 +86,11 @@
     SS_MODIFIED_TO_SS = 27,               // SS request modified to different SS request
     LCE_NOT_SUPPORTED = 36,               // LCE service not supported(36 in RILConstants.java)
     NO_MEMORY = 37,                       // Not sufficient memory to process the request
-    INTERNAL_ERR = 38,                    // Hit unexpected vendor internal error scenario
+    INTERNAL_ERR = 38,                    // Modem hit unexpected error scenario while handling
+                                          // this request
     SYSTEM_ERR = 39,                      // Hit platform or system error
-    MODEM_ERR = 40,                       // Hit unexpected modem error
+    MODEM_ERR = 40,                       // Vendor RIL got unexpected or incorrect response
+                                          // from modem for this request
     INVALID_STATE = 41,                   // Unexpected request for the current state
     NO_RESOURCES = 42,                    // Not sufficient resource to process the request
     SIM_ERR = 43,                         // Received error from SIM card
diff --git a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
index 1298e16..d21b512 100644
--- a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
+++ b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
@@ -20,6 +20,7 @@
 #include <android/hardware/sensors/1.0/types.h>
 #include <android/log.h>
 #include <cutils/ashmem.h>
+#include <utils/SystemClock.h>
 #include <VtsHalHidlTargetTestBase.h>
 #include <hardware/sensors.h>       // for sensor type strings
 
@@ -42,6 +43,7 @@
 using namespace ::android::hardware::sensors::V1_0;
 
 // Test environment for sensors
+class SensorsHidlTest;
 class SensorsHidlEnvironment : public ::testing::Environment {
  public:
   // get the test environment singleton
@@ -50,9 +52,6 @@
     return instance;
   }
 
-  // sensors hidl service
-  sp<ISensors> sensors;
-
   virtual void SetUp();
   virtual void TearDown();
 
@@ -64,10 +63,15 @@
   void setCollection(bool enable);
 
  private:
+  friend SensorsHidlTest;
+  // sensors hidl service
+  sp<ISensors> sensors;
+
   SensorsHidlEnvironment() {}
 
   void addEvent(const Event& ev);
   void startPollingThread();
+  void resetHal();
   static void pollingThread(SensorsHidlEnvironment* env, std::shared_ptr<bool> stop);
 
   bool collectionEnabled;
@@ -80,9 +84,9 @@
 };
 
 void SensorsHidlEnvironment::SetUp() {
-  sensors = ::testing::VtsHalHidlTargetTestBase::getService<ISensors>();
-  ALOGI_IF(sensors, "sensors is not nullptr, %p", sensors.get());
-  ASSERT_NE(sensors, nullptr);
+  resetHal();
+
+  ASSERT_NE(sensors, nullptr) << "sensors is nullptr, cannot get hidl service";
 
   collectionEnabled = false;
   startPollingThread();
@@ -93,14 +97,77 @@
 }
 
 void SensorsHidlEnvironment::TearDown() {
-  ALOGI("TearDown SensorsHidlEnvironement");
-
   if (stopThread) {
     *stopThread = true;
   }
   pollThread.detach();
 }
 
+void SensorsHidlEnvironment::resetHal() {
+  // wait upto 100ms * 10 = 1s for hidl service.
+  constexpr auto RETRY_DELAY = std::chrono::milliseconds(100);
+
+  std::string step;
+  bool succeed = false;
+  for (size_t retry = 10; retry > 0; --retry) {
+    // this do ... while is for easy error handling
+    do {
+      step = "getService()";
+      sensors = ISensors::getService();
+      if (sensors == nullptr) {
+        break;
+      }
+
+      step = "poll() check";
+      // Poke ISensor service. If it has lingering connection from previous generation of
+      // system server, it will kill itself. There is no intention to handle the poll result,
+      // which will be done since the size is 0.
+      if(!sensors->poll(0, [](auto, const auto &, const auto &) {}).isOk()) {
+        break;
+      }
+
+      step = "getSensorList";
+      std::vector<SensorInfo> sensorList;
+      if (!sensors->getSensorsList(
+          [&] (const ::android::hardware::hidl_vec<SensorInfo> &list) {
+            sensorList.reserve(list.size());
+            for (size_t i = 0; i < list.size(); ++i) {
+              sensorList.push_back(list[i]);
+            }
+          }).isOk()) {
+        break;
+      }
+
+      // stop each sensor individually
+      step = "stop each sensor";
+      bool ok = true;
+      for (const auto &i : sensorList) {
+        if (!sensors->activate(i.sensorHandle, false).isOk()) {
+          ok = false;
+          break;
+        }
+      }
+      if (!ok) {
+        break;
+      }
+
+      // mark it done
+      step = "done";
+      succeed = true;
+    } while(0);
+
+    if (succeed) {
+      return;
+    }
+
+    // Delay 100ms before retry, hidl service is expected to come up in short time after crash.
+    ALOGI("%s unsuccessful, try again soon (remaining retry %zu).", step.c_str(), retry - 1);
+    std::this_thread::sleep_for(RETRY_DELAY);
+  }
+
+  sensors = nullptr;
+}
+
 void SensorsHidlEnvironment::catEvents(std::vector<Event>* output) {
   std::lock_guard<std::mutex> lock(events_mutex);
   if (output) {
@@ -257,6 +324,10 @@
       }
       break;
     }
+    case SharedMemType::GRALLOC: {
+
+      break;
+    }
     default:
       break;
   }
@@ -308,6 +379,58 @@
   return m;
 }
 
+class SensorEventsChecker {
+ public:
+  virtual bool check(const std::vector<Event> &events, std::string *out) const = 0;
+  virtual ~SensorEventsChecker() {}
+};
+
+class NullChecker : public SensorEventsChecker {
+ public:
+  virtual bool check(const std::vector<Event> &, std::string *) const {
+    return true;
+  }
+};
+
+class SensorEventPerEventChecker : public SensorEventsChecker {
+ public:
+  virtual bool checkEvent(const Event &event, std::string *out) const = 0;
+  virtual bool check(const std::vector<Event> &events, std::string *out) const {
+    for (const auto &e : events) {
+      if (!checkEvent(e, out)) {
+        return false;
+      }
+    }
+    return true;
+  }
+};
+
+class Vec3NormChecker : public SensorEventPerEventChecker {
+ public:
+  Vec3NormChecker(float min, float max) : mRange(min, max) {}
+  static Vec3NormChecker byNominal(float nominal, float allowedError) {
+    return Vec3NormChecker(nominal - allowedError, nominal + allowedError);
+  }
+
+  virtual bool checkEvent(const Event &event, std::string *out) const {
+    Vec3 v = event.u.vec3;
+    float norm = std::sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
+    if (norm < mRange.first || norm > mRange.second) {
+      if (out != nullptr) {
+        std::ostringstream ss;
+        ss << "Event @ " << event.timestamp << " (" << v.x << ", " << v.y << ", " << v.z << ")"
+           << " has norm " << norm << ", which is beyond range"
+           << " [" << mRange.first << ", " << mRange.second << "]";
+        *out = ss.str();
+      }
+      return false;
+    }
+    return true;
+  }
+ protected:
+  std::pair<float, float> mRange;
+};
+
 // The main test class for SENSORS HIDL HAL.
 class SensorsHidlTest : public ::testing::VtsHalHidlTargetTestBase {
  public:
@@ -332,6 +455,7 @@
 
  protected:
   SensorInfo defaultSensorByType(SensorType type);
+  std::vector<SensorInfo> getSensorsList();
   std::vector<Event> collectEvents(useconds_t timeLimitUs, size_t nEventLimit,
         bool clearBeforeStart = true, bool changeCollection = true);
 
@@ -393,16 +517,36 @@
     return (int32_t) type > 0;
   }
 
-  static bool typeMatchStringType(SensorType type, const hidl_string& stringType);
-  static bool typeMatchReportMode(SensorType type, SensorFlagBits reportMode);
-  static bool delayMatchReportMode(int32_t minDelay, int32_t maxDelay, SensorFlagBits reportMode);
+  void testStreamingOperation(SensorType type,
+                              std::chrono::nanoseconds samplingPeriod,
+                              std::chrono::seconds duration,
+                              const SensorEventsChecker &checker);
+  void testSamplingRateHotSwitchOperation(SensorType type);
+  void testBatchingOperation(SensorType type);
+  void testDirectReportOperation(
+      SensorType type, SharedMemType memType, RateLevel rate, const SensorEventsChecker &checker);
+
+  static void assertTypeMatchStringType(SensorType type, const hidl_string& stringType);
+  static void assertTypeMatchReportMode(SensorType type, SensorFlagBits reportMode);
+  static void assertDelayMatchReportMode(
+          int32_t minDelay, int32_t maxDelay, SensorFlagBits reportMode);
   static SensorFlagBits expectedReportModeForType(SensorType type);
+  static bool isDirectReportRateSupported(SensorInfo sensor, RateLevel rate);
+  static bool isDirectChannelTypeSupported(SensorInfo sensor, SharedMemType type);
+
+  // checkers
+  static const Vec3NormChecker sAccelNormChecker;
+  static const Vec3NormChecker sGyroNormChecker;
 
   // all sensors and direct channnels used
   std::unordered_set<int32_t> mSensorHandles;
   std::unordered_set<int32_t> mDirectChannelHandles;
 };
 
+const Vec3NormChecker SensorsHidlTest::sAccelNormChecker(
+        Vec3NormChecker::byNominal(GRAVITY_EARTH, 0.5f/*m/s^2*/));
+const Vec3NormChecker SensorsHidlTest::sGyroNormChecker(
+        Vec3NormChecker::byNominal(0.f, 0.1f/*rad/s*/));
 
 Return<Result> SensorsHidlTest::activate(int32_t sensorHandle, bool enabled) {
   // If activating a sensor, add the handle in a set so that when test fails it can be turned off.
@@ -433,7 +577,7 @@
 std::vector<Event> SensorsHidlTest::collectEvents(useconds_t timeLimitUs, size_t nEventLimit,
       bool clearBeforeStart, bool changeCollection) {
   std::vector<Event> events;
-  constexpr useconds_t SLEEP_GRANULARITY = 100*1000; //gradularity 100 ms
+  constexpr useconds_t SLEEP_GRANULARITY = 100*1000; //granularity 100 ms
 
   ALOGI("collect max of %zu events for %d us, clearBeforeStart %d",
         nEventLimit, timeLimitUs, clearBeforeStart);
@@ -464,94 +608,93 @@
   return events;
 }
 
-bool SensorsHidlTest::typeMatchStringType(SensorType type, const hidl_string& stringType) {
+void SensorsHidlTest::assertTypeMatchStringType(SensorType type, const hidl_string& stringType) {
 
   if (type >= SensorType::DEVICE_PRIVATE_BASE) {
-    return true;
+    return;
   }
 
-  bool res = true;
   switch (type) {
 #define CHECK_TYPE_STRING_FOR_SENSOR_TYPE(type) \
-    case SensorType::type: res = stringType == SENSOR_STRING_TYPE_ ## type;\
-      break;\
-
+    case SensorType::type: ASSERT_STREQ(SENSOR_STRING_TYPE_ ## type, stringType); break;
     CHECK_TYPE_STRING_FOR_SENSOR_TYPE(ACCELEROMETER);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(MAGNETIC_FIELD);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(ORIENTATION);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(GYROSCOPE);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(LIGHT);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(PRESSURE);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(TEMPERATURE);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(PROXIMITY);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(GRAVITY);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(LINEAR_ACCELERATION);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(ROTATION_VECTOR);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(RELATIVE_HUMIDITY);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(ACCELEROMETER_UNCALIBRATED);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(ADDITIONAL_INFO);
     CHECK_TYPE_STRING_FOR_SENSOR_TYPE(AMBIENT_TEMPERATURE);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(MAGNETIC_FIELD_UNCALIBRATED);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(DEVICE_ORIENTATION);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(DYNAMIC_SENSOR_META);
     CHECK_TYPE_STRING_FOR_SENSOR_TYPE(GAME_ROTATION_VECTOR);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(GYROSCOPE_UNCALIBRATED);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(SIGNIFICANT_MOTION);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(STEP_DETECTOR);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(STEP_COUNTER);
     CHECK_TYPE_STRING_FOR_SENSOR_TYPE(GEOMAGNETIC_ROTATION_VECTOR);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(GLANCE_GESTURE);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(GRAVITY);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(GYROSCOPE);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(GYROSCOPE_UNCALIBRATED);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(HEART_BEAT);
     CHECK_TYPE_STRING_FOR_SENSOR_TYPE(HEART_RATE);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(LIGHT);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(LINEAR_ACCELERATION);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(LOW_LATENCY_OFFBODY_DETECT);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(MAGNETIC_FIELD);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(MAGNETIC_FIELD_UNCALIBRATED);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(MOTION_DETECT);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(ORIENTATION);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(PICK_UP_GESTURE);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(POSE_6DOF);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(PRESSURE);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(PROXIMITY);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(RELATIVE_HUMIDITY);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(ROTATION_VECTOR);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(SIGNIFICANT_MOTION);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(STATIONARY_DETECT);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(STEP_COUNTER);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(STEP_DETECTOR);
+    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(TEMPERATURE);
     CHECK_TYPE_STRING_FOR_SENSOR_TYPE(TILT_DETECTOR);
     CHECK_TYPE_STRING_FOR_SENSOR_TYPE(WAKE_GESTURE);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(GLANCE_GESTURE);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(PICK_UP_GESTURE);
     CHECK_TYPE_STRING_FOR_SENSOR_TYPE(WRIST_TILT_GESTURE);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(DEVICE_ORIENTATION);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(POSE_6DOF);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(STATIONARY_DETECT);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(MOTION_DETECT);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(HEART_BEAT);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(DYNAMIC_SENSOR_META);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(ADDITIONAL_INFO);
-    CHECK_TYPE_STRING_FOR_SENSOR_TYPE(LOW_LATENCY_OFFBODY_DETECT);
     default:
-      ALOGW("Type %d is not checked, stringType = %s", (int)type, stringType.c_str());
+      FAIL() << "Type " << static_cast<int>(type) << " in android defined range is not checked, "
+             << "stringType = " << stringType;
 #undef CHECK_TYPE_STRING_FOR_SENSOR_TYPE
   }
-  return res;
 }
 
-bool SensorsHidlTest::typeMatchReportMode(SensorType type, SensorFlagBits reportMode) {
+void SensorsHidlTest::assertTypeMatchReportMode(SensorType type, SensorFlagBits reportMode) {
   if (type >= SensorType::DEVICE_PRIVATE_BASE) {
-    return true;
+    return;
   }
 
   SensorFlagBits expected = expectedReportModeForType(type);
 
-  return expected == (SensorFlagBits)-1 || expected == reportMode;
+  ASSERT_TRUE(expected == (SensorFlagBits) -1 || expected == reportMode)
+      << "reportMode=" << static_cast<int>(reportMode)
+      << "expected=" << static_cast<int>(expected);
 }
 
-bool SensorsHidlTest::delayMatchReportMode(
+void SensorsHidlTest::assertDelayMatchReportMode(
     int32_t minDelay, int32_t maxDelay, SensorFlagBits reportMode) {
-  bool res = true;
   switch(reportMode) {
     case SensorFlagBits::CONTINUOUS_MODE:
-      res = (minDelay > 0) && (maxDelay >= 0);
+      ASSERT_LT(0, minDelay);
+      ASSERT_LE(0, maxDelay);
       break;
     case SensorFlagBits::ON_CHANGE_MODE:
-      //TODO: current implementation does not satisfy minDelay == 0 on Proximity
-      res = (minDelay >= 0) && (maxDelay >= 0);
-      //res = (minDelay == 0) && (maxDelay >= 0);
+      ASSERT_LE(0, minDelay);
+      ASSERT_LE(0, maxDelay);
       break;
     case SensorFlagBits::ONE_SHOT_MODE:
-      res = (minDelay == -1) && (maxDelay == 0);
+      ASSERT_EQ(-1, minDelay);
+      ASSERT_EQ(0, maxDelay);
       break;
     case SensorFlagBits::SPECIAL_REPORTING_MODE:
-      res = (minDelay == 0) && (maxDelay == 0);
+      // do not enforce anything for special reporting mode
       break;
     default:
-      res = false;
+      FAIL() << "Report mode " << static_cast<int>(reportMode) << " not checked";
   }
-
-  return res;
 }
 
+// return -1 means no expectation for this type
 SensorFlagBits SensorsHidlTest::expectedReportModeForType(SensorType type) {
   switch (type) {
     case SensorType::ACCELEROMETER:
@@ -599,6 +742,24 @@
   }
 }
 
+bool SensorsHidlTest::isDirectReportRateSupported(SensorInfo sensor, RateLevel rate) {
+  unsigned int r =
+      static_cast<unsigned int>(sensor.flags & SensorFlagBits::MASK_DIRECT_REPORT)
+        >> static_cast<unsigned int>(SensorFlagShift::DIRECT_REPORT);
+  return r >= static_cast<unsigned int>(rate);
+}
+
+bool SensorsHidlTest::isDirectChannelTypeSupported(SensorInfo sensor, SharedMemType type) {
+  switch (type) {
+    case SharedMemType::ASHMEM:
+      return (sensor.flags & SensorFlagBits::DIRECT_CHANNEL_ASHMEM) != 0;
+    case SharedMemType::GRALLOC:
+      return (sensor.flags & SensorFlagBits::DIRECT_CHANNEL_GRALLOC) != 0;
+    default:
+      return false;
+  }
+}
+
 SensorInfo SensorsHidlTest::defaultSensorByType(SensorType type) {
   SensorInfo ret;
 
@@ -617,60 +778,142 @@
   return ret;
 }
 
+std::vector<SensorInfo> SensorsHidlTest::getSensorsList() {
+  std::vector<SensorInfo> ret;
+
+  S()->getSensorsList(
+      [&] (const auto &list) {
+        const size_t count = list.size();
+        ret.reserve(list.size());
+        for (size_t i = 0; i < count; ++i) {
+          ret.push_back(list[i]);
+        }
+      });
+
+  return ret;
+}
+
 // Test if sensor list returned is valid
 TEST_F(SensorsHidlTest, SensorListValid) {
   S()->getSensorsList(
       [&] (const auto &list) {
         const size_t count = list.size();
         for (size_t i = 0; i < count; ++i) {
-          auto &s = list[i];
-          ALOGV("\t%zu: handle=%#08x type=%d name=%s",
-                i, s.sensorHandle, (int)s.type, s.name.c_str());
+          const auto &s = list[i];
+          SCOPED_TRACE(::testing::Message() << i << "/" << count << ": "
+                       << " handle=0x" << std::hex << std::setw(8) << std::setfill('0')
+                       << s.sensorHandle << std::dec
+                       << " type=" << static_cast<int>(s.type)
+                       << " name=" << s.name);
 
           // Test non-empty type string
-          ASSERT_FALSE(s.typeAsString.empty());
+          EXPECT_FALSE(s.typeAsString.empty());
 
           // Test defined type matches defined string type
-          ASSERT_TRUE(typeMatchStringType(s.type, s.typeAsString));
+          EXPECT_NO_FATAL_FAILURE(assertTypeMatchStringType(s.type, s.typeAsString));
 
           // Test if all sensor has name and vendor
-          ASSERT_FALSE(s.name.empty());
-          ASSERT_FALSE(s.vendor.empty());
+          EXPECT_FALSE(s.name.empty());
+          EXPECT_FALSE(s.vendor.empty());
 
           // Test power > 0, maxRange > 0
-          ASSERT_GE(s.power, 0);
-          ASSERT_GT(s.maxRange, 0);
+          EXPECT_LE(0, s.power);
+          EXPECT_LT(0, s.maxRange);
 
           // Info type, should have no sensor
-          ASSERT_FALSE(
+          EXPECT_FALSE(
               s.type == SensorType::ADDITIONAL_INFO
               || s.type == SensorType::META_DATA);
 
           // Test fifoMax >= fifoReserved
-          ALOGV("max reserve = %d, %d", s.fifoMaxEventCount, s.fifoReservedEventCount);
-          ASSERT_GE(s.fifoMaxEventCount, s.fifoReservedEventCount);
+          EXPECT_GE(s.fifoMaxEventCount, s.fifoReservedEventCount)
+              << "max=" << s.fifoMaxEventCount << " reserved=" << s.fifoReservedEventCount;
 
           // Test Reporting mode valid
-          ASSERT_TRUE(typeMatchReportMode(s.type, extractReportMode(s.flags)));
+          EXPECT_NO_FATAL_FAILURE(assertTypeMatchReportMode(s.type, extractReportMode(s.flags)));
 
           // Test min max are in the right order
-          ASSERT_LE(s.minDelay, s.maxDelay);
+          EXPECT_LE(s.minDelay, s.maxDelay);
           // Test min/max delay matches reporting mode
-          ASSERT_TRUE(delayMatchReportMode(s.minDelay, s.maxDelay, extractReportMode(s.flags)));
+          EXPECT_NO_FATAL_FAILURE(
+              assertDelayMatchReportMode(s.minDelay, s.maxDelay, extractReportMode(s.flags)));
         }
       });
 }
 
-// Test if sensor hal can do normal accelerometer streaming properly
-TEST_F(SensorsHidlTest, NormalAccelerometerStreamingOperation) {
+// Test if sensor list returned is valid
+TEST_F(SensorsHidlTest, SetOperationMode) {
+    std::vector<SensorInfo> sensorList = getSensorsList();
 
+    bool needOperationModeSupport =
+        std::any_of(sensorList.begin(), sensorList.end(),
+                    [] (const auto& s) {
+                      return (s.flags & SensorFlagBits::DATA_INJECTION) != 0;
+                    });
+    if (!needOperationModeSupport) {
+      return;
+    }
+
+    ASSERT_EQ(Result::OK, S()->setOperationMode(OperationMode::NORMAL));
+    ASSERT_EQ(Result::OK, S()->setOperationMode(OperationMode::DATA_INJECTION));
+    ASSERT_EQ(Result::OK, S()->setOperationMode(OperationMode::NORMAL));
+}
+
+// Test if sensor list returned is valid
+TEST_F(SensorsHidlTest, InjectSensorEventData) {
+    std::vector<SensorInfo> sensorList = getSensorsList();
+    std::vector<SensorInfo> sensorSupportInjection;
+
+    bool needOperationModeSupport =
+        std::any_of(sensorList.begin(), sensorList.end(),
+                    [&sensorSupportInjection] (const auto& s) {
+                      bool ret = (s.flags & SensorFlagBits::DATA_INJECTION) != 0;
+                      if (ret) {
+                        sensorSupportInjection.push_back(s);
+                      }
+                      return ret;
+                    });
+    if (!needOperationModeSupport) {
+      return;
+    }
+
+    ASSERT_EQ(Result::OK, S()->setOperationMode(OperationMode::NORMAL));
+    ASSERT_EQ(Result::OK, S()->setOperationMode(OperationMode::DATA_INJECTION));
+
+    for (const auto &s : sensorSupportInjection) {
+      switch (s.type) {
+        case SensorType::ACCELEROMETER:
+        case SensorType::GYROSCOPE:
+        case SensorType::MAGNETIC_FIELD: {
+          usleep(100000); // sleep 100ms
+
+          Event dummy;
+          dummy.timestamp = android::elapsedRealtimeNano();
+          dummy.sensorType = s.type;
+          dummy.sensorHandle = s.sensorHandle;
+          Vec3 v = {1, 2, 3, SensorStatus::ACCURACY_HIGH};
+          dummy.u.vec3 = v;
+
+          EXPECT_EQ(Result::OK, S()->injectSensorData(dummy));
+          break;
+        }
+        default:
+          break;
+      }
+    }
+    ASSERT_EQ(Result::OK, S()->setOperationMode(OperationMode::NORMAL));
+}
+
+void SensorsHidlTest::testStreamingOperation(SensorType type,
+                                             std::chrono::nanoseconds samplingPeriod,
+                                             std::chrono::seconds duration,
+                                             const SensorEventsChecker &checker) {
   std::vector<Event> events;
 
-  constexpr int64_t samplingPeriodInNs = 20ull*1000*1000; // 20ms
-  constexpr int64_t batchingPeriodInNs = 0; // no batching
-  constexpr useconds_t minTimeUs = 5*1000*1000;  // 5 s
-  constexpr size_t minNEvent = 100;  // at lease 100 events
-  constexpr SensorType type = SensorType::ACCELEROMETER;
+  const int64_t samplingPeriodInNs = samplingPeriod.count();
+  const int64_t batchingPeriodInNs = 0; // no batching
+  const useconds_t minTimeUs = std::chrono::microseconds(duration).count();
+  const size_t minNEvent = duration / samplingPeriod;
 
   SensorInfo sensor = defaultSensorByType(type);
 
@@ -679,6 +922,11 @@
     return;
   }
 
+  if (std::chrono::microseconds(sensor.minDelay) > samplingPeriod) {
+    // rate not supported
+    return;
+  }
+
   int32_t handle = sensor.sensorHandle;
 
   ASSERT_EQ(batch(handle, samplingPeriodInNs, batchingPeriodInNs), Result::OK);
@@ -691,90 +939,110 @@
   ASSERT_GT(events.size(), 0u);
 
   size_t nRealEvent = 0;
+  bool handleMismatchReported = false;
+  bool metaSensorTypeErrorReported = false;
   for (auto & e : events) {
     if (e.sensorType == type) {
-
-      ASSERT_EQ(e.sensorHandle, handle);
-
-      Vec3 acc = e.u.vec3;
-
-      double gravityNorm = std::sqrt(acc.x * acc.x + acc.y * acc.y + acc.z * acc.z);
-      ALOGV("Norm = %f", gravityNorm);
-
-      // assert this is earth gravity
-      ASSERT_TRUE(std::fabs(gravityNorm - GRAVITY_EARTH) < 1);
-
+      // avoid generating hundreds of error
+      if (!handleMismatchReported) {
+        EXPECT_EQ(e.sensorHandle, handle)
+            << (handleMismatchReported = true,
+                "Event of the same type must come from the sensor registered");
+      }
       ++ nRealEvent;
     } else {
-      ALOGI("Event type %d, handle %d", (int) e.sensorType, (int) e.sensorHandle);
-      // Only meta types are allowed besides the subscribed sensor
-      ASSERT_TRUE(isMetaSensorType(e.sensorType));
+      // avoid generating hundreds of error
+      if (!metaSensorTypeErrorReported) {
+        EXPECT_TRUE(isMetaSensorType(e.sensorType))
+            << (metaSensorTypeErrorReported = true,
+                "Only meta types are allowed besides the type registered");
+      }
     }
   }
 
-  ASSERT_GE(nRealEvent, minNEvent / 2); // make sure returned events are not all meta
+  std::string s;
+  EXPECT_TRUE(checker.check(events, &s)) << s;
+
+  EXPECT_GE(nRealEvent, minNEvent / 2); // make sure returned events are not all meta
 }
 
-// Test if sensor hal can do gyroscope streaming properly
-TEST_F(SensorsHidlTest, NormalGyroscopeStreamingOperation) {
-  std::vector<Event> events;
-
-  constexpr int64_t samplingPeriodInNs = 10ull*1000*1000; // 10ms
-  constexpr int64_t batchingPeriodInNs = 0; // no batching
-  constexpr useconds_t minTimeUs = 5*1000*1000;  // 5 s
-  constexpr size_t minNEvent = 200;
-  constexpr SensorType type = SensorType::GYROSCOPE;
-
-  SensorInfo sensor = defaultSensorByType(type);
-
-  if (!isValidType(sensor.type)) {
-    // no default sensor of this type
-    return;
-  }
-
-  int32_t handle = sensor.sensorHandle;
-
-  ASSERT_EQ(batch(handle, samplingPeriodInNs, batchingPeriodInNs), Result::OK);
-  ASSERT_EQ(activate(handle, 1), Result::OK);
-  events = collectEvents(minTimeUs, minNEvent, true /*clearBeforeStart*/);
-  ASSERT_EQ(activate(handle, 0), Result::OK);
-
-  ALOGI("Collected %zu samples", events.size());
-
-  ASSERT_GT(events.size(), 0u);
-
-  size_t nRealEvent = 0;
-  for (auto & e : events) {
-    if (e.sensorType == type) {
-
-      ASSERT_EQ(e.sensorHandle, handle);
-
-      Vec3 gyro = e.u.vec3;
-
-      double gyroNorm = std::sqrt(gyro.x * gyro.x + gyro.y * gyro.y + gyro.z * gyro.z);
-      ALOGV("Gyro Norm = %f", gyroNorm);
-
-      // assert not drifting
-      ASSERT_TRUE(gyroNorm < 0.1);  // < ~5 degree/s
-
-      ++ nRealEvent;
-    } else {
-      ALOGI("Event type %d, handle %d", (int) e.sensorType, (int) e.sensorHandle);
-      // Only meta types are allowed besides the subscribed sensor
-      ASSERT_TRUE(isMetaSensorType(e.sensorType));
-    }
-  }
-
-  ASSERT_GE(nRealEvent, minNEvent / 2); // make sure returned events are not all meta
+// Test if sensor hal can do UI speed accelerometer streaming properly
+TEST_F(SensorsHidlTest, AccelerometerStreamingOperationSlow) {
+  testStreamingOperation(SensorType::ACCELEROMETER,
+                         std::chrono::milliseconds(200),
+                         std::chrono::seconds(5),
+                         sAccelNormChecker);
 }
 
-// Test if sensor hal can do accelerometer sampling rate switch properly when sensor is active
-TEST_F(SensorsHidlTest, AccelerometerSamplingPeriodHotSwitchOperation) {
+// Test if sensor hal can do normal speed accelerometer streaming properly
+TEST_F(SensorsHidlTest, AccelerometerStreamingOperationNormal) {
+  testStreamingOperation(SensorType::ACCELEROMETER,
+                         std::chrono::milliseconds(20),
+                         std::chrono::seconds(5),
+                         sAccelNormChecker);
+}
+
+// Test if sensor hal can do game speed accelerometer streaming properly
+TEST_F(SensorsHidlTest, AccelerometerStreamingOperationFast) {
+  testStreamingOperation(SensorType::ACCELEROMETER,
+                         std::chrono::milliseconds(5),
+                         std::chrono::seconds(5),
+                         sAccelNormChecker);
+}
+
+// Test if sensor hal can do UI speed gyroscope streaming properly
+TEST_F(SensorsHidlTest, GyroscopeStreamingOperationSlow) {
+  testStreamingOperation(SensorType::GYROSCOPE,
+                         std::chrono::milliseconds(200),
+                         std::chrono::seconds(5),
+                         sGyroNormChecker);
+}
+
+// Test if sensor hal can do normal speed gyroscope streaming properly
+TEST_F(SensorsHidlTest, GyroscopeStreamingOperationNormal) {
+  testStreamingOperation(SensorType::GYROSCOPE,
+                         std::chrono::milliseconds(20),
+                         std::chrono::seconds(5),
+                         sGyroNormChecker);
+}
+
+// Test if sensor hal can do game speed gyroscope streaming properly
+TEST_F(SensorsHidlTest, GyroscopeStreamingOperationFast) {
+  testStreamingOperation(SensorType::GYROSCOPE,
+                         std::chrono::milliseconds(5),
+                         std::chrono::seconds(5),
+                         sGyroNormChecker);
+}
+
+// Test if sensor hal can do UI speed magnetometer streaming properly
+TEST_F(SensorsHidlTest, MagnetometerStreamingOperationSlow) {
+  testStreamingOperation(SensorType::MAGNETIC_FIELD,
+                         std::chrono::milliseconds(200),
+                         std::chrono::seconds(5),
+                         NullChecker());
+}
+
+// Test if sensor hal can do normal speed magnetometer streaming properly
+TEST_F(SensorsHidlTest, MagnetometerStreamingOperationNormal) {
+  testStreamingOperation(SensorType::MAGNETIC_FIELD,
+                         std::chrono::milliseconds(20),
+                         std::chrono::seconds(5),
+                         NullChecker());
+}
+
+// Test if sensor hal can do game speed magnetometer streaming properly
+TEST_F(SensorsHidlTest, MagnetometerStreamingOperationFast) {
+  testStreamingOperation(SensorType::MAGNETIC_FIELD,
+                         std::chrono::milliseconds(5),
+                         std::chrono::seconds(5),
+                         NullChecker());
+}
+
+void SensorsHidlTest::testSamplingRateHotSwitchOperation(SensorType type) {
   std::vector<Event> events1, events2;
 
   constexpr int64_t batchingPeriodInNs = 0; // no batching
   constexpr size_t minNEvent = 50;
-  constexpr SensorType type = SensorType::ACCELEROMETER;
 
   SensorInfo sensor = defaultSensorByType(type);
 
@@ -845,21 +1113,34 @@
   maxDelayAverageInterval = timestampInterval / (nEvent - 1);
 
   // change of rate is significant.
-  ASSERT_GT((maxDelayAverageInterval - minDelayAverageInterval), minDelayAverageInterval / 10);
+  EXPECT_GT((maxDelayAverageInterval - minDelayAverageInterval), minDelayAverageInterval / 10);
 
   // fastest rate sampling time is close to spec
   ALOGI("minDelayAverageInterval = %" PRId64, minDelayAverageInterval);
-  ASSERT_LT(std::abs(minDelayAverageInterval - minSamplingPeriodInNs),
+  EXPECT_LT(std::abs(minDelayAverageInterval - minSamplingPeriodInNs),
       minSamplingPeriodInNs / 10);
 }
 
-// Test if sensor hal can do normal accelerometer batching properly
-TEST_F(SensorsHidlTest, AccelerometerBatchingOperation) {
+// Test if sensor hal can do accelerometer sampling rate switch properly when sensor is active
+TEST_F(SensorsHidlTest, AccelerometerSamplingPeriodHotSwitchOperation) {
+  testSamplingRateHotSwitchOperation(SensorType::ACCELEROMETER);
+}
+
+// Test if sensor hal can do gyroscope sampling rate switch properly when sensor is active
+TEST_F(SensorsHidlTest, GyroscopeSamplingPeriodHotSwitchOperation) {
+  testSamplingRateHotSwitchOperation(SensorType::GYROSCOPE);
+}
+
+// Test if sensor hal can do magnetometer sampling rate switch properly when sensor is active
+TEST_F(SensorsHidlTest, MagnetometerSamplingPeriodHotSwitchOperation) {
+  testSamplingRateHotSwitchOperation(SensorType::MAGNETIC_FIELD);
+}
+
+void SensorsHidlTest::testBatchingOperation(SensorType type) {
   std::vector<Event> events;
 
-  constexpr int64_t oneSecondInNs = 1ull * 1000 * 1000 * 1000;
-  constexpr SensorType type = SensorType::ACCELEROMETER;
   constexpr int64_t maxBatchingTestTimeNs = 30ull * 1000 * 1000 * 1000;
+  constexpr int64_t oneSecondInNs = 1ull * 1000 * 1000 * 1000;
 
   SensorInfo sensor = defaultSensorByType(type);
 
@@ -922,24 +1203,46 @@
   ASSERT_GT(nEvent, (size_t)(batchingPeriodInNs / minSamplingPeriodInNs * 9 / 10));
 }
 
-// Test sensor event direct report with ashmem for gyro sensor
-TEST_F(SensorsHidlTest, GyroscopeAshmemDirectReport) {
+// Test if sensor hal can do accelerometer batching properly
+TEST_F(SensorsHidlTest, AccelerometerBatchingOperation) {
+  testBatchingOperation(SensorType::ACCELEROMETER);
+}
 
-  constexpr SensorType type = SensorType::GYROSCOPE;
-  constexpr size_t kEventSize = 104;
+// Test if sensor hal can do gyroscope batching properly
+TEST_F(SensorsHidlTest, GyroscopeBatchingOperation) {
+  testBatchingOperation(SensorType::GYROSCOPE);
+}
+
+// Test if sensor hal can do magnetometer batching properly
+TEST_F(SensorsHidlTest, MagnetometerBatchingOperation) {
+  testBatchingOperation(SensorType::MAGNETIC_FIELD);
+}
+
+void SensorsHidlTest::testDirectReportOperation(
+    SensorType type, SharedMemType memType, RateLevel rate, const SensorEventsChecker &checker) {
+  constexpr size_t kEventSize = static_cast<size_t>(SensorsEventFormatOffset::TOTAL_LENGTH);
   constexpr size_t kNEvent = 500;
   constexpr size_t kMemSize = kEventSize * kNEvent;
 
+  constexpr float kNormalNominal = 50;
+  constexpr float kFastNominal = 200;
+  constexpr float kVeryFastNominal = 800;
+
+  constexpr float kNominalTestTimeSec = 1.f;
+  constexpr float kMaxTestTimeSec = kNominalTestTimeSec + 0.5f; // 0.5 second for initialization
+
   SensorInfo sensor = defaultSensorByType(type);
 
-  if (!(sensor.flags | SensorFlagBits::MASK_DIRECT_REPORT)
-      || !(sensor.flags | SensorFlagBits::DIRECT_CHANNEL_ASHMEM)) {
-    // does not declare support
+  if (!isDirectReportRateSupported(sensor, rate)) {
+    return;
+  }
+
+  if (!isDirectChannelTypeSupported(sensor, memType)) {
     return;
   }
 
   std::unique_ptr<SensorsTestSharedMemory>
-      mem(SensorsTestSharedMemory::create(SharedMemType::ASHMEM, kMemSize));
+      mem(SensorsTestSharedMemory::create(memType, kMemSize));
   ASSERT_NE(mem, nullptr);
 
   char* buffer = mem->getBuffer();
@@ -961,39 +1264,119 @@
   }
 
   int32_t eventToken;
-  configDirectReport(sensor.sensorHandle, channelHandle, RateLevel::NORMAL,
+  configDirectReport(sensor.sensorHandle, channelHandle, rate,
       [&eventToken] (auto result, auto token) {
           ASSERT_EQ(result, Result::OK);
           eventToken = token;
       });
 
-  usleep(1500000); // sleep 1 sec for data, plus 0.5 sec for initialization
+  usleep(static_cast<useconds_t>(kMaxTestTimeSec * 1e6f));
   auto events = mem->parseEvents();
 
-  // allowed to be 55% of nominal freq (50Hz)
-  ASSERT_GT(events.size(), 50u / 2u);
-  ASSERT_LT(events.size(), static_cast<size_t>(110*1.5));
+  // find norminal rate
+  float nominalFreq = 0.f;
+  switch (rate) {
+      case RateLevel::NORMAL:
+          nominalFreq = kNormalNominal;
+          break;
+      case RateLevel::FAST:
+          nominalFreq = kFastNominal;
+          break;
+      case RateLevel::VERY_FAST:
+          nominalFreq = kVeryFastNominal;
+          break;
+      case RateLevel::STOP:
+          FAIL();
+  }
+
+  // allowed to be between 55% and 220% of nominal freq
+  ASSERT_GT(events.size(), static_cast<size_t>(nominalFreq * 0.55f * kNominalTestTimeSec));
+  ASSERT_LT(events.size(), static_cast<size_t>(nominalFreq * 2.2f * kMaxTestTimeSec));
 
   int64_t lastTimestamp = 0;
+  bool typeErrorReported = false;
+  bool tokenErrorReported = false;
+  bool timestampErrorReported = false;
   for (auto &e : events) {
-    ASSERT_EQ(e.sensorType, type);
-    ASSERT_EQ(e.sensorHandle, eventToken);
-    ASSERT_GT(e.timestamp, lastTimestamp);
-
-    Vec3 gyro = e.u.vec3;
-    double gyroNorm = std::sqrt(gyro.x * gyro.x + gyro.y * gyro.y + gyro.z * gyro.z);
-    // assert not drifting
-    ASSERT_TRUE(gyroNorm < 0.1);  // < ~5 degree/sa
-
+    if (!typeErrorReported) {
+      EXPECT_EQ(type, e.sensorType)
+          << (typeErrorReported = true, "Type in event does not match type of sensor registered.");
+    }
+    if (!tokenErrorReported) {
+      EXPECT_EQ(eventToken, e.sensorHandle)
+          << (tokenErrorReported = true,
+            "Event token does not match that retured from configDirectReport");
+    }
+    if (!timestampErrorReported) {
+      EXPECT_GT(e.timestamp, lastTimestamp)
+          << (timestampErrorReported = true, "Timestamp not monotonically increasing");
+    }
     lastTimestamp = e.timestamp;
   }
 
+  std::string s;
+  EXPECT_TRUE(checker.check(events, &s)) << s;
+
   // stop sensor and unregister channel
   configDirectReport(sensor.sensorHandle, channelHandle, RateLevel::STOP,
         [&eventToken] (auto result, auto) {
-            ASSERT_EQ(result, Result::OK);
+            EXPECT_EQ(result, Result::OK);
         });
-  ASSERT_EQ(unregisterDirectChannel(channelHandle), Result::OK);
+  EXPECT_EQ(unregisterDirectChannel(channelHandle), Result::OK);
+}
+
+// Test sensor event direct report with ashmem for accel sensor at normal rate
+TEST_F(SensorsHidlTest, AccelerometerAshmemDirectReportOperationNormal) {
+  testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::ASHMEM, RateLevel::NORMAL,
+                            sAccelNormChecker);
+}
+
+// Test sensor event direct report with ashmem for accel sensor at fast rate
+TEST_F(SensorsHidlTest, AccelerometerAshmemDirectReportOperationFast) {
+  testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::ASHMEM, RateLevel::FAST,
+                            sAccelNormChecker);
+}
+
+// Test sensor event direct report with ashmem for accel sensor at very fast rate
+TEST_F(SensorsHidlTest, AccelerometerAshmemDirectReportOperationVeryFast) {
+  testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::ASHMEM, RateLevel::VERY_FAST,
+                            sAccelNormChecker);
+}
+
+// Test sensor event direct report with ashmem for gyro sensor at normal rate
+TEST_F(SensorsHidlTest, GyroscopeAshmemDirectReportOperationNormal) {
+  testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::ASHMEM, RateLevel::NORMAL,
+                            sGyroNormChecker);
+}
+
+// Test sensor event direct report with ashmem for gyro sensor at fast rate
+TEST_F(SensorsHidlTest, GyroscopeAshmemDirectReportOperationFast) {
+  testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::ASHMEM, RateLevel::FAST,
+                            sGyroNormChecker);
+}
+
+// Test sensor event direct report with ashmem for gyro sensor at very fast rate
+TEST_F(SensorsHidlTest, GyroscopeAshmemDirectReportOperationVeryFast) {
+  testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::ASHMEM, RateLevel::VERY_FAST,
+                            sGyroNormChecker);
+}
+
+// Test sensor event direct report with ashmem for mag sensor at normal rate
+TEST_F(SensorsHidlTest, MagnetometerAshmemDirectReportOperationNormal) {
+  testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::ASHMEM, RateLevel::NORMAL,
+                            NullChecker());
+}
+
+// Test sensor event direct report with ashmem for mag sensor at fast rate
+TEST_F(SensorsHidlTest, MagnetometerAshmemDirectReportOperationFast) {
+  testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::ASHMEM, RateLevel::FAST,
+                            NullChecker());
+}
+
+// Test sensor event direct report with ashmem for mag sensor at very fast rate
+TEST_F(SensorsHidlTest, MagnetometerAshmemDirectReportOperationVeryFast) {
+  testDirectReportOperation(
+      SensorType::MAGNETIC_FIELD, SharedMemType::ASHMEM, RateLevel::VERY_FAST, NullChecker());
 }
 
 int main(int argc, char **argv) {
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
index ab1b6a3..c6ac03c 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
@@ -18,8 +18,33 @@
 
 #include <VtsHalHidlTargetTestBase.h>
 
+#include <android/hardware/wifi/supplicant/1.0/ISupplicant.h>
+
 #include "supplicant_hidl_test_utils.h"
 
+using ::android::sp;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::wifi::supplicant::V1_0::ISupplicant;
+using ::android::hardware::wifi::supplicant::V1_0::ISupplicantIface;
+using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
+using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
+using ::android::hardware::wifi::supplicant::V1_0::IfaceType;
+
+class SupplicantHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+   public:
+    virtual void SetUp() override {
+        startSupplicantAndWaitForHidlService();
+        supplicant_ = getSupplicant();
+        ASSERT_NE(supplicant_.get(), nullptr);
+    }
+
+    virtual void TearDown() override { stopSupplicant(); }
+
+   protected:
+    // ISupplicant object used for all tests in this fixture.
+    sp<ISupplicant> supplicant_;
+};
+
 /*
  * Create:
  * Ensures that an instance of the ISupplicant proxy object is
@@ -30,3 +55,131 @@
     EXPECT_NE(nullptr, getSupplicant().get());
     stopSupplicant();
 }
+
+/*
+ * ListInterfaces
+ */
+TEST_F(SupplicantHidlTest, ListInterfaces) {
+    std::vector<ISupplicant::IfaceInfo> ifaces;
+    supplicant_->listInterfaces(
+        [&](const SupplicantStatus& status,
+            const hidl_vec<ISupplicant::IfaceInfo>& hidl_ifaces) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            ifaces = hidl_ifaces;
+        });
+
+    EXPECT_NE(ifaces.end(),
+              std::find_if(ifaces.begin(), ifaces.end(), [](const auto& iface) {
+                  return iface.type == IfaceType::STA;
+              }));
+    EXPECT_NE(ifaces.end(),
+              std::find_if(ifaces.begin(), ifaces.end(), [](const auto& iface) {
+                  return iface.type == IfaceType::P2P;
+              }));
+}
+
+/*
+ * GetInterface
+ */
+TEST_F(SupplicantHidlTest, GetInterface) {
+    std::vector<ISupplicant::IfaceInfo> ifaces;
+    supplicant_->listInterfaces(
+        [&](const SupplicantStatus& status,
+            const hidl_vec<ISupplicant::IfaceInfo>& hidl_ifaces) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            ifaces = hidl_ifaces;
+        });
+
+    ASSERT_NE(0u, ifaces.size());
+    supplicant_->getInterface(
+        ifaces[0],
+        [&](const SupplicantStatus& status, const sp<ISupplicantIface>& iface) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_NE(nullptr, iface.get());
+        });
+}
+
+/*
+ * SetDebugParams
+ */
+TEST_F(SupplicantHidlTest, SetDebugParams) {
+    bool show_timestamp = true;
+    bool show_keys = true;
+    ISupplicant::DebugLevel level = ISupplicant::DebugLevel::EXCESSIVE;
+
+    supplicant_->setDebugParams(level,
+                                show_timestamp,  // show timestamps
+                                show_keys,       // show keys
+                                [](const SupplicantStatus& status) {
+                                    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+                                              status.code);
+                                });
+}
+
+/*
+ * GetDebugLevel
+ */
+TEST_F(SupplicantHidlTest, GetDebugLevel) {
+    bool show_timestamp = true;
+    bool show_keys = true;
+    ISupplicant::DebugLevel level = ISupplicant::DebugLevel::EXCESSIVE;
+
+    supplicant_->setDebugParams(level,
+                                show_timestamp,  // show timestamps
+                                show_keys,       // show keys
+                                [](const SupplicantStatus& status) {
+                                    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+                                              status.code);
+                                });
+    EXPECT_EQ(level, supplicant_->getDebugLevel());
+}
+
+/*
+ * IsDebugShowTimestampEnabled
+ */
+TEST_F(SupplicantHidlTest, IsDebugShowTimestampEnabled) {
+    bool show_timestamp = true;
+    bool show_keys = true;
+    ISupplicant::DebugLevel level = ISupplicant::DebugLevel::EXCESSIVE;
+
+    supplicant_->setDebugParams(level,
+                                show_timestamp,  // show timestamps
+                                show_keys,       // show keys
+                                [](const SupplicantStatus& status) {
+                                    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+                                              status.code);
+                                });
+    EXPECT_EQ(show_timestamp, supplicant_->isDebugShowTimestampEnabled());
+}
+
+/*
+ * IsDebugShowKeysEnabled
+ */
+TEST_F(SupplicantHidlTest, IsDebugShowKeysEnabled) {
+    bool show_timestamp = true;
+    bool show_keys = true;
+    ISupplicant::DebugLevel level = ISupplicant::DebugLevel::EXCESSIVE;
+
+    supplicant_->setDebugParams(level,
+                                show_timestamp,  // show timestamps
+                                show_keys,       // show keys
+                                [](const SupplicantStatus& status) {
+                                    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+                                              status.code);
+                                });
+    EXPECT_EQ(show_keys, supplicant_->isDebugShowKeysEnabled());
+}
+
+/*
+ * SetConcurrenyPriority
+ */
+TEST_F(SupplicantHidlTest, SetConcurrencyPriority) {
+    supplicant_->setConcurrencyPriority(
+        IfaceType::STA, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    supplicant_->setConcurrencyPriority(
+        IfaceType::P2P, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+}
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp
index fdee0c6..1fcfc8c 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp
@@ -17,9 +17,9 @@
 #include <android-base/logging.h>
 #include <VtsHalHidlTargetTestBase.h>
 
-#include <hidl/HidlTransportSupport.h>
 #include <android/hidl/manager/1.0/IServiceManager.h>
 #include <android/hidl/manager/1.0/IServiceNotification.h>
+#include <hidl/HidlTransportSupport.h>
 
 #include <wifi_hal/driver_tool.h>
 #include <wifi_system/interface_tool.h>
@@ -174,7 +174,7 @@
 }
 
 sp<ISupplicant> getSupplicant() {
-    return getService<ISupplicant>(kSupplicantServiceName);
+    return ::testing::VtsHalHidlTargetTestBase::getService<ISupplicant>();
 }
 
 sp<ISupplicantStaIface> getSupplicantStaIface() {
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
index 332b57b..c6cf01f 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
@@ -18,8 +18,144 @@
 
 #include <VtsHalHidlTargetTestBase.h>
 
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantP2pIface.h>
+
 #include "supplicant_hidl_test_utils.h"
 
+using ::android::sp;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIface;
+using ::android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIfaceCallback;
+using ::android::hardware::wifi::supplicant::V1_0::SupplicantNetworkId;
+using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
+using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
+
+namespace {
+constexpr uint8_t kTestSsidPostfix[] = {'t', 'e', 's', 't'};
+constexpr uint8_t kTestMacAddr[] = {0x56, 0x67, 0x67, 0xf4, 0x56, 0x92};
+constexpr uint8_t kTestPeerMacAddr[] = {0x56, 0x67, 0x55, 0xf4, 0x56, 0x92};
+constexpr char kTestConnectPin[] = "34556665";
+constexpr char kTestGroupIfName[] = "TestGroup";
+constexpr uint32_t kTestConnectGoIntent = 6;
+constexpr uint32_t kTestFindTimeout = 5;
+constexpr SupplicantNetworkId kTestNetworkId = 5;
+constexpr uint32_t kTestChannel = 1;
+constexpr uint32_t kTestOperatingClass = 81;
+constexpr uint32_t kTestFreqRange[] = {2412, 2432};
+constexpr uint32_t kTestExtListenPeriod = 400;
+constexpr uint32_t kTestExtListenInterval = 400;
+}  // namespace
+
+class SupplicantP2pIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+   public:
+    virtual void SetUp() override {
+        startSupplicantAndWaitForHidlService();
+        EXPECT_TRUE(turnOnExcessiveLogging());
+        p2p_iface_ = getSupplicantP2pIface();
+        ASSERT_NE(p2p_iface_.get(), nullptr);
+
+        memcpy(mac_addr_.data(), kTestMacAddr, mac_addr_.size());
+        memcpy(peer_mac_addr_.data(), kTestPeerMacAddr, peer_mac_addr_.size());
+    }
+
+    virtual void TearDown() override { stopSupplicant(); }
+
+   protected:
+    // ISupplicantP2pIface object used for all tests in this fixture.
+    sp<ISupplicantP2pIface> p2p_iface_;
+    // MAC address to use for various tests.
+    std::array<uint8_t, 6> mac_addr_;
+    std::array<uint8_t, 6> peer_mac_addr_;
+};
+
+class IfaceCallback : public ISupplicantP2pIfaceCallback {
+    Return<void> onNetworkAdded(uint32_t /* id */) override { return Void(); }
+    Return<void> onNetworkRemoved(uint32_t /* id */) override { return Void(); }
+    Return<void> onDeviceFound(
+        const hidl_array<uint8_t, 6>& /* srcAddress */,
+        const hidl_array<uint8_t, 6>& /* p2pDeviceAddress */,
+        const hidl_array<uint8_t, 8>& /* primaryDeviceType */,
+        const hidl_string& /* deviceName */, uint16_t /* configMethods */,
+        uint8_t /* deviceCapabilities */, uint32_t /* groupCapabilities */,
+        const hidl_array<uint8_t, 8>& /* wfdDeviceInfo */) override {
+        return Void();
+    }
+    Return<void> onDeviceLost(
+        const hidl_array<uint8_t, 6>& /* p2pDeviceAddress */) override {
+        return Void();
+    }
+    Return<void> onFindStopped() override { return Void(); }
+    Return<void> onGoNegotiationRequest(
+        const hidl_array<uint8_t, 6>& /* srcAddress */,
+        ISupplicantP2pIfaceCallback::WpsDevPasswordId /* passwordId */)
+        override {
+        return Void();
+    }
+    Return<void> onGoNegotiationCompleted(
+        ISupplicantP2pIfaceCallback::P2pStatusCode /* status */) override {
+        return Void();
+    }
+    Return<void> onGroupFormationSuccess() override { return Void(); }
+    Return<void> onGroupFormationFailure(
+        const hidl_string& /* failureReason */) override {
+        return Void();
+    }
+    Return<void> onGroupStarted(
+        const hidl_string& /* groupIfname */, bool /* isGo */,
+        const hidl_vec<uint8_t>& /* ssid */, uint32_t /* frequency */,
+        const hidl_array<uint8_t, 32>& /* psk */,
+        const hidl_string& /* passphrase */,
+        const hidl_array<uint8_t, 6>& /* goDeviceAddress */,
+        bool /* isPersistent */) override {
+        return Void();
+    }
+    Return<void> onGroupRemoved(const hidl_string& /* groupIfname */,
+                                bool /* isGo */) override {
+        return Void();
+    }
+    Return<void> onInvitationReceived(
+        const hidl_array<uint8_t, 6>& /* srcAddress */,
+        const hidl_array<uint8_t, 6>& /* goDeviceAddress */,
+        const hidl_array<uint8_t, 6>& /* bssid */,
+        uint32_t /* persistentNetworkId */,
+        uint32_t /* operatingFrequency */) override {
+        return Void();
+    }
+    Return<void> onInvitationResult(
+        const hidl_array<uint8_t, 6>& /* bssid */,
+        ISupplicantP2pIfaceCallback::P2pStatusCode /* status */) override {
+        return Void();
+    }
+    Return<void> onProvisionDiscoveryCompleted(
+        const hidl_array<uint8_t, 6>& /* p2pDeviceAddress */,
+        bool /* isRequest */,
+        ISupplicantP2pIfaceCallback::P2pProvDiscStatusCode /* status */,
+        uint16_t /* configMethods */,
+        const hidl_string& /* generatedPin */) override {
+        return Void();
+    }
+    Return<void> onServiceDiscoveryResponse(
+        const hidl_array<uint8_t, 6>& /* srcAddress */,
+        uint16_t /* updateIndicator */,
+        const hidl_vec<uint8_t>& /* tlvs */) override {
+        return Void();
+    }
+    Return<void> onStaAuthorized(
+        const hidl_array<uint8_t, 6>& /* srcAddress */,
+        const hidl_array<uint8_t, 6>& /* p2pDeviceAddress */) override {
+        return Void();
+    }
+    Return<void> onStaDeauthorized(
+        const hidl_array<uint8_t, 6>& /* srcAddress */,
+        const hidl_array<uint8_t, 6>& /* p2pDeviceAddress */) override {
+        return Void();
+    }
+};
+
 /*
  * Create:
  * Ensures that an instance of the ISupplicantP2pIface proxy object is
@@ -30,3 +166,248 @@
     EXPECT_NE(nullptr, getSupplicantP2pIface().get());
     stopSupplicant();
 }
+
+/*
+ * RegisterCallback
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, RegisterCallback) {
+    p2p_iface_->registerCallback(
+        new IfaceCallback(), [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+}
+
+/*
+ * GetDeviceAddress
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, GetDeviceAddress) {
+    p2p_iface_->getDeviceAddress(
+        [](const SupplicantStatus& status,
+           const hidl_array<uint8_t, 6>& /* mac_addr */) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+}
+
+/*
+ * SetSsidPostfix
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetSsidPostfix) {
+    std::vector<uint8_t> ssid(kTestSsidPostfix,
+                              kTestSsidPostfix + sizeof(kTestSsidPostfix));
+    p2p_iface_->setSsidPostfix(ssid, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+}
+
+/*
+ * Find
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, Find) {
+    p2p_iface_->find(kTestFindTimeout, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+}
+
+/*
+ * StopFind
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, StopFind) {
+    p2p_iface_->find(kTestFindTimeout, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+
+    p2p_iface_->stopFind([](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+
+    p2p_iface_->stopFind([](const SupplicantStatus& status) {
+        EXPECT_NE(SupplicantStatusCode::SUCCESS, status.code);
+    });
+}
+
+/*
+ * Flush
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, Flush) {
+    p2p_iface_->flush([](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+}
+
+/*
+ * Connect
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, Connect) {
+    p2p_iface_->connect(
+        mac_addr_, ISupplicantP2pIface::WpsProvisionMethod::PBC,
+        kTestConnectPin, false, false, kTestConnectGoIntent,
+        [](const SupplicantStatus& status, const hidl_string& /* pin */) {
+            // This is not going to work with fake values.
+            EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
+        });
+}
+
+/*
+ * CancelConnect
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, CancelConnect) {
+    p2p_iface_->connect(
+        mac_addr_, ISupplicantP2pIface::WpsProvisionMethod::PBC,
+        kTestConnectPin, false, false, kTestConnectGoIntent,
+        [](const SupplicantStatus& status, const hidl_string& /* pin */) {
+            // This is not going to work with fake values.
+            EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
+        });
+
+    p2p_iface_->cancelConnect([](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
+    });
+}
+
+/*
+ * ProvisionDiscovery
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, ProvisionDiscovery) {
+    p2p_iface_->provisionDiscovery(
+        mac_addr_, ISupplicantP2pIface::WpsProvisionMethod::PBC,
+        [](const SupplicantStatus& status) {
+            // This is not going to work with fake values.
+            EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
+        });
+}
+
+/*
+ * AddGroup
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, AddGroup) {
+    p2p_iface_->addGroup(false, kTestNetworkId,
+                         [](const SupplicantStatus& /* status */) {
+                             // TODO: Figure out the initialization sequence for
+                             // this to work.
+                             // EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+                             // status.code);
+                         });
+}
+
+/*
+ * Reject
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, Reject) {
+    p2p_iface_->reject(mac_addr_, [](const SupplicantStatus& status) {
+        // This is not going to work with fake values.
+        EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
+    });
+}
+
+/*
+ * Invite
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, Invite) {
+    p2p_iface_->invite(kTestGroupIfName, mac_addr_, peer_mac_addr_,
+                       [](const SupplicantStatus& status) {
+                           // This is not going to work with fake values.
+                           EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN,
+                                     status.code);
+                       });
+}
+
+/*
+ * Reinvoke
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, Reinvoke) {
+    p2p_iface_->reinvoke(
+        kTestNetworkId, mac_addr_, [](const SupplicantStatus& status) {
+            // This is not going to work with fake values.
+            EXPECT_EQ(SupplicantStatusCode::FAILURE_NETWORK_UNKNOWN,
+                      status.code);
+        });
+}
+
+/*
+ * ConfigureExtListen
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, ConfigureExtListen) {
+    p2p_iface_->configureExtListen(kTestExtListenPeriod, kTestExtListenInterval,
+                                   [](const SupplicantStatus& status) {
+                                       EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+                                                 status.code);
+                                   });
+}
+
+/*
+ * SetListenChannel
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetListenChannel) {
+    p2p_iface_->setListenChannel(
+        kTestChannel, kTestOperatingClass, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+}
+
+/*
+ * SetDisallowedFrequencies
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetDisallowedFrequencies) {
+    std::vector<ISupplicantP2pIface::FreqRange> ranges = {
+        {kTestFreqRange[0], kTestFreqRange[1]}};
+    p2p_iface_->setDisallowedFrequencies(
+        ranges, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+}
+
+/*
+ * GetSsid
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, GetSsid) {
+    std::array<uint8_t, 6> mac_addr;
+    memcpy(mac_addr.data(), kTestMacAddr, mac_addr.size());
+    p2p_iface_->getSsid(mac_addr, [](const SupplicantStatus& status,
+                                     const hidl_vec<uint8_t>& /* ssid */) {
+        // This is not going to work with fake values.
+        EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
+    });
+}
+
+/*
+ * GetGroupCapability
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, GetGroupCapability) {
+    std::array<uint8_t, 6> mac_addr;
+    memcpy(mac_addr.data(), kTestMacAddr, mac_addr.size());
+    p2p_iface_->getGroupCapability(
+        mac_addr, [](const SupplicantStatus& status, uint32_t /* caps */) {
+            // This is not going to work with fake values.
+            EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
+        });
+}
+
+/*
+ * FlushServices
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, FlushServices) {
+    p2p_iface_->flushServices([](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+}
+
+/*
+ * SetMiracastMode
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetMiracastMode) {
+    p2p_iface_->setMiracastMode(ISupplicantP2pIface::MiracastMode::DISABLED,
+                                [](const SupplicantStatus& status) {
+                                    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+                                              status.code);
+                                });
+    p2p_iface_->setMiracastMode(ISupplicantP2pIface::MiracastMode::SOURCE,
+                                [](const SupplicantStatus& status) {
+                                    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+                                              status.code);
+                                });
+    p2p_iface_->setMiracastMode(ISupplicantP2pIface::MiracastMode::SINK,
+                                [](const SupplicantStatus& status) {
+                                    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+                                              status.code);
+                                });
+}
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
index c50539b..c2a58b6 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
@@ -18,8 +18,122 @@
 
 #include <VtsHalHidlTargetTestBase.h>
 
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaIface.h>
+
 #include "supplicant_hidl_test_utils.h"
 
+using ::android::sp;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaIface;
+using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaIfaceCallback;
+using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaNetwork;
+using ::android::hardware::wifi::supplicant::V1_0::SupplicantNetworkId;
+using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
+using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
+
+namespace {
+constexpr uint8_t kTestMacAddr[] = {0x56, 0x67, 0x67, 0xf4, 0x56, 0x92};
+constexpr ISupplicantStaIface::AnqpInfoId kTestAnqpInfoIds[] = {
+    ISupplicantStaIface::AnqpInfoId::VENUE_NAME,
+    ISupplicantStaIface::AnqpInfoId::NAI_REALM,
+    ISupplicantStaIface::AnqpInfoId::DOMAIN_NAME};
+constexpr ISupplicantStaIface::Hs20AnqpSubtypes kTestHs20Types[] = {
+    ISupplicantStaIface::Hs20AnqpSubtypes::WAN_METRICS,
+    ISupplicantStaIface::Hs20AnqpSubtypes::OPERATOR_FRIENDLY_NAME};
+constexpr char kTestHs20IconFile[] = "TestFile";
+constexpr int8_t kTestCountryCode[] = {'U', 'S'};
+}  // namespace
+
+class SupplicantStaIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+   public:
+    virtual void SetUp() override {
+        startSupplicantAndWaitForHidlService();
+        EXPECT_TRUE(turnOnExcessiveLogging());
+        sta_iface_ = getSupplicantStaIface();
+        ASSERT_NE(sta_iface_.get(), nullptr);
+
+        memcpy(mac_addr_.data(), kTestMacAddr, mac_addr_.size());
+    }
+
+    virtual void TearDown() override { stopSupplicant(); }
+
+   protected:
+    // ISupplicantStaIface object used for all tests in this fixture.
+    sp<ISupplicantStaIface> sta_iface_;
+    // MAC address to use for various tests.
+    std::array<uint8_t, 6> mac_addr_;
+};
+
+class IfaceCallback : public ISupplicantStaIfaceCallback {
+    Return<void> onNetworkAdded(uint32_t /* id */) override { return Void(); }
+    Return<void> onNetworkRemoved(uint32_t /* id */) override { return Void(); }
+    Return<void> onStateChanged(
+        ISupplicantStaIfaceCallback::State /* newState */,
+        const hidl_array<uint8_t, 6>& /*bssid */, uint32_t /* id */,
+        const hidl_vec<uint8_t>& /* ssid */) override {
+        return Void();
+    }
+    Return<void> onAnqpQueryDone(
+        const hidl_array<uint8_t, 6>& /* bssid */,
+        const ISupplicantStaIfaceCallback::AnqpData& /* data */,
+        const ISupplicantStaIfaceCallback::Hs20AnqpData& /* hs20Data */)
+        override {
+        return Void();
+    }
+    virtual Return<void> onHs20IconQueryDone(
+        const hidl_array<uint8_t, 6>& /* bssid */,
+        const hidl_string& /* fileName */,
+        const hidl_vec<uint8_t>& /* data */) override {
+        return Void();
+    }
+    virtual Return<void> onHs20SubscriptionRemediation(
+        const hidl_array<uint8_t, 6>& /* bssid */,
+        ISupplicantStaIfaceCallback::OsuMethod /* osuMethod */,
+        const hidl_string& /* url*/) override {
+        return Void();
+    }
+    Return<void> onHs20DeauthImminentNotice(
+        const hidl_array<uint8_t, 6>& /* bssid */, uint32_t /* reasonCode */,
+        uint32_t /* reAuthDelayInSec */,
+        const hidl_string& /* url */) override {
+        return Void();
+    }
+    Return<void> onDisconnected(const hidl_array<uint8_t, 6>& /* bssid */,
+                                bool /* locallyGenerated */,
+                                uint32_t /* reasonCode */) override {
+        return Void();
+    }
+    Return<void> onAssociationRejected(
+        const hidl_array<uint8_t, 6>& /* bssid */, uint32_t /* statusCode */,
+        bool /*timedOut */) override {
+        return Void();
+    }
+    Return<void> onAuthenticationTimeout(
+        const hidl_array<uint8_t, 6>& /* bssid */) override {
+        return Void();
+    }
+    Return<void> onEapFailure() override { return Void(); }
+    Return<void> onWpsEventSuccess() override { return Void(); }
+    Return<void> onWpsEventFail(
+        const hidl_array<uint8_t, 6>& /* bssid */,
+        ISupplicantStaIfaceCallback::WpsConfigError /* configError */,
+        ISupplicantStaIfaceCallback::WpsErrorIndication /* errorInd */)
+        override {
+        return Void();
+    }
+    Return<void> onWpsEventPbcOverlap() override { return Void(); }
+    Return<void> onExtRadioWorkStart(uint32_t /* id */) override {
+        return Void();
+    }
+    Return<void> onExtRadioWorkTimeout(uint32_t /* id*/) override {
+        return Void();
+    }
+};
+
 /*
  * Create:
  * Ensures that an instance of the ISupplicantStaIface proxy object is
@@ -30,3 +144,257 @@
     EXPECT_NE(nullptr, getSupplicantStaIface().get());
     stopSupplicant();
 }
+
+/*
+ * RegisterCallback
+ */
+TEST_F(SupplicantStaIfaceHidlTest, RegisterCallback) {
+    sta_iface_->registerCallback(
+        new IfaceCallback(), [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+}
+
+/*
+ * listNetworks.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, listNetworks) {
+    sta_iface_->listNetworks([](const SupplicantStatus& status,
+                                const hidl_vec<SupplicantNetworkId>& ids) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        EXPECT_EQ(0u, ids.size());
+    });
+
+    sp<ISupplicantStaNetwork> sta_network = createSupplicantStaNetwork();
+    EXPECT_NE(nullptr, sta_network.get());
+
+    sta_iface_->listNetworks([](const SupplicantStatus& status,
+                                const hidl_vec<SupplicantNetworkId>& ids) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        EXPECT_LT(0u, ids.size());
+    });
+}
+
+/*
+ * Reassociate.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, Reassociate) {
+    sta_iface_->reassociate([](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+}
+
+/*
+ * Reconnect.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, Reconnect) {
+    sta_iface_->reconnect([](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::FAILURE_IFACE_NOT_DISCONNECTED,
+                  status.code);
+    });
+}
+
+/*
+ * Disconnect.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, Disconnect) {
+    sta_iface_->disconnect([](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+}
+
+/*
+ * SetPowerSave.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, SetPowerSave) {
+    sta_iface_->setPowerSave(true, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+    sta_iface_->setPowerSave(false, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+}
+
+/*
+ * InitiateTdlsDiscover.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, InitiateTdlsDiscover) {
+    sta_iface_->initiateTdlsDiscover(
+        mac_addr_, [](const SupplicantStatus& status) {
+            // These requests will fail unless the MAC address mentioned is
+            // actually around.
+            EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
+        });
+}
+
+/*
+ * InitiateTdlsSetup.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, InitiateTdlsSetup) {
+    sta_iface_->initiateTdlsSetup(
+        mac_addr_, [](const SupplicantStatus& status) {
+            // These requests will fail unless the MAC address mentioned is
+            // actually around.
+            EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
+        });
+}
+
+/*
+ * InitiateTdlsTeardown.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, InitiateTdlsTeardown) {
+    sta_iface_->initiateTdlsTeardown(
+        mac_addr_, [](const SupplicantStatus& status) {
+            // These requests will fail unless the MAC address mentioned is
+            // actually around.
+            EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
+        });
+}
+
+/*
+ * InitiateAnqpQuery.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, InitiateAnqpQuery) {
+    std::vector<ISupplicantStaIface::AnqpInfoId> anqp_ids(
+        kTestAnqpInfoIds, kTestAnqpInfoIds + sizeof(kTestAnqpInfoIds));
+    std::vector<ISupplicantStaIface::Hs20AnqpSubtypes> hs_types(
+        kTestHs20Types, kTestHs20Types + sizeof(kTestHs20Types));
+    sta_iface_->initiateAnqpQuery(
+        mac_addr_, anqp_ids, hs_types, [](const SupplicantStatus& status) {
+            // These requests will fail unless the BSSID mentioned is actually
+            // present in scan results.
+            EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
+        });
+}
+
+/*
+ * InitiateHs20IconQuery.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, InitiateHs20IconQuery) {
+    sta_iface_->initiateHs20IconQuery(
+        mac_addr_, kTestHs20IconFile, [](const SupplicantStatus& status) {
+            // These requests will fail unless the BSSID mentioned is actually
+            // present in scan results.
+            EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
+        });
+}
+
+/*
+ * GetMacAddress.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, GetMacAddress) {
+    sta_iface_->getMacAddress([](const SupplicantStatus& status,
+                                 const hidl_array<uint8_t, 6>& mac_addr) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        std::array<uint8_t, 6> std_mac_addr(mac_addr);
+        EXPECT_GT(6, std::count(std_mac_addr.begin(), std_mac_addr.end(), 0));
+    });
+}
+
+/*
+ * StartRxFilter.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, StartRxFilter) {
+    sta_iface_->startRxFilter([](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+}
+
+/*
+ * StopRxFilter.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, StopRxFilter) {
+    sta_iface_->stopRxFilter([](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+}
+
+/*
+ * AddRxFilter.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, AddRxFilter) {
+    sta_iface_->addRxFilter(ISupplicantStaIface::RxFilterType::V4_MULTICAST,
+                            [](const SupplicantStatus& status) {
+                                EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+                                          status.code);
+                            });
+    sta_iface_->addRxFilter(ISupplicantStaIface::RxFilterType::V6_MULTICAST,
+                            [](const SupplicantStatus& status) {
+                                EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+                                          status.code);
+                            });
+}
+
+/*
+ * RemoveRxFilter.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, RemoveRxFilter) {
+    sta_iface_->removeRxFilter(ISupplicantStaIface::RxFilterType::V4_MULTICAST,
+                               [](const SupplicantStatus& status) {
+                                   EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+                                             status.code);
+                               });
+    sta_iface_->removeRxFilter(ISupplicantStaIface::RxFilterType::V6_MULTICAST,
+                               [](const SupplicantStatus& status) {
+                                   EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+                                             status.code);
+                               });
+}
+
+/*
+ * SetBtCoexistenceMode.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, SetBtCoexistenceMode) {
+    sta_iface_->setBtCoexistenceMode(
+        ISupplicantStaIface::BtCoexistenceMode::ENABLED,
+        [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_iface_->setBtCoexistenceMode(
+        ISupplicantStaIface::BtCoexistenceMode::DISABLED,
+        [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_iface_->setBtCoexistenceMode(
+        ISupplicantStaIface::BtCoexistenceMode::SENSE,
+        [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+}
+
+/*
+ * SetBtCoexistenceScanModeEnabled.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, SetBtCoexistenceScanModeEnabled) {
+    sta_iface_->setBtCoexistenceScanModeEnabled(
+        true, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_iface_->setBtCoexistenceScanModeEnabled(
+        false, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+}
+
+/*
+ * SetSuspendModeEnabled.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, SetSuspendModeEnabled) {
+    sta_iface_->setSuspendModeEnabled(true, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+    sta_iface_->setSuspendModeEnabled(
+        false, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+}
+
+/*
+ * SetCountryCode.
+ */
+TEST_F(SupplicantStaIfaceHidlTest, SetCountryCode) {
+    sta_iface_->setCountryCode(
+        kTestCountryCode, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+}
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
index cde75fa..aa84e9a 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
@@ -18,8 +18,104 @@
 
 #include <VtsHalHidlTargetTestBase.h>
 
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetwork.h>
+
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetwork.h>
+
 #include "supplicant_hidl_test_utils.h"
 
+using ::android::sp;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaIface;
+using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaNetwork;
+using ::android::hardware::wifi::supplicant::V1_0::
+    ISupplicantStaNetworkCallback;
+using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
+using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
+
+namespace {
+constexpr char kTestSsidStr[] = "TestSsid1234";
+constexpr char kTestPsk[] = "TestPsk123";
+constexpr char kTestIdStr[] = "TestIdstr";
+constexpr char kTestEapPasswdStr[] = "TestEapPasswd1234";
+constexpr char kTestEapCert[] = "keystore://CERT";
+constexpr char kTestEapPrivateKeyId[] = "key_id";
+constexpr char kTestEapMatch[] = "match";
+constexpr char kTestEapEngineID[] = "engine_id";
+constexpr uint8_t kTestBssid[] = {0x56, 0x67, 0x67, 0xf4, 0x56, 0x92};
+constexpr uint8_t kTestWepKey[] = {0x56, 0x67, 0x67, 0xf4, 0x56};
+constexpr uint8_t kTestKc[] = {0x56, 0x67, 0x67, 0xf4, 0x76, 0x87, 0x98, 0x12};
+constexpr uint8_t kTestSres[] = {0x56, 0x67, 0x67, 0xf4};
+constexpr uint8_t kTestRes[] = {0x56, 0x67, 0x67, 0xf4, 0x67};
+constexpr uint8_t kTestIk[] = {[0 ... 15] = 0x65};
+constexpr uint8_t kTestCk[] = {[0 ... 15] = 0x45};
+constexpr uint8_t kTestIdentity[] = {0x45, 0x67, 0x98, 0x67, 0x56};
+constexpr uint32_t kTestWepTxKeyIdx = 2;
+constexpr uint32_t kTestKeyMgmt = (ISupplicantStaNetwork::KeyMgmtMask::WPA_PSK |
+                                   ISupplicantStaNetwork::KeyMgmtMask::WPA_EAP);
+constexpr uint32_t kTestProto = (ISupplicantStaNetwork::ProtoMask::OSEN |
+                                 ISupplicantStaNetwork::ProtoMask::RSN);
+constexpr uint32_t kTestAuthAlg = (ISupplicantStaNetwork::AuthAlgMask::OPEN |
+                                   ISupplicantStaNetwork::AuthAlgMask::SHARED);
+constexpr uint32_t kTestGroupCipher =
+    (ISupplicantStaNetwork::GroupCipherMask::CCMP |
+     ISupplicantStaNetwork::GroupCipherMask::WEP104);
+constexpr uint32_t kTestPairwiseCipher =
+    (ISupplicantStaNetwork::PairwiseCipherMask::CCMP |
+     ISupplicantStaNetwork::PairwiseCipherMask::TKIP);
+}  // namespace
+
+class SupplicantStaNetworkHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+   public:
+    virtual void SetUp() override {
+        startSupplicantAndWaitForHidlService();
+        EXPECT_TRUE(turnOnExcessiveLogging());
+        sta_network_ = createSupplicantStaNetwork();
+        ASSERT_NE(sta_network_.get(), nullptr);
+
+        ssid_.assign(kTestSsidStr, kTestSsidStr + strlen(kTestSsidStr));
+    }
+
+    virtual void TearDown() override { stopSupplicant(); }
+
+   protected:
+    void removeNetwork() {
+      sp<ISupplicantStaIface> sta_iface = getSupplicantStaIface();
+      ASSERT_NE(nullptr, sta_iface.get());
+      uint32_t net_id;
+      sta_network_->getId([&](const SupplicantStatus& status, int network_id) {
+              ASSERT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+              net_id = network_id;
+          });
+      sta_iface->removeNetwork(net_id, [](const SupplicantStatus& status) {
+              ASSERT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+          });
+    }
+
+    // ISupplicantStaNetwork object used for all tests in this fixture.
+    sp<ISupplicantStaNetwork> sta_network_;
+    // SSID to use for various tests.
+    std::vector<uint8_t> ssid_;
+};
+
+class NetworkCallback : public ISupplicantStaNetworkCallback {
+    Return<void> onNetworkEapSimGsmAuthRequest(
+        const ISupplicantStaNetworkCallback::NetworkRequestEapSimGsmAuthParams&
+        /* params */) override {
+        return Void();
+    }
+    Return<void> onNetworkEapSimUmtsAuthRequest(
+        const ISupplicantStaNetworkCallback::NetworkRequestEapSimUmtsAuthParams&
+        /* params */) override {
+        return Void();
+    }
+    Return<void> onNetworkEapIdentityRequest() override { return Void(); }
+};
+
 /*
  * Create:
  * Ensures that an instance of the ISupplicantStaNetwork proxy object is
@@ -30,3 +126,535 @@
     EXPECT_NE(nullptr, createSupplicantStaNetwork().get());
     stopSupplicant();
 }
+
+/*
+ * RegisterCallback
+ */
+TEST_F(SupplicantStaNetworkHidlTest, RegisterCallback) {
+    sta_network_->registerCallback(
+        new NetworkCallback(), [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+}
+
+/* Tests out the various setter/getter methods. */
+/*
+ * SetGetSsid
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetSsid) {
+    sta_network_->setSsid(ssid_, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+    sta_network_->getSsid(
+        [&](const SupplicantStatus& status, const hidl_vec<uint8_t>& get_ssid) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(ssid_, std::vector<uint8_t>(get_ssid));
+        });
+}
+
+/*
+ * SetGetBssid
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetBssid) {
+    std::array<uint8_t, 6> set_bssid;
+    memcpy(set_bssid.data(), kTestBssid, set_bssid.size());
+    sta_network_->setBssid(set_bssid, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+    sta_network_->getBssid([&](const SupplicantStatus& status,
+                               const hidl_array<uint8_t, 6>& get_bssid_hidl) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        std::array<uint8_t, 6> get_bssid;
+        memcpy(get_bssid.data(), get_bssid_hidl.data(), get_bssid.size());
+        EXPECT_EQ(set_bssid, get_bssid);
+    });
+}
+
+/*
+ * SetGetKeyMgmt
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetKeyMgmt) {
+    sta_network_->setKeyMgmt(kTestKeyMgmt, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+    sta_network_->getKeyMgmt(
+        [&](const SupplicantStatus& status, uint32_t key_mgmt) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(key_mgmt, kTestKeyMgmt);
+        });
+}
+
+/*
+ * SetGetProto
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetProto) {
+    sta_network_->setProto(kTestProto, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+    sta_network_->getProto([&](const SupplicantStatus& status, uint32_t proto) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        EXPECT_EQ(proto, kTestProto);
+    });
+}
+
+/*
+ * SetGetKeyAuthAlg
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetAuthAlg) {
+    sta_network_->setAuthAlg(kTestAuthAlg, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+    sta_network_->getAuthAlg(
+        [&](const SupplicantStatus& status, uint32_t auth_alg) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(auth_alg, kTestAuthAlg);
+        });
+}
+
+/*
+ * SetGetGroupCipher
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetGroupCipher) {
+    sta_network_->setGroupCipher(
+        kTestGroupCipher, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getGroupCipher(
+        [&](const SupplicantStatus& status, uint32_t group_cipher) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(group_cipher, kTestGroupCipher);
+        });
+}
+
+/*
+ * SetGetPairwiseCipher
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetPairwiseCipher) {
+    sta_network_->setPairwiseCipher(
+        kTestPairwiseCipher, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getPairwiseCipher(
+        [&](const SupplicantStatus& status, uint32_t pairwise_cipher) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(pairwise_cipher, kTestPairwiseCipher);
+        });
+}
+
+/*
+ * SetGetPskPassphrase
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetPskPassphrase) {
+    sta_network_->setPskPassphrase(
+        kTestPsk, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getPskPassphrase(
+        [&](const SupplicantStatus& status, const hidl_string& psk) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(kTestPsk, std::string(psk.c_str()));
+        });
+}
+
+/*
+ * SetGetWepKeys
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetWepTxKeyIdx) {
+    sta_network_->setWepTxKeyIdx(
+        kTestWepTxKeyIdx, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getWepTxKeyIdx(
+        [&](const SupplicantStatus& status, uint32_t key_idx) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(kTestWepTxKeyIdx, key_idx);
+        });
+}
+
+/*
+ * SetGetWepKeys
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetWepKeys) {
+    for (uint32_t i = 0;
+         i < static_cast<uint32_t>(
+                 ISupplicantStaNetwork::ParamSizeLimits::WEP_KEYS_MAX_NUM);
+         i++) {
+        std::vector<uint8_t> set_wep_key(std::begin(kTestWepKey),
+                                         std::end(kTestWepKey));
+        sta_network_->setWepKey(
+            i, set_wep_key, [](const SupplicantStatus& status) {
+                EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            });
+        sta_network_->getWepKey(i, [&](const SupplicantStatus& status,
+                                       const hidl_vec<uint8_t>& get_wep_key) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(set_wep_key, std::vector<uint8_t>(get_wep_key));
+        });
+    }
+}
+
+/*
+ * SetGetScanSsid
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetScanSsid) {
+    sta_network_->setScanSsid(
+        true, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getScanSsid(
+        [&](const SupplicantStatus& status, bool scan_ssid) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(true, scan_ssid);
+        });
+}
+
+/*
+ * SetGetRequirePmf
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetRequirePmf) {
+    sta_network_->setRequirePmf(
+        true, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getRequirePmf(
+        [&](const SupplicantStatus& status, bool require_pmf) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(true, require_pmf);
+        });
+}
+
+/*
+ * SetGetIdStr
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetIdStr) {
+    sta_network_->setIdStr(
+        kTestIdStr, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getIdStr(
+        [&](const SupplicantStatus& status, const hidl_string& id_str) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(kTestIdStr, std::string(id_str.c_str()));
+        });
+}
+
+
+/*
+ * SetGetEapMethod
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapMethod) {
+    ISupplicantStaNetwork::EapMethod set_eap_method =
+        ISupplicantStaNetwork::EapMethod::PEAP;
+    sta_network_->setEapMethod(
+        set_eap_method, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getEapMethod(
+        [&](const SupplicantStatus& status,
+            ISupplicantStaNetwork::EapMethod eap_method) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(set_eap_method, eap_method);
+        });
+}
+
+/*
+ * SetGetEapPhase2Method
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapPhase2Method) {
+    ISupplicantStaNetwork::EapPhase2Method set_eap_phase2_method =
+        ISupplicantStaNetwork::EapPhase2Method::NONE;
+    sta_network_->setEapPhase2Method(
+        set_eap_phase2_method, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getEapPhase2Method(
+        [&](const SupplicantStatus& status,
+            ISupplicantStaNetwork::EapPhase2Method eap_phase2_method) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(set_eap_phase2_method, eap_phase2_method);
+        });
+}
+
+/*
+ * SetGetEapIdentity
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapIdentity) {
+    std::vector<uint8_t> set_identity(kTestIdentity, kTestIdentity + sizeof(kTestIdentity));
+    sta_network_->setEapIdentity(
+        set_identity, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getEapIdentity(
+        [&](const SupplicantStatus& status, const std::vector<uint8_t>& identity) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(set_identity, identity);
+        });
+}
+
+/*
+ * SetGetEapAnonymousIdentity
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapAnonymousIdentity) {
+    std::vector<uint8_t> set_identity(kTestIdentity, kTestIdentity + sizeof(kTestIdentity));
+    sta_network_->setEapAnonymousIdentity(
+        set_identity, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getEapAnonymousIdentity(
+        [&](const SupplicantStatus& status, const std::vector<uint8_t>& identity) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            EXPECT_EQ(set_identity, identity);
+        });
+}
+
+/*
+ * SetGetEapPassword
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapPassword) {
+    std::vector<uint8_t> set_eap_passwd(
+        kTestEapPasswdStr, kTestEapPasswdStr + strlen(kTestEapPasswdStr));
+    sta_network_->setEapPassword(
+        set_eap_passwd, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getEapPassword([&](const SupplicantStatus& status,
+                                     const hidl_vec<uint8_t>& eap_passwd) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        EXPECT_EQ(set_eap_passwd, std::vector<uint8_t>(eap_passwd));
+    });
+}
+
+/*
+ * SetGetEapCACert
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapCACert) {
+    sta_network_->setEapCACert(
+        kTestEapCert, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getEapCACert([&](const SupplicantStatus& status,
+                                   const hidl_string& eap_cert) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        EXPECT_EQ(kTestEapCert, std::string(eap_cert.c_str()));
+    });
+}
+
+/*
+ * SetGetEapCAPath
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapCAPath) {
+    sta_network_->setEapCAPath(
+        kTestEapCert, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getEapCAPath([&](const SupplicantStatus& status,
+                                   const hidl_string& eap_cert) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        EXPECT_EQ(kTestEapCert, std::string(eap_cert.c_str()));
+    });
+}
+
+/*
+ * SetGetEapClientCert
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapClientCert) {
+    sta_network_->setEapClientCert(
+        kTestEapCert, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getEapClientCert([&](const SupplicantStatus& status,
+                                       const hidl_string& eap_cert) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        EXPECT_EQ(kTestEapCert, std::string(eap_cert.c_str()));
+    });
+}
+
+/*
+ * SetGetEapPrivateKeyId
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapPrivateKeyId) {
+    sta_network_->setEapPrivateKeyId(
+        kTestEapPrivateKeyId, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getEapPrivateKeyId([&](const SupplicantStatus& status,
+                                         const hidl_string& key_id) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        EXPECT_EQ(kTestEapPrivateKeyId, std::string(key_id.c_str()));
+    });
+}
+
+/*
+ * SetGetEapAltSubjectMatch
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapAltSubjectMatch) {
+    sta_network_->setEapAltSubjectMatch(
+        kTestEapMatch, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getEapAltSubjectMatch([&](const SupplicantStatus& status,
+                                            const hidl_string& match) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        EXPECT_EQ(kTestEapMatch, std::string(match.c_str()));
+    });
+}
+
+/*
+ * SetGetEapDomainSuffixMatch
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapDomainSuffixMatch) {
+    sta_network_->setEapDomainSuffixMatch(
+        kTestEapMatch, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getEapDomainSuffixMatch([&](const SupplicantStatus& status,
+                                              const hidl_string& match) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        EXPECT_EQ(kTestEapMatch, std::string(match.c_str()));
+    });
+}
+
+/*
+ * SetGetEapEngine
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapEngine) {
+    sta_network_->setEapEngine(
+        true, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getEapEngine([&](const SupplicantStatus& status,
+                                   bool enable) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        EXPECT_EQ(true, enable);
+    });
+}
+
+/*
+ * SetGetEapEngineID
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapEngineID) {
+    sta_network_->setEapEngineID(
+        kTestEapEngineID, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+    sta_network_->getEapEngineID([&](const SupplicantStatus& status,
+                                     const hidl_string& id) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        EXPECT_EQ(kTestEapEngineID, std::string(id.c_str()));
+    });
+}
+
+/*
+ * Enable
+ */
+TEST_F(SupplicantStaNetworkHidlTest, Enable) {
+    // wpa_supplicant doesn't perform any connection initiation
+    // unless atleast the Ssid and Ket mgmt params are set.
+    sta_network_->setSsid(ssid_, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+    sta_network_->setKeyMgmt(kTestKeyMgmt, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+
+    sta_network_->enable(false, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+    sta_network_->enable(true, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+
+    // Now remove the network and ensure that the calls fail.
+    removeNetwork();
+    sta_network_->enable(true, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::FAILURE_NETWORK_INVALID, status.code);
+    });
+}
+
+/*
+ * Disable
+ */
+TEST_F(SupplicantStaNetworkHidlTest, Disable) {
+    // wpa_supplicant doesn't perform any connection initiation
+    // unless atleast the Ssid and Ket mgmt params are set.
+    sta_network_->setSsid(ssid_, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+    sta_network_->setKeyMgmt(kTestKeyMgmt, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+
+    sta_network_->disable([](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+    // Now remove the network and ensure that the calls fail.
+    removeNetwork();
+    sta_network_->disable([](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::FAILURE_NETWORK_INVALID, status.code);
+    });
+}
+
+/*
+ * Select.
+ */
+TEST_F(SupplicantStaNetworkHidlTest, Select) {
+    // wpa_supplicant doesn't perform any connection initiation
+    // unless atleast the Ssid and Ket mgmt params are set.
+    sta_network_->setSsid(ssid_, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+    sta_network_->setKeyMgmt(kTestKeyMgmt, [](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+
+    sta_network_->select([](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+    });
+    // Now remove the network and ensure that the calls fail.
+    removeNetwork();
+    sta_network_->select([](const SupplicantStatus& status) {
+        EXPECT_EQ(SupplicantStatusCode::FAILURE_NETWORK_INVALID, status.code);
+    });
+}
+
+/*
+ * SendNetworkEapSimGsmAuthResponse
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SendNetworkEapSimGsmAuthResponse) {
+    std::vector<ISupplicantStaNetwork::NetworkResponseEapSimGsmAuthParams>
+        params;
+    ISupplicantStaNetwork::NetworkResponseEapSimGsmAuthParams param;
+    memcpy(param.kc.data(), kTestKc, param.kc.size());
+    memcpy(param.sres.data(), kTestSres, param.sres.size());
+    params.push_back(param);
+    sta_network_->sendNetworkEapSimGsmAuthResponse(
+        params, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+}
+
+/*
+ * SendNetworkEapSimUmtsAuthResponse
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SendNetworkEapSimUmtsAuthResponse) {
+    ISupplicantStaNetwork::NetworkResponseEapSimUmtsAuthParams params;
+    params.res = std::vector<uint8_t>(kTestRes, kTestRes + sizeof(kTestRes));
+    memcpy(params.ik.data(), kTestIk, params.ik.size());
+    memcpy(params.ck.data(), kTestCk, params.ck.size());
+    sta_network_->sendNetworkEapSimUmtsAuthResponse(
+        params, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+}
+
+/*
+ * SendNetworkEapIdentityResponse
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SendNetworkEapIdentityResponse) {
+    sta_network_->sendNetworkEapIdentityResponse(
+        std::vector<uint8_t>(kTestIdentity,
+                             kTestIdentity + sizeof(kTestIdentity)),
+        [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
+}
