Merge "Adding for adding async large parcelalbe callbacks functionality" into udc-dev
diff --git a/audio/core/all-versions/vts/functional/7.0/PolicyConfig.h b/audio/core/all-versions/vts/functional/7.0/PolicyConfig.h
index c1d5669..f6271ff 100644
--- a/audio/core/all-versions/vts/functional/7.0/PolicyConfig.h
+++ b/audio/core/all-versions/vts/functional/7.0/PolicyConfig.h
@@ -41,15 +41,10 @@
 
 class PolicyConfig {
   public:
-    explicit PolicyConfig(const std::string& configFileName)
-        : mConfigFileName{configFileName},
-          mFilePath{findExistingConfigurationFile(mConfigFileName)},
-          mConfig{xsd::read(mFilePath.c_str())} {
-        init();
-    }
     PolicyConfig(const std::string& configPath, const std::string& configFileName)
         : mConfigFileName{configFileName},
-          mFilePath{configPath + "/" + mConfigFileName},
+          mFilePath{configPath.empty() ? findExistingConfigurationFile(mConfigFileName)
+                                       : configPath + "/" + mConfigFileName},
           mConfig{xsd::read(mFilePath.c_str())} {
         init();
     }
diff --git a/automotive/remoteaccess/hal/default/include/RemoteAccessService.h b/automotive/remoteaccess/hal/default/include/RemoteAccessService.h
index 9aabad6..b18986a 100644
--- a/automotive/remoteaccess/hal/default/include/RemoteAccessService.h
+++ b/automotive/remoteaccess/hal/default/include/RemoteAccessService.h
@@ -105,6 +105,8 @@
     size_t mRetryWaitInMs = 10'000;
     std::shared_ptr<DebugRemoteTaskCallback> mDebugCallback;
 
+    std::thread mInjectDebugTaskThread;
+
     void runTaskLoop();
     void maybeStartTaskLoop();
     void maybeStopTaskLoop();
@@ -116,6 +118,8 @@
     void printCurrentStatus(int fd);
     std::string clientIdToTaskCountToStringLocked() REQUIRES(mLock);
     void debugInjectTask(int fd, std::string_view clientId, std::string_view taskData);
+    void debugInjectTaskNextReboot(int fd, std::string_view clientId, std::string_view taskData,
+                                   const char* latencyInSecStr);
     void updateGrpcConnected(bool connected);
     android::base::Result<void> deliverRemoteTaskThroughCallback(const std::string& clientId,
                                                                  std::string_view taskData);
diff --git a/automotive/remoteaccess/hal/default/src/RemoteAccessService.cpp b/automotive/remoteaccess/hal/default/src/RemoteAccessService.cpp
index bbda9df..dbe8150 100644
--- a/automotive/remoteaccess/hal/default/src/RemoteAccessService.cpp
+++ b/automotive/remoteaccess/hal/default/src/RemoteAccessService.cpp
@@ -18,12 +18,16 @@
 
 #include <VehicleUtils.h>
 #include <aidl/android/hardware/automotive/vehicle/VehicleProperty.h>
+#include <android-base/parseint.h>
 #include <android-base/stringprintf.h>
 #include <android/binder_status.h>
 #include <grpc++/grpc++.h>
 #include <private/android_filesystem_config.h>
+#include <sys/stat.h>
 #include <utils/Log.h>
 #include <chrono>
+#include <fstream>
+#include <iostream>
 #include <thread>
 
 namespace android {
@@ -37,6 +41,7 @@
 using ::aidl::android::hardware::automotive::remoteaccess::IRemoteTaskCallback;
 using ::aidl::android::hardware::automotive::vehicle::VehicleProperty;
 using ::android::base::Error;
+using ::android::base::ParseInt;
 using ::android::base::Result;
 using ::android::base::ScopedLockAssertion;
 using ::android::base::StringAppendF;
@@ -57,8 +62,12 @@
 constexpr char COMMAND_SHOW_TASK[] = "--show-task";
 constexpr char COMMAND_GET_VEHICLE_ID[] = "--get-vehicle-id";
 constexpr char COMMAND_INJECT_TASK[] = "--inject-task";
+constexpr char COMMAND_INJECT_TASK_NEXT_REBOOT[] = "--inject-task-next-reboot";
 constexpr char COMMAND_STATUS[] = "--status";
 
+constexpr char DEBUG_TASK_FOLDER[] = "/data/local/tests";
+constexpr char DEBUG_TASK_FILE[] = "/data/local/tests/debugTask";
+
 std::vector<uint8_t> stringToBytes(std::string_view s) {
     const char* data = s.data();
     return std::vector<uint8_t>(data, data + s.size());
@@ -92,10 +101,43 @@
 }  // namespace
 
 RemoteAccessService::RemoteAccessService(WakeupClient::StubInterface* grpcStub)
-    : mGrpcStub(grpcStub){};
+    : mGrpcStub(grpcStub) {
+    std::ifstream debugTaskFile;
+    debugTaskFile.open(DEBUG_TASK_FILE, std::ios::in);
+    if (!debugTaskFile.is_open()) {
+        ALOGD("No debug task available");
+        return;
+    }
+
+    char buffer[1024] = {};
+    debugTaskFile.getline(buffer, sizeof(buffer));
+    std::string clientId = std::string(buffer);
+    debugTaskFile.getline(buffer, sizeof(buffer));
+    std::string taskData = std::string(buffer);
+    int latencyInSec;
+    debugTaskFile >> latencyInSec;
+    debugTaskFile.close();
+
+    ALOGD("Task for client: %s, data: [%s], latency: %d\n", clientId.c_str(), taskData.c_str(),
+          latencyInSec);
+
+    mInjectDebugTaskThread = std::thread([this, clientId, taskData, latencyInSec] {
+        std::this_thread::sleep_for(std::chrono::seconds(latencyInSec));
+        if (auto result = deliverRemoteTaskThroughCallback(clientId, taskData); !result.ok()) {
+            ALOGE("Failed to inject debug task, clientID: %s, taskData: %s, error: %s",
+                  clientId.c_str(), taskData.c_str(), result.error().message().c_str());
+            return;
+        }
+        ALOGD("Task for client: %s, data: [%s] successfully injected\n", clientId.c_str(),
+              taskData.c_str());
+    });
+}
 
 RemoteAccessService::~RemoteAccessService() {
     maybeStopTaskLoop();
+    if (mInjectDebugTaskThread.joinable()) {
+        mInjectDebugTaskThread.join();
+    }
 }
 
 void RemoteAccessService::maybeStartTaskLoop() {
@@ -286,9 +328,12 @@
             "%s: Show tasks received by debug callback\n"
             "%s: Get vehicle id\n"
             "%s [client_id] [task_data]: Inject a task\n"
+            "%s [client_id] [task_data] [latencyInSec]: "
+            "Inject a task on next reboot after latencyInSec seconds\n"
             "%s: Show status\n",
             COMMAND_SET_AP_STATE, COMMAND_START_DEBUG_CALLBACK, COMMAND_STOP_DEBUG_CALLBACK,
-            COMMAND_SHOW_TASK, COMMAND_GET_VEHICLE_ID, COMMAND_INJECT_TASK, COMMAND_STATUS);
+            COMMAND_SHOW_TASK, COMMAND_GET_VEHICLE_ID, COMMAND_INJECT_TASK,
+            COMMAND_INJECT_TASK_NEXT_REBOOT, COMMAND_STATUS);
 }
 
 binder_status_t RemoteAccessService::dump(int fd, const char** args, uint32_t numArgs) {
@@ -365,6 +410,12 @@
             return STATUS_OK;
         }
         debugInjectTask(fd, args[1], args[2]);
