Merge "Skip VTS tests based on HAL interface version"
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl
index eaa4bb1..3ba44a0 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl
@@ -35,7 +35,7 @@
 @VintfStability
 union Parameter {
   android.hardware.audio.effect.Parameter.Common common;
-  android.media.audio.common.AudioDeviceDescription deviceDescription;
+  android.media.audio.common.AudioDeviceDescription[] deviceDescription;
   android.media.audio.common.AudioMode mode;
   android.media.audio.common.AudioSource source;
   android.hardware.audio.effect.Parameter.VolumeStereo volumeStereo;
diff --git a/audio/aidl/android/hardware/audio/effect/Parameter.aidl b/audio/aidl/android/hardware/audio/effect/Parameter.aidl
index 1c001d2..473dfb5 100644
--- a/audio/aidl/android/hardware/audio/effect/Parameter.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Parameter.aidl
@@ -120,10 +120,11 @@
     Common common;
 
     /**
-     * Used by audio framework to set the device type to effect engine.
-     * Effect must implement setParameter(device) if Flags.deviceIndication set to true.
+     * Used by audio framework to set the device type(s) to effect engine.
+     * Effect engine must apply all AudioDeviceDescription in the list.
+     * Effect must implement setParameter(deviceDescription) if Flags.deviceIndication set to true.
      */
-    AudioDeviceDescription deviceDescription;
+    AudioDeviceDescription[] deviceDescription;
     /**
      * Used by audio framework to set the audio mode to effect engine.
      * Effect must implement setParameter(mode) if Flags.audioModeIndication set to true.
diff --git a/audio/aidl/default/Android.bp b/audio/aidl/default/Android.bp
index 1e6785f..95043f7 100644
--- a/audio/aidl/default/Android.bp
+++ b/audio/aidl/default/Android.bp
@@ -69,6 +69,7 @@
         "Module.cpp",
         "SoundDose.cpp",
         "Stream.cpp",
+        "StreamStub.cpp",
         "Telephony.cpp",
     ],
     generated_sources: [
@@ -163,6 +164,7 @@
         "libloudnessenhanceraidl",
         "libnssw",
         "libpresetreverbsw",
+        "libreverbaidl",
         "libtinyxml2",
         "libvirtualizersw",
         "libvisualizeraidl",
diff --git a/audio/aidl/default/EffectFactory.cpp b/audio/aidl/default/EffectFactory.cpp
index 3b40ae0..5cd87fd 100644
--- a/audio/aidl/default/EffectFactory.cpp
+++ b/audio/aidl/default/EffectFactory.cpp
@@ -165,7 +165,7 @@
     return status;
 }
 
-void Factory::openEffectLibrary(const AudioUuid& impl, const std::string& libName) {
+bool Factory::openEffectLibrary(const AudioUuid& impl, const std::string& libName) {
     std::function<void(void*)> dlClose = [](void* handle) -> void {
         if (handle && dlclose(handle)) {
             LOG(ERROR) << "dlclose failed " << dlerror();
@@ -176,7 +176,7 @@
             std::unique_ptr<void, decltype(dlClose)>{dlopen(libName.c_str(), RTLD_LAZY), dlClose};
     if (!libHandle) {
         LOG(ERROR) << __func__ << ": dlopen failed, err: " << dlerror();
-        return;
+        return false;
     }
 
     LOG(INFO) << __func__ << " dlopen lib:" << libName << "\nimpl:" << impl.toString()
@@ -186,6 +186,7 @@
             {impl,
              std::make_tuple(std::move(libHandle),
                              std::unique_ptr<struct effect_dl_interface_s>(interface), libName)});
+    return true;
 }
 
 void Factory::createIdentityWithConfig(const EffectConfig::LibraryUuid& configLib,
@@ -201,8 +202,9 @@
         LOG(DEBUG) << __func__ << ": typeUuid " << id.type.toString() << "\nimplUuid "
                    << id.uuid.toString() << " proxyUuid "
                    << (proxyUuid.has_value() ? proxyUuid->toString() : "null");
-        openEffectLibrary(id.uuid, path->second);
-        mIdentitySet.insert(std::move(id));
+        if (openEffectLibrary(id.uuid, path->second)) {
+            mIdentitySet.insert(std::move(id));
+        }
     } else {
         LOG(ERROR) << __func__ << ": library " << libName << " not exist!";
         return;
diff --git a/audio/aidl/default/Module.cpp b/audio/aidl/default/Module.cpp
index 13b04cd..acad70f 100644
--- a/audio/aidl/default/Module.cpp
+++ b/audio/aidl/default/Module.cpp
@@ -28,6 +28,7 @@
 #include "core-impl/Bluetooth.h"
 #include "core-impl/Module.h"
 #include "core-impl/SoundDose.h"
+#include "core-impl/StreamStub.h"
 #include "core-impl/Telephony.h"
 #include "core-impl/utils.h"
 
@@ -102,9 +103,10 @@
     erase_all_values(mPatches, std::set<int32_t>{patchId});
 }
 
-ndk::ScopedAStatus Module::createStreamContext(int32_t in_portConfigId, int64_t in_bufferSizeFrames,
-                                               std::shared_ptr<IStreamCallback> asyncCallback,
-                                               StreamContext* out_context) {
+ndk::ScopedAStatus Module::createStreamContext(
+        int32_t in_portConfigId, int64_t in_bufferSizeFrames,
+        std::shared_ptr<IStreamCallback> asyncCallback,
+        std::shared_ptr<IStreamOutEventCallback> outEventCallback, StreamContext* out_context) {
     if (in_bufferSizeFrames <= 0) {
         LOG(ERROR) << __func__ << ": non-positive buffer size " << in_bufferSizeFrames;
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
@@ -147,7 +149,7 @@
                 std::make_unique<StreamContext::ReplyMQ>(1, true /*configureEventFlagWord*/),
                 portConfigIt->format.value(), portConfigIt->channelMask.value(),
                 std::make_unique<StreamContext::DataMQ>(frameSize * in_bufferSizeFrames),
-                asyncCallback, params);
+                asyncCallback, outEventCallback, params);
         if (temp.isValid()) {
             *out_context = std::move(temp);
         } else {
@@ -545,14 +547,15 @@
     }
     StreamContext context;
     if (auto status = createStreamContext(in_args.portConfigId, in_args.bufferSizeFrames, nullptr,
-                                          &context);
+                                          nullptr, &context);
         !status.isOk()) {
         return status;
     }
     context.fillDescriptor(&_aidl_return->desc);
     std::shared_ptr<StreamIn> stream;
-    if (auto status = StreamIn::createInstance(in_args.sinkMetadata, std::move(context),
-                                               mConfig->microphones, &stream);
+    // TODO: Add a mapping from module instance names to a corresponding 'createInstance'.
+    if (auto status = StreamInStub::createInstance(in_args.sinkMetadata, std::move(context),
+                                                   mConfig->microphones, &stream);
         !status.isOk()) {
         return status;
     }
@@ -598,14 +601,16 @@
     }
     StreamContext context;
     if (auto status = createStreamContext(in_args.portConfigId, in_args.bufferSizeFrames,
-                                          isNonBlocking ? in_args.callback : nullptr, &context);
+                                          isNonBlocking ? in_args.callback : nullptr,
+                                          in_args.eventCallback, &context);
         !status.isOk()) {
         return status;
     }
     context.fillDescriptor(&_aidl_return->desc);
     std::shared_ptr<StreamOut> stream;
-    if (auto status = StreamOut::createInstance(in_args.sourceMetadata, std::move(context),
-                                                in_args.offloadInfo, &stream);
+    // TODO: Add a mapping from module instance names to a corresponding 'createInstance'.
+    if (auto status = StreamOutStub::createInstance(in_args.sourceMetadata, std::move(context),
+                                                    in_args.offloadInfo, &stream);
         !status.isOk()) {
         return status;
     }
diff --git a/audio/aidl/default/Stream.cpp b/audio/aidl/default/Stream.cpp
index 0520cba..25814e4 100644
--- a/audio/aidl/default/Stream.cpp
+++ b/audio/aidl/default/Stream.cpp
@@ -85,16 +85,19 @@
     if (mCommandMQ == nullptr) return "Command MQ is null";
     if (mReplyMQ == nullptr) return "Reply MQ is null";
     if (mDataMQ == nullptr) return "Data MQ is null";
-    if (sizeof(decltype(mDataBuffer)::element_type) != mDataMQ->getQuantumSize()) {
+    if (sizeof(DataBufferElement) != mDataMQ->getQuantumSize()) {
         return "Unexpected Data MQ quantum size: " + std::to_string(mDataMQ->getQuantumSize());
     }
     mDataBufferSize = mDataMQ->getQuantumCount() * mDataMQ->getQuantumSize();
-    mDataBuffer.reset(new (std::nothrow) int8_t[mDataBufferSize]);
+    mDataBuffer.reset(new (std::nothrow) DataBufferElement[mDataBufferSize]);
     if (mDataBuffer == nullptr) {
         return "Failed to allocate data buffer for element count " +
                std::to_string(mDataMQ->getQuantumCount()) +
                ", size in bytes: " + std::to_string(mDataBufferSize);
     }
+    if (::android::status_t status = mDriver->init(); status != STATUS_OK) {
+        return "Failed to initialize the driver: " + std::to_string(status);
+    }
     return "";
 }
 
@@ -191,46 +194,59 @@
             }
             break;
         case Tag::drain:
