Merge "Add filegroup for trout project to use VehicleHalProto definition" into rvc-dev
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 543acf6..acae4f3 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -8,6 +8,9 @@
     },
     {
       "name": "hal_implementation_test"
+    },
+    {
+      "name": "VtsHalTvInputV1_0TargetTest"
     }
   ]
 }
diff --git a/automotive/audiocontrol/1.0/vts/functional/Android.bp b/automotive/audiocontrol/1.0/vts/functional/Android.bp
index 3cb6340..1bb8e88 100644
--- a/automotive/audiocontrol/1.0/vts/functional/Android.bp
+++ b/automotive/audiocontrol/1.0/vts/functional/Android.bp
@@ -25,5 +25,8 @@
     static_libs: [
         "android.hardware.automotive.audiocontrol@1.0",
     ],
-    test_suites: ["general-tests"],
+    test_suites: [
+        "general-tests",
+        "vts",
+    ],
 }
diff --git a/automotive/audiocontrol/1.0/vts/functional/VtsHalAudioControlV1_0TargetTest.cpp b/automotive/audiocontrol/1.0/vts/functional/VtsHalAudioControlV1_0TargetTest.cpp
index fc0deb9..de1ec02 100644
--- a/automotive/audiocontrol/1.0/vts/functional/VtsHalAudioControlV1_0TargetTest.cpp
+++ b/automotive/audiocontrol/1.0/vts/functional/VtsHalAudioControlV1_0TargetTest.cpp
@@ -25,11 +25,12 @@
 #include <utils/Errors.h>
 #include <utils/StrongPointer.h>
 
-#include <android/hardware/automotive/audiocontrol/1.0/types.h>
 #include <android/hardware/automotive/audiocontrol/1.0/IAudioControl.h>
+#include <android/hardware/automotive/audiocontrol/1.0/types.h>
 #include <android/log.h>
-
-#include <VtsHalHidlTargetTestBase.h>
+#include <gtest/gtest.h>
+#include <hidl/GtestPrinter.h>
+#include <hidl/ServiceManagement.h>
 
 using namespace ::android::hardware::automotive::audiocontrol::V1_0;
 using ::android::hardware::Return;
@@ -40,30 +41,12 @@
 using ::android::hardware::hidl_vec;
 using ::android::sp;
 
-
-// Boiler plate for test harness
-class CarAudioControlHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
-   public:
-    // get the test environment singleton
-    static CarAudioControlHidlEnvironment* Instance() {
-        static CarAudioControlHidlEnvironment* instance = new CarAudioControlHidlEnvironment;
-        return instance;
-    }
-
-    virtual void registerTestServices() override { registerTestService<IAudioControl>(); }
-   private:
-    CarAudioControlHidlEnvironment() {}
-};
-
-
 // The main test class for the automotive AudioControl HAL