+    } else if (!strcmp(args[0], COMMAND_INJECT_TASK_NEXT_REBOOT)) {
+        if (numArgs < 4) {
+            dumpHelp(fd);
+            return STATUS_OK;
+        }
+        debugInjectTaskNextReboot(fd, args[1], args[2], args[3]);
     } else if (!strcmp(args[0], COMMAND_STATUS)) {
         printCurrentStatus(fd);
     } else {
@@ -389,13 +440,41 @@
                                           std::string_view taskData) {
     std::string clientIdCopy = std::string(clientId);
     if (auto result = deliverRemoteTaskThroughCallback(clientIdCopy, taskData); !result.ok()) {
-        dprintf(fd, "Failed to inject task: %s", result.error().message().c_str());
+        dprintf(fd, "Failed to inject task: %s\n", result.error().message().c_str());
         return;
     }
     dprintf(fd, "Task for client: %s, data: [%s] successfully injected\n", clientId.data(),
             taskData.data());
 }
 
+void RemoteAccessService::debugInjectTaskNextReboot(int fd, std::string_view clientId,
+                                                    std::string_view taskData,
+                                                    const char* latencyInSecStr) {
+    int latencyInSec;
+    if (!ParseInt(latencyInSecStr, &latencyInSec)) {
+        dprintf(fd, "The input latency in second is not a valid integer");
+        return;
+    }
+    std::ofstream debugTaskFile;
+    debugTaskFile.open(DEBUG_TASK_FILE, std::ios::out);
+    if (!debugTaskFile.is_open()) {
+        dprintf(fd,
+                "Failed to open debug task file, please run the command: "
+                "'adb shell touch %s' first\n",
+                DEBUG_TASK_FILE);
+        return;
+    }
+    if (taskData.find("\n") != std::string::npos) {
+        dprintf(fd, "Task data must not contain newline\n");
+        return;
+    }
+    debugTaskFile << clientId << "\n" << taskData << "\n" << latencyInSec;
+    debugTaskFile.close();
+    dprintf(fd,
+            "Task with clientId: %s, task data: %s, latency: %d sec scheduled for next reboot\n",
+            clientId.data(), taskData.data(), latencyInSec);
+}
+
 std::string RemoteAccessService::clientIdToTaskCountToStringLocked() {
     // Print the table header
     std::string output = "| ClientId | Count |\n";
diff --git a/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl b/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl
index 6dca41f..d9c6de7 100644
--- a/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl
+++ b/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl
@@ -4384,12 +4384,6 @@
     /***********************************************************************************************
      * Start of ADAS Properties
      *
-     * Android is not a safety critical system and is provided as is without any timing guarantees,
-     * representations or warranties. OEMs implementing these properties, and clients using these
-     * properties should ensure they complete any necessary safety reviews, in accordance with
-     * industry standards, to ensure the use of these APIs do not negatively impact driver safety.
-     * Use of any Google APIs will be at the OEM's sole risk.
-     *
      * Allocate IDs in range of 0x1000 (inclusive) to 0x1100 (exclusive) for ADAS properties
      **********************************************************************************************/
 
diff --git a/biometrics/fingerprint/aidl/default/Android.bp b/biometrics/fingerprint/aidl/default/Android.bp
index fe224c9..16302eb 100644
--- a/biometrics/fingerprint/aidl/default/Android.bp
+++ b/biometrics/fingerprint/aidl/default/Android.bp
@@ -110,6 +110,32 @@
     require_root: true,
 }
 