-            if (command.get<Tag::drain>() == StreamDescriptor::DrainMode::DRAIN_UNSPECIFIED) {
+            if (const auto mode = command.get<Tag::drain>();
+                mode == StreamDescriptor::DrainMode::DRAIN_UNSPECIFIED) {
                 if (mState == StreamDescriptor::State::ACTIVE) {
-                    usleep(1000);  // Simulate a blocking call into the driver.
-                    populateReply(&reply, mIsConnected);
-                    // Can switch the state to ERROR if a driver error occurs.
-                    mState = StreamDescriptor::State::DRAINING;
+                    if (::android::status_t status = mDriver->drain(mode);
+                        status == ::android::OK) {
+                        populateReply(&reply, mIsConnected);
+                        mState = StreamDescriptor::State::DRAINING;
+                    } else {
+                        LOG(ERROR) << __func__ << ": drain failed: " << status;
+                        mState = StreamDescriptor::State::ERROR;
+                    }
                 } else {
                     populateReplyWrongState(&reply, command);
                 }
             } else {
-                LOG(WARNING) << __func__
-                             << ": invalid drain mode: " << toString(command.get<Tag::drain>());
+                LOG(WARNING) << __func__ << ": invalid drain mode: " << toString(mode);
             }
             break;
         case Tag::standby:
             if (mState == StreamDescriptor::State::IDLE) {
-                usleep(1000);  // Simulate a blocking call into the driver.
-                populateReply(&reply, mIsConnected);
-                // Can switch the state to ERROR if a driver error occurs.
-                mState = StreamDescriptor::State::STANDBY;
+                if (::android::status_t status = mDriver->standby(); status == ::android::OK) {
+                    populateReply(&reply, mIsConnected);
+                    mState = StreamDescriptor::State::STANDBY;
+                } else {
+                    LOG(ERROR) << __func__ << ": standby failed: " << status;
+                    mState = StreamDescriptor::State::ERROR;
+                }
             } else {
                 populateReplyWrongState(&reply, command);
             }
             break;
         case Tag::pause:
             if (mState == StreamDescriptor::State::ACTIVE) {
-                usleep(1000);  // Simulate a blocking call into the driver.
-                populateReply(&reply, mIsConnected);
-                // Can switch the state to ERROR if a driver error occurs.
-                mState = StreamDescriptor::State::PAUSED;
+                if (::android::status_t status = mDriver->pause(); status == ::android::OK) {
+                    populateReply(&reply, mIsConnected);
+                    mState = StreamDescriptor::State::PAUSED;
+                } else {
+                    LOG(ERROR) << __func__ << ": pause failed: " << status;
+                    mState = StreamDescriptor::State::ERROR;
+                }
             } else {
                 populateReplyWrongState(&reply, command);
             }
             break;
         case Tag::flush:
             if (mState == StreamDescriptor::State::PAUSED) {
-                usleep(1000);  // Simulate a blocking call into the driver.
-                populateReply(&reply, mIsConnected);
-                // Can switch the state to ERROR if a driver error occurs.
-                mState = StreamDescriptor::State::STANDBY;
+                if (::android::status_t status = mDriver->flush(); status == ::android::OK) {
+                    populateReply(&reply, mIsConnected);
+                    mState = StreamDescriptor::State::STANDBY;
+                } else {
+                    LOG(ERROR) << __func__ << ": flush failed: " << status;
+                    mState = StreamDescriptor::State::ERROR;
+                }
             } else {
                 populateReplyWrongState(&reply, command);
             }
@@ -247,33 +263,39 @@
 }
 
 bool StreamInWorkerLogic::read(size_t clientSize, StreamDescriptor::Reply* reply) {
-    // Can switch the state to ERROR if a driver error occurs.
     const size_t byteCount = std::min({clientSize, mDataMQ->availableToWrite(), mDataBufferSize});
     const bool isConnected = mIsConnected;
+    size_t actualFrameCount = 0;
     bool fatal = false;
-    // Simulate reading of data, or provide zeroes if the stream is not connected.
-    for (size_t i = 0; i < byteCount; ++i) {
-        using buffer_type = decltype(mDataBuffer)::element_type;
-        constexpr int kBufferValueRange = std::numeric_limits<buffer_type>::max() -
-                                          std::numeric_limits<buffer_type>::min() + 1;
-        mDataBuffer[i] = isConnected ? (std::rand() % kBufferValueRange) +
-                                               std::numeric_limits<buffer_type>::min()
-                                     : 0;
+    int32_t latency = Module::kLatencyMs;
+    if (isConnected) {
+        if (::android::status_t status = mDriver->transfer(
+                    mDataBuffer.get(), byteCount / mFrameSize, &actualFrameCount, &latency);
+            status != ::android::OK) {
+            fatal = true;
+            LOG(ERROR) << __func__ << ": read failed: " << status;
+        }
+    } else {
+        usleep(3000);  // Simulate blocking transfer delay.
+        for (size_t i = 0; i < byteCount; ++i) mDataBuffer[i] = 0;
+        actualFrameCount = byteCount / mFrameSize;
     }
-    usleep(3000);  // Simulate a blocking call into the driver.
-    // Set 'fatal = true' if a driver error occurs.
-    if (bool success = byteCount > 0 ? mDataMQ->write(&mDataBuffer[0], byteCount) : true; success) {
-        LOG(DEBUG) << __func__ << ": writing of " << byteCount << " bytes into data MQ"
+    const size_t actualByteCount = actualFrameCount * mFrameSize;
+    if (bool success =
+                actualByteCount > 0 ? mDataMQ->write(&mDataBuffer[0], actualByteCount) : true;
+        success) {
+        LOG(DEBUG) << __func__ << ": writing of " << actualByteCount << " bytes into data MQ"
                    << " succeeded; connected? " << isConnected;
         // Frames are provided and counted regardless of connection status.
-        reply->fmqByteCount += byteCount;
-        mFrameCount += byteCount / mFrameSize;
+        reply->fmqByteCount += actualByteCount;
+        mFrameCount += actualFrameCount;
         populateReply(reply, isConnected);
     } else {
-        LOG(WARNING) << __func__ << ": writing of " << byteCount << " bytes of data to MQ failed";
+        LOG(WARNING) << __func__ << ": writing of " << actualByteCount
+                     << " bytes of data to MQ failed";
         reply->status = STATUS_NOT_ENOUGH_DATA;
     }
-    reply->latencyMs = Module::kLatencyMs;
+    reply->latencyMs = latency;
     return !fatal;
 }
 
@@ -395,17 +417,22 @@
             }
             break;
         case Tag::drain:
-            if (command.get<Tag::drain>() == StreamDescriptor::DrainMode::DRAIN_ALL ||
-                command.get<Tag::drain>() == StreamDescriptor::DrainMode::DRAIN_EARLY_NOTIFY) {
+            if (const auto mode = command.get<Tag::drain>();
+                mode == StreamDescriptor::DrainMode::DRAIN_ALL ||
+                mode == StreamDescriptor::DrainMode::DRAIN_EARLY_NOTIFY) {
                 if (mState == StreamDescriptor::State::ACTIVE ||
                     mState == StreamDescriptor::State::TRANSFERRING) {
-                    usleep(1000);  // Simulate a blocking call into the driver.
-                    populateReply(&reply, mIsConnected);
-                    // Can switch the state to ERROR if a driver error occurs.
-                    if (mState == StreamDescriptor::State::ACTIVE && mForceSynchronousDrain) {
-                        mState = StreamDescriptor::State::IDLE;
+                    if (::android::status_t status = mDriver->drain(mode);
+                        status == ::android::OK) {
+                        populateReply(&reply, mIsConnected);
+                        if (mState == StreamDescriptor::State::ACTIVE && mForceSynchronousDrain) {
+                            mState = StreamDescriptor::State::IDLE;
+                        } else {
+                            switchToTransientState(StreamDescriptor::State::DRAINING);
+                        }
                     } else {
-                        switchToTransientState(StreamDescriptor::State::DRAINING);
+                        LOG(ERROR) << __func__ << ": drain failed: " << status;
+                        mState = StreamDescriptor::State::ERROR;
                     }
                 } else if (mState == StreamDescriptor::State::TRANSFER_PAUSED) {
                     mState = StreamDescriptor::State::DRAIN_PAUSED;
@@ -414,46 +441,58 @@
                     populateReplyWrongState(&reply, command);
                 }
             } else {
-                LOG(WARNING) << __func__
-                             << ": invalid drain mode: " << toString(command.get<Tag::drain>());
+                LOG(WARNING) << __func__ << ": invalid drain mode: " << toString(mode);
             }
             break;
         case Tag::standby:
             if (mState == StreamDescriptor::State::IDLE) {
-                usleep(1000);  // Simulate a blocking call into the driver.
-                populateReply(&reply, mIsConnected);
-                // Can switch the state to ERROR if a driver error occurs.
-                mState = StreamDescriptor::State::STANDBY;
+                if (::android::status_t status = mDriver->standby(); status == ::android::OK) {
+                    populateReply(&reply, mIsConnected);
+                    mState = StreamDescriptor::State::STANDBY;
+                } else {
+                    LOG(ERROR) << __func__ << ": standby failed: " << status;
+                    mState = StreamDescriptor::State::ERROR;
+                }
             } else {
                 populateReplyWrongState(&reply, command);
             }
             break;
         case Tag::pause: {
-            bool commandAccepted = true;
+            std::optional<StreamDescriptor::State> nextState;
             switch (mState) {
                 case StreamDescriptor::State::ACTIVE:
-                    mState = StreamDescriptor::State::PAUSED;
+                    nextState = StreamDescriptor::State::PAUSED;
                     break;
                 case StreamDescriptor::State::DRAINING:
-                    mState = StreamDescriptor::State::DRAIN_PAUSED;
+                    nextState = StreamDescriptor::State::DRAIN_PAUSED;
                     break;
                 case StreamDescriptor::State::TRANSFERRING:
-                    mState = StreamDescriptor::State::TRANSFER_PAUSED;
+                    nextState = StreamDescriptor::State::TRANSFER_PAUSED;
                     break;
                 default:
                     populateReplyWrongState(&reply, command);
-                    commandAccepted = false;
             }
-            if (commandAccepted) {
-                populateReply(&reply, mIsConnected);
+            if (nextState.has_value()) {
+                if (::android::status_t status = mDriver->pause(); status == ::android::OK) {
+                    populateReply(&reply, mIsConnected);
+                    mState = nextState.value();
+                } else {
+                    LOG(ERROR) << __func__ << ": pause failed: " << status;
+                    mState = StreamDescriptor::State::ERROR;
+                }
             }
         } break;
         case Tag::flush:
             if (mState == StreamDescriptor::State::PAUSED ||
                 mState == StreamDescriptor::State::DRAIN_PAUSED ||
                 mState == StreamDescriptor::State::TRANSFER_PAUSED) {
-                populateReply(&reply, mIsConnected);
-                mState = StreamDescriptor::State::IDLE;
+                if (::android::status_t status = mDriver->flush(); status == ::android::OK) {
+                    populateReply(&reply, mIsConnected);
+                    mState = StreamDescriptor::State::IDLE;
+                } else {
+                    LOG(ERROR) << __func__ << ": flush failed: " << status;
+                    mState = StreamDescriptor::State::ERROR;
+                }
             } else {
                 populateReplyWrongState(&reply, command);
             }
@@ -472,6 +511,7 @@
 bool StreamOutWorkerLogic::write(size_t clientSize, StreamDescriptor::Reply* reply) {
     const size_t readByteCount = mDataMQ->availableToRead();
     bool fatal = false;
+    int32_t latency = Module::kLatencyMs;
     if (bool success = readByteCount > 0 ? mDataMQ->read(&mDataBuffer[0], readByteCount) : true) {
         const bool isConnected = mIsConnected;
         LOG(DEBUG) << __func__ << ": reading of " << readByteCount << " bytes from data MQ"
@@ -483,23 +523,36 @@
             // simulate partial write.
             byteCount -= mFrameSize;
         }
+        size_t actualFrameCount = 0;
+        if (isConnected) {
+            if (::android::status_t status = mDriver->transfer(
+                        mDataBuffer.get(), byteCount / mFrameSize, &actualFrameCount, &latency);
+                status != ::android::OK) {
+                fatal = true;
+                LOG(ERROR) << __func__ << ": write failed: " << status;
+            }
+        } else {
+            if (mAsyncCallback == nullptr) {
+                usleep(3000);  // Simulate blocking transfer delay.
+            }
+            actualFrameCount = byteCount / mFrameSize;
+        }
+        const size_t actualByteCount = actualFrameCount * mFrameSize;
         // Frames are consumed and counted regardless of the connection status.
-        reply->fmqByteCount += byteCount;
-        mFrameCount += byteCount / mFrameSize;
+        reply->fmqByteCount += actualByteCount;
+        mFrameCount += actualFrameCount;
         populateReply(reply, isConnected);
-        usleep(3000);  // Simulate a blocking call into the driver.
-        // Set 'fatal = true' if a driver error occurs.
     } else {
         LOG(WARNING) << __func__ << ": reading of " << readByteCount
                      << " bytes of data from MQ failed";
         reply->status = STATUS_NOT_ENOUGH_DATA;
     }
-    reply->latencyMs = Module::kLatencyMs;
+    reply->latencyMs = latency;
     return !fatal;
 }
 
-template <class Metadata, class StreamWorker>
-StreamCommonImpl<Metadata, StreamWorker>::~StreamCommonImpl() {
+template <class Metadata>
+StreamCommonImpl<Metadata>::~StreamCommonImpl() {
     if (!isClosed()) {
         LOG(ERROR) << __func__ << ": stream was not closed prior to destruction, resource leak";
         stopWorker();
@@ -507,8 +560,8 @@
     }
 }
 
-template <class Metadata, class StreamWorker>
-void StreamCommonImpl<Metadata, StreamWorker>::createStreamCommon(
+template <class Metadata>
+void StreamCommonImpl<Metadata>::createStreamCommon(
         const std::shared_ptr<StreamCommonInterface>& delegate) {
     if (mCommon != nullptr) {
         LOG(FATAL) << __func__ << ": attempting to create the common interface twice";
@@ -518,8 +571,8 @@
     AIBinder_setMinSchedulerPolicy(mCommonBinder.get(), SCHED_NORMAL, ANDROID_PRIORITY_AUDIO);
 }
 
-template <class Metadata, class StreamWorker>
-ndk::ScopedAStatus StreamCommonImpl<Metadata, StreamWorker>::getStreamCommon(
+template <class Metadata>
+ndk::ScopedAStatus StreamCommonImpl<Metadata>::getStreamCommon(
         std::shared_ptr<IStreamCommon>* _aidl_return) {
     if (mCommon == nullptr) {
         LOG(FATAL) << __func__ << ": the common interface was not created";
@@ -529,31 +582,30 @@
     return ndk::ScopedAStatus::ok();
 }
 
-template <class Metadata, class StreamWorker>
-ndk::ScopedAStatus StreamCommonImpl<Metadata, StreamWorker>::updateHwAvSyncId(
-        int32_t in_hwAvSyncId) {
+template <class Metadata>
+ndk::ScopedAStatus StreamCommonImpl<Metadata>::updateHwAvSyncId(int32_t in_hwAvSyncId) {
     LOG(DEBUG) << __func__ << ": id " << in_hwAvSyncId;
     return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
 }
 
-template <class Metadata, class StreamWorker>
-ndk::ScopedAStatus StreamCommonImpl<Metadata, StreamWorker>::getVendorParameters(
+template <class Metadata>
+ndk::ScopedAStatus StreamCommonImpl<Metadata>::getVendorParameters(
         const std::vector<std::string>& in_ids, std::vector<VendorParameter>* _aidl_return) {
     LOG(DEBUG) << __func__ << ": id count: " << in_ids.size();
     (void)_aidl_return;
     return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
 }
 
-template <class Metadata, class StreamWorker>
-ndk::ScopedAStatus StreamCommonImpl<Metadata, StreamWorker>::setVendorParameters(
+template <class Metadata>
+ndk::ScopedAStatus StreamCommonImpl<Metadata>::setVendorParameters(
         const std::vector<VendorParameter>& in_parameters, bool in_async) {
     LOG(DEBUG) << __func__ << ": parameters count " << in_parameters.size()
                << ", async: " << in_async;
     return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
 }
 
-template <class Metadata, class StreamWorker>
-ndk::ScopedAStatus StreamCommonImpl<Metadata, StreamWorker>::addEffect(
+template <class Metadata>
+ndk::ScopedAStatus StreamCommonImpl<Metadata>::addEffect(
         const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>& in_effect) {
     if (in_effect == nullptr) {
         LOG(DEBUG) << __func__ << ": null effect";
@@ -563,8 +615,8 @@
     return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
 }
 
-template <class Metadata, class StreamWorker>
-ndk::ScopedAStatus StreamCommonImpl<Metadata, StreamWorker>::removeEffect(
+template <class Metadata>
+ndk::ScopedAStatus StreamCommonImpl<Metadata>::removeEffect(
         const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>& in_effect) {
     if (in_effect == nullptr) {
         LOG(DEBUG) << __func__ << ": null effect";
@@ -574,16 +626,16 @@
     return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
 }
 
-template <class Metadata, class StreamWorker>
-ndk::ScopedAStatus StreamCommonImpl<Metadata, StreamWorker>::close() {
+template <class Metadata>
+ndk::ScopedAStatus StreamCommonImpl<Metadata>::close() {
     LOG(DEBUG) << __func__;
     if (!isClosed()) {
         stopWorker();
         LOG(DEBUG) << __func__ << ": joining the worker thread...";
-        mWorker.stop();
+        mWorker->stop();
         LOG(DEBUG) << __func__ << ": worker thread joined";
         mContext.reset();
-        mWorker.setClosed();
+        mWorker->setClosed();
         return ndk::ScopedAStatus::ok();
     } else {
         LOG(ERROR) << __func__ << ": stream was already closed";
@@ -591,8 +643,8 @@
     }
 }
 
-template <class Metadata, class StreamWorker>
-void StreamCommonImpl<Metadata, StreamWorker>::stopWorker() {
+template <class Metadata>
+void StreamCommonImpl<Metadata>::stopWorker() {
     if (auto commandMQ = mContext.getCommandMQ(); commandMQ != nullptr) {
         LOG(DEBUG) << __func__ << ": asking the worker to exit...";
         auto cmd = StreamDescriptor::Command::make<StreamDescriptor::Command::Tag::halReservedExit>(
@@ -608,9 +660,8 @@
     }
 }
 
-template <class Metadata, class StreamWorker>
-ndk::ScopedAStatus StreamCommonImpl<Metadata, StreamWorker>::updateMetadata(
-        const Metadata& metadata) {
+template <class Metadata>
+ndk::ScopedAStatus StreamCommonImpl<Metadata>::updateMetadata(const Metadata& metadata) {
     LOG(DEBUG) << __func__;
     if (!isClosed()) {
         mMetadata = metadata;
@@ -621,16 +672,11 @@
 }
 
 // static
-ndk::ScopedAStatus StreamIn::createInstance(const common::SinkMetadata& sinkMetadata,
-                                            StreamContext context,
-                                            const std::vector<MicrophoneInfo>& microphones,
-                                            std::shared_ptr<StreamIn>* result) {
-    auto stream = ndk::SharedRefBase::make<StreamIn>(sinkMetadata, std::move(context), microphones);
+ndk::ScopedAStatus StreamIn::initInstance(const std::shared_ptr<StreamIn>& stream) {
     if (auto status = stream->init(); !status.isOk()) {
         return status;
     }
     stream->createStreamCommon(stream);
-    *result = std::move(stream);
     return ndk::ScopedAStatus::ok();
 }
 
@@ -645,8 +691,10 @@
 }  // namespace
 
 StreamIn::StreamIn(const SinkMetadata& sinkMetadata, StreamContext&& context,
+                   const DriverInterface::CreateInstance& createDriver,
+                   const StreamWorkerInterface::CreateInstance& createWorker,
                    const std::vector<MicrophoneInfo>& microphones)
-    : StreamCommonImpl<SinkMetadata, StreamInWorker>(sinkMetadata, std::move(context)),
+    : StreamCommonImpl<SinkMetadata>(sinkMetadata, std::move(context), createDriver, createWorker),
       mMicrophones(transformMicrophones(microphones)) {
     LOG(DEBUG) << __func__;
 }
@@ -704,23 +752,20 @@
 }
 
 // static
-ndk::ScopedAStatus StreamOut::createInstance(const SourceMetadata& sourceMetadata,
-                                             StreamContext context,
-                                             const std::optional<AudioOffloadInfo>& offloadInfo,
-                                             std::shared_ptr<StreamOut>* result) {
-    auto stream =
-            ndk::SharedRefBase::make<StreamOut>(sourceMetadata, std::move(context), offloadInfo);
+ndk::ScopedAStatus StreamOut::initInstance(const std::shared_ptr<StreamOut>& stream) {
     if (auto status = stream->init(); !status.isOk()) {
         return status;
     }
     stream->createStreamCommon(stream);
-    *result = std::move(stream);
     return ndk::ScopedAStatus::ok();
 }
 
 StreamOut::StreamOut(const SourceMetadata& sourceMetadata, StreamContext&& context,
+                     const DriverInterface::CreateInstance& createDriver,
+                     const StreamWorkerInterface::CreateInstance& createWorker,
                      const std::optional<AudioOffloadInfo>& offloadInfo)
-    : StreamCommonImpl<SourceMetadata, StreamOutWorker>(sourceMetadata, std::move(context)),
+    : StreamCommonImpl<SourceMetadata>(sourceMetadata, std::move(context), createDriver,
+                                       createWorker),
       mOffloadInfo(offloadInfo) {
     LOG(DEBUG) << __func__;
 }
diff --git a/audio/aidl/default/StreamStub.cpp b/audio/aidl/default/StreamStub.cpp
new file mode 100644
index 0000000..5442179
--- /dev/null
+++ b/audio/aidl/default/StreamStub.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.
+ */
+
+#define LOG_TAG "AHAL_Stream"
+#include <android-base/logging.h>
+
+#include "core-impl/Module.h"
+#include "core-impl/StreamStub.h"
+
+using aidl::android::hardware::audio::common::SinkMetadata;
+using aidl::android::hardware::audio::common::SourceMetadata;
+using aidl::android::media::audio::common::AudioOffloadInfo;
+
+namespace aidl::android::hardware::audio::core {
+
+DriverStub::DriverStub(const StreamContext& context, bool isInput)
+    : mFrameSizeBytes(context.getFrameSize()), mIsInput(isInput) {}
+
+::android::status_t DriverStub::init() {
+    usleep(1000);
+    return ::android::OK;
+}
+
+::android::status_t DriverStub::drain(StreamDescriptor::DrainMode) {
+    usleep(1000);
+    return ::android::OK;
+}
+
+::android::status_t DriverStub::flush() {
+    usleep(1000);
+    return ::android::OK;
+}
+
+::android::status_t DriverStub::pause() {
+    usleep(1000);
+    return ::android::OK;
+}
+
+::android::status_t DriverStub::transfer(void* buffer, size_t frameCount, size_t* actualFrameCount,
+                                         int32_t* latencyMs) {
+    usleep(3000);
+    if (mIsInput) {
+        uint8_t* byteBuffer = static_cast<uint8_t*>(buffer);
+        for (size_t i = 0; i < frameCount * mFrameSizeBytes; ++i) {
+            byteBuffer[i] = std::rand() % 255;
+        }
+    }
+    *actualFrameCount = frameCount;
+    *latencyMs = Module::kLatencyMs;
+    return ::android::OK;
+}
+
+::android::status_t DriverStub::standby() {
+    usleep(1000);
+    return ::android::OK;
+}
+
+// static
+ndk::ScopedAStatus StreamInStub::createInstance(const SinkMetadata& sinkMetadata,
+                                                StreamContext&& context,
+                                                const std::vector<MicrophoneInfo>& microphones,
+                                                std::shared_ptr<StreamIn>* result) {
+    std::shared_ptr<StreamIn> stream =
+            ndk::SharedRefBase::make<StreamInStub>(sinkMetadata, std::move(context), microphones);
+    if (auto status = initInstance(stream); !status.isOk()) {
+        return status;
+    }
+    *result = std::move(stream);
+    return ndk::ScopedAStatus::ok();
+}
+
+StreamInStub::StreamInStub(const SinkMetadata& sinkMetadata, StreamContext&& context,
+                           const std::vector<MicrophoneInfo>& microphones)
+    : StreamIn(
+              sinkMetadata, std::move(context),
+              [](const StreamContext& ctx) -> DriverInterface* {
+                  return new DriverStub(ctx, true /*isInput*/);
+              },
+              [](const StreamContext& ctx, DriverInterface* driver) -> StreamWorkerInterface* {
+                  // The default worker implementation is used.
+                  return new StreamInWorker(ctx, driver);
+              },
+              microphones) {}
+
+// static
+ndk::ScopedAStatus StreamOutStub::createInstance(const SourceMetadata& sourceMetadata,
+                                                 StreamContext&& context,
+                                                 const std::optional<AudioOffloadInfo>& offloadInfo,
+                                                 std::shared_ptr<StreamOut>* result) {
+    std::shared_ptr<StreamOut> stream = ndk::SharedRefBase::make<StreamOutStub>(
+            sourceMetadata, std::move(context), offloadInfo);
+    if (auto status = initInstance(stream); !status.isOk()) {
+        return status;
+    }
+    *result = std::move(stream);
+    return ndk::ScopedAStatus::ok();
+}
+
+StreamOutStub::StreamOutStub(const SourceMetadata& sourceMetadata, StreamContext&& context,
+                             const std::optional<AudioOffloadInfo>& offloadInfo)
+    : StreamOut(
+              sourceMetadata, std::move(context),
+              [](const StreamContext& ctx) -> DriverInterface* {
+                  return new DriverStub(ctx, false /*isInput*/);
+              },
+              [](const StreamContext& ctx, DriverInterface* driver) -> StreamWorkerInterface* {
+                  // The default worker implementation is used.
+                  return new StreamOutWorker(ctx, driver);
+              },
+              offloadInfo) {}
+
+}  // namespace aidl::android::hardware::audio::core
diff --git a/audio/aidl/default/audio_effects_config.xml b/audio/aidl/default/audio_effects_config.xml
index e460f89..6714a7e 100644
--- a/audio/aidl/default/audio_effects_config.xml
+++ b/audio/aidl/default/audio_effects_config.xml
@@ -40,6 +40,7 @@
         <library name="nssw" path="libnssw.so"/>
         <library name="env_reverbsw" path="libenvreverbsw.so"/>
         <library name="preset_reverbsw" path="libpresetreverbsw.so"/>
+        <library name="reverb" path="libreverbaidl.so"/>
         <library name="virtualizersw" path="libvirtualizersw.so"/>
         <library name="visualizer" path="libvisualizeraidl.so"/>
         <library name="volumesw" path="libvolumesw.so"/>
@@ -78,6 +79,10 @@
         <effect name="env_reverb" library="env_reverbsw" uuid="fa819886-588b-11ed-9b6a-0242ac120002"/>
         <effect name="noise_suppression" library="nssw" uuid="c06c8400-8e06-11e0-9cb6-0002a5d5c51b"/>
         <effect name="preset_reverb" library="preset_reverbsw" uuid="fa8199c6-588b-11ed-9b6a-0242ac120002"/>
+        <effect name="reverb_env_aux" library="reverb" uuid="4a387fc0-8ab3-11df-8bad-0002a5d5c51b"/>
+        <effect name="reverb_env_ins" library="reverb" uuid="c7a511a0-a3bb-11df-860e-0002a5d5c51b"/>
+        <effect name="reverb_pre_aux" library="reverb" uuid="f29a1400-a3bb-11df-8ddc-0002a5d5c51b"/>
+        <effect name="reverb_pre_ins" library="reverb" uuid="172cdf00-a3bc-11df-a72f-0002a5d5c51b"/>
         <effectProxy name="virtualizer" uuid="d3467faa-acc7-4d34-acaf-0002a5d5c51b">
             <libsw library="virtualizersw" uuid="fa819d86-588b-11ed-9b6a-0242ac120002"/>
             <libsw library="bundle" uuid="1d4033c0-8557-11df-9f2d-0002a5d5c51b"/>
diff --git a/audio/aidl/default/include/core-impl/Module.h b/audio/aidl/default/include/core-impl/Module.h
index 000a704..9e4499b 100644
--- a/audio/aidl/default/include/core-impl/Module.h
+++ b/audio/aidl/default/include/core-impl/Module.h
@@ -115,6 +115,7 @@
     ndk::ScopedAStatus createStreamContext(
             int32_t in_portConfigId, int64_t in_bufferSizeFrames,
             std::shared_ptr<IStreamCallback> asyncCallback,
+            std::shared_ptr<IStreamOutEventCallback> outEventCallback,
             ::aidl::android::hardware::audio::core::StreamContext* out_context);
     std::vector<::aidl::android::media::audio::common::AudioDevice> findConnectedDevices(
             int32_t portConfigId);
diff --git a/audio/aidl/default/include/core-impl/Stream.h b/audio/aidl/default/include/core-impl/Stream.h
index 2cf5951..7cd4259 100644
--- a/audio/aidl/default/include/core-impl/Stream.h
+++ b/audio/aidl/default/include/core-impl/Stream.h
@@ -31,12 +31,14 @@
 #include <aidl/android/hardware/audio/core/BnStreamIn.h>
 #include <aidl/android/hardware/audio/core/BnStreamOut.h>
 #include <aidl/android/hardware/audio/core/IStreamCallback.h>
+#include <aidl/android/hardware/audio/core/IStreamOutEventCallback.h>
 #include <aidl/android/hardware/audio/core/MicrophoneInfo.h>
 #include <aidl/android/hardware/audio/core/StreamDescriptor.h>
 #include <aidl/android/media/audio/common/AudioDevice.h>
 #include <aidl/android/media/audio/common/AudioOffloadInfo.h>
 #include <fmq/AidlMessageQueue.h>
 #include <system/thread_defs.h>
+#include <utils/Errors.h>
 
 #include "core-impl/utils.h"
 
@@ -76,6 +78,7 @@
                   const ::aidl::android::media::audio::common::AudioFormatDescription& format,
                   const ::aidl::android::media::audio::common::AudioChannelLayout& channelLayout,
                   std::unique_ptr<DataMQ> dataMQ, std::shared_ptr<IStreamCallback> asyncCallback,
+                  std::shared_ptr<IStreamOutEventCallback> outEventCallback,
                   DebugParameters debugParameters)
         : mCommandMQ(std::move(commandMQ)),
           mInternalCommandCookie(std::rand()),
@@ -84,6 +87,7 @@
           mChannelLayout(channelLayout),
           mDataMQ(std::move(dataMQ)),
           mAsyncCallback(asyncCallback),
+          mOutEventCallback(outEventCallback),
           mDebugParameters(debugParameters) {}
     StreamContext(StreamContext&& other)
         : mCommandMQ(std::move(other.mCommandMQ)),
@@ -93,6 +97,7 @@
           mChannelLayout(other.mChannelLayout),
           mDataMQ(std::move(other.mDataMQ)),
           mAsyncCallback(std::move(other.mAsyncCallback)),
+          mOutEventCallback(std::move(other.mOutEventCallback)),
           mDebugParameters(std::move(other.mDebugParameters)) {}
     StreamContext& operator=(StreamContext&& other) {
         mCommandMQ = std::move(other.mCommandMQ);
@@ -102,6 +107,7 @@
         mChannelLayout = std::move(other.mChannelLayout);
         mDataMQ = std::move(other.mDataMQ);
         mAsyncCallback = std::move(other.mAsyncCallback);
+        mOutEventCallback = std::move(other.mOutEventCallback);
         mDebugParameters = std::move(other.mDebugParameters);
         return *this;
     }
@@ -120,6 +126,9 @@
     bool getForceSynchronousDrain() const { return mDebugParameters.forceSynchronousDrain; }
     size_t getFrameSize() const;
     int getInternalCommandCookie() const { return mInternalCommandCookie; }
+    std::shared_ptr<IStreamOutEventCallback> getOutEventCallback() const {
+        return mOutEventCallback;
+    }
     ReplyMQ* getReplyMQ() const { return mReplyMQ.get(); }
     int getTransientStateDelayMs() const { return mDebugParameters.transientStateDelayMs; }
     bool isValid() const;
@@ -133,9 +142,24 @@
     ::aidl::android::media::audio::common::AudioChannelLayout mChannelLayout;
     std::unique_ptr<DataMQ> mDataMQ;
     std::shared_ptr<IStreamCallback> mAsyncCallback;
+    std::shared_ptr<IStreamOutEventCallback> mOutEventCallback;  // Only used by output streams
     DebugParameters mDebugParameters;
 };
 
+struct DriverInterface {
+    using CreateInstance = std::function<DriverInterface*(const StreamContext&)>;
+    virtual ~DriverInterface() = default;
+    // This function is called once, on the main thread, before starting the worker thread.
+    virtual ::android::status_t init() = 0;
+    // All the functions below are called on the worker thread.
+    virtual ::android::status_t drain(StreamDescriptor::DrainMode mode) = 0;
+    virtual ::android::status_t flush() = 0;
+    virtual ::android::status_t pause() = 0;
+    virtual ::android::status_t transfer(void* buffer, size_t frameCount, size_t* actualFrameCount,
+                                         int32_t* latencyMs) = 0;
+    virtual ::android::status_t standby() = 0;
+};
+
 class StreamWorkerCommonLogic : public ::android::hardware::audio::common::StreamLogic {
   public:
     bool isClosed() const {
@@ -145,8 +169,11 @@
     void setIsConnected(bool connected) { mIsConnected = connected; }
 
   protected:
-    explicit StreamWorkerCommonLogic(const StreamContext& context)
-        : mInternalCommandCookie(context.getInternalCommandCookie()),
+    using DataBufferElement = int8_t;
+
+    StreamWorkerCommonLogic(const StreamContext& context, DriverInterface* driver)
+        : mDriver(driver),
+          mInternalCommandCookie(context.getInternalCommandCookie()),
           mFrameSize(context.getFrameSize()),
           mCommandMQ(context.getCommandMQ()),
           mReplyMQ(context.getReplyMQ()),
@@ -164,6 +191,7 @@
         mTransientStateStart = std::chrono::steady_clock::now();
     }
 
+    DriverInterface* const mDriver;
     // Atomic fields are used both by the main and worker threads.
     std::atomic<bool> mIsConnected = false;
     static_assert(std::atomic<StreamDescriptor::State>::is_always_lock_free);
@@ -171,9 +199,9 @@
     // All fields are used on the worker thread only.
     const int mInternalCommandCookie;
     const size_t mFrameSize;
-    StreamContext::CommandMQ* mCommandMQ;
-    StreamContext::ReplyMQ* mReplyMQ;
-    StreamContext::DataMQ* mDataMQ;
+    StreamContext::CommandMQ* const mCommandMQ;
+    StreamContext::ReplyMQ* const mReplyMQ;
+    StreamContext::DataMQ* const mDataMQ;
     std::shared_ptr<IStreamCallback> mAsyncCallback;
     const std::chrono::duration<int, std::milli> mTransientStateDelayMs;
     std::chrono::time_point<std::chrono::steady_clock> mTransientStateStart;
@@ -181,15 +209,46 @@
     const bool mForceSynchronousDrain;
     // We use an array and the "size" field instead of a vector to be able to detect
     // memory allocation issues.
-    std::unique_ptr<int8_t[]> mDataBuffer;
+    std::unique_ptr<DataBufferElement[]> mDataBuffer;
     size_t mDataBufferSize;
     long mFrameCount = 0;
 };
 
+// This interface is used to decouple stream implementations from a concrete StreamWorker
+// implementation.
+struct StreamWorkerInterface {
+    using CreateInstance = std::function<StreamWorkerInterface*(const StreamContext& context,
+                                                                DriverInterface* driver)>;
+    virtual ~StreamWorkerInterface() = default;
+    virtual bool isClosed() const = 0;
+    virtual void setIsConnected(bool isConnected) = 0;
+    virtual void setClosed() = 0;
+    virtual bool start() = 0;
+    virtual void stop() = 0;
+};
+
+template <class WorkerLogic>
+class StreamWorkerImpl : public StreamWorkerInterface,
+                         public ::android::hardware::audio::common::StreamWorker<WorkerLogic> {
+    using WorkerImpl = ::android::hardware::audio::common::StreamWorker<WorkerLogic>;
+
+  public:
+    StreamWorkerImpl(const StreamContext& context, DriverInterface* driver)
+        : WorkerImpl(context, driver) {}
+    bool isClosed() const override { return WorkerImpl::isClosed(); }
+    void setIsConnected(bool isConnected) override { WorkerImpl::setIsConnected(isConnected); }
+    void setClosed() override { WorkerImpl::setClosed(); }
+    bool start() override {
+        return WorkerImpl::start(WorkerImpl::kThreadName, ANDROID_PRIORITY_AUDIO);
+    }
+    void stop() override { return WorkerImpl::stop(); }
+};
+
 class StreamInWorkerLogic : public StreamWorkerCommonLogic {
   public:
     static const std::string kThreadName;
-    explicit StreamInWorkerLogic(const StreamContext& context) : StreamWorkerCommonLogic(context) {}
+    StreamInWorkerLogic(const StreamContext& context, DriverInterface* driver)
+        : StreamWorkerCommonLogic(context, driver) {}
 
   protected:
     Status cycle() override;
@@ -197,21 +256,23 @@
   private:
     bool read(size_t clientSize, StreamDescriptor::Reply* reply);
 };
-using StreamInWorker = ::android::hardware::audio::common::StreamWorker<StreamInWorkerLogic>;
+using StreamInWorker = StreamWorkerImpl<StreamInWorkerLogic>;
 
 class StreamOutWorkerLogic : public StreamWorkerCommonLogic {
   public:
     static const std::string kThreadName;
-    explicit StreamOutWorkerLogic(const StreamContext& context)
-        : StreamWorkerCommonLogic(context) {}
+    StreamOutWorkerLogic(const StreamContext& context, DriverInterface* driver)
+        : StreamWorkerCommonLogic(context, driver), mEventCallback(context.getOutEventCallback()) {}
 
   protected:
     Status cycle() override;
 
   private:
     bool write(size_t clientSize, StreamDescriptor::Reply* reply);
+
+    std::shared_ptr<IStreamOutEventCallback> mEventCallback;
 };
-using StreamOutWorker = ::android::hardware::audio::common::StreamWorker<StreamOutWorkerLogic>;
+using StreamOutWorker = StreamWorkerImpl<StreamOutWorkerLogic>;
 
 // This provides a C++ interface with methods of the IStreamCommon Binder interface,
 // but intentionally does not inherit from it. This is needed to avoid inheriting
@@ -283,7 +344,7 @@
     std::weak_ptr<StreamCommonInterface> mDelegate;
 };
 
-template <class Metadata, class StreamWorker>
+template <class Metadata>
 class StreamCommonImpl : public StreamCommonInterface {
   public:
     ndk::ScopedAStatus close() override;
@@ -301,21 +362,25 @@
 
     ndk::ScopedAStatus getStreamCommon(std::shared_ptr<IStreamCommon>* _aidl_return);
     ndk::ScopedAStatus init() {
-        return mWorker.start(StreamWorker::kThreadName, ANDROID_PRIORITY_AUDIO)
-                       ? ndk::ScopedAStatus::ok()
-                       : ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
+        return mWorker->start() ? ndk::ScopedAStatus::ok()
+                                : ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
     }
-    bool isClosed() const { return mWorker.isClosed(); }
+    bool isClosed() const { return mWorker->isClosed(); }
     void setIsConnected(
             const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices) {
-        mWorker.setIsConnected(!devices.empty());
+        mWorker->setIsConnected(!devices.empty());
         mConnectedDevices = devices;
     }
     ndk::ScopedAStatus updateMetadata(const Metadata& metadata);
 
   protected:
-    StreamCommonImpl(const Metadata& metadata, StreamContext&& context)
-        : mMetadata(metadata), mContext(std::move(context)), mWorker(mContext) {}
+    StreamCommonImpl(const Metadata& metadata, StreamContext&& context,
+                     const DriverInterface::CreateInstance& createDriver,
+                     const StreamWorkerInterface::CreateInstance& createWorker)
+        : mMetadata(metadata),
+          mContext(std::move(context)),
+          mDriver(createDriver(mContext)),
+          mWorker(createWorker(mContext, mDriver.get())) {}
     ~StreamCommonImpl();
     void stopWorker();
     void createStreamCommon(const std::shared_ptr<StreamCommonInterface>& delegate);
@@ -324,16 +389,16 @@
     ndk::SpAIBinder mCommonBinder;
     Metadata mMetadata;
     StreamContext mContext;
-    StreamWorker mWorker;
+    std::unique_ptr<DriverInterface> mDriver;
+    std::unique_ptr<StreamWorkerInterface> mWorker;
     std::vector<::aidl::android::media::audio::common::AudioDevice> mConnectedDevices;
 };
 
-class StreamIn : public StreamCommonImpl<::aidl::android::hardware::audio::common::SinkMetadata,
-                                         StreamInWorker>,
+class StreamIn : public StreamCommonImpl<::aidl::android::hardware::audio::common::SinkMetadata>,
                  public BnStreamIn {
     ndk::ScopedAStatus getStreamCommon(std::shared_ptr<IStreamCommon>* _aidl_return) override {
-        return StreamCommonImpl<::aidl::android::hardware::audio::common::SinkMetadata,
-                                StreamInWorker>::getStreamCommon(_aidl_return);
+        return StreamCommonImpl<::aidl::android::hardware::audio::common::SinkMetadata>::
+                getStreamCommon(_aidl_return);
     }
     ndk::ScopedAStatus getActiveMicrophones(
             std::vector<MicrophoneDynamicInfo>* _aidl_return) override;
@@ -343,42 +408,46 @@
     ndk::ScopedAStatus setMicrophoneFieldDimension(float in_zoom) override;
     ndk::ScopedAStatus updateMetadata(const ::aidl::android::hardware::audio::common::SinkMetadata&
                                               in_sinkMetadata) override {
-        return StreamCommonImpl<::aidl::android::hardware::audio::common::SinkMetadata,
-                                StreamInWorker>::updateMetadata(in_sinkMetadata);
+        return StreamCommonImpl<::aidl::android::hardware::audio::common::SinkMetadata>::
+                updateMetadata(in_sinkMetadata);
     }
     ndk::ScopedAStatus getHwGain(std::vector<float>* _aidl_return) override;
     ndk::ScopedAStatus setHwGain(const std::vector<float>& in_channelGains) override;
 
-  public:
-    static ndk::ScopedAStatus createInstance(
-            const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
-            StreamContext context, const std::vector<MicrophoneInfo>& microphones,
-            std::shared_ptr<StreamIn>* result);
-
-  private:
+  protected:
     friend class ndk::SharedRefBase;
+
+    static ndk::ScopedAStatus initInstance(const std::shared_ptr<StreamIn>& stream);
+
     StreamIn(const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
-             StreamContext&& context, const std::vector<MicrophoneInfo>& microphones);
+             StreamContext&& context, const DriverInterface::CreateInstance& createDriver,
+             const StreamWorkerInterface::CreateInstance& createWorker,
+             const std::vector<MicrophoneInfo>& microphones);
     void createStreamCommon(const std::shared_ptr<StreamIn>& myPtr) {
-        StreamCommonImpl<::aidl::android::hardware::audio::common::SinkMetadata,
-                         StreamInWorker>::createStreamCommon(myPtr);
+        StreamCommonImpl<
+                ::aidl::android::hardware::audio::common::SinkMetadata>::createStreamCommon(myPtr);
     }
 
     const std::map<::aidl::android::media::audio::common::AudioDevice, std::string> mMicrophones;
+
+  public:
+    using CreateInstance = std::function<ndk::ScopedAStatus(
+            const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
+            StreamContext&& context, const std::vector<MicrophoneInfo>& microphones,
+            std::shared_ptr<StreamIn>* result)>;
 };
 
-class StreamOut : public StreamCommonImpl<::aidl::android::hardware::audio::common::SourceMetadata,
-                                          StreamOutWorker>,
+class StreamOut : public StreamCommonImpl<::aidl::android::hardware::audio::common::SourceMetadata>,
                   public BnStreamOut {
     ndk::ScopedAStatus getStreamCommon(std::shared_ptr<IStreamCommon>* _aidl_return) override {
-        return StreamCommonImpl<::aidl::android::hardware::audio::common::SourceMetadata,
-                                StreamOutWorker>::getStreamCommon(_aidl_return);
+        return StreamCommonImpl<::aidl::android::hardware::audio::common::SourceMetadata>::
+                getStreamCommon(_aidl_return);
     }
     ndk::ScopedAStatus updateMetadata(
             const ::aidl::android::hardware::audio::common::SourceMetadata& in_sourceMetadata)
             override {
-        return StreamCommonImpl<::aidl::android::hardware::audio::common::SourceMetadata,
-                                StreamOutWorker>::updateMetadata(in_sourceMetadata);
+        return StreamCommonImpl<::aidl::android::hardware::audio::common::SourceMetadata>::
+                updateMetadata(in_sourceMetadata);
     }
     ndk::ScopedAStatus getHwVolume(std::vector<float>* _aidl_return) override;
     ndk::ScopedAStatus setHwVolume(const std::vector<float>& in_channelVolumes) override;
@@ -400,26 +469,31 @@
             override;
     ndk::ScopedAStatus selectPresentation(int32_t in_presentationId, int32_t in_programId) override;
 
-  public:
-    static ndk::ScopedAStatus createInstance(
-            const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
-            StreamContext context,
-            const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
-                    offloadInfo,
-            std::shared_ptr<StreamOut>* result);
-
-  private:
-    friend class ndk::SharedRefBase;
-    StreamOut(const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
-              StreamContext&& context,
-              const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
-                      offloadInfo);
     void createStreamCommon(const std::shared_ptr<StreamOut>& myPtr) {
-        StreamCommonImpl<::aidl::android::hardware::audio::common::SourceMetadata,
-                         StreamOutWorker>::createStreamCommon(myPtr);
+        StreamCommonImpl<::aidl::android::hardware::audio::common::SourceMetadata>::
+                createStreamCommon(myPtr);
     }
 
+  protected:
+    friend class ndk::SharedRefBase;
+
+    static ndk::ScopedAStatus initInstance(const std::shared_ptr<StreamOut>& stream);
+
+    StreamOut(const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
+              StreamContext&& context, const DriverInterface::CreateInstance& createDriver,
+              const StreamWorkerInterface::CreateInstance& createWorker,
+              const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
+                      offloadInfo);
+
     std::optional<::aidl::android::media::audio::common::AudioOffloadInfo> mOffloadInfo;
+
+  public:
+    using CreateInstance = std::function<ndk::ScopedAStatus(
+            const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
+            StreamContext&& context,
+            const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
+                    offloadInfo,
+            std::shared_ptr<StreamOut>* result)>;
 };
 
 class StreamWrapper {
diff --git a/audio/aidl/default/include/core-impl/StreamStub.h b/audio/aidl/default/include/core-impl/StreamStub.h
new file mode 100644
index 0000000..98a062a
--- /dev/null
+++ b/audio/aidl/default/include/core-impl/StreamStub.h
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include "core-impl/Stream.h"
+
+namespace aidl::android::hardware::audio::core {
+
+class DriverStub : public DriverInterface {
+  public:
+    DriverStub(const StreamContext& context, bool isInput);
+    ::android::status_t init() override;
+    ::android::status_t drain(StreamDescriptor::DrainMode) override;
+    ::android::status_t flush() override;
+    ::android::status_t pause() override;
+    ::android::status_t transfer(void* buffer, size_t frameCount, size_t* actualFrameCount,
+                                 int32_t* latencyMs) override;
+    ::android::status_t standby() override;
+
+  private:
+    const size_t mFrameSizeBytes;
+    const bool mIsInput;
+};
+
+class StreamInStub final : public StreamIn {
+  public:
+    static ndk::ScopedAStatus createInstance(
+            const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
+            StreamContext&& context, const std::vector<MicrophoneInfo>& microphones,
+            std::shared_ptr<StreamIn>* result);
+
+  private:
+    friend class ndk::SharedRefBase;
+    StreamInStub(const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
+                 StreamContext&& context, const std::vector<MicrophoneInfo>& microphones);
+};
+
+class StreamOutStub final : public StreamOut {
+  public:
+    static ndk::ScopedAStatus createInstance(
+            const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
+            StreamContext&& context,
+            const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
+                    offloadInfo,
+            std::shared_ptr<StreamOut>* result);
+
+  private:
+    friend class ndk::SharedRefBase;
+    StreamOutStub(const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
+                  StreamContext&& context,
+                  const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
+                          offloadInfo);
+};
+
+}  // namespace aidl::android::hardware::audio::core
diff --git a/audio/aidl/default/include/effect-impl/EffectContext.h b/audio/aidl/default/include/effect-impl/EffectContext.h
index a3e7ff2..7bbf19e 100644
--- a/audio/aidl/default/include/effect-impl/EffectContext.h
+++ b/audio/aidl/default/include/effect-impl/EffectContext.h
@@ -91,11 +91,13 @@
     int getSessionId() { return mSessionId; }
 
     virtual RetCode setOutputDevice(
-            const aidl::android::media::audio::common::AudioDeviceDescription& device) {
+            const std::vector<aidl::android::media::audio::common::AudioDeviceDescription>&
+                    device) {
         mOutputDevice = device;
         return RetCode::SUCCESS;
     }
-    virtual aidl::android::media::audio::common::AudioDeviceDescription getOutputDevice() {
+    virtual std::vector<aidl::android::media::audio::common::AudioDeviceDescription>
+    getOutputDevice() {
         return mOutputDevice;
     }
 
@@ -133,7 +135,7 @@
     size_t mInputFrameSize;
     size_t mOutputFrameSize;
     Parameter::Common mCommon;
-    aidl::android::media::audio::common::AudioDeviceDescription mOutputDevice;
+    std::vector<aidl::android::media::audio::common::AudioDeviceDescription> mOutputDevice;
     aidl::android::media::audio::common::AudioMode mMode;
     aidl::android::media::audio::common::AudioSource mSource;
     Parameter::VolumeStereo mVolumeStereo;
diff --git a/audio/aidl/default/include/effect-impl/EffectUUID.h b/audio/aidl/default/include/effect-impl/EffectUUID.h
index 1a60829..7703091 100644
--- a/audio/aidl/default/include/effect-impl/EffectUUID.h
+++ b/audio/aidl/default/include/effect-impl/EffectUUID.h
@@ -189,6 +189,18 @@
                                                0x11ed,
                                                0x9b6a,
                                                {0x02, 0x42, 0xac, 0x12, 0x00, 0x02}};
+// 4a387fc0-8ab3-11df-8bad-0002a5d5c51b
+static const AudioUuid kAuxEnvReverbImplUUID = {static_cast<int32_t>(0x4a387fc0),
+                                                0x8ab3,
+                                                0x11df,
+                                                0x8bad,
+                                                {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+// c7a511a0-a3bb-11df-860e-0002a5d5c51b
+static const AudioUuid kInsertEnvReverbImplUUID = {static_cast<int32_t>(0xc7a511a0),
+                                                   0xa3bb,
+                                                   0x11df,
+                                                   0x860e,
+                                                   {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
 // 58b4b260-8e06-11e0-aa8e-0002a5d5c51b
 static const AudioUuid kNoiseSuppressionTypeUUID = {static_cast<int32_t>(0x58b4b260),
                                                     0x8e06,
@@ -213,6 +225,18 @@
                                                   0x11ed,
                                                   0x9b6a,
                                                   {0x02, 0x42, 0xac, 0x12, 0x00, 0x02}};
+// f29a1400-a3bb-11df-8ddc-0002a5d5c51b
+static const AudioUuid kAuxPresetReverbImplUUID = {static_cast<int32_t>(0xf29a1400),
+                                                   0xa3bb,
+                                                   0x11df,
+                                                   0x8ddc,
+                                                   {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+// 172cdf00-a3bc-11df-a72f-0002a5d5c51b
+static const AudioUuid kInsertPresetReverbImplUUID = {static_cast<int32_t>(0x172cdf00),
+                                                      0xa3bc,
+                                                      0x11df,
+                                                      0xa72f,
+                                                      {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
 // 37cc2c00-dddd-11db-8577-0002a5d5c51b
 static const AudioUuid kVirtualizerTypeUUID = {static_cast<int32_t>(0x37cc2c00),
                                                0xdddd,
diff --git a/audio/aidl/default/include/effectFactory-impl/EffectFactory.h b/audio/aidl/default/include/effectFactory-impl/EffectFactory.h
index 04bd1bb..b32ec56 100644
--- a/audio/aidl/default/include/effectFactory-impl/EffectFactory.h
+++ b/audio/aidl/default/include/effectFactory-impl/EffectFactory.h
@@ -101,7 +101,7 @@
 
     ndk::ScopedAStatus destroyEffectImpl(const std::shared_ptr<IEffect>& in_handle);
     void cleanupEffectMap();
-    void openEffectLibrary(const ::aidl::android::media::audio::common::AudioUuid& impl,
+    bool openEffectLibrary(const ::aidl::android::media::audio::common::AudioUuid& impl,
                            const std::string& libName);
     void createIdentityWithConfig(
             const EffectConfig::LibraryUuid& configLib,
diff --git a/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp b/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
index 8938618..c5a0943 100644
--- a/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
@@ -47,6 +47,10 @@
 using aidl::android::hardware::audio::effect::IFactory;
 using aidl::android::hardware::audio::effect::Parameter;
 using aidl::android::hardware::audio::effect::State;
+using aidl::android::media::audio::common::AudioDeviceDescription;
+using aidl::android::media::audio::common::AudioDeviceType;
+using aidl::android::media::audio::common::AudioMode;
+using aidl::android::media::audio::common::AudioSource;
 
 enum ParamName { PARAM_INSTANCE_NAME };
 using EffectTestParam = std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>>;
@@ -73,6 +77,13 @@
     std::shared_ptr<IFactory> mFactory;
     std::shared_ptr<IEffect> mEffect;
     Descriptor mDescriptor;
+
+    void setAndGetParameter(Parameter::Id id, const Parameter& set) {
+        Parameter get;
+        EXPECT_IS_OK(mEffect->setParameter(set));
+        EXPECT_IS_OK(mEffect->getParameter(id, &get));
+        EXPECT_EQ(set, get) << set.toString() << " vs " << get.toString();
+    }
 };
 
 TEST_P(AudioEffectTest, SetupAndTearDown) {
@@ -392,14 +403,8 @@
 
     Parameter::Common common = EffectHelper::createParamCommon(
             0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */);
-    Parameter get = Parameter(), set = Parameter();
-    set.set<Parameter::common>(common);
-    EXPECT_IS_OK(mEffect->setParameter(set));
-
-    Parameter::Id id;
-    id.set<Parameter::Id::commonTag>(Parameter::common);
-    EXPECT_IS_OK(mEffect->getParameter(id, &get));
-    EXPECT_EQ(set, get) << set.toString() << " vs " << get.toString();
+    Parameter::Id id = Parameter::Id::make<Parameter::Id::commonTag>(Parameter::common);
+    ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
 
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
@@ -414,14 +419,8 @@
 
     Parameter::Common common = EffectHelper::createParamCommon(
             0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */);
-    Parameter get = Parameter(), set = Parameter();
-    set.set<Parameter::common>(common);
-    EXPECT_IS_OK(mEffect->setParameter(set));
-
-    Parameter::Id id;
-    id.set<Parameter::Id::commonTag>(Parameter::common);
-    EXPECT_IS_OK(mEffect->getParameter(id, &get));
-    EXPECT_EQ(set, get) << set.toString() << " vs " << get.toString();
+    Parameter::Id id = Parameter::Id::make<Parameter::Id::commonTag>(Parameter::common);
+    ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
 
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
@@ -439,14 +438,8 @@
 
     Parameter::Common common = EffectHelper::createParamCommon(
             0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */);
-    Parameter get = Parameter(), set = Parameter();
-    set.set<Parameter::common>(common);
-    EXPECT_IS_OK(mEffect->setParameter(set));
-
-    Parameter::Id id;
-    id.set<Parameter::Id::commonTag>(Parameter::common);
-    EXPECT_IS_OK(mEffect->getParameter(id, &get));
-    EXPECT_EQ(set, get) << set.toString() << " vs " << get.toString();
+    Parameter::Id id = Parameter::Id::make<Parameter::Id::commonTag>(Parameter::common);
+    ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
 
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
@@ -461,18 +454,11 @@
 
     Parameter::Common common = EffectHelper::createParamCommon(
             0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */);
-    Parameter get = Parameter(), set = Parameter();
-    set.set<Parameter::common>(common);
-    EXPECT_IS_OK(mEffect->setParameter(set));
+    Parameter::Id id = Parameter::Id::make<Parameter::Id::commonTag>(Parameter::common);
+    ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
 
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
     ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
-
-    Parameter::Id id;
-    id.set<Parameter::Id::commonTag>(Parameter::common);
-    EXPECT_IS_OK(mEffect->getParameter(id, &get));
-    EXPECT_EQ(set, get) << set.toString() << " vs " << get.toString();
-
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
 }
@@ -487,21 +473,102 @@
 
     Parameter::Common common = EffectHelper::createParamCommon(
             0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */);
-    Parameter get = Parameter(), set = Parameter();
-    set.set<Parameter::common>(common);
-    EXPECT_IS_OK(mEffect->setParameter(set));
+    Parameter::Id id = Parameter::Id::make<Parameter::Id::commonTag>(Parameter::common);
+    ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
 
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
     ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
 
-    Parameter::Id id;
-    id.set<Parameter::Id::commonTag>(Parameter::common);
-    EXPECT_IS_OK(mEffect->getParameter(id, &get));
-    EXPECT_EQ(set, get) << set.toString() << " vs " << get.toString();
+    ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
 
+    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
+    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
 }
+
+// Set and get AudioDeviceDescription in Parameter
+TEST_P(AudioEffectTest, SetAndGetParameterDeviceDescription) {
+    ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
+    ASSERT_NO_FATAL_FAILURE(open(mEffect));
+
+    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
+    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
+
+    std::vector<AudioDeviceDescription> deviceDescs = {
+            {.type = AudioDeviceType::IN_DEFAULT,
+             .connection = AudioDeviceDescription::CONNECTION_ANALOG},
+            {.type = AudioDeviceType::IN_DEVICE,
+             .connection = AudioDeviceDescription::CONNECTION_BT_A2DP}};
+    Parameter::Id id = Parameter::Id::make<Parameter::Id::commonTag>(Parameter::deviceDescription);
+    ASSERT_NO_FATAL_FAILURE(
+            setAndGetParameter(id, Parameter::make<Parameter::deviceDescription>(deviceDescs)));
+
+    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
+    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
+    ASSERT_NO_FATAL_FAILURE(close(mEffect));
+    ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
+}
+
+// Set and get AudioMode in Parameter
+TEST_P(AudioEffectTest, SetAndGetParameterAudioMode) {
+    ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
+    ASSERT_NO_FATAL_FAILURE(open(mEffect));
+
+    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
+    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
+
+    Parameter::Id id = Parameter::Id::make<Parameter::Id::commonTag>(Parameter::mode);
+    ASSERT_NO_FATAL_FAILURE(
+            setAndGetParameter(id, Parameter::make<Parameter::mode>(AudioMode::NORMAL)));
+    ASSERT_NO_FATAL_FAILURE(
+            setAndGetParameter(id, Parameter::make<Parameter::mode>(AudioMode::IN_COMMUNICATION)));
+
+    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
+    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
+    ASSERT_NO_FATAL_FAILURE(close(mEffect));
+    ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
+}
+
+// Set and get AudioSource in Parameter
+TEST_P(AudioEffectTest, SetAndGetParameterAudioSource) {
+    ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
+    ASSERT_NO_FATAL_FAILURE(open(mEffect));
+
+    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
+    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
+
+    Parameter::Id id = Parameter::Id::make<Parameter::Id::commonTag>(Parameter::source);
+    ASSERT_NO_FATAL_FAILURE(
+            setAndGetParameter(id, Parameter::make<Parameter::source>(AudioSource::DEFAULT)));
+    ASSERT_NO_FATAL_FAILURE(setAndGetParameter(
+            id, Parameter::make<Parameter::source>(AudioSource::VOICE_RECOGNITION)));
+
+    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
+    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
+    ASSERT_NO_FATAL_FAILURE(close(mEffect));
+    ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
+}
+
+// Set and get VolumeStereo in Parameter
+TEST_P(AudioEffectTest, SetAndGetParameterVolume) {
+    ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
+    ASSERT_NO_FATAL_FAILURE(open(mEffect));
+
+    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
+    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
+
+    Parameter::Id id = Parameter::Id::make<Parameter::Id::commonTag>(Parameter::volumeStereo);
+    Parameter::VolumeStereo volume = {.left = 10.0, .right = 10.0};
+    ASSERT_NO_FATAL_FAILURE(
+            setAndGetParameter(id, Parameter::make<Parameter::volumeStereo>(volume)));
+
+    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
+    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
+    ASSERT_NO_FATAL_FAILURE(close(mEffect));
+    ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
+}
+
 /// Data processing test
 // Send data to effects and expect it to be consumed by checking statusMQ.
 TEST_P(AudioEffectTest, ConsumeDataInProcessingState) {
diff --git a/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/AmFmRegionConfig.aidl b/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/AmFmRegionConfig.aidl
index f3aecdf..fe8489c 100644
--- a/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/AmFmRegionConfig.aidl
+++ b/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/AmFmRegionConfig.aidl
@@ -37,8 +37,8 @@
   android.hardware.broadcastradio.AmFmBandRange[] ranges;
   int fmDeemphasis;
   int fmRds;
-  const int DEEMPHASIS_D50 = 1;
-  const int DEEMPHASIS_D75 = 2;
-  const int RDS = 1;
-  const int RBDS = 2;
+  const int DEEMPHASIS_D50 = (1 << 0);
+  const int DEEMPHASIS_D75 = (1 << 1);
+  const int RDS = (1 << 0);
+  const int RBDS = (1 << 1);
 }
diff --git a/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/AnnouncementType.aidl b/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/AnnouncementType.aidl
index 237b868..1d187fe 100644
--- a/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/AnnouncementType.aidl
+++ b/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/AnnouncementType.aidl
@@ -36,11 +36,11 @@
 enum AnnouncementType {
   INVALID = 0,
   EMERGENCY = 1,
-  WARNING = 2,
-  TRAFFIC = 3,
-  WEATHER = 4,
-  NEWS = 5,
-  EVENT = 6,
-  SPORT = 7,
-  MISC = 8,
+  WARNING,
+  TRAFFIC,
+  WEATHER,
+  NEWS,
+  EVENT,
+  SPORT,
+  MISC,
 }
diff --git a/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/ConfigFlag.aidl b/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/ConfigFlag.aidl
index 6fb9a62..98af437 100644
--- a/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/ConfigFlag.aidl
+++ b/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/ConfigFlag.aidl
@@ -35,12 +35,12 @@
 @Backing(type="int") @JavaDerive(equals=true, toString=true) @VintfStability
 enum ConfigFlag {
   FORCE_MONO = 1,
-  FORCE_ANALOG = 2,
-  FORCE_DIGITAL = 3,
-  RDS_AF = 4,
-  RDS_REG = 5,
-  DAB_DAB_LINKING = 6,
-  DAB_FM_LINKING = 7,
-  DAB_DAB_SOFT_LINKING = 8,
-  DAB_FM_SOFT_LINKING = 9,
+  FORCE_ANALOG,
+  FORCE_DIGITAL,
+  RDS_AF,
+  RDS_REG,
+  DAB_DAB_LINKING,
+  DAB_FM_LINKING,
+  DAB_DAB_SOFT_LINKING,
+  DAB_FM_SOFT_LINKING,
 }
diff --git a/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/IdentifierType.aidl b/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/IdentifierType.aidl
index 4e8296a..4df272c 100644
--- a/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/IdentifierType.aidl
+++ b/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/IdentifierType.aidl
@@ -37,16 +37,16 @@
   VENDOR_START = 1000,
   VENDOR_END = 1999,
   INVALID = 0,
-  AMFM_FREQUENCY_KHZ = 1,
-  RDS_PI = 2,
-  HD_STATION_ID_EXT = 3,
-  HD_STATION_NAME = 4,
-  DAB_SID_EXT = 5,
-  DAB_ENSEMBLE = 6,
-  DAB_SCID = 7,
-  DAB_FREQUENCY_KHZ = 8,
-  DRMO_SERVICE_ID = 9,
-  DRMO_FREQUENCY_KHZ = 10,
-  SXM_SERVICE_ID = 12,
-  SXM_CHANNEL = 13,
+  AMFM_FREQUENCY_KHZ,
+  RDS_PI,
+  HD_STATION_ID_EXT,
+  HD_STATION_NAME,
+  DAB_SID_EXT,
+  DAB_ENSEMBLE,
+  DAB_SCID,
+  DAB_FREQUENCY_KHZ,
+  DRMO_SERVICE_ID,
+  DRMO_FREQUENCY_KHZ,
+  SXM_SERVICE_ID = (DRMO_FREQUENCY_KHZ + 2),
+  SXM_CHANNEL,
 }
diff --git a/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/ProgramInfo.aidl b/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/ProgramInfo.aidl
index 5e662d2..b14023a 100644
--- a/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/ProgramInfo.aidl
+++ b/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/ProgramInfo.aidl
@@ -42,10 +42,10 @@
   int signalQuality;
   android.hardware.broadcastradio.Metadata[] metadata;
   android.hardware.broadcastradio.VendorKeyValue[] vendorInfo;
-  const int FLAG_LIVE = 1;
-  const int FLAG_MUTED = 2;
-  const int FLAG_TRAFFIC_PROGRAM = 4;
-  const int FLAG_TRAFFIC_ANNOUNCEMENT = 8;
-  const int FLAG_TUNABLE = 16;
-  const int FLAG_STEREO = 32;
+  const int FLAG_LIVE = (1 << 0);
+  const int FLAG_MUTED = (1 << 1);
+  const int FLAG_TRAFFIC_PROGRAM = (1 << 2);
+  const int FLAG_TRAFFIC_ANNOUNCEMENT = (1 << 3);
+  const int FLAG_TUNABLE = (1 << 4);
+  const int FLAG_STEREO = (1 << 5);
 }
diff --git a/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/Result.aidl b/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/Result.aidl
index 3464412..8af74c7 100644
--- a/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/Result.aidl
+++ b/broadcastradio/aidl/aidl_api/android.hardware.broadcastradio/current/android/hardware/broadcastradio/Result.aidl
@@ -32,14 +32,14 @@
 // later when a module using the interface is updated, e.g., Mainline modules.
 
 package android.hardware.broadcastradio;
-@Backing(type="int") @VintfStability
+@Backing(type="int") @JavaDerive(equals=true, toString=true) @VintfStability
 enum Result {
-  OK = 0,
-  INTERNAL_ERROR = 1,
-  INVALID_ARGUMENTS = 2,
-  INVALID_STATE = 3,
-  NOT_SUPPORTED = 4,
-  TIMEOUT = 5,
-  CANCELED = 6,
-  UNKNOWN_ERROR = 7,
+  OK,
+  INTERNAL_ERROR,
+  INVALID_ARGUMENTS,
+  INVALID_STATE,
+  NOT_SUPPORTED,
+  TIMEOUT,
+  CANCELED,
+  UNKNOWN_ERROR,
 }
diff --git a/broadcastradio/aidl/android/hardware/broadcastradio/Result.aidl b/broadcastradio/aidl/android/hardware/broadcastradio/Result.aidl
index 3f7ddac..9f7263a 100644
--- a/broadcastradio/aidl/android/hardware/broadcastradio/Result.aidl
+++ b/broadcastradio/aidl/android/hardware/broadcastradio/Result.aidl
@@ -21,11 +21,12 @@
  */
 @VintfStability
 @Backing(type="int")
+@JavaDerive(equals=true, toString=true)
 enum Result {
     /**
      * Methods run without error.
      */
-    OK,
+    OK = 0,
 
     /**
      * Internal error in HAL.
diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml
index dd73060..92c2398 100644
--- a/compatibility_matrices/compatibility_matrix.current.xml
+++ b/compatibility_matrices/compatibility_matrix.current.xml
@@ -60,14 +60,6 @@
              <instance>default</instance>
          </interface>
     </hal>
-    <hal format="hidl" optional="true">
-        <name>android.hardware.authsecret</name>
-        <version>1.0</version>
-        <interface>
-            <name>IAuthSecret</name>
-            <instance>default</instance>
-        </interface>
-    </hal>
     <hal format="aidl" optional="true">
         <name>android.hardware.automotive.audiocontrol</name>
         <version>2</version>
@@ -243,14 +235,6 @@
             <instance>default</instance>
         </interface>
     </hal>
-    <hal format="hidl" optional="true">
-        <name>android.hardware.gatekeeper</name>
-        <version>1.0</version>
-        <interface>
-            <name>IGatekeeper</name>
-            <instance>default</instance>
-        </interface>
-    </hal>
     <hal format="aidl" optional="true">
         <name>android.hardware.gatekeeper</name>
         <version>1</version>
diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl
index c1f4df8..d66e1ac 100644
--- a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl
+++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl
@@ -47,5 +47,6 @@
   void onHostEndpointDisconnected(char hostEndpointId);
   long[] getPreloadedNanoappIds();
   void onNanSessionStateChanged(in boolean state);
-  const int EX_CONTEXT_HUB_UNSPECIFIED = -1;
+  void setTestMode(in boolean enable);
+  const int EX_CONTEXT_HUB_UNSPECIFIED = (-1);
 }
diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/NanoappBinary.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/NanoappBinary.aidl
index d53b28f..741a9cf 100644
--- a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/NanoappBinary.aidl
+++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/NanoappBinary.aidl
@@ -40,7 +40,7 @@
   byte targetChreApiMajorVersion;
   byte targetChreApiMinorVersion;
   byte[] customBinary;
-  const int FLAG_SIGNED = 1;
-  const int FLAG_ENCRYPTED = 2;
-  const int FLAG_TCM_CAPABLE = 4;
+  const int FLAG_SIGNED = (1 << 0);
+  const int FLAG_ENCRYPTED = (1 << 1);
+  const int FLAG_TCM_CAPABLE = (1 << 2);
 }
diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/Setting.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/Setting.aidl
index d998478..aeb720b 100644
--- a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/Setting.aidl
+++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/Setting.aidl
@@ -35,10 +35,10 @@
 @Backing(type="byte") @VintfStability
 enum Setting {
   LOCATION = 1,
-  WIFI_MAIN = 2,
-  WIFI_SCANNING = 3,
-  AIRPLANE_MODE = 4,
-  MICROPHONE = 5,
-  BT_MAIN = 6,
-  BT_SCANNING = 7,
+  WIFI_MAIN,
+  WIFI_SCANNING,
+  AIRPLANE_MODE,
+  MICROPHONE,
+  BT_MAIN,
+  BT_SCANNING,
 }
diff --git a/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl b/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl
index 7f50730..f9838bd 100644
--- a/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl
+++ b/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl
@@ -217,6 +217,22 @@
     void onNanSessionStateChanged(in boolean state);
 
     /**
+     * Puts the context hub in and out of test mode. Test mode is a clean state
+     * where tests can be executed in the same environment. If enable is true,
+     * this will enable test mode by unloading all nanoapps. If enable is false,
+     * this will disable test mode and reverse the actions of enabling test mode
+     * by loading all preloaded nanoapps. This puts CHRE in a normal state.
+     *
+     * This should only be used for a test environment, either through a
+     * @TestApi or development tools. This should not be used in a production
+     * environment.
+     *
+     * @param enable If true, put the context hub in test mode. If false, disable
+     *               test mode.
+     */
+    void setTestMode(in boolean enable);
+
+    /**
      * Error codes that are used as service specific errors with the AIDL return
      * value EX_SERVICE_SPECIFIC.
      */
diff --git a/contexthub/aidl/default/ContextHub.cpp b/contexthub/aidl/default/ContextHub.cpp
index 615ac5c..b98bfb2 100644
--- a/contexthub/aidl/default/ContextHub.cpp
+++ b/contexthub/aidl/default/ContextHub.cpp
@@ -113,6 +113,10 @@
     }
 }
 
+ScopedAStatus ContextHub::setTestMode(bool /* enable */) {
+    return ndk::ScopedAStatus::ok();
+}
+
 ScopedAStatus ContextHub::onHostEndpointConnected(const HostEndpointInfo& in_info) {
     mConnectedHostEndpoints.insert(in_info.hostEndpointId);
 
diff --git a/contexthub/aidl/default/include/contexthub-impl/ContextHub.h b/contexthub/aidl/default/include/contexthub-impl/ContextHub.h
index b3998b9..dc9aef0 100644
--- a/contexthub/aidl/default/include/contexthub-impl/ContextHub.h
+++ b/contexthub/aidl/default/include/contexthub-impl/ContextHub.h
@@ -44,6 +44,7 @@
             int32_t in_contextHubId, const std::shared_ptr<IContextHubCallback>& in_cb) override;
     ::ndk::ScopedAStatus sendMessageToHub(int32_t in_contextHubId,
                                           const ContextHubMessage& in_message) override;
+    ::ndk::ScopedAStatus setTestMode(bool enable) override;
     ::ndk::ScopedAStatus onHostEndpointConnected(const HostEndpointInfo& in_info) override;
 
     ::ndk::ScopedAStatus onHostEndpointDisconnected(char16_t in_hostEndpointId) override;
diff --git a/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp b/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp
index 4731648..f7ff73d 100644
--- a/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp
+++ b/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp
@@ -84,6 +84,26 @@
     }
 }
 
+TEST_P(ContextHubAidl, TestEnableTestMode) {
+    Status status = contextHub->setTestMode(true);
+    if (status.exceptionCode() == Status::EX_UNSUPPORTED_OPERATION ||
+        status.transactionError() == android::UNKNOWN_TRANSACTION) {
+        return;  // not supported -> old API; or not implemented
+    }
+
+    ASSERT_TRUE(status.isOk());
+}
+
+TEST_P(ContextHubAidl, TestDisableTestMode) {
+    Status status = contextHub->setTestMode(false);
+    if (status.exceptionCode() == Status::EX_UNSUPPORTED_OPERATION ||
+        status.transactionError() == android::UNKNOWN_TRANSACTION) {
+        return;  // not supported -> old API; or not implemented
+    }
+
+    ASSERT_TRUE(status.isOk());
+}
+
 class EmptyContextHubCallback : public android::hardware::contexthub::BnContextHubCallback {
   public:
     Status handleNanoappInfo(const std::vector<NanoappInfo>& /* appInfo */) override {
diff --git a/graphics/allocator/aidl/aidl_api/android.hardware.graphics.allocator/current/android/hardware/graphics/allocator/AllocationError.aidl b/graphics/allocator/aidl/aidl_api/android.hardware.graphics.allocator/current/android/hardware/graphics/allocator/AllocationError.aidl
index 6e7b739..e50d170 100644
--- a/graphics/allocator/aidl/aidl_api/android.hardware.graphics.allocator/current/android/hardware/graphics/allocator/AllocationError.aidl
+++ b/graphics/allocator/aidl/aidl_api/android.hardware.graphics.allocator/current/android/hardware/graphics/allocator/AllocationError.aidl
@@ -34,7 +34,7 @@
 package android.hardware.graphics.allocator;
 @Backing(type="int") @VintfStability
 enum AllocationError {
-  BAD_DESCRIPTOR = 0,
-  NO_RESOURCES = 1,
-  UNSUPPORTED = 2,
+  BAD_DESCRIPTOR,
+  NO_RESOURCES,
+  UNSUPPORTED,
 }
diff --git a/graphics/allocator/aidl/aidl_api/android.hardware.graphics.allocator/current/android/hardware/graphics/allocator/IAllocator.aidl b/graphics/allocator/aidl/aidl_api/android.hardware.graphics.allocator/current/android/hardware/graphics/allocator/IAllocator.aidl
index 48bef16..66e49a7 100644
--- a/graphics/allocator/aidl/aidl_api/android.hardware.graphics.allocator/current/android/hardware/graphics/allocator/IAllocator.aidl
+++ b/graphics/allocator/aidl/aidl_api/android.hardware.graphics.allocator/current/android/hardware/graphics/allocator/IAllocator.aidl
@@ -35,7 +35,7 @@
 @VintfStability
 interface IAllocator {
   /**
-   * @deprecated As of android.hardware.graphics.allocator-V2, this is deprecated & replaced with allocate2
+   * @deprecated As of android.hardware.graphics.allocator-V2 in combination with AIMAPPER_VERSION_5 this is deprecated & replaced with allocate2. If android.hardware.graphics.mapper@4 is still in use, however, this is still required to be implemented.
    */
   android.hardware.graphics.allocator.AllocationResult allocate(in byte[] descriptor, in int count);
   android.hardware.graphics.allocator.AllocationResult allocate2(in android.hardware.graphics.allocator.BufferDescriptorInfo descriptor, in int count);
diff --git a/graphics/allocator/aidl/android/hardware/graphics/allocator/IAllocator.aidl b/graphics/allocator/aidl/android/hardware/graphics/allocator/IAllocator.aidl
index 71cebd6..2277bae 100644
--- a/graphics/allocator/aidl/android/hardware/graphics/allocator/IAllocator.aidl
+++ b/graphics/allocator/aidl/android/hardware/graphics/allocator/IAllocator.aidl
@@ -32,8 +32,10 @@
      * @param count The number of buffers to allocate.
      * @return An AllocationResult containing the result of the allocation
      * @throws AllocationError on failure
-     * @deprecated As of android.hardware.graphics.allocator-V2, this is deprecated & replaced with
-     *         allocate2
+     * @deprecated As of android.hardware.graphics.allocator-V2 in combination with
+     *             AIMAPPER_VERSION_5 this is deprecated & replaced with allocate2.
+     *             If android.hardware.graphics.mapper@4 is still in use, however, this is
+     *             still required to be implemented.
      */
     AllocationResult allocate(in byte[] descriptor, in int count);
 
diff --git a/health/aidl/Android.bp b/health/aidl/Android.bp
index a4d4ace..64d83f3 100644
--- a/health/aidl/Android.bp
+++ b/health/aidl/Android.bp
@@ -46,8 +46,8 @@
 
 }
 
-cc_library {
-    name: "android.hardware.health-translate-ndk",
+cc_defaults {
+    name: "android.hardware.health-translate-ndk_defaults",
     vendor_available: true,
     recovery_available: true,
     host_supported: true,
@@ -55,7 +55,6 @@
     shared_libs: [
         "libbinder_ndk",
         "libhidlbase",
-        "android.hardware.health-V1-ndk",
         "android.hardware.health@2.0",
         "android.hardware.health@2.1",
     ],
@@ -71,6 +70,23 @@
     },
 }
 
+cc_library {
+    name: "android.hardware.health-translate-ndk",
+    defaults: ["android.hardware.health-translate-ndk_defaults"],
+    shared_libs: [
+        "android.hardware.health-V1-ndk",
+    ],
+}
+
+// TODO(b/251425963): remove when android.hardware.health is upgraded to V2.
+cc_library {
+    name: "android.hardware.health-translate-V1-ndk",
+    defaults: ["android.hardware.health-translate-ndk_defaults"],
+    shared_libs: [
+        "android.hardware.health-V1-ndk",
+    ],
+}
+
 java_library {
     name: "android.hardware.health-translate-java",
     srcs: ["android/hardware/health/Translate.java"],
diff --git a/tv/hdmi/aidl/TEST_MAPPING b/tv/hdmi/aidl/TEST_MAPPING
deleted file mode 100644
index 6bd3b57..0000000
--- a/tv/hdmi/aidl/TEST_MAPPING
+++ /dev/null
@@ -1,7 +0,0 @@
-{
-  "presubmit": [
-    {
-      "name": "VtsHalTvHdmiAidlTargetTest"
-    }
-  ]
-}
diff --git a/tv/hdmi/aidl/vts/functional/AndroidTest.xml b/tv/hdmi/aidl/vts/functional/AndroidTest.xml
deleted file mode 100644
index 0640b2d..0000000
--- a/tv/hdmi/aidl/vts/functional/AndroidTest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright 2021 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.
--->
-<configuration description="Runs VtsHalTvHdmiAidlTargetTest.">
-    <option name="test-suite-tag" value="apct" />
-    <option name="test-suite-tag" value="apct-native" />
-
-    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer">
-    </target_preparer>
-
-    <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
-        <option name="cleanup" value="true" />
-        <option name="push" value="VtsHalTvHdmiAidlTargetTest->/data/local/tmp/VtsHalTvHdmiAidlTargetTest" />
-    </target_preparer>
-
-    <test class="com.android.tradefed.testtype.GTest" >
-        <option name="native-test-device-path" value="/data/local/tmp" />
-        <option name="module-name" value="VtsHalTvHdmiAidlTargetTest" />
-        <option name="native-test-timeout" value="30m" />
-    </test>
-</configuration>
diff --git a/tv/hdmi/aidl/vts/functional/VtsHalTvHdmiAidlTargetTest.cpp b/tv/hdmi/aidl/vts/functional/VtsHalTvHdmiAidlTargetTest.cpp
deleted file mode 100644
index fd4d94f..0000000
--- a/tv/hdmi/aidl/vts/functional/VtsHalTvHdmiAidlTargetTest.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2022 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.
- */
-
-#define LOG_TAG "Hdmi_hal_test"
-
-#include <aidl/Gtest.h>
-#include <aidl/Vintf.h>
-#include <aidl/android/hardware/tv/hdmi/BnHdmi.h>
-#include <aidl/android/hardware/tv/hdmi/BnHdmiCallback.h>
-#include <android-base/logging.h>
-#include <android/binder_manager.h>
-#include <android/binder_process.h>
-#include <gtest/gtest.h>
-#include <log/log.h>
-#include <sstream>
-#include <vector>
-
-using ::aidl::android::hardware::tv::hdmi::BnHdmiCallback;
-using ::aidl::android::hardware::tv::hdmi::HdmiPortInfo;
-using ::aidl::android::hardware::tv::hdmi::HdmiPortType;
-using ::aidl::android::hardware::tv::hdmi::HpdSignal;
-using ::aidl::android::hardware::tv::hdmi::IHdmi;
-using ::aidl::android::hardware::tv::hdmi::IHdmiCallback;
-using ::ndk::SpAIBinder;
-
-#define INCORRECT_VENDOR_ID 0x00
-#define TV_PHYSICAL_ADDRESS 0x0000
-
-// The main test class for TV HDMI HAL.
-class HdmiTest : public ::testing::TestWithParam<std::string> {
-    static void serviceDied(void* /* cookie */) { ALOGE("VtsHalTvCecAidlTargetTest died"); }
-
-  public:
-    void SetUp() override {
-        hdmi = IHdmi::fromBinder(SpAIBinder(AServiceManager_waitForService(GetParam().c_str())));
-        ASSERT_NE(hdmi, nullptr);
-        ALOGI("%s: getService() for hdmi is %s", __func__, hdmi->isRemote() ? "remote" : "local");
-
-        hdmiCallback = ::ndk::SharedRefBase::make<HdmiCallback>();
-        ASSERT_NE(hdmiCallback, nullptr);
-        hdmiDeathRecipient =
-                ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(&serviceDied));
-        ASSERT_EQ(AIBinder_linkToDeath(hdmi->asBinder().get(), hdmiDeathRecipient.get(), 0),
-                  STATUS_OK);
-    }
-
-    class HdmiCallback : public BnHdmiCallback {
-      public:
-        ::ndk::ScopedAStatus onHotplugEvent(bool connected __unused, int32_t portId __unused) {
-            return ::ndk::ScopedAStatus::ok();
-        };
-    };
-
-    std::shared_ptr<IHdmi> hdmi;
-    std::shared_ptr<IHdmiCallback> hdmiCallback;
-    ::ndk::ScopedAIBinder_DeathRecipient hdmiDeathRecipient;
-};
-
-GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(HdmiTest);
-INSTANTIATE_TEST_SUITE_P(PerInstance, HdmiTest,
-                         testing::ValuesIn(android::getAidlHalInstanceNames(IHdmi::descriptor)),
-                         android::PrintInstanceNameToString);
-
-TEST_P(HdmiTest, SetCallback) {
-    ASSERT_TRUE(hdmi->setCallback(::ndk::SharedRefBase::make<HdmiCallback>()).isOk());
-}
-
-TEST_P(HdmiTest, GetPortInfo) {
-    std::vector<HdmiPortInfo> ports;
-    ASSERT_TRUE(hdmi->getPortInfo(&ports).isOk());
-
-    bool cecSupportedOnDevice = false;
-    for (size_t i = 0; i < ports.size(); ++i) {
-        EXPECT_TRUE((ports[i].type == HdmiPortType::OUTPUT) ||
-                    (ports[i].type == HdmiPortType::INPUT));
-        if (ports[i].portId == 0) {
-            ALOGW("%s: Port id should start from 1", __func__);
-        }
-        cecSupportedOnDevice = cecSupportedOnDevice | ports[i].cecSupported;
-    }
-    EXPECT_NE(cecSupportedOnDevice, false) << "At least one port should support CEC";
-}
-
-TEST_P(HdmiTest, IsConnected) {
-    std::vector<HdmiPortInfo> ports;
-    ASSERT_TRUE(hdmi->getPortInfo(&ports).isOk());
-    for (size_t i = 0; i < ports.size(); ++i) {
-        bool connected;
-        ASSERT_TRUE(hdmi->isConnected(ports[i].portId, &connected).isOk());
-    }
-}
-
-TEST_P(HdmiTest, HdpSignal) {
-    HpdSignal originalSignal;
-    HpdSignal signal = HpdSignal::HDMI_HPD_STATUS_BIT;
-    HpdSignal readSignal;
-    ASSERT_TRUE(hdmi->getHpdSignal(&originalSignal).isOk());
-    ASSERT_TRUE(hdmi->setHpdSignal(signal).isOk());
-    ASSERT_TRUE(hdmi->getHpdSignal(&readSignal).isOk());
-    EXPECT_EQ(readSignal, signal);
-    signal = HpdSignal::HDMI_HPD_PHYSICAL;
-    ASSERT_TRUE(hdmi->setHpdSignal(signal).isOk());
-    ASSERT_TRUE(hdmi->getHpdSignal(&readSignal).isOk());
-    EXPECT_EQ(readSignal, signal);
-    ASSERT_TRUE(hdmi->setHpdSignal(originalSignal).isOk());
-}
diff --git a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanCapabilities.aidl b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanCapabilities.aidl
index cb5a95c..bb44679 100644
--- a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanCapabilities.aidl
+++ b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanCapabilities.aidl
@@ -53,4 +53,5 @@
   boolean supportsHe;
   boolean supportsPairing;
   boolean supportsSetClusterId;
+  boolean supportsSuspension;
 }
diff --git a/wifi/aidl/android/hardware/wifi/NanCapabilities.aidl b/wifi/aidl/android/hardware/wifi/NanCapabilities.aidl
index 4160176..c1d6201 100644
--- a/wifi/aidl/android/hardware/wifi/NanCapabilities.aidl
+++ b/wifi/aidl/android/hardware/wifi/NanCapabilities.aidl
@@ -98,7 +98,11 @@
      */
     boolean supportsPairing;
     /**
-     * Flag to indicate if NAN setting cluster ID is supported.
+     * Flag to indicate if setting NAN cluster ID is supported.
      */
     boolean supportsSetClusterId;
+    /**
+     * Flag to indicate if NAN suspension is supported.
+     */
+    boolean supportsSuspension;
 }
diff --git a/wifi/aidl/default/aidl_struct_util.cpp b/wifi/aidl/default/aidl_struct_util.cpp
index ba7d2db..8a7f7e4 100644
--- a/wifi/aidl/default/aidl_struct_util.cpp
+++ b/wifi/aidl/default/aidl_struct_util.cpp
@@ -2248,6 +2248,8 @@
     aidl_response->supportsHe = legacy_response.is_he_supported;
     aidl_response->supportsPairing = legacy_response.is_pairing_supported;
     aidl_response->supportsSetClusterId = legacy_response.is_set_cluster_id_supported;
+    aidl_response->supportsSuspension = legacy_response.is_suspension_supported;
+
     return true;
 }