-class CarAudioControlHidlTest : public ::testing::VtsHalHidlTargetTestBase {
-public:
+class CarAudioControlHidlTest : public ::testing::TestWithParam<std::string> {
+  public:
     virtual void SetUp() override {
         // Make sure we can connect to the driver
-        pAudioControl = ::testing::VtsHalHidlTargetTestBase::getService<IAudioControl>(
-                                    CarAudioControlHidlEnvironment::Instance()->
-                                    getServiceName<IAudioControl>());
+        pAudioControl = IAudioControl::getService(GetParam());
         ASSERT_NE(pAudioControl.get(), nullptr);
     }
 
@@ -82,7 +65,7 @@
  * fader actually works.  The only thing we can do is exercise the HAL and if the HAL crashes,
  * we _might_ get a test failure if that breaks the connection to the driver.
  */
-TEST_F(CarAudioControlHidlTest, FaderExercise) {
+TEST_P(CarAudioControlHidlTest, FaderExercise) {
     ALOGI("Fader exercise test (silent)");
 
     // Set the fader all the way to the back
@@ -104,7 +87,7 @@
 /*
  * Balance exercise test.
  */
-TEST_F(CarAudioControlHidlTest, BalanceExercise) {
+TEST_P(CarAudioControlHidlTest, BalanceExercise) {
     ALOGI("Balance exercise test (silent)");
 
     // Set the balance all the way to the left
@@ -126,7 +109,7 @@
 /*
  * Context mapping test.
  */
-TEST_F(CarAudioControlHidlTest, ContextMapping) {
+TEST_P(CarAudioControlHidlTest, ContextMapping) {
     ALOGI("Context mapping test");
 
     int bus = -1;
@@ -156,3 +139,8 @@
     bus = pAudioControl->getBusForContext((ContextNumber)~0);
     EXPECT_EQ(bus, -1);
 }
+
+INSTANTIATE_TEST_SUITE_P(
+        PerInstance, CarAudioControlHidlTest,
+        testing::ValuesIn(android::hardware::getAllHalInstanceNames(IAudioControl::descriptor)),
+        android::hardware::PrintInstanceNameToString);
\ No newline at end of file
diff --git a/automotive/audiocontrol/2.0/types.hal b/automotive/audiocontrol/2.0/types.hal
index 65b0988..80d9ee1 100644
--- a/automotive/audiocontrol/2.0/types.hal
+++ b/automotive/audiocontrol/2.0/types.hal
@@ -19,7 +19,7 @@
 /**
  * Changes in audio focus that can be experienced
  */
-enum AudioFocusChange : uint32_t {
+enum AudioFocusChange : int32_t {
     NONE = 0,
     GAIN = 1,
     GAIN_TRANSIENT = 2,
diff --git a/automotive/can/1.0/vts/functional/Android.bp b/automotive/can/1.0/vts/functional/Android.bp
index e3e770b..d020750 100644
--- a/automotive/can/1.0/vts/functional/Android.bp
+++ b/automotive/can/1.0/vts/functional/Android.bp
@@ -28,7 +28,10 @@
         "android.hardware.automotive.can@vts-utils-lib",
         "libgmock",
     ],
-    test_suites: ["general-tests"],
+    test_suites: [
+        "general-tests",
+        "vts",
+    ],
 }
 
 cc_test {
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp
index 84354c1..bdc5244 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp
@@ -16,8 +16,12 @@
 #define LOG_TAG "DefaultVehicleHal_v2_0"
 
 #include <android-base/macros.h>
+#include <android-base/properties.h>
 #include <android/log.h>
+#include <dirent.h>
 #include <sys/system_properties.h>
+#include <fstream>
+#include <regex>
 
 #include "EmulatedVehicleHal.h"
 #include "JsonFakeValueGenerator.h"
@@ -101,6 +105,30 @@
     mVehicleClient->registerPropertyValueCallback(std::bind(&EmulatedVehicleHal::onPropertyValue,
                                                             this, std::placeholders::_1,
                                                             std::placeholders::_2));
+
+    mInitVhalValueOverride =
+            android::base::GetBoolProperty("persist.vendor.vhal_init_value_override", false);
+    if (mInitVhalValueOverride) {
+        getAllPropertiesOverride();
+    }
+}
+
+void EmulatedVehicleHal::getAllPropertiesOverride() {
+    if (auto dir = opendir("/vendor/etc/vhaloverride/")) {
+        std::regex reg_json(".*[.]json", std::regex::icase);
+        while (auto f = readdir(dir)) {
+            if (!regex_match(f->d_name, reg_json)) {
+                continue;
+            }
+            std::string file = "/vendor/etc/vhaloverride/" + std::string(f->d_name);
+            JsonFakeValueGenerator tmpGenerator(file);
+
+            std::vector<VehiclePropValue> propvalues = tmpGenerator.getAllEvents();
+            mVehiclePropertiesOverride.insert(std::end(mVehiclePropertiesOverride),
+                                              std::begin(propvalues), std::end(propvalues));
+        }
+        closedir(dir);
+    }
 }
 
 VehicleHal::VehiclePropValuePtr EmulatedVehicleHal::get(
@@ -277,6 +305,13 @@
                 }
             } else {
                 prop.value = it.initialValue;
+                if (mInitVhalValueOverride) {
+                    for (auto& itOverride : mVehiclePropertiesOverride) {
+                        if (itOverride.prop == cfg.prop) {
+                            prop.value = itOverride.value;
+                        }
+                    }
+                }
             }
             mPropStore->writeValue(prop, shouldUpdateStatus);
         }
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h
index dc05145..cba4b8a 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h
@@ -62,6 +62,7 @@
     //  Methods from EmulatedVehicleHalIface
     bool setPropertyFromVehicle(const VehiclePropValue& propValue) override;
     std::vector<VehiclePropValue> getAllProperties() const override;
+    void getAllPropertiesOverride();
 
 private:
     constexpr std::chrono::nanoseconds hertzToNanoseconds(float hz) const {
@@ -87,6 +88,8 @@
     RecurrentTimer mRecurrentTimer;
     VehicleHalClient* mVehicleClient;
     bool mInEmulator;
+    bool mInitVhalValueOverride;
+    std::vector<VehiclePropValue> mVehiclePropertiesOverride;
 };
 
 }  // impl
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/JsonFakeValueGenerator.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/JsonFakeValueGenerator.cpp
index 8677f83..890eb33 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/JsonFakeValueGenerator.cpp
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/JsonFakeValueGenerator.cpp
@@ -48,6 +48,22 @@
     mNumOfIterations = v.int32Values.size() < 2 ? -1 : v.int32Values[1];
 }
 
+JsonFakeValueGenerator::JsonFakeValueGenerator(std::string path) {
+    std::ifstream ifs(path);
+    if (!ifs) {
+        ALOGE("%s: couldn't open %s for parsing.", __func__, path.c_str());
+    }
+    mGenCfg = {
+        .index = 0,
+        .events = parseFakeValueJson(ifs),
+    };
+    mNumOfIterations = mGenCfg.events.size();
+}
+
+std::vector<VehiclePropValue> JsonFakeValueGenerator::getAllEvents() {
+    return mGenCfg.events;
+}
+
 VehiclePropValue JsonFakeValueGenerator::nextEvent() {
     VehiclePropValue generatedValue;
     if (!hasNext()) {
@@ -109,6 +125,7 @@
 
         Json::Value rawEventValue = rawEvent["value"];
         auto& value = event.value;
+        int32_t count;
         switch (getPropType(event.prop)) {
             case VehiclePropertyType::BOOLEAN:
             case VehiclePropertyType::INT32:
@@ -126,6 +143,13 @@
             case VehiclePropertyType::STRING:
                 value.stringValue = rawEventValue.asString();
                 break;
+            case VehiclePropertyType::INT32_VEC:
+                value.int32Values.resize(rawEventValue.size());
+                count = 0;
+                for (auto& it : rawEventValue) {
+                    value.int32Values[count++] = it.asInt();
+                }
+                break;
             case VehiclePropertyType::MIXED:
                 copyMixedValueJson(value, rawEventValue);
                 if (isDiagnosticProperty(event.prop)) {
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/JsonFakeValueGenerator.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/JsonFakeValueGenerator.h
index 70575f7..dc8ff66 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/JsonFakeValueGenerator.h
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/JsonFakeValueGenerator.h
@@ -41,9 +41,12 @@
 
 public:
     JsonFakeValueGenerator(const VehiclePropValue& request);
+    JsonFakeValueGenerator(std::string path);
+
     ~JsonFakeValueGenerator() = default;
 
     VehiclePropValue nextEvent();
+    std::vector<VehiclePropValue> getAllEvents();
 
     bool hasNext();
 
diff --git a/boot/1.1/vts/functional/Android.bp b/boot/1.1/vts/functional/Android.bp
index 49ea09a..9f0c74a 100644
--- a/boot/1.1/vts/functional/Android.bp
+++ b/boot/1.1/vts/functional/Android.bp
@@ -23,6 +23,8 @@
         "android.hardware.boot@1.1",
         "libgmock",
     ],
-    test_suites: ["device-tests"],
+    test_suites: [
+        "device-tests",
+        "vts",
+    ],
 }
-
diff --git a/broadcastradio/1.0/vts/functional/Android.bp b/broadcastradio/1.0/vts/functional/Android.bp
index 9ba9fbe..2a4f942 100644
--- a/broadcastradio/1.0/vts/functional/Android.bp
+++ b/broadcastradio/1.0/vts/functional/Android.bp
@@ -22,5 +22,8 @@
         "android.hardware.broadcastradio@1.0",
         "android.hardware.broadcastradio@vts-utils-lib",
     ],
-    test_suites: ["general-tests"],
+    test_suites: [
+        "general-tests",
+        "vts",
+    ],
 }
diff --git a/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp b/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
index 90c8463..9897ab7 100644
--- a/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
+++ b/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
@@ -15,11 +15,13 @@
  */
 
 #define LOG_TAG "BroadcastRadioHidlHalTest"
-#include <VtsHalHidlTargetTestBase.h>
 #include <android-base/logging.h>
 #include <cutils/native_handle.h>
 #include <cutils/properties.h>
+#include <gtest/gtest.h>
+#include <hidl/GtestPrinter.h>
 #include <hidl/HidlTransportSupport.h>
+#include <hidl/ServiceManagement.h>
 #include <utils/threads.h>
 
 #include <android/hardware/broadcastradio/1.0/IBroadcastRadio.h>
@@ -27,28 +29,28 @@
 #include <android/hardware/broadcastradio/1.0/ITuner.h>
 #include <android/hardware/broadcastradio/1.0/ITunerCallback.h>
 #include <android/hardware/broadcastradio/1.0/types.h>
-#include <broadcastradio-vts-utils/environment-utils.h>
+#include <broadcastradio-vts-utils/hal-1.x-enum-utils.h>
 
-using ::android::sp;
-using ::android::Mutex;
 using ::android::Condition;
+using ::android::Mutex;
+using ::android::sp;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::broadcastradio::V1_0::IBroadcastRadioFactory;
-using ::android::hardware::broadcastradio::V1_0::IBroadcastRadio;
-using ::android::hardware::broadcastradio::V1_0::ITuner;
-using ::android::hardware::broadcastradio::V1_0::ITunerCallback;
-using ::android::hardware::broadcastradio::V1_0::Result;
-using ::android::hardware::broadcastradio::V1_0::Class;
-using ::android::hardware::broadcastradio::V1_0::Properties;
 using ::android::hardware::broadcastradio::V1_0::Band;
 using ::android::hardware::broadcastradio::V1_0::BandConfig;
+using ::android::hardware::broadcastradio::V1_0::Class;
 using ::android::hardware::broadcastradio::V1_0::Direction;
-using ::android::hardware::broadcastradio::V1_0::ProgramInfo;
+using ::android::hardware::broadcastradio::V1_0::IBroadcastRadio;
+using ::android::hardware::broadcastradio::V1_0::IBroadcastRadioFactory;
+using ::android::hardware::broadcastradio::V1_0::ITuner;
+using ::android::hardware::broadcastradio::V1_0::ITunerCallback;
 using ::android::hardware::broadcastradio::V1_0::MetaData;
 using ::android::hardware::broadcastradio::V1_0::MetadataKey;
 using ::android::hardware::broadcastradio::V1_0::MetadataType;
-using ::android::hardware::broadcastradio::vts::BroadcastRadioHidlEnvironment;
+using ::android::hardware::broadcastradio::V1_0::ProgramInfo;
+using ::android::hardware::broadcastradio::V1_0::Properties;
+using ::android::hardware::broadcastradio::V1_0::Result;
+using ::android::hardware::broadcastradio::V1_0::vts::RadioClassFromString;
 
 #define RETURN_IF_SKIPPED \
     if (skipped) { \
@@ -56,19 +58,19 @@
         return; \
     }
 
-static BroadcastRadioHidlEnvironment<IBroadcastRadioFactory>* gEnv = nullptr;
 // The main test class for Broadcast Radio HIDL HAL.
-class BroadcastRadioHidlTest : public ::testing::VtsHalHidlTargetTestBase,
-        public ::testing::WithParamInterface<Class> {
- protected:
+class BroadcastRadioHidlTest
+    : public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
+  protected:
     virtual void SetUp() override {
         ASSERT_EQ(nullptr, mRadio.get());
 
-        radioClass = GetParam();
+        radioClass = RadioClassFromString(std::get<1>(GetParam()));
+
         skipped = false;
 
         sp<IBroadcastRadioFactory> factory =
-            getService<IBroadcastRadioFactory>(gEnv->getServiceName<IBroadcastRadioFactory>());
+                IBroadcastRadioFactory::getService(std::get<0>(GetParam()));
         ASSERT_NE(nullptr, factory.get());
 
         Result connectResult;
@@ -727,16 +729,8 @@
 }
 
 INSTANTIATE_TEST_CASE_P(
-    BroadcastRadioHidlTestCases,
-    BroadcastRadioHidlTest,
-    ::testing::Values(Class::AM_FM, Class::SAT, Class::DT));
-
-int main(int argc, char** argv) {
-    gEnv = new BroadcastRadioHidlEnvironment<IBroadcastRadioFactory>;
-    ::testing::AddGlobalTestEnvironment(gEnv);
-    ::testing::InitGoogleTest(&argc, argv);
-    gEnv->init(&argc, argv);
-    int status = RUN_ALL_TESTS();
-    ALOGI("Test result = %d", status);
-    return status;
-}
+        PerInstance, BroadcastRadioHidlTest,
+        testing::Combine(testing::ValuesIn(android::hardware::getAllHalInstanceNames(
+                                 IBroadcastRadioFactory::descriptor)),
+                         ::testing::Values("AM_FM", "SAT", "DT")),
+        android::hardware::PrintInstanceTupleNameToString<>);
\ No newline at end of file
diff --git a/broadcastradio/1.1/vts/functional/Android.bp b/broadcastradio/1.1/vts/functional/Android.bp
index 0a02a69..661439a 100644
--- a/broadcastradio/1.1/vts/functional/Android.bp
+++ b/broadcastradio/1.1/vts/functional/Android.bp
@@ -25,5 +25,8 @@
         "android.hardware.broadcastradio@vts-utils-lib",
         "libgmock",
     ],
-    test_suites: ["general-tests"],
+    test_suites: [
+        "general-tests",
+        "vts",
+    ],
 }
diff --git a/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp b/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
index 6687731..4833beb 100644
--- a/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
+++ b/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
@@ -16,7 +16,6 @@
 
 #define LOG_TAG "broadcastradio.vts"
 
-#include <VtsHalHidlTargetTestBase.h>
 #include <android-base/logging.h>
 #include <android/hardware/broadcastradio/1.1/IBroadcastRadio.h>
 #include <android/hardware/broadcastradio/1.1/IBroadcastRadioFactory.h>
@@ -25,13 +24,16 @@
 #include <android/hardware/broadcastradio/1.1/types.h>
 #include <broadcastradio-utils-1x/Utils.h>
 #include <broadcastradio-vts-utils/call-barrier.h>
-#include <broadcastradio-vts-utils/environment-utils.h>
+#include <broadcastradio-vts-utils/hal-1.x-enum-utils.h>
 #include <broadcastradio-vts-utils/mock-timeout.h>
 #include <broadcastradio-vts-utils/pointer-utils.h>
 #include <cutils/native_handle.h>
 #include <cutils/properties.h>
 #include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <hidl/GtestPrinter.h>
 #include <hidl/HidlTransportSupport.h>
+#include <hidl/ServiceManagement.h>
 #include <utils/threads.h>
 
 #include <chrono>
@@ -51,6 +53,7 @@
 using testing::Invoke;
 using testing::SaveArg;
 
+using broadcastradio::V1_0::vts::RadioClassFromString;
 using broadcastradio::vts::CallBarrier;
 using V1_0::BandConfig;
 using V1_0::Class;
@@ -59,7 +62,6 @@
 using V1_0::MetadataType;
 
 using broadcastradio::vts::clearAndWait;
-using broadcastradio::vts::BroadcastRadioHidlEnvironment;
 
 static constexpr auto kConfigTimeout = 10s;
 static constexpr auto kConnectModuleTimeout = 1s;
@@ -93,11 +95,9 @@
     MOCK_TIMEOUT_METHOD1(currentProgramInfoChanged, Return<void>(const ProgramInfo&));
 };
 