+cc_test {
+    name: "android.hardware.biometrics.fingerprint.SessionTest",
+    local_include_dirs: ["include"],
+    srcs: [
+        "tests/SessionTest.cpp",
+        "Session.cpp",
+        "FakeFingerprintEngine.cpp",
+        "FakeLockoutTracker.cpp",
+    ],
+    shared_libs: [
+        "libbase",
+        "libbinder_ndk",
+        "android.hardware.biometrics.common.thread",
+    ],
+    static_libs: [
+        "libandroid.hardware.biometrics.fingerprint.VirtualProps",
+        "android.hardware.biometrics.fingerprint-V3-ndk",
+        "android.hardware.biometrics.common-V3-ndk",
+        "android.hardware.keymaster-V4-ndk",
+        "android.hardware.biometrics.common.util",
+    ],
+    vendor: true,
+    test_suites: ["general-tests"],
+    require_root: true,
+}
+
 sysprop_library {
     name: "android.hardware.biometrics.fingerprint.VirtualProps",
     srcs: ["fingerprint.sysprop"],
diff --git a/biometrics/fingerprint/aidl/default/Fingerprint.cpp b/biometrics/fingerprint/aidl/default/Fingerprint.cpp
index 7808a13..f00a49d 100644
--- a/biometrics/fingerprint/aidl/default/Fingerprint.cpp
+++ b/biometrics/fingerprint/aidl/default/Fingerprint.cpp
@@ -103,6 +103,8 @@
     mSession = SharedRefBase::make<Session>(sensorId, userId, cb, mEngine.get(), &mWorker);
     *out = mSession;
 
+    mSession->linkToDeath(cb->asBinder().get());
+
     LOG(INFO) << "createSession: sensorId:" << sensorId << " userId:" << userId;
     return ndk::ScopedAStatus::ok();
 }
