Merge changes from topic "rvc-dev-trout" into rvc-dev

* changes:
  Merge nested namesapces
  Split client and server impl
  Split vehicle client and server interface header
  Add headers and macros for building VHAL server for AGL
diff --git a/camera/common/1.0/default/Exif.cpp b/camera/common/1.0/default/Exif.cpp
index 4de05c5..413b6bb 100644
--- a/camera/common/1.0/default/Exif.cpp
+++ b/camera/common/1.0/default/Exif.cpp
@@ -632,13 +632,13 @@
 }
 
 bool ExifUtilsImpl::setImageHeight(uint32_t length) {
-    SET_LONG(EXIF_IFD_0, EXIF_TAG_IMAGE_LENGTH, length);
+    SET_SHORT(EXIF_IFD_0, EXIF_TAG_IMAGE_LENGTH, length);
     SET_LONG(EXIF_IFD_EXIF, EXIF_TAG_PIXEL_Y_DIMENSION, length);
     return true;
 }
 
 bool ExifUtilsImpl::setImageWidth(uint32_t width) {
-    SET_LONG(EXIF_IFD_0, EXIF_TAG_IMAGE_WIDTH, width);
+    SET_SHORT(EXIF_IFD_0, EXIF_TAG_IMAGE_WIDTH, width);
     SET_LONG(EXIF_IFD_EXIF, EXIF_TAG_PIXEL_X_DIMENSION, width);
     return true;
 }
diff --git a/confirmationui/1.0/vts/functional/Android.bp b/confirmationui/1.0/vts/functional/Android.bp
index fd088cd..c8b522c 100644
--- a/confirmationui/1.0/vts/functional/Android.bp
+++ b/confirmationui/1.0/vts/functional/Android.bp
@@ -27,5 +27,5 @@
         "libcn-cbor",
         "android.hardware.confirmationui-support-lib",
     ],
-    test_suites: ["general-tests"],
+    test_suites: ["general-tests", "vts-core"],
 }
diff --git a/confirmationui/1.0/vts/functional/VtsHalConfirmationUIV1_0TargetTest.cpp b/confirmationui/1.0/vts/functional/VtsHalConfirmationUIV1_0TargetTest.cpp
index fb01ad0..d953ab0 100644
--- a/confirmationui/1.0/vts/functional/VtsHalConfirmationUIV1_0TargetTest.cpp
+++ b/confirmationui/1.0/vts/functional/VtsHalConfirmationUIV1_0TargetTest.cpp
@@ -26,8 +26,12 @@
 #include <android/hardware/confirmationui/1.0/types.h>
 #include <android/hardware/confirmationui/support/confirmationui_utils.h>
 
+#include <gtest/gtest.h>
+
 #include <VtsHalHidlTargetCallbackBase.h>
-#include <VtsHalHidlTargetTestBase.h>
+
+#include <hidl/GtestPrinter.h>
+#include <hidl/ServiceManagement.h>
 
 #include <openssl/hmac.h>
 #include <openssl/sha.h>
@@ -199,43 +203,18 @@
     }
 };
 