-static BroadcastRadioHidlEnvironment<IBroadcastRadioFactory>* gEnv = nullptr;
-
-class BroadcastRadioHalTest : public ::testing::VtsHalHidlTargetTestBase,
-                              public ::testing::WithParamInterface<Class> {
-   protected:
+class BroadcastRadioHalTest
+    : public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
+  protected:
     virtual void SetUp() override;
     virtual void TearDown() override;
 
@@ -120,11 +120,10 @@
 };
 
 void BroadcastRadioHalTest::SetUp() {
-    radioClass = GetParam();
+    radioClass = RadioClassFromString(std::get<1>(GetParam()));
 
     // lookup HIDL service
-    auto factory =
-        getService<IBroadcastRadioFactory>(gEnv->getServiceName<IBroadcastRadioFactory>());
+    auto factory = IBroadcastRadioFactory::getService(std::get<0>(GetParam()));
     ASSERT_NE(nullptr, factory.get());
 
     // connect radio module
@@ -601,24 +600,15 @@
     } while (nextBand());
 }
 
-INSTANTIATE_TEST_CASE_P(BroadcastRadioHalTestCases, BroadcastRadioHalTest,
-                        ::testing::Values(Class::AM_FM, Class::SAT, Class::DT));
+INSTANTIATE_TEST_CASE_P(
+        PerInstance, BroadcastRadioHalTest,
+        testing::Combine(testing::ValuesIn(android::hardware::getAllHalInstanceNames(
+                                 IBroadcastRadioFactory::descriptor)),
+                         ::testing::Values("AM_FM", "SAT", "DT")),
+        android::hardware::PrintInstanceTupleNameToString<>);
 
 }  // namespace vts
 }  // namespace V1_1
 }  // namespace broadcastradio
 }  // namespace hardware
 }  // namespace android