diff --git a/biometrics/fingerprint/aidl/default/Session.cpp b/biometrics/fingerprint/aidl/default/Session.cpp
index 38d6a13..c06c931 100644
--- a/biometrics/fingerprint/aidl/default/Session.cpp
+++ b/biometrics/fingerprint/aidl/default/Session.cpp
@@ -25,6 +25,14 @@
 
 namespace aidl::android::hardware::biometrics::fingerprint {
 
+void onClientDeath(void* cookie) {
+    LOG(INFO) << "FingerprintService has died";
+    Session* session = static_cast<Session*>(cookie);
+    if (session && !session->isClosed()) {
+        session->close();
+    }
+}
+
 Session::Session(int sensorId, int userId, std::shared_ptr<ISessionCallback> cb,
                  FakeFingerprintEngine* engine, WorkerThread* worker)
     : mSensorId(sensorId),
@@ -39,6 +47,12 @@
     CHECK(mEngine);
     CHECK(mWorker);
     CHECK(mCb);
+
+    mDeathRecipient = AIBinder_DeathRecipient_new(onClientDeath);
+}
+
+binder_status_t Session::linkToDeath(AIBinder* binder) {
+    return AIBinder_linkToDeath(binder, mDeathRecipient, this);
 }
 
 void Session::scheduleStateOrCrash(SessionState state) {
@@ -228,6 +242,7 @@
     // Crashing.";
     mCurrentState = SessionState::CLOSED;
     mCb->onSessionClosed();
+    AIBinder_DeathRecipient_delete(mDeathRecipient);
     return ndk::ScopedAStatus::ok();
 }
 
diff --git a/biometrics/fingerprint/aidl/default/include/Session.h b/biometrics/fingerprint/aidl/default/include/Session.h
index b596d9e..526d579 100644
--- a/biometrics/fingerprint/aidl/default/include/Session.h
+++ b/biometrics/fingerprint/aidl/default/include/Session.h
@@ -42,6 +42,8 @@
     RESETTING_LOCKOUT,
 };
 
+void onClientDeath(void* cookie);
+
 class Session : public BnSession {
   public:
     Session(int sensorId, int userId, std::shared_ptr<ISessionCallback> cb,
@@ -101,6 +103,8 @@
 
     ndk::ScopedAStatus setIgnoreDisplayTouches(bool shouldIgnore) override;
 
+    binder_status_t linkToDeath(AIBinder* binder);
+
     bool isClosed();
 
   private:
@@ -139,6 +143,9 @@
     // modified from both the main and the worker threads.
     std::atomic<SessionState> mScheduledState;
     std::atomic<SessionState> mCurrentState;
+
+    // Binder death handler.
+    AIBinder_DeathRecipient* mDeathRecipient;
 };
 
 }  // namespace aidl::android::hardware::biometrics::fingerprint