-class ConfirmationUIHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
-   public:
-    // get the test environment singleton
-    static ConfirmationUIHidlEnvironment* Instance() {
-        static ConfirmationUIHidlEnvironment* instance = new ConfirmationUIHidlEnvironment;
-        return instance;
-    }
-
-    void registerTestServices() override { registerTestService<IConfirmationUI>(); }
-
-   private:
-    ConfirmationUIHidlEnvironment(){};
-
-    GTEST_DISALLOW_COPY_AND_ASSIGN_(ConfirmationUIHidlEnvironment);
-};
-
-class ConfirmationUIHidlTest : public ::testing::VtsHalHidlTargetTestBase {
-   public:
-    void TearDown() override { confirmator().abort(); }
-
-    static void SetUpTestCase() {
-        string service_name =
-            ConfirmationUIHidlEnvironment::Instance()->getServiceName<IConfirmationUI>();
-        confirmator_ = IConfirmationUI::getService(service_name);
+class ConfirmationUIHidlTest : public ::testing::TestWithParam<std::string> {
+  public:
+    void TearDown() override { confirmator_->abort(); }
+    void SetUp() override {
+        confirmator_ = IConfirmationUI::getService(GetParam());
         ASSERT_NE(nullptr, confirmator_.get());
     }
 
-    static void TearDownTestCase() { confirmator_.clear(); }
-
-    static IConfirmationUI& confirmator() { return *confirmator_; }
-
-   private:
-    static sp<IConfirmationUI> confirmator_;
+  protected:
+    sp<IConfirmationUI> confirmator_;
 };
 
-sp<IConfirmationUI> ConfirmationUIHidlTest::confirmator_;
-
 #define ASSERT_HAL_CALL(expected, call)                               \
     {                                                                 \
         auto result = call;                                           \
@@ -250,17 +229,17 @@
 typedef std::unique_ptr<cn_cbor, CnCborDeleter> CnCborPtr;
 
 // Simulates the User taping Ok
-TEST_F(ConfirmationUIHidlTest, UserOkTest) {
+TEST_P(ConfirmationUIHidlTest, UserOkTest) {
     static constexpr char test_prompt[] = "Me first, gimme gimme!";
     static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3};
     sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback;
     hidl_string prompt_text(test_prompt);
     hidl_vec<uint8_t> extra(test_extra, test_extra + 3);
     ASSERT_HAL_CALL(ResponseCode::OK,
-                    confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
+                    confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
 
-    ASSERT_HAL_CALL(ResponseCode::OK, confirmator().deliverSecureInputEvent(
-                                          makeTestToken(TestModeCommands::OK_EVENT)));
+    ASSERT_HAL_CALL(ResponseCode::OK, confirmator_->deliverSecureInputEvent(
+                                              makeTestToken(TestModeCommands::OK_EVENT)));
 
     auto result = conf_cb->WaitForCallback();
     ASSERT_EQ(ResponseCode::OK, result.args->error_);
@@ -294,40 +273,40 @@
 }
 
 // Initiates a confirmation prompt with a message that is too long
-TEST_F(ConfirmationUIHidlTest, MessageTooLongTest) {
+TEST_P(ConfirmationUIHidlTest, MessageTooLongTest) {
     static constexpr uint8_t test_extra[static_cast<uint32_t>(MessageSize::MAX)] = {};
     static constexpr char test_prompt[] = "D\'oh!";
     sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback;
     hidl_string prompt_text(test_prompt);
     hidl_vec<uint8_t> extra(test_extra, test_extra + sizeof(test_extra));
     ASSERT_HAL_CALL(ResponseCode::UIErrorMessageTooLong,
-                    confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
+                    confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
 }
 
 // If the message gets very long some HAL implementations might fail even before the message
 // reaches the trusted app implementation. But the HAL must still diagnose the correct error.
-TEST_F(ConfirmationUIHidlTest, MessageWayTooLongTest) {
+TEST_P(ConfirmationUIHidlTest, MessageWayTooLongTest) {
     static constexpr uint8_t test_extra[static_cast<uint32_t>(MessageSize::MAX) * 10] = {};
     static constexpr char test_prompt[] = "D\'oh!";
     sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback;
     hidl_string prompt_text(test_prompt);
     hidl_vec<uint8_t> extra(test_extra, test_extra + sizeof(test_extra));
     ASSERT_HAL_CALL(ResponseCode::UIErrorMessageTooLong,
-                    confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
+                    confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
 }
 
 // Simulates the User tapping the Cancel
-TEST_F(ConfirmationUIHidlTest, UserCancelTest) {
+TEST_P(ConfirmationUIHidlTest, UserCancelTest) {
     static constexpr char test_prompt[] = "Me first, gimme gimme!";
     static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3};
     sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback;
     hidl_string prompt_text(test_prompt);
     hidl_vec<uint8_t> extra(test_extra, test_extra + 3);
     ASSERT_HAL_CALL(ResponseCode::OK,
-                    confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
+                    confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
 
-    ASSERT_HAL_CALL(ResponseCode::OK, confirmator().deliverSecureInputEvent(
-                                          makeTestToken(TestModeCommands::CANCEL_EVENT)));
+    ASSERT_HAL_CALL(ResponseCode::OK, confirmator_->deliverSecureInputEvent(
+                                              makeTestToken(TestModeCommands::CANCEL_EVENT)));
 
     auto result = conf_cb->WaitForCallback();
     ASSERT_EQ(ResponseCode::Canceled, result.args->error_);
@@ -337,16 +316,16 @@
 }
 
 // Simulates the framework cancelling an ongoing prompt
-TEST_F(ConfirmationUIHidlTest, AbortTest) {
+TEST_P(ConfirmationUIHidlTest, AbortTest) {
     static constexpr char test_prompt[] = "Me first, gimme gimme!";
     static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3};
     sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback;
     hidl_string prompt_text(test_prompt);
     hidl_vec<uint8_t> extra(test_extra, test_extra + 3);
     ASSERT_HAL_CALL(ResponseCode::OK,
-                    confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
+                    confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
 
-    confirmator().abort();
+    confirmator_->abort();
 
     auto result = conf_cb->WaitForCallback();
     ASSERT_EQ(ResponseCode::Aborted, result.args->error_);
@@ -356,7 +335,7 @@
 
 // Tests if the confirmation dialog can successfully render 100 'W' characters as required by
 // the design guidelines.
-TEST_F(ConfirmationUIHidlTest, PortableMessageTest1) {
+TEST_P(ConfirmationUIHidlTest, PortableMessageTest1) {
     static constexpr char test_prompt[] =
             "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW"
             "WWWWWWWWWWWWWW";
@@ -365,9 +344,9 @@
     hidl_string prompt_text(test_prompt);
     hidl_vec<uint8_t> extra(test_extra, test_extra + 3);
     ASSERT_HAL_CALL(ResponseCode::OK,
-                    confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
+                    confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
 
-    confirmator().abort();
+    confirmator_->abort();
 
     auto result = conf_cb->WaitForCallback();
     ASSERT_EQ(ResponseCode::Aborted, result.args->error_);
@@ -377,7 +356,7 @@
 
 // Tests if the confirmation dialog can successfully render 100 'W' characters as required by
 // the design guidelines in magnified mode.
-TEST_F(ConfirmationUIHidlTest, PortableMessageTest1Magnified) {
+TEST_P(ConfirmationUIHidlTest, PortableMessageTest1Magnified) {
     static constexpr char test_prompt[] =
             "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW"
             "WWWWWWWWWWWWWW";
@@ -386,10 +365,10 @@
     hidl_string prompt_text(test_prompt);
     hidl_vec<uint8_t> extra(test_extra, test_extra + 3);
     ASSERT_HAL_CALL(ResponseCode::OK,
-                    confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en",
+                    confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en",
                                                          {UIOption::AccessibilityMagnified}));
 
-    confirmator().abort();
+    confirmator_->abort();
 
     auto result = conf_cb->WaitForCallback();
     ASSERT_EQ(ResponseCode::Aborted, result.args->error_);
@@ -399,7 +378,7 @@
 
 // Tests if the confirmation dialog can successfully render 8 groups of 12 'W' characters as
 // required by the design guidelines.
-TEST_F(ConfirmationUIHidlTest, PortableMessageTest2) {
+TEST_P(ConfirmationUIHidlTest, PortableMessageTest2) {
     static constexpr char test_prompt[] =
             "WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW "
             "WWWWWWWWWWWW WWWWWWWWWWWW";
@@ -408,9 +387,9 @@
     hidl_string prompt_text(test_prompt);
     hidl_vec<uint8_t> extra(test_extra, test_extra + 3);
     ASSERT_HAL_CALL(ResponseCode::OK,
-                    confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
+                    confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
 
-    confirmator().abort();
+    confirmator_->abort();
 
     auto result = conf_cb->WaitForCallback();
     ASSERT_EQ(ResponseCode::Aborted, result.args->error_);
@@ -420,7 +399,7 @@
 
 // Tests if the confirmation dialog can successfully render 8 groups of 12 'W' characters as
 // required by the design guidelines in magnified mode.
-TEST_F(ConfirmationUIHidlTest, PortableMessageTest2Magnified) {
+TEST_P(ConfirmationUIHidlTest, PortableMessageTest2Magnified) {
     static constexpr char test_prompt[] =
             "WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW "
             "WWWWWWWWWWWW WWWWWWWWWWWW";
@@ -429,10 +408,10 @@
     hidl_string prompt_text(test_prompt);
     hidl_vec<uint8_t> extra(test_extra, test_extra + 3);
     ASSERT_HAL_CALL(ResponseCode::OK,
-                    confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en",
+                    confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en",
                                                          {UIOption::AccessibilityMagnified}));
 
-    confirmator().abort();
+    confirmator_->abort();
 
     auto result = conf_cb->WaitForCallback();
     ASSERT_EQ(ResponseCode::Aborted, result.args->error_);
@@ -442,19 +421,19 @@
 
 // Passing malformed UTF-8 to the confirmation UI
 // This test passes a string that ends in the middle of a multibyte character
-TEST_F(ConfirmationUIHidlTest, MalformedUTF8Test1) {
+TEST_P(ConfirmationUIHidlTest, MalformedUTF8Test1) {
     static constexpr char test_prompt[] = {char(0xc0), 0};
     static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3};
     sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback;
     hidl_string prompt_text(test_prompt);
     hidl_vec<uint8_t> extra(test_extra, test_extra + 3);
     ASSERT_HAL_CALL(ResponseCode::UIErrorMalformedUTF8Encoding,
-                    confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
+                    confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
 }
 
 // Passing malformed UTF-8 to the confirmation UI
 // This test passes a string with a 5-byte character.
-TEST_F(ConfirmationUIHidlTest, MalformedUTF8Test2) {
+TEST_P(ConfirmationUIHidlTest, MalformedUTF8Test2) {
     static constexpr char test_prompt[] = {char(0xf8), char(0x82), char(0x82),
                                            char(0x82), char(0x82), 0};
     static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3};
@@ -462,19 +441,19 @@
     hidl_string prompt_text(test_prompt);
     hidl_vec<uint8_t> extra(test_extra, test_extra + 3);
     ASSERT_HAL_CALL(ResponseCode::UIErrorMalformedUTF8Encoding,
-                    confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
+                    confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
 }
 
 // Passing malformed UTF-8 to the confirmation UI
 // This test passes a string with a 2-byte character followed by a stray non UTF-8 character.
-TEST_F(ConfirmationUIHidlTest, MalformedUTF8Test3) {
+TEST_P(ConfirmationUIHidlTest, MalformedUTF8Test3) {
     static constexpr char test_prompt[] = {char(0xc0), char(0x82), char(0x83), 0};
     static constexpr uint8_t test_extra[] = {0x1, 0x2, 0x3};
     sp<ConfirmationTestCallback> conf_cb = new ConfirmationTestCallback;
     hidl_string prompt_text(test_prompt);
     hidl_vec<uint8_t> extra(test_extra, test_extra + 3);
     ASSERT_HAL_CALL(ResponseCode::UIErrorMalformedUTF8Encoding,
-                    confirmator().promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
+                    confirmator_->promptUserConfirmation(conf_cb, prompt_text, extra, "en", {}));
 }
 
 // Test the implementation of HMAC SHA 256 against a golden blob.
@@ -494,16 +473,13 @@
     ASSERT_EQ(expected, result.value());
 }
 
+INSTANTIATE_TEST_SUITE_P(
+        PerInstance, ConfirmationUIHidlTest,
+        testing::ValuesIn(android::hardware::getAllHalInstanceNames(IConfirmationUI::descriptor)),
+        android::hardware::PrintInstanceNameToString);
+
 }  // namespace test
 }  // namespace V1_0
 }  // namespace confirmationui
 }  // namespace hardware
 }  // namespace android
-
-int main(int argc, char** argv) {
-    ::testing::InitGoogleTest(&argc, argv);
-    std::vector<std::string> positional_args;
-    int status = RUN_ALL_TESTS();
-    ALOGI("Test result = %d", status);
-    return status;
-}
diff --git a/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp
index 8c9393b..83a8d94 100644
--- a/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp
+++ b/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp
@@ -626,21 +626,28 @@
             ErrorStatus result;
             hidl_handle syncFenceHandle;
             sp<IFencedExecutionCallback> fencedCallback;
-            Return<void> ret = preparedModel->executeFenced(
-                    request, {}, testConfig.measureTiming, {}, loopTimeoutDuration, {},
-                    [&result, &syncFenceHandle, &fencedCallback](
-                            ErrorStatus error, const hidl_handle& handle,
-                            const sp<IFencedExecutionCallback>& callback) {
-                        result = error;
-                        syncFenceHandle = handle;
-                        fencedCallback = callback;
-                    });
+            auto callbackFunc = [&result, &syncFenceHandle, &fencedCallback](
+                                        ErrorStatus error, const hidl_handle& handle,
+                                        const sp<IFencedExecutionCallback>& callback) {
+                result = error;
+                syncFenceHandle = handle;
+                fencedCallback = callback;
+            };
+            Return<void> ret =
+                    preparedModel->executeFenced(request, {}, testConfig.measureTiming, {},
+                                                 loopTimeoutDuration, {}, callbackFunc);
             ASSERT_TRUE(ret.isOk());
             if (result != ErrorStatus::NONE) {
                 ASSERT_EQ(syncFenceHandle.getNativeHandle(), nullptr);
                 ASSERT_EQ(fencedCallback, nullptr);
-                executionStatus = ErrorStatus::GENERAL_FAILURE;
+                executionStatus = result;
             } else if (syncFenceHandle.getNativeHandle()) {
+                // If a sync fence is returned, try start another run waiting for the sync fence.
+                ret = preparedModel->executeFenced(request, {syncFenceHandle},
+                                                   testConfig.measureTiming, {},
+                                                   loopTimeoutDuration, {}, callbackFunc);
+                ASSERT_TRUE(ret.isOk());
+                ASSERT_EQ(result, ErrorStatus::NONE);
                 waitForSyncFence(syncFenceHandle.getNativeHandle()->data[0]);
             }
             if (result == ErrorStatus::NONE) {
@@ -656,9 +663,7 @@
         }
     }
 
-    // The driver is allowed to reject executeFenced, and if they do, we should skip.
-    if ((testConfig.outputType != OutputType::FULLY_SPECIFIED ||
-         testConfig.executor == Executor::FENCED) &&
+    if (testConfig.outputType != OutputType::FULLY_SPECIFIED &&
         executionStatus == ErrorStatus::GENERAL_FAILURE) {
         if (skipped != nullptr) {
             *skipped = true;
@@ -691,12 +696,22 @@
                         outputShapes.size() == testModel.main.outputIndexes.size());
             break;
         case OutputType::UNSPECIFIED:
+            if (testConfig.executor == Executor::FENCED) {
+                // For Executor::FENCED, the output shape must be fully specified.
+                ASSERT_EQ(ErrorStatus::INVALID_ARGUMENT, executionStatus);
+                return;
+            }
             // If the model output operands are not fully specified, outputShapes must have
             // the same number of elements as the number of outputs.
             ASSERT_EQ(ErrorStatus::NONE, executionStatus);
             ASSERT_EQ(outputShapes.size(), testModel.main.outputIndexes.size());
             break;
         case OutputType::INSUFFICIENT:
+            if (testConfig.executor == Executor::FENCED) {
+                // For Executor::FENCED, the output shape must be fully specified.
+                ASSERT_EQ(ErrorStatus::INVALID_ARGUMENT, executionStatus);
+                return;
+            }
             ASSERT_EQ(ErrorStatus::OUTPUT_INSUFFICIENT_SIZE, executionStatus);
             ASSERT_EQ(outputShapes.size(), testModel.main.outputIndexes.size());
             ASSERT_FALSE(outputShapes[0].isSufficient);
@@ -739,12 +754,12 @@
         case TestKind::DYNAMIC_SHAPE: {
             outputTypesList = {OutputType::UNSPECIFIED, OutputType::INSUFFICIENT};
             measureTimingList = {MeasureTiming::NO, MeasureTiming::YES};
-            executorList = {Executor::ASYNC, Executor::SYNC, Executor::BURST};
+            executorList = {Executor::ASYNC, Executor::SYNC, Executor::BURST, Executor::FENCED};
         } break;
         case TestKind::MEMORY_DOMAIN: {
             outputTypesList = {OutputType::FULLY_SPECIFIED};
             measureTimingList = {MeasureTiming::NO};
-            executorList = {Executor::ASYNC, Executor::SYNC};
+            executorList = {Executor::ASYNC, Executor::SYNC, Executor::FENCED};
             memoryType = MemoryType::DEVICE;
         } break;
         case TestKind::FENCED_COMPUTE: {
@@ -921,8 +936,13 @@
 INSTANTIATE_GENERATED_TEST(MemoryDomainTest,
                            [](const TestModel& testModel) { return !testModel.expectFailure; });
 
-INSTANTIATE_GENERATED_TEST(FencedComputeTest,
-                           [](const TestModel& testModel) { return !testModel.expectFailure; });
+INSTANTIATE_GENERATED_TEST(FencedComputeTest, [](const TestModel& testModel) {
+    return !testModel.expectFailure &&
+           std::all_of(testModel.main.outputIndexes.begin(), testModel.main.outputIndexes.end(),
+                       [&testModel](uint32_t index) {
+                           return testModel.main.operands[index].data.size() > 0;
+                       });
+});
 
 INSTANTIATE_GENERATED_TEST(QuantizationCouplingTest, [](const TestModel& testModel) {
     return testModel.hasQuant8CoupledOperands() && testModel.main.operations.size() == 1;
diff --git a/sensors/1.0/vts/functional/SensorsHidlEnvironmentV1_0.cpp b/sensors/1.0/vts/functional/SensorsHidlEnvironmentV1_0.cpp
index 1e5e886..aca6961 100644
--- a/sensors/1.0/vts/functional/SensorsHidlEnvironmentV1_0.cpp
+++ b/sensors/1.0/vts/functional/SensorsHidlEnvironmentV1_0.cpp
@@ -25,6 +25,13 @@
 using ::android::hardware::sensors::V1_0::Result;
 using ::android::hardware::sensors::V1_0::SensorInfo;
 
+void SensorsHidlEnvironmentV1_0::HidlTearDown() {
+    mStopThread = true;
+    if (mPollThread.joinable()) {
+        mPollThread.detach();
+    }
+}
+
 bool SensorsHidlEnvironmentV1_0::resetHal() {
     // wait upto 100ms * 10 = 1s for hidl service.
     constexpr auto RETRY_DELAY = std::chrono::milliseconds(100);
@@ -103,18 +110,23 @@
     ALOGD("polling thread start");
 
     while (!stop) {
-        env->sensors->poll(
-            64, [&](auto result, const auto& events, const auto& dynamicSensorsAdded) {
-                if (result != Result::OK ||
-                    (events.size() == 0 && dynamicSensorsAdded.size() == 0) || stop) {
-                    stop = true;
-                    return;
-                }
+        if (!env->sensors
+                     ->poll(64,
+                            [&](auto result, const auto& events, const auto& dynamicSensorsAdded) {
+                                if (result != Result::OK ||
+                                    (events.size() == 0 && dynamicSensorsAdded.size() == 0) ||
+                                    stop) {
+                                    stop = true;
+                                    return;
+                                }
 
-                for (const auto& e : events) {
-                    env->addEvent(e);
-                }
-            });
+                                for (const auto& e : events) {
+                                    env->addEvent(e);
+                                }
+                            })
+                     .isOk()) {
+            break;
+        }
     }
     ALOGD("polling thread end");
 }
\ No newline at end of file
diff --git a/sensors/1.0/vts/functional/SensorsHidlEnvironmentV1_0.h b/sensors/1.0/vts/functional/SensorsHidlEnvironmentV1_0.h
index 485ed1e..168777d 100644
--- a/sensors/1.0/vts/functional/SensorsHidlEnvironmentV1_0.h
+++ b/sensors/1.0/vts/functional/SensorsHidlEnvironmentV1_0.h
@@ -32,6 +32,8 @@
 class SensorsHidlEnvironmentV1_0
     : public SensorsHidlEnvironmentBase<::android::hardware::sensors::V1_0::Event> {
   public:
+    void HidlTearDown() override;
+
     using Event = ::android::hardware::sensors::V1_0::Event;
     SensorsHidlEnvironmentV1_0(const std::string& service_name)
         : SensorsHidlEnvironmentBase(service_name) {}
diff --git a/sensors/2.0/multihal/Android.bp b/sensors/2.0/multihal/Android.bp
index 24c475c..b7fa15a 100644
--- a/sensors/2.0/multihal/Android.bp
+++ b/sensors/2.0/multihal/Android.bp
@@ -92,3 +92,18 @@
         "android.hardware.sensors@2.0-ScopedWakelock",
     ],
 }
+
+cc_test_library {
+    name: "android.hardware.sensors@2.0-ScopedWakelock.testlib",
+    defaults: [
+        "hidl_defaults",
+        "android.hardware.sensors@2.0-multihal-defaults",
+    ],
+    srcs: [
+        "ScopedWakelock.cpp",
+    ],
+    vendor_available: true,
+    export_header_lib_headers: [
+        "android.hardware.sensors@2.0-multihal.header",
+    ],
+}
diff --git a/sensors/2.0/multihal/tests/Android.bp b/sensors/2.0/multihal/tests/Android.bp
index a9feaf7..472f3f3 100644
--- a/sensors/2.0/multihal/tests/Android.bp
+++ b/sensors/2.0/multihal/tests/Android.bp
@@ -80,11 +80,11 @@
     static_libs: [
         "android.hardware.sensors@2.0-HalProxy",
         "android.hardware.sensors@2.0-fakesubhal-unittest",
+        "android.hardware.sensors@2.0-ScopedWakelock.testlib",
     ],
     shared_libs: [
         "android.hardware.sensors@1.0",
         "android.hardware.sensors@2.0",
-        "android.hardware.sensors@2.0-ScopedWakelock",
         "libbase",
         "libcutils",
         "libfmq",
diff --git a/sensors/2.0/multihal/tests/HalProxy_test.cpp b/sensors/2.0/multihal/tests/HalProxy_test.cpp
index 1fd35d1..4633a75 100644
--- a/sensors/2.0/multihal/tests/HalProxy_test.cpp
+++ b/sensors/2.0/multihal/tests/HalProxy_test.cpp
@@ -724,6 +724,45 @@
     EXPECT_EQ(eventOut.sensorHandle, (subhal2Index << 24) | sensorHandleToPost);
 }
 
+TEST(HalProxyTest, FillAndDrainPendingQueueTest) {
+    constexpr size_t kQueueSize = 5;
+    // TODO: Make this constant linked to same limit in HalProxy.h
+    constexpr size_t kMaxPendingQueueSize = 100000;
+    AllSensorsSubHal subhal;
+    std::vector<ISensorsSubHal*> subHals{&subhal};
+
+    std::unique_ptr<EventMessageQueue> eventQueue = makeEventFMQ(kQueueSize);
+    std::unique_ptr<WakeupMessageQueue> wakeLockQueue = makeWakelockFMQ(kQueueSize);
+    ::android::sp<ISensorsCallback> callback = new SensorsCallback();
+    EventFlag* eventQueueFlag;
+    EventFlag::createEventFlag(eventQueue->getEventFlagWord(), &eventQueueFlag);
+    HalProxy proxy(subHals);
+    proxy.initialize(*eventQueue->getDesc(), *wakeLockQueue->getDesc(), callback);
+
+    // Fill pending queue
+    std::vector<Event> events = makeMultipleAccelerometerEvents(kQueueSize);
+    subhal.postEvents(events, false);
+    events = makeMultipleAccelerometerEvents(kMaxPendingQueueSize);
+    subhal.postEvents(events, false);
+
+    // Drain pending queue
+    for (int i = 0; i < kMaxPendingQueueSize + kQueueSize; i += kQueueSize) {
+        ASSERT_TRUE(readEventsOutOfQueue(kQueueSize, eventQueue, eventQueueFlag));
+    }
+
+    // Put one event on pending queue
+    events = makeMultipleAccelerometerEvents(kQueueSize);
+    subhal.postEvents(events, false);
+    events = {makeAccelerometerEvent()};
+    subhal.postEvents(events, false);
+
+    // Read out to make room for one event on pending queue to write to FMQ
+    ASSERT_TRUE(readEventsOutOfQueue(kQueueSize, eventQueue, eventQueueFlag));
+
+    // Should be able to read that last event off queue
+    EXPECT_TRUE(readEventsOutOfQueue(1, eventQueue, eventQueueFlag));
+}
+
 // Helper implementations follow
 void testSensorsListFromProxyAndSubHal(const std::vector<SensorInfo>& proxySensorsList,
                                        const std::vector<SensorInfo>& subHalSensorsList) {
diff --git a/sensors/common/vts/utils/include/sensors-vts-utils/SensorsHidlEnvironmentBase.h b/sensors/common/vts/utils/include/sensors-vts-utils/SensorsHidlEnvironmentBase.h
index 781427d..19dfbe5 100644
--- a/sensors/common/vts/utils/include/sensors-vts-utils/SensorsHidlEnvironmentBase.h
+++ b/sensors/common/vts/utils/include/sensors-vts-utils/SensorsHidlEnvironmentBase.h
@@ -46,12 +46,7 @@
         std::this_thread::sleep_for(std::chrono::seconds(3));
     }
 
-    virtual void HidlTearDown() {
-        mStopThread = true;
-        if (mPollThread.joinable()) {
-            mPollThread.join();
-        }
-    }
+    virtual void HidlTearDown() = 0;
 
     // Get and clear all events collected so far (like "cat" shell command).
     // If output is nullptr, it clears all collected events.
diff --git a/vibrator/aidl/android/hardware/vibrator/IVibrator.aidl b/vibrator/aidl/android/hardware/vibrator/IVibrator.aidl
index 06a8bf5..6489c1d 100644
--- a/vibrator/aidl/android/hardware/vibrator/IVibrator.aidl
+++ b/vibrator/aidl/android/hardware/vibrator/IVibrator.aidl
@@ -202,6 +202,12 @@
      * once enabled and assigned an effect to play. This may not be supported
      * and this support is reflected in getCapabilities (CAP_ALWAYS_ON_CONTROL).
      *
+     * The always-on source ID is conveyed directly to clients through
+     * device/board configuration files ensuring that no ID is assigned to
+     * multiple clients. No client should use this API unless explicitly
+     * assigned an always-on source ID. Clients must develop their own way to
+     * get IDs from vendor in a stable way.
+     *
      * @param id The device-specific always-on source ID to enable.
      * @param effect The type of haptic event to trigger.
      * @param strength The intensity of haptic event to trigger.
@@ -212,6 +218,12 @@
      * Disable an always-on haptic source. This may not be supported and this
      * support is reflected in getCapabilities (CAP_ALWAYS_ON_CONTROL).
      *
+     * The always-on source ID is conveyed directly to clients through
+     * device/board configuration files ensuring that no ID is assigned to
+     * multiple clients. No client should use this API unless explicitly
+     * assigned an always-on source ID. Clients must develop their own way to
+     * get IDs from vendor in a stable way.
+     *
      * @param id The device-specific always-on source ID to disable.
      */
     void alwaysOnDisable(in int id);