-
-int main(int argc, char** argv) {
-    using android::hardware::broadcastradio::V1_1::vts::gEnv;
-    using android::hardware::broadcastradio::V1_1::IBroadcastRadioFactory;
-    using android::hardware::broadcastradio::vts::BroadcastRadioHidlEnvironment;
-    gEnv = new BroadcastRadioHidlEnvironment<IBroadcastRadioFactory>;
-    ::testing::AddGlobalTestEnvironment(gEnv);
-    ::testing::InitGoogleTest(&argc, argv);
-    gEnv->init(&argc, argv);
-    int status = RUN_ALL_TESTS();
-    ALOGI("Test result = %d", status);
-    return status;
-}
diff --git a/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/environment-utils.h b/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/environment-utils.h
deleted file mode 100644
index 274e632..0000000
--- a/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/environment-utils.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef ANDROID_HARDWARE_BROADCASTRADIO_VTS_ENVIRONMENT_UTILS
-#define ANDROID_HARDWARE_BROADCASTRADIO_VTS_ENVIRONMENT_UTILS
-
-#include <VtsHalHidlTargetTestEnvBase.h>
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace vts {
-
-// Test environment for BroadcastRadio HIDL HAL.
-template <typename... T>
-class BroadcastRadioHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
-   public:
-    virtual void registerTestServices() override {
-        using expander = int[];
-        (void)expander{0, (registerTestService<T>(), 0)...};
-    }
-};
-
-}  // namespace vts
-}  // namespace broadcastradio
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_BROADCASTRADIO_VTS_ENVIRONMENT_UTILS
diff --git a/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/hal-1.x-enum-utils.h b/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/hal-1.x-enum-utils.h
new file mode 100644
index 0000000..6059ef8
--- /dev/null
+++ b/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/hal-1.x-enum-utils.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+namespace android::hardware::broadcastradio::V1_0::vts {
+
+using android::hardware::broadcastradio::V1_0::Class;
+
+/**
+ * Convert a string of Class name to its enum value. Fail the test if the enum
+ * value is not found.
+ *
+ * @param className string value of a Class enum.
+ * @return Class enum that matches the string value.
+ */
+Class RadioClassFromString(std::string className) {
+    if (className == "AM_FM") return Class::AM_FM;
+    if (className == "SAT") return Class::SAT;
+    if (className == "DT") return Class::DT;
+    // Fail the test run.
+    CHECK(false) << "Class name not found: " << className;
+    // Return some arbitrary enum.
+    return Class::AM_FM;
+}
+}  // namespace android::hardware::broadcastradio::V1_0::vts
diff --git a/current.txt b/current.txt
index 3a69465..2677eb1 100644
--- a/current.txt
+++ b/current.txt
@@ -635,7 +635,7 @@
 4bc4e8087f5c389f013370ed68bc8a1a29cb2f203237937697f35e005a5ad0b4 android.hardware.automotive.audiocontrol@2.0::IAudioControl
 37ef585d6687cb31e35c67ab456140d70edba9c4333ce5a6ddd70e636e985773 android.hardware.automotive.audiocontrol@2.0::ICloseHandle
 3cf3e5e48ba2642052bbccc1aa4e8bb142933ac960ff40eeedd16e4fe452e7a5 android.hardware.automotive.audiocontrol@2.0::IFocusListener