diff --git a/biometrics/fingerprint/aidl/default/tests/SessionTest.cpp b/biometrics/fingerprint/aidl/default/tests/SessionTest.cpp
new file mode 100644
index 0000000..3b96d7f
--- /dev/null
+++ b/biometrics/fingerprint/aidl/default/tests/SessionTest.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android/binder_process.h>
+#include <fingerprint.sysprop.h>
+#include <gtest/gtest.h>
+
+#include <android-base/logging.h>
+
+#include <aidl/android/hardware/biometrics/fingerprint/BnSessionCallback.h>
+
+#include "Session.h"
+#include "thread/WorkerThread.h"
+#include "util/Util.h"
+
+using namespace ::android::fingerprint::virt;
+using namespace ::aidl::android::hardware::biometrics::fingerprint;
+
+namespace aidl::android::hardware::biometrics::fingerprint {
+
+class TestSessionCallback : public BnSessionCallback {
+  public:
+    ndk::ScopedAStatus onChallengeGenerated(int64_t /*challenge*/) override {
+        return ndk::ScopedAStatus::ok();
+    };
+    ::ndk::ScopedAStatus onChallengeRevoked(int64_t /*challenge*/) override {
+        return ndk::ScopedAStatus::ok();
+    };
+    ::ndk::ScopedAStatus onError(fingerprint::Error /*error*/, int32_t /*vendorCode*/) override {
+        return ndk::ScopedAStatus::ok();
+    };
+    ::ndk::ScopedAStatus onEnrollmentProgress(int32_t /*enrollmentId*/,
+                                              int32_t /*remaining*/) override {
+        return ndk::ScopedAStatus::ok();
+    };
+
+    ::ndk::ScopedAStatus onAuthenticationSucceeded(int32_t /*enrollmentId*/,
+                                                   const keymaster::HardwareAuthToken&) override {
+        return ndk::ScopedAStatus::ok();
+    };
+    ::ndk::ScopedAStatus onAuthenticationFailed() override { return ndk::ScopedAStatus::ok(); };
+    ::ndk::ScopedAStatus onInteractionDetected() override { return ndk::ScopedAStatus::ok(); };
+    ndk::ScopedAStatus onAcquired(AcquiredInfo /*info*/, int32_t /*vendorCode*/) override {
+        return ndk::ScopedAStatus::ok();
+    }
+    ::ndk::ScopedAStatus onEnrollmentsEnumerated(
+            const std::vector<int32_t>& /*enrollmentIds*/) override {
+        return ndk::ScopedAStatus::ok();
+    };
+    ::ndk::ScopedAStatus onEnrollmentsRemoved(
+            const std::vector<int32_t>& /*enrollmentIds*/) override {
+        return ndk::ScopedAStatus::ok();
+    };
+    ::ndk::ScopedAStatus onAuthenticatorIdRetrieved(int64_t /*authenticatorId*/) override {
+        return ndk::ScopedAStatus::ok();
+    };
+    ::ndk::ScopedAStatus onAuthenticatorIdInvalidated(int64_t /*authenticatorId*/) override {
+        return ndk::ScopedAStatus::ok();
+    };
+    ::ndk::ScopedAStatus onLockoutPermanent() override { return ndk::ScopedAStatus::ok(); };
+    ndk::ScopedAStatus onLockoutTimed(int64_t /* timeout */) override {
+        return ndk::ScopedAStatus::ok();
+    }
+    ndk::ScopedAStatus onLockoutCleared() override { return ndk::ScopedAStatus::ok(); }
+    ndk::ScopedAStatus onSessionClosed() override {
+        mIsClosed = true;
+        return ndk::ScopedAStatus::ok();
+    }
+
+    bool mIsClosed = false;
+};
+
+class SessionTest : public ::testing::Test {
+  public:
+    SessionTest() : mWorker(2) {}
+
+  protected:
+    void SetUp() override {
+        mCb = ndk::SharedRefBase::make<TestSessionCallback>();
+        mSession = ndk::SharedRefBase::make<Session>(1, 2, mCb, &mFakeFingerprintEngine, &mWorker);
+        ASSERT_TRUE(mSession != nullptr);
+        mSession->linkToDeath(mCb->asBinder().get());
+    }
+
+    void TearDown() override {}
+
+    std::shared_ptr<Session> mSession;
+    std::shared_ptr<TestSessionCallback> mCb;
+
+  private:
+    FakeFingerprintEngine mFakeFingerprintEngine;
+    WorkerThread mWorker;
+};
+
+TEST_F(SessionTest, close) {
+    ASSERT_TRUE(!mSession->isClosed());
+    ASSERT_TRUE(!mCb->mIsClosed);
+    onClientDeath(nullptr);
+    ASSERT_TRUE(!mSession->isClosed());
+    ASSERT_TRUE(!mCb->mIsClosed);
+    onClientDeath(static_cast<void*>(mSession.get()));
+    ASSERT_TRUE(mSession->isClosed());
+    ASSERT_TRUE(mCb->mIsClosed);
+}
+
+}  //  namespace aidl::android::hardware::biometrics::fingerprint
+
+int main(int argc, char** argv) {
+    testing::InitGoogleTest(&argc, argv);
+    ABinderProcess_startThreadPool();
+    return RUN_ALL_TESTS();
+}
diff --git a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp
index ed4f28c..18d36e4 100644
--- a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp
+++ b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp
@@ -655,8 +655,15 @@
         return;
     }
     const auto& [status, conversionCapabilities] = mComposerClient->getHdrConversionCapabilities();