-d06fc14b325beeef06bd39de8f178f490d9e9095255626866071aab42be1fc40 android.hardware.automotive.audiocontrol@2.0::types
+44c03f3341939524b5f5acb6680f8a91924d02e335a32840d56597616db7f1ea android.hardware.automotive.audiocontrol@2.0::types
 949a2582c9efa3f6f631f56120eae3f02313f251dbf9246c327e419cdf0652a2 android.hardware.automotive.can@1.0::ICanBus
 43cddb1907a30343bced68946884416ea25ab14ae2df4709357528b2bedba84c android.hardware.automotive.can@1.0::ICanController
 272e826492b27b0dbdeda408e84a41ae43e98f29e57995b6452ded270aae4eee android.hardware.automotive.can@1.0::ICanErrorListener
diff --git a/neuralnetworks/1.3/vts/functional/Android.bp b/neuralnetworks/1.3/vts/functional/Android.bp
index 545a5be..2c1be0b 100644
--- a/neuralnetworks/1.3/vts/functional/Android.bp
+++ b/neuralnetworks/1.3/vts/functional/Android.bp
@@ -77,5 +77,8 @@
     header_libs: [
         "libneuralnetworks_headers",
     ],
-    test_suites: ["general-tests"],
+    test_suites: [
+        "general-tests",
+        "vts",
+    ],
 }