+    const auto& [status2, hdrCapabilities] =
+            mComposerClient->getHdrCapabilities(getPrimaryDisplayId());
+    const auto& hdrTypes = hdrCapabilities.types;
     for (auto conversionCapability : conversionCapabilities) {
         if (conversionCapability.outputType != common::Hdr::INVALID) {
+            if (std::find(hdrTypes.begin(), hdrTypes.end(), conversionCapability.outputType) ==
+                hdrTypes.end()) {
+                continue;
+            }
             common::HdrConversionStrategy hdrConversionStrategy;
             hdrConversionStrategy.set<common::HdrConversionStrategy::Tag::forceHdrConversion>(
                     conversionCapability.outputType);
@@ -674,6 +681,11 @@
         return;
     }
     const auto& [status, conversionCapabilities] = mComposerClient->getHdrConversionCapabilities();
+    const auto& [status2, hdrCapabilities] =
+            mComposerClient->getHdrCapabilities(getPrimaryDisplayId());
+    if (hdrCapabilities.types.size() <= 0) {
+        return;
+    }
     std::vector<aidl::android::hardware::graphics::common::Hdr> autoHdrTypes;
     for (auto conversionCapability : conversionCapabilities) {
         if (conversionCapability.outputType != common::Hdr::INVALID) {
diff --git a/wifi/1.6/vts/functional/wifi_rtt_controller_hidl_test.cpp b/wifi/1.6/vts/functional/wifi_rtt_controller_hidl_test.cpp
index 5b5e623..0572ac6 100644
--- a/wifi/1.6/vts/functional/wifi_rtt_controller_hidl_test.cpp
+++ b/wifi/1.6/vts/functional/wifi_rtt_controller_hidl_test.cpp
@@ -78,6 +78,13 @@
 
     virtual void TearDown() override { stopWifi(GetInstanceName()); }
 
+    RttCapabilities getRttCapabilities() {
+        std::pair<WifiStatus, RttCapabilities> status_and_caps;
+        status_and_caps = HIDL_INVOKE(wifi_rtt_controller_, getCapabilities_1_6);
+        EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_caps.first.code);
+        return status_and_caps.second;
+    }
+
     // A simple test implementation of WifiRttControllerEventCallback.
     class WifiRttControllerEventCallback
         : public ::testing::VtsHalHidlTargetCallbackBase<WifiRttControllerHidlTest>,
@@ -151,12 +158,9 @@
  * This test case tests the two sided ranging - 802.11mc FTM protocol.
  */
 TEST_P(WifiRttControllerHidlTest, Request2SidedRangeMeasurement) {
-    std::pair<WifiStatus, RttCapabilities> status_and_caps;
-
     // Get the Capabilities
-    status_and_caps = HIDL_INVOKE(wifi_rtt_controller_, getCapabilities_1_6);
-    EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_caps.first.code);
-    if (!status_and_caps.second.rttFtmSupported) {
+    RttCapabilities capabilities = getRttCapabilities();
+    if (!capabilities.rttFtmSupported) {
         GTEST_SKIP() << "Skipping two sided RTT since driver/fw doesn't support";
     }
     std::vector<RttConfig> configs;
@@ -196,19 +200,16 @@
  * rangeRequest_1_6
  */
 TEST_P(WifiRttControllerHidlTest, RangeRequest_1_6) {
-    std::pair<WifiStatus, RttCapabilities> status_and_caps;
-
     // Get the Capabilities
-    status_and_caps = HIDL_INVOKE(wifi_rtt_controller_, getCapabilities_1_6);
-    EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_caps.first.code);
-    if (!status_and_caps.second.rttOneSidedSupported) {
+    RttCapabilities capabilities = getRttCapabilities();
+    if (!capabilities.rttOneSidedSupported) {
         GTEST_SKIP() << "Skipping one sided RTT since driver/fw doesn't support";
     }
     // 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;
+    capabilities.preambleSupport >>= 1;
+    while (capabilities.preambleSupport != 0) {
+        capabilities.preambleSupport >>= 1;
         preamble <<= 1;
     }
     std::vector<RttConfig> configs;
@@ -259,9 +260,14 @@
  * getResponderInfo_1_6
  */
 TEST_P(WifiRttControllerHidlTest, GetResponderInfo_1_6) {
-    std::pair<WifiStatus, RttResponder> status_and_info;
+    // Get the capabilities
+    RttCapabilities capabilities = getRttCapabilities();
+    if (!capabilities.responderSupported) {
+        GTEST_SKIP() << "Skipping because responder is not supported";
+    }
 
     // Invoke the call
+    std::pair<WifiStatus, RttResponder> status_and_info;
     status_and_info = HIDL_INVOKE(wifi_rtt_controller_, getResponderInfo_1_6);
     EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_info.first.code);
 }
@@ -270,6 +276,12 @@
  * enableResponder_1_6
  */
 TEST_P(WifiRttControllerHidlTest, EnableResponder_1_6) {
+    // Get the capabilities
+    RttCapabilities capabilities = getRttCapabilities();
+    if (!capabilities.responderSupported) {
+        GTEST_SKIP() << "Skipping because responder is not supported";
+    }
+
     std::pair<WifiStatus, RttResponder> status_and_info;
     int cmdId = 55;
     WifiChannelInfo channelInfo;