diff --git a/radio/1.3/vts/functional/radio_hidl_hal_api.cpp b/radio/1.3/vts/functional/radio_hidl_hal_api.cpp
index ca64305..1a01b28 100644
--- a/radio/1.3/vts/functional/radio_hidl_hal_api.cpp
+++ b/radio/1.3/vts/functional/radio_hidl_hal_api.cpp
@@ -16,6 +16,7 @@
 
 #include <radio_hidl_hal_utils_v1_3.h>
 #include <vector>
+#include "VtsCoreUtil.h"
 
 #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
 
@@ -25,6 +26,15 @@
 TEST_P(RadioHidlTest_v1_3, enableModem) {
     serial = GetRandomSerialNumber();
 
+    bool isMultiSimEnabled =
+            testing::checkSubstringInCommandOutput("getprop persist.radio.multisim.config",
+                                                   "dsds") ||
+            testing::checkSubstringInCommandOutput("getprop persist.radio.multisim.config", "tsts");
+    if (!isMultiSimEnabled) {
+        ALOGI("enableModem, no need to test in single SIM mode");
+        return;
+    }
+
     bool responseToggle = radioRsp_v1_3->enableModemResponseToggle;
     Return<void> res = radio_v1_3->enableModem(serial, true);
     ASSERT_OK(res);
diff --git a/usb/1.2/vts/functional/Android.bp b/usb/1.2/vts/functional/Android.bp
index 761d37f..d6aaf2d 100644
--- a/usb/1.2/vts/functional/Android.bp
+++ b/usb/1.2/vts/functional/Android.bp
@@ -23,6 +23,8 @@
         "android.hardware.usb@1.1",
         "android.hardware.usb@1.2",
     ],
-    test_suites: ["general-tests"],
+    test_suites: [
+        "general-tests",
+        "vts",
+    ],
 }
-
diff --git a/usb/1.2/vts/functional/VtsHalUsbV1_2TargetTest.cpp b/usb/1.2/vts/functional/VtsHalUsbV1_2TargetTest.cpp
index 7b3dea9..5f901cd 100644
--- a/usb/1.2/vts/functional/VtsHalUsbV1_2TargetTest.cpp
+++ b/usb/1.2/vts/functional/VtsHalUsbV1_2TargetTest.cpp
@@ -22,8 +22,10 @@
 #include <android/hardware/usb/1.2/types.h>
 
 #include <VtsHalHidlTargetCallbackBase.h>
-#include <VtsHalHidlTargetTestBase.h>
-#include <VtsHalHidlTargetTestEnvBase.h>
+#include <gtest/gtest.h>
+#include <hidl/GtestPrinter.h>
+#include <hidl/ServiceManagement.h>
+
 #include <log/log.h>
 #include <stdlib.h>
 #include <chrono>
@@ -139,24 +141,12 @@
     };
 };
 
-// Test environment for Usb HIDL HAL.
-class UsbHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
-   public:
-    // get the test environment singleton
-    static UsbHidlEnvironment* Instance() {
-        static UsbHidlEnvironment* instance = new UsbHidlEnvironment;
-        return instance;
-    }
-
-    virtual void registerTestServices() override { registerTestService<IUsb>(); }
-};
-
 // The main test class for the USB hidl HAL
-class UsbHidlTest : public ::testing::VtsHalHidlTargetTestBase {
-   public:
+class UsbHidlTest : public ::testing::TestWithParam<std::string> {
+  public:
     virtual void SetUp() override {
         ALOGI(__FUNCTION__);
-        usb = ::testing::VtsHalHidlTargetTestBase::getService<IUsb>();
+        usb = IUsb::getService(GetParam());
         ASSERT_NE(usb, nullptr);
 
         usb_cb_2 = new UsbCallback(kCallbackIdentifier);
@@ -182,7 +172,7 @@
  * Callback oject is created and registered.
  * Check to see if the hidl transaction succeeded.
  */
-TEST_F(UsbHidlTest, setCallback) {
+TEST_P(UsbHidlTest, setCallback) {
     usb_cb_1 = new UsbCallback(1);
     ASSERT_NE(usb_cb_1, nullptr);
     Return<void> ret = usb->setCallback(usb_cb_1);
@@ -195,7 +185,7 @@
  * HAL service should call notifyPortStatusChange_1_2
  * instead of notifyPortStatusChange of V1_0/V1_1 interface
  */
-TEST_F(UsbHidlTest, queryPortStatus) {
+TEST_P(UsbHidlTest, queryPortStatus) {
     Return<void> ret = usb->queryPortStatus();
     ASSERT_TRUE(ret.isOk());
     auto res = usb_cb_2->WaitForCallback(kCallbackNameNotifyPortStatusChange_1_2);
@@ -211,7 +201,7 @@
  * Check if supportedContaminantProtectionModes changes across queryPortStatus
  * call.
  */
-TEST_F(UsbHidlTest, checkSupportedContaminantProtectionModes) {
+TEST_P(UsbHidlTest, checkSupportedContaminantProtectionModes) {
     Return<void> ret = usb->queryPortStatus();
     ASSERT_TRUE(ret.isOk());
     auto res = usb_cb_2->WaitForCallback(kCallbackNameNotifyPortStatusChange_1_2);
@@ -243,7 +233,7 @@
  * enableContaminantPresenceDetection should not enable/disable
  * contaminantPresenceProtection.
  */
-TEST_F(UsbHidlTest, presenceDetectionSupportedCheck) {
+TEST_P(UsbHidlTest, presenceDetectionSupportedCheck) {
     Return<void> ret = usb->queryPortStatus();
     ASSERT_TRUE(ret.isOk());
     auto res = usb_cb_2->WaitForCallback(kCallbackNameNotifyPortStatusChange_1_2);
@@ -272,7 +262,7 @@
 /*
  * enableContaminantPresenceDetection should succeed atleast 90% when supported.
  */
-TEST_F(UsbHidlTest, contaminantPresenceDetectionStability) {
+TEST_P(UsbHidlTest, contaminantPresenceDetectionStability) {
     int successCount = 0;
     bool currentStatus;
     bool supported = true;
@@ -309,7 +299,7 @@
  * enableContaminantPresenceProtection should not enable/disable
  * contaminantPresenceProtection.
  */
-TEST_F(UsbHidlTest, presenceProtectionSupportedCheck) {
+TEST_P(UsbHidlTest, presenceProtectionSupportedCheck) {
     Return<void> ret = usb->queryPortStatus();
     ASSERT_TRUE(ret.isOk());
     auto res = usb_cb_2->WaitForCallback(kCallbackNameNotifyPortStatusChange_1_2);
@@ -338,7 +328,7 @@
 /*
  * enableContaminantPresenceProtection should succeed atleast 90% when supported.
  */
-TEST_F(UsbHidlTest, contaminantPresenceProtectionStability) {
+TEST_P(UsbHidlTest, contaminantPresenceProtectionStability) {
     int successCount = 0;
     bool currentStatus;
     bool supported = true;
@@ -370,11 +360,7 @@
     if (!supported) EXPECT_GE(successCount, 9);
 }
 
-int main(int argc, char** argv) {
-    ::testing::AddGlobalTestEnvironment(UsbHidlEnvironment::Instance());
-    ::testing::InitGoogleTest(&argc, argv);
-    UsbHidlEnvironment::Instance()->init(&argc, argv);
-    int status = RUN_ALL_TESTS();
-    ALOGI("Test result = %d", status);
-    return status;
-}
+INSTANTIATE_TEST_SUITE_P(
+        PerInstance, UsbHidlTest,
+        testing::ValuesIn(android::hardware::getAllHalInstanceNames(IUsb::descriptor)),
+        android::hardware::PrintInstanceNameToString);
diff --git a/wifi/1.4/vts/functional/wifi_rtt_controller_hidl_test.cpp b/wifi/1.4/vts/functional/wifi_rtt_controller_hidl_test.cpp
index 726470c..295c86e 100644
--- a/wifi/1.4/vts/functional/wifi_rtt_controller_hidl_test.cpp
+++ b/wifi/1.4/vts/functional/wifi_rtt_controller_hidl_test.cpp
@@ -140,6 +140,18 @@
  * rangeRequest_1_4
  */
 TEST_P(WifiRttControllerHidlTest, RangeRequest_1_4) {
+    std::pair<WifiStatus, RttCapabilities> status_and_caps;
+
+    // Get the Capabilities
+    status_and_caps = HIDL_INVOKE(wifi_rtt_controller_, getCapabilities_1_4);
+    EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_caps.first.code);
+    // Get the highest support preamble
+    int preamble = 1;
+    status_and_caps.second.preambleSupport >>= 1;
+    while (status_and_caps.second.preambleSupport != 0) {
+        status_and_caps.second.preambleSupport >>= 1;
+        preamble <<= 1;
+    }
     std::vector<RttConfig> configs;
     RttConfig config;
     int cmdId = 55;
@@ -148,13 +160,13 @@
         config.addr[i] = i;
     }
     config.type = RttType::ONE_SIDED;
-    config.peer = RttPeerType::STA;
+    config.peer = RttPeerType::AP;
     config.channel.width = WifiChannelWidthInMhz::WIDTH_80;
     config.channel.centerFreq = 5765;
     config.channel.centerFreq0 = 5775;
     config.channel.centerFreq1 = 0;
     config.bw = RttBw::BW_80MHZ;
-    config.preamble = RttPreamble::HE;
+    config.preamble = (RttPreamble)preamble;
     config.mustRequestLci = false;
     config.mustRequestLcr = false;
     config.burstPeriod = 0;