Merge "Enable rust backend" into main
diff --git a/audio/aidl/default/audio_effects_config.xml b/audio/aidl/default/audio_effects_config.xml
index c01eb3f..11683d2 100644
--- a/audio/aidl/default/audio_effects_config.xml
+++ b/audio/aidl/default/audio_effects_config.xml
@@ -88,7 +88,6 @@
         <effect name="extension_effect" library="extensioneffect" uuid="fa81dd00-588b-11ed-9b6a-0242ac120002" type="fa81de0e-588b-11ed-9b6a-0242ac120002"/>
         <effect name="acoustic_echo_canceler" library="pre_processing" uuid="bb392ec0-8d4d-11e0-a896-0002a5d5c51b"/>
         <effect name="noise_suppression" library="pre_processing" uuid="c06c8400-8e06-11e0-9cb6-0002a5d5c51b"/>
-        <effect name="spatializer" library="spatializersw" uuid="fa81a880-588b-11ed-9b6a-0242ac120002"/>
     </effects>
 
     <preprocess>
diff --git a/audio/aidl/vts/EffectHelper.h b/audio/aidl/vts/EffectHelper.h
index 72a4667..cad1195 100644
--- a/audio/aidl/vts/EffectHelper.h
+++ b/audio/aidl/vts/EffectHelper.h
@@ -92,6 +92,7 @@
         ASSERT_STATUS(status, factory->createEffect(id.uuid, &effect));
         if (status == EX_NONE) {
             ASSERT_NE(effect, nullptr) << toString(id.uuid);
+            ASSERT_NO_FATAL_FAILURE(expectState(effect, State::INIT));
         }
         mIsSpatializer = id.type == getEffectTypeUuidSpatializer();
         mDescriptor = desc;
@@ -111,11 +112,17 @@
         ASSERT_STATUS(status, factory->destroyEffect(effect));
     }
 
-    static void open(std::shared_ptr<IEffect> effect, const Parameter::Common& common,
-                     const std::optional<Parameter::Specific>& specific,
-                     IEffect::OpenEffectReturn* ret, binder_status_t status = EX_NONE) {
+    void open(std::shared_ptr<IEffect> effect, const Parameter::Common& common,
+              const std::optional<Parameter::Specific>& specific, IEffect::OpenEffectReturn* ret,
+              binder_status_t status = EX_NONE) {
         ASSERT_NE(effect, nullptr);
         ASSERT_STATUS(status, effect->open(common, specific, ret));
+        if (status != EX_NONE) {
+            return;
+        }
+
+        ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
+        updateFrameSize(common);
     }
 
     void open(std::shared_ptr<IEffect> effect, int session = 0, binder_status_t status = EX_NONE) {
@@ -125,21 +132,37 @@
         ASSERT_NO_FATAL_FAILURE(open(effect, common, std::nullopt /* specific */, &ret, status));
     }
 
+    void reopen(std::shared_ptr<IEffect> effect, const Parameter::Common& common,
+                IEffect::OpenEffectReturn* ret, binder_status_t status = EX_NONE) {
+        ASSERT_NE(effect, nullptr);
+        ASSERT_STATUS(status, effect->reopen(ret));
+        if (status != EX_NONE) {
+            return;
+        }
+        updateFrameSize(common);
+    }
+
     static void closeIgnoreRet(std::shared_ptr<IEffect> effect) {
         if (effect) {
             effect->close();
         }
     }
+
     static void close(std::shared_ptr<IEffect> effect, binder_status_t status = EX_NONE) {
         if (effect) {
             ASSERT_STATUS(status, effect->close());
+            if (status == EX_NONE) {
+                ASSERT_NO_FATAL_FAILURE(expectState(effect, State::INIT));
+            }
         }
     }
+
     static void getDescriptor(std::shared_ptr<IEffect> effect, Descriptor& desc,
                               binder_status_t status = EX_NONE) {
         ASSERT_NE(effect, nullptr);
         ASSERT_STATUS(status, effect->getDescriptor(&desc));
     }
+
     static void expectState(std::shared_ptr<IEffect> effect, State expectState,
                             binder_status_t status = EX_NONE) {
         ASSERT_NE(effect, nullptr);
@@ -147,27 +170,35 @@
         ASSERT_STATUS(status, effect->getState(&state));
         ASSERT_EQ(expectState, state);
     }
+
     static void commandIgnoreRet(std::shared_ptr<IEffect> effect, CommandId command) {
         if (effect) {
             effect->command(command);
         }
     }
+
     static void command(std::shared_ptr<IEffect> effect, CommandId command,
                         binder_status_t status = EX_NONE) {
         ASSERT_NE(effect, nullptr);
         ASSERT_STATUS(status, effect->command(command));
+        if (status != EX_NONE) {
+            return;
+        }
+
+        switch (command) {
+            case CommandId::START:
+                ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
+                break;
+            case CommandId::STOP:
+                FALLTHROUGH_INTENDED;
+            case CommandId::RESET:
+                ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
+                break;
+            default:
+                return;
+        }
     }
-    static void allocateInputData(const Parameter::Common common, std::unique_ptr<DataMQ>& mq,
-                                  std::vector<float>& buffer) {
-        ASSERT_NE(mq, nullptr);
-        auto frameSize = ::aidl::android::hardware::audio::common::getFrameSizeInBytes(
-                common.input.base.format, common.input.base.channelMask);
-        const size_t floatsToWrite = mq->availableToWrite();
-        ASSERT_NE(0UL, floatsToWrite);
-        ASSERT_EQ(frameSize * common.input.frameCount, floatsToWrite * sizeof(float));
-        buffer.resize(floatsToWrite);
-        std::fill(buffer.begin(), buffer.end(), 0x5a);
-    }
+
     static void writeToFmq(std::unique_ptr<StatusMQ>& statusMq, std::unique_ptr<DataMQ>& dataMq,
                            const std::vector<float>& buffer, int version) {
         const size_t available = dataMq->availableToWrite();
@@ -184,6 +215,7 @@
                                                          : kEventFlagNotEmpty);
         ASSERT_EQ(::android::OK, EventFlag::deleteEventFlag(&efGroup));
     }
+
     static void readFromFmq(std::unique_ptr<StatusMQ>& statusMq, size_t statusNum,
                             std::unique_ptr<DataMQ>& dataMq, size_t expectFloats,
                             std::vector<float>& buffer,
@@ -204,6 +236,7 @@
             ASSERT_TRUE(dataMq->read(buffer.data(), expectFloats));
         }
     }
+
     static void expectDataMqUpdateEventFlag(std::unique_ptr<StatusMQ>& statusMq) {
         EventFlag* efGroup;
         ASSERT_EQ(::android::OK,
@@ -218,8 +251,10 @@
     Parameter::Common createParamCommon(int session = 0, int ioHandle = -1, int iSampleRate = 48000,
                                         int oSampleRate = 48000, long iFrameCount = 0x100,
                                         long oFrameCount = 0x100) {
-        AudioChannelLayout defaultLayout = AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
+        AudioChannelLayout inputLayout = AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
                 AudioChannelLayout::LAYOUT_STEREO);
+        AudioChannelLayout outputLayout = inputLayout;
+
         // query supported input layout and use it as the default parameter in common
         if (mIsSpatializer && isRangeValid<Range::spatializer>(Spatializer::supportedChannelLayout,
                                                                mDescriptor.capability)) {
@@ -229,12 +264,14 @@
                 layoutRange &&
                 0 != (layouts = layoutRange->min.get<Spatializer::supportedChannelLayout>())
                                 .size()) {
-                defaultLayout = layouts[0];
+                inputLayout = layouts[0];
             }
         }
+
         return createParamCommon(session, ioHandle, iSampleRate, oSampleRate, iFrameCount,
-                                 oFrameCount, defaultLayout, defaultLayout);
+                                 oFrameCount, inputLayout, outputLayout);
     }
+
     static Parameter::Common createParamCommon(int session, int ioHandle, int iSampleRate,
                                                int oSampleRate, long iFrameCount, long oFrameCount,
                                                AudioChannelLayout inputChannelLayout,
@@ -333,33 +370,38 @@
 
     static void processAndWriteToOutput(std::vector<float>& inputBuffer,
                                         std::vector<float>& outputBuffer,
-                                        const std::shared_ptr<IEffect>& mEffect,
-                                        IEffect::OpenEffectReturn* mOpenEffectReturn) {
+                                        const std::shared_ptr<IEffect>& effect,
+                                        IEffect::OpenEffectReturn* openEffectReturn,
+                                        int version = -1, int times = 1) {
         // Initialize AidlMessagequeues
-        auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(mOpenEffectReturn->statusMQ);
+        auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(openEffectReturn->statusMQ);
         ASSERT_TRUE(statusMQ->isValid());
-        auto inputMQ = std::make_unique<EffectHelper::DataMQ>(mOpenEffectReturn->inputDataMQ);
+        auto inputMQ = std::make_unique<EffectHelper::DataMQ>(openEffectReturn->inputDataMQ);
         ASSERT_TRUE(inputMQ->isValid());
-        auto outputMQ = std::make_unique<EffectHelper::DataMQ>(mOpenEffectReturn->outputDataMQ);
+        auto outputMQ = std::make_unique<EffectHelper::DataMQ>(openEffectReturn->outputDataMQ);
         ASSERT_TRUE(outputMQ->isValid());
 
         // Enabling the process
-        ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-        ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
+        ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
 
         // Write from buffer to message queues and calling process
-        EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, inputBuffer, [&]() {
-            int version = 0;
-            return (mEffect && mEffect->getInterfaceVersion(&version).isOk()) ? version : 0;
-        }()));
+        if (version == -1) {
+            ASSERT_IS_OK(effect->getInterfaceVersion(&version));
+        }
 
-        // Read the updated message queues into buffer
-        EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 1, outputMQ,
-                                                          outputBuffer.size(), outputBuffer));
+        for (int i = 0; i < times; i++) {
+            EXPECT_NO_FATAL_FAILURE(
+                    EffectHelper::writeToFmq(statusMQ, inputMQ, inputBuffer, version));
+            // Read the updated message queues into buffer
+            EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 1, outputMQ,
+                                                              outputBuffer.size(), outputBuffer));
+        }
+
+        ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
+        EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, outputBuffer));
 
         // Disable the process
-        ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
-        ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
+        ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::RESET));
     }
 
     // Find FFT bin indices for testFrequencies and get bin center frequencies
@@ -403,6 +445,17 @@
         return bufferMag;
     }
 
+    void updateFrameSize(const Parameter::Common& common) {
+        mInputFrameSize = ::aidl::android::hardware::audio::common::getFrameSizeInBytes(
+                common.input.base.format, common.input.base.channelMask);
+        mInputSamples = common.input.frameCount * mInputFrameSize / sizeof(float);
+        mOutputFrameSize = ::aidl::android::hardware::audio::common::getFrameSizeInBytes(
+                common.output.base.format, common.output.base.channelMask);
+        mOutputSamples = common.output.frameCount * mOutputFrameSize / sizeof(float);
+    }
+
     bool mIsSpatializer;
     Descriptor mDescriptor;
+    size_t mInputFrameSize, mOutputFrameSize;
+    size_t mInputSamples, mOutputSamples;
 };
diff --git a/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp b/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
index 2f47d07..d23bdc9 100644
--- a/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
@@ -200,7 +200,6 @@
 // An effect instance is in INIT state by default after it was created.
 TEST_P(AudioEffectTest, InitStateAfterCreation) {
     ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::INIT));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
 }
 
@@ -208,7 +207,6 @@
 TEST_P(AudioEffectTest, IdleStateAfterOpen) {
     ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
     ASSERT_NO_FATAL_FAILURE(open(mEffect));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
 }
@@ -216,11 +214,8 @@
 // An effect instance is in PROCESSING state after it receive an START command.
 TEST_P(AudioEffectTest, ProcessingStateAfterStart) {
     ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::INIT));
     ASSERT_NO_FATAL_FAILURE(open(mEffect));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
@@ -231,9 +226,7 @@
     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));
     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));
 }
@@ -243,9 +236,7 @@
     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));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
 }
@@ -257,7 +248,6 @@
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::INIT));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
 }
 
@@ -274,9 +264,7 @@
 TEST_P(AudioEffectTest, StopCommandInIdleStateNoOp) {
     ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
     ASSERT_NO_FATAL_FAILURE(open(mEffect));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     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));
 }
@@ -285,9 +273,7 @@
 TEST_P(AudioEffectTest, ResetCommandInIdleStateNoOp) {
     ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
     ASSERT_NO_FATAL_FAILURE(open(mEffect));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
 }
@@ -296,16 +282,11 @@
 TEST_P(AudioEffectTest, RepeatStartAndStop) {
     ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
     ASSERT_NO_FATAL_FAILURE(open(mEffect));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
 
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
     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));
 }
@@ -314,16 +295,10 @@
 TEST_P(AudioEffectTest, RepeatStartAndReset) {
     ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
     ASSERT_NO_FATAL_FAILURE(open(mEffect));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
-
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
 }
@@ -332,14 +307,11 @@
 TEST_P(AudioEffectTest, CloseProcessingStateEffects) {
     ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
     ASSERT_NO_FATAL_FAILURE(open(mEffect));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
 
     ASSERT_NO_FATAL_FAILURE(close(mEffect, EX_ILLEGAL_STATE));
 
     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));
 }
@@ -348,8 +320,6 @@
 TEST_P(AudioEffectTest, DestroyOpenEffects) {
     ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
     ASSERT_NO_FATAL_FAILURE(open(mEffect));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
-
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect, EX_ILLEGAL_STATE));
 
     // cleanup
@@ -361,32 +331,22 @@
 TEST_P(AudioEffectTest, DestroyProcessingEffects) {
     ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
     ASSERT_NO_FATAL_FAILURE(open(mEffect));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect, EX_ILLEGAL_STATE));
 
     // cleanup
     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));
 }
 
 TEST_P(AudioEffectTest, NormalSequenceStates) {
     ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::INIT));
     ASSERT_NO_FATAL_FAILURE(open(mEffect));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
 }
@@ -430,7 +390,6 @@
     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::Common common = createParamCommon(0 /* session */, 1 /* ioHandle */,
                                                  44100 /* iSampleRate */, 44100 /* oSampleRate */);
@@ -447,9 +406,7 @@
     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));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
 
     Parameter::Common common = createParamCommon(0 /* session */, 1 /* ioHandle */,
                                                  44100 /* iSampleRate */, 44100 /* oSampleRate */);
@@ -465,7 +422,6 @@
     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::Common common = createParamCommon(0 /* session */, 1 /* ioHandle */,
                                                  44100 /* iSampleRate */, 44100 /* oSampleRate */);
@@ -473,7 +429,6 @@
     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));
 }
@@ -484,7 +439,6 @@
     ASSERT_NO_FATAL_FAILURE(open(mEffect));
 
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
 
     Parameter::Common common = createParamCommon(0 /* session */, 1 /* ioHandle */,
                                                  44100 /* iSampleRate */, 44100 /* oSampleRate */);
@@ -492,12 +446,10 @@
     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));
 
     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));
 }
@@ -511,9 +463,7 @@
 
     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,
@@ -525,7 +475,6 @@
             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));
 }
@@ -541,7 +490,6 @@
     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(
@@ -550,7 +498,6 @@
             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));
 }
@@ -564,9 +511,7 @@
 
     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(
@@ -575,7 +520,6 @@
             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));
 }
@@ -589,9 +533,7 @@
 
     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};
@@ -605,7 +547,6 @@
     }
 
     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));
 }
@@ -638,7 +579,7 @@
     ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
     ASSERT_TRUE(statusMQ->isValid());
     expectDataMqUpdateEventFlag(statusMQ);
-    EXPECT_IS_OK(mEffect->reopen(&ret));
+    ASSERT_NO_FATAL_FAILURE(reopen(mEffect, common, &ret));
     inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
     outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
     ASSERT_TRUE(statusMQ->isValid());
@@ -649,7 +590,7 @@
     ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
     ASSERT_TRUE(statusMQ->isValid());
     expectDataMqUpdateEventFlag(statusMQ);
-    EXPECT_IS_OK(mEffect->reopen(&ret));
+    ASSERT_NO_FATAL_FAILURE(reopen(mEffect, common, &ret));
     inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
     outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
     ASSERT_TRUE(statusMQ->isValid());
@@ -671,26 +612,9 @@
             kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
     IEffect::OpenEffectReturn ret;
     ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE));
-    auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(ret.statusMQ);
-    ASSERT_TRUE(statusMQ->isValid());
-    auto inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
-    ASSERT_TRUE(inputMQ->isValid());
-    auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
-    ASSERT_TRUE(outputMQ->isValid());
-
-    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-
-    std::vector<float> buffer;
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
-    EXPECT_NO_FATAL_FAILURE(
-            EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
-    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
-
+    std::vector<float> inputBuffer(mInputSamples), outputBuffer(mOutputSamples);
+    ASSERT_NO_FATAL_FAILURE(
+            processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion));
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
 }
@@ -705,31 +629,12 @@
             kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
     IEffect::OpenEffectReturn ret;
     ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE));
-    auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(ret.statusMQ);
-    ASSERT_TRUE(statusMQ->isValid());
-    auto inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
-    ASSERT_TRUE(inputMQ->isValid());
-    auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
-    ASSERT_TRUE(outputMQ->isValid());
 
-    std::vector<float> buffer;
-    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
-    EXPECT_NO_FATAL_FAILURE(
-            EffectHelper::readFromFmq(statusMQ, 0, outputMQ, buffer.size(), buffer));
-    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
-    EXPECT_NO_FATAL_FAILURE(
-            EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
-    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
+    std::vector<float> inputBuffer(mInputSamples), outputBuffer(mOutputSamples);
+    ASSERT_NO_FATAL_FAILURE(
+            processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion));
+    ASSERT_NO_FATAL_FAILURE(
+            processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion));
 
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
@@ -751,18 +656,10 @@
     ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE));
     auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(ret.statusMQ);
     ASSERT_TRUE(statusMQ->isValid());
-    auto inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
-    ASSERT_TRUE(inputMQ->isValid());
-    auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
-    ASSERT_TRUE(outputMQ->isValid());
 
-    std::vector<float> buffer;
-    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
-    EXPECT_NO_FATAL_FAILURE(
-            EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
+    std::vector<float> inputBuffer(mInputSamples), outputBuffer(mOutputSamples);
+    ASSERT_NO_FATAL_FAILURE(
+            processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion));
 
     // set a new common parameter with different IO frameCount, reopen
     Parameter::Id id = Parameter::Id::make<Parameter::Id::commonTag>(Parameter::common);
@@ -771,22 +668,12 @@
     ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
     ASSERT_TRUE(statusMQ->isValid());
     expectDataMqUpdateEventFlag(statusMQ);
-    EXPECT_IS_OK(mEffect->reopen(&ret));
-    inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
-    outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
-    ASSERT_TRUE(statusMQ->isValid());
-    ASSERT_TRUE(inputMQ->isValid());
-    ASSERT_TRUE(outputMQ->isValid());
+    ASSERT_NO_FATAL_FAILURE(reopen(mEffect, common, &ret));
 
-    // verify data consume again
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
-    EXPECT_NO_FATAL_FAILURE(
-            EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
-    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
+    inputBuffer.resize(mInputSamples);
+    outputBuffer.resize(mOutputSamples);
+    ASSERT_NO_FATAL_FAILURE(
+            processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion));
 
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
@@ -809,19 +696,15 @@
     auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
     ASSERT_TRUE(outputMQ->isValid());
 
-    std::vector<float> buffer;
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
+    std::vector<float> inputBuffer(mInputSamples), outputBuffer(mOutputSamples);
+    ASSERT_NO_FATAL_FAILURE(
+            processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion));
 
+    EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, inputBuffer, mVersion));
     ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-
     EXPECT_NO_FATAL_FAILURE(
-            EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
+            EffectHelper::readFromFmq(statusMQ, 1, outputMQ, outputBuffer.size(), outputBuffer));
     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));
 }
@@ -836,31 +719,10 @@
             kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
     IEffect::OpenEffectReturn ret;
     ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE));
-    auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(ret.statusMQ);
-    ASSERT_TRUE(statusMQ->isValid());
-    auto inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
-    ASSERT_TRUE(inputMQ->isValid());
-    auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
-    ASSERT_TRUE(outputMQ->isValid());
+    std::vector<float> inputBuffer(mInputSamples), outputBuffer(mOutputSamples);
 
-    std::vector<float> buffer;
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
-
-    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-
-    EXPECT_NO_FATAL_FAILURE(
-            EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
-    EXPECT_NO_FATAL_FAILURE(
-            EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
-    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
+    ASSERT_NO_FATAL_FAILURE(
+            processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion, 2));
 
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
@@ -876,33 +738,12 @@
             kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
     IEffect::OpenEffectReturn ret;
     ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE));
-    auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(ret.statusMQ);
-    ASSERT_TRUE(statusMQ->isValid());
-    auto inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
-    ASSERT_TRUE(inputMQ->isValid());
-    auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
-    ASSERT_TRUE(outputMQ->isValid());
+    std::vector<float> inputBuffer(mInputSamples), outputBuffer(mOutputSamples);
 
-    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-    std::vector<float> buffer;
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
-    EXPECT_NO_FATAL_FAILURE(
-            EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
-    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
-
-    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-    EXPECT_NO_FATAL_FAILURE(
-            EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
-    ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
-    ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
+    ASSERT_NO_FATAL_FAILURE(
+            processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion, 2));
+    ASSERT_NO_FATAL_FAILURE(
+            processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion, 2));
 
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
@@ -918,6 +759,7 @@
             kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
     IEffect::OpenEffectReturn ret;
     ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE));
+    std::vector<float> inputBuffer(mInputSamples), outputBuffer(mOutputSamples);
     ASSERT_NO_FATAL_FAILURE(close(mEffect));
 
     auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(ret.statusMQ);
@@ -927,10 +769,8 @@
     auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
     ASSERT_TRUE(outputMQ->isValid());
 
-    std::vector<float> buffer;
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
+    EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, inputBuffer, mVersion));
+    EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, outputBuffer));
 
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
 }
@@ -951,42 +791,19 @@
     IEffect::OpenEffectReturn ret1, ret2;
     ASSERT_NO_FATAL_FAILURE(open(effect1, common1, std::nullopt /* specific */, &ret1, EX_NONE));
     ASSERT_NO_FATAL_FAILURE(open(effect2, common2, std::nullopt /* specific */, &ret2, EX_NONE));
-    ASSERT_NO_FATAL_FAILURE(command(effect1, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(effect1, State::PROCESSING));
-    ASSERT_NO_FATAL_FAILURE(command(effect2, CommandId::START));
-    ASSERT_NO_FATAL_FAILURE(expectState(effect2, State::PROCESSING));
+    std::vector<float> inputBuffer1(kInputFrameCount * mInputFrameSize / sizeof(float)),
+            outputBuffer1(kOutputFrameCount * mOutputFrameSize / sizeof(float));
+    std::vector<float> inputBuffer2(2 * kInputFrameCount * mInputFrameSize / sizeof(float)),
+            outputBuffer2(2 * kOutputFrameCount * mOutputFrameSize / sizeof(float));
 
-    auto statusMQ1 = std::make_unique<EffectHelper::StatusMQ>(ret1.statusMQ);
-    ASSERT_TRUE(statusMQ1->isValid());
-    auto inputMQ1 = std::make_unique<EffectHelper::DataMQ>(ret1.inputDataMQ);
-    ASSERT_TRUE(inputMQ1->isValid());
-    auto outputMQ1 = std::make_unique<EffectHelper::DataMQ>(ret1.outputDataMQ);
-    ASSERT_TRUE(outputMQ1->isValid());
+    ASSERT_NO_FATAL_FAILURE(
+            processAndWriteToOutput(inputBuffer1, outputBuffer1, effect1, &ret1, mVersion, 2));
+    ASSERT_NO_FATAL_FAILURE(
+            processAndWriteToOutput(inputBuffer2, outputBuffer2, effect2, &ret2, mVersion, 2));
 
-    std::vector<float> buffer1, buffer2;
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common1, inputMQ1, buffer1));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ1, inputMQ1, buffer1, mVersion));
-    EXPECT_NO_FATAL_FAILURE(
-            EffectHelper::readFromFmq(statusMQ1, 1, outputMQ1, buffer1.size(), buffer1));
-
-    auto statusMQ2 = std::make_unique<EffectHelper::StatusMQ>(ret2.statusMQ);
-    ASSERT_TRUE(statusMQ2->isValid());
-    auto inputMQ2 = std::make_unique<EffectHelper::DataMQ>(ret2.inputDataMQ);
-    ASSERT_TRUE(inputMQ2->isValid());
-    auto outputMQ2 = std::make_unique<EffectHelper::DataMQ>(ret2.outputDataMQ);
-    ASSERT_TRUE(outputMQ2->isValid());
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common2, inputMQ2, buffer2));
-    EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ2, inputMQ2, buffer2, mVersion));
-    EXPECT_NO_FATAL_FAILURE(
-            EffectHelper::readFromFmq(statusMQ2, 1, outputMQ2, buffer2.size(), buffer2));
-
-    ASSERT_NO_FATAL_FAILURE(command(effect1, CommandId::STOP));
-    ASSERT_NO_FATAL_FAILURE(expectState(effect1, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(close(effect1));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect1));
 
-    ASSERT_NO_FATAL_FAILURE(command(effect2, CommandId::STOP));
-    ASSERT_NO_FATAL_FAILURE(expectState(effect2, State::IDLE));
     ASSERT_NO_FATAL_FAILURE(close(effect2));
     ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect2));
 }
diff --git a/audio/aidl/vts/VtsHalDownmixTargetTest.cpp b/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
index 844a340..a1491e6 100644
--- a/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
@@ -96,8 +96,7 @@
         Parameter::Specific specific = getDefaultParamSpecific();
         Parameter::Common common = EffectHelper::createParamCommon(
                 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
-                kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */,
-                inputChannelLayout,
+                kFrameCount /* iFrameCount */, kFrameCount /* oFrameCount */, inputChannelLayout,
                 AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
                         AudioChannelLayout::LAYOUT_STEREO));
         ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &mOpenEffectReturn, EX_NONE));
@@ -139,14 +138,14 @@
     }
 
     void setDataTestParams(int32_t layoutType) {
-        mInputBuffer.resize(kBufferSize);
-
         // Get the number of channels used
         mInputChannelCount = getChannelCount(
                 AudioChannelLayout::make<AudioChannelLayout::layoutMask>(layoutType));
+        mInputBufferSize = kFrameCount * mInputChannelCount;
+        mInputBuffer.resize(mInputBufferSize);
 
         // In case of downmix, output is always configured to stereo layout.
-        mOutputBufferSize = (mInputBuffer.size() / mInputChannelCount) * kOutputChannelCount;
+        mOutputBufferSize = kFrameCount * kOutputChannelCount;
         mOutputBuffer.resize(mOutputBufferSize);
     }
 
@@ -173,7 +172,12 @@
         return true;
     }
 
-    static constexpr long kInputFrameCount = 100, kOutputFrameCount = 100;
+    static const long kFrameCount = 256;
+    static constexpr float kMaxDownmixSample = 1;
+    static constexpr int kOutputChannelCount = 2;
+    // Mask for layouts greater than MAX_INPUT_CHANNELS_SUPPORTED
+    static constexpr int32_t kMaxChannelMask =
+            ~((1 << ChannelMix<AUDIO_CHANNEL_OUT_STEREO>::MAX_INPUT_CHANNELS_SUPPORTED) - 1);
     std::shared_ptr<IFactory> mFactory;
     Descriptor mDescriptor;
     std::shared_ptr<IEffect> mEffect;
@@ -183,12 +187,7 @@
     std::vector<float> mOutputBuffer;
     size_t mInputChannelCount;
     size_t mOutputBufferSize;
-    static constexpr size_t kBufferSize = 128;
-    static constexpr float kMaxDownmixSample = 1;
-    static constexpr int kOutputChannelCount = 2;
-    // Mask for layouts greater than MAX_INPUT_CHANNELS_SUPPORTED
-    static constexpr int32_t kMaxChannelMask =
-            ~((1 << ChannelMix<AUDIO_CHANNEL_OUT_STEREO>::MAX_INPUT_CHANNELS_SUPPORTED) - 1);
+    size_t mInputBufferSize;
 };
 
 /**
@@ -401,9 +400,9 @@
     void TearDown() override { TearDownDownmix(); }
 
     void validateOutput() {
-        ASSERT_EQ(kBufferSize, mInputBuffer.size());
-        ASSERT_GE(kBufferSize, mOutputBufferSize);
-        for (size_t i = 0, j = 0; i < kBufferSize && j < mOutputBufferSize;
+        ASSERT_EQ(mInputBufferSize, mInputBuffer.size());
+        ASSERT_GE(mInputBufferSize, mOutputBufferSize);
+        for (size_t i = 0, j = 0; i < mInputBufferSize && j < mOutputBufferSize;
              i += mInputChannelCount, j += kOutputChannelCount) {
             ASSERT_EQ(mOutputBuffer[j], mInputBuffer[i]);
             ASSERT_EQ(mOutputBuffer[j + 1], mInputBuffer[i + 1]);
diff --git a/audio/aidl/vts/VtsHalEnvironmentalReverbTargetTest.cpp b/audio/aidl/vts/VtsHalEnvironmentalReverbTargetTest.cpp
index c7c6505..5fe27f6 100644
--- a/audio/aidl/vts/VtsHalEnvironmentalReverbTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalEnvironmentalReverbTargetTest.cpp
@@ -18,6 +18,7 @@
 #include <android-base/logging.h>
 #include <audio_utils/power.h>
 #include <system/audio.h>
+#include <numeric>
 
 #include "EffectHelper.h"
 
@@ -39,7 +40,6 @@
 static constexpr int kMinDelay = 0;
 
 static const std::vector<TagVectorPair> kParamsIncreasingVector = {
-
         {EnvironmentalReverb::roomLevelMb, {-3500, -2800, -2100, -1400, -700, 0}},
         {EnvironmentalReverb::roomHfLevelMb, {-4000, -3200, -2400, -1600, -800, 0}},
         {EnvironmentalReverb::decayTimeMs, {800, 1600, 2400, 3200, 4000}},
@@ -47,6 +47,9 @@
         {EnvironmentalReverb::levelMb, {-3500, -2800, -2100, -1400, -700, 0}},
 };
 
+static const TagVectorPair kDiffusionParam = {EnvironmentalReverb::diffusionPm,
+                                              {200, 400, 600, 800, 1000}};
+
 static const std::vector<TagValuePair> kParamsMinimumValue = {
         {EnvironmentalReverb::roomLevelMb, kMinRoomLevel},
         {EnvironmentalReverb::decayTimeMs, kMinDecayTime},
@@ -452,6 +455,75 @@
 
 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbMinimumParamTest);
 
+class EnvironmentalReverbDiffusionTest
+    : public ::testing::TestWithParam<
+              std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, TagVectorPair>>,
+      public EnvironmentalReverbHelper {
+  public:
+    EnvironmentalReverbDiffusionTest()
+        : EnvironmentalReverbHelper(std::get<DESCRIPTOR_INDEX>(GetParam())) {
+        std::tie(mTag, mParamValues) = std::get<TAG_VALUE_PAIR>(GetParam());
+        mInput.resize(kBufferSize);
+        generateSineWaveInput(mInput);
+    }
+    void SetUp() override { SetUpReverb(); }
+    void TearDown() override { TearDownReverb(); }
+
+    float getMean(std::vector<float>& buffer) {
+        return std::accumulate(buffer.begin(), buffer.end(), 0.0) / buffer.size();
+    }
+
+    float getVariance(std::vector<float>& buffer) {
+        if (isAuxiliary()) {
+            for (size_t i = 0; i < buffer.size(); i++) {
+                buffer[i] += mInput[i];
+            }
+        }
+        float mean = getMean(buffer);
+        float squaredDeltas =
+                std::accumulate(buffer.begin(), buffer.end(), 0.0,
+                                [mean](float a, float b) { return a + pow(b - mean, 2); });
+
+        return squaredDeltas / buffer.size();
+    }
+
+    EnvironmentalReverb::Tag mTag;
+    std::vector<int> mParamValues;
+    std::vector<float> mInput;
+};
+
+TEST_P(EnvironmentalReverbDiffusionTest, DecreasingVarianceTest) {
+    std::vector<float> baseOutput(kBufferSize);
+    setParameterAndProcess(mInput, baseOutput, kMinDiffusion, mTag);
+    ASSERT_EQ(baseOutput.size(),
+              static_cast<size_t>(mFrameCount) * static_cast<size_t>(mStereoChannelCount));
+    float baseVariance = getVariance(baseOutput);
+    for (int value : mParamValues) {
+        std::vector<float> output(kBufferSize);
+        setParameterAndProcess(mInput, output, value, mTag);
+        ASSERT_EQ(output.size(),
+                  static_cast<size_t>(mFrameCount) * static_cast<size_t>(mStereoChannelCount));
+        float variance = getVariance(output);
+        ASSERT_LT(variance, baseVariance);
+        baseVariance = variance;
+    }
+}
+
+INSTANTIATE_TEST_SUITE_P(
+        EnvironmentalReverbTest, EnvironmentalReverbDiffusionTest,
+        ::testing::Combine(
+                testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors(
+                                          IFactory::descriptor, getEffectTypeUuidEnvReverb())),
+                testing::Values(kDiffusionParam)),
+        [](const testing::TestParamInfo<EnvironmentalReverbDiffusionTest::ParamType>& info) {
+            auto descriptor = std::get<DESCRIPTOR_INDEX>(info.param).second;
+            auto tag = std::get<TAG_VALUE_PAIR>(info.param).first;
+            std::string name = getPrefix(descriptor) + "_Tag_" + toString(tag);
+            return name;
+        });
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDiffusionTest);
+
 int main(int argc, char** argv) {
     ::testing::InitGoogleTest(&argc, argv);
     ::testing::UnitTest::GetInstance()->listeners().Append(new TestExecutionTracer());
diff --git a/audio/aidl/vts/VtsHalLoudnessEnhancerTargetTest.cpp b/audio/aidl/vts/VtsHalLoudnessEnhancerTargetTest.cpp
index 3c72dfa..1fe8beb 100644
--- a/audio/aidl/vts/VtsHalLoudnessEnhancerTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalLoudnessEnhancerTargetTest.cpp
@@ -23,6 +23,7 @@
 
 using namespace android;
 
+using aidl::android::hardware::audio::common::getChannelCount;
 using aidl::android::hardware::audio::effect::Descriptor;
 using aidl::android::hardware::audio::effect::getEffectTypeUuidLoudnessEnhancer;
 using aidl::android::hardware::audio::effect::IEffect;
@@ -50,7 +51,7 @@
         Parameter::Specific specific = getDefaultParamSpecific();
         Parameter::Common common = createParamCommon(
                 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
-                kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
+                kFrameCount /* iFrameCount */, kFrameCount /* oFrameCount */);
         ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &mOpenEffectReturn, EX_NONE));
         ASSERT_NE(nullptr, mEffect);
         mVersion = EffectFactoryHelper::getHalVersion(mFactory);
@@ -110,7 +111,7 @@
                                            << "\ngetParam:" << getParam.toString();
     }
 
-    static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
+    static const long kFrameCount = 256;
     IEffect::OpenEffectReturn mOpenEffectReturn;
     std::shared_ptr<IFactory> mFactory;
     std::shared_ptr<IEffect> mEffect;
@@ -153,8 +154,12 @@
   public:
     LoudnessEnhancerDataTest() {
         std::tie(mFactory, mDescriptor) = GetParam();
+        mBufferSize = kFrameCount *
+                      getChannelCount(AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
+                              AudioChannelLayout::LAYOUT_STEREO));
         generateInputBuffer();
-        mOutputBuffer.resize(kBufferSize);
+
+        mOutputBuffer.resize(mBufferSize);
     }
 
     void SetUp() override {
@@ -174,7 +179,7 @@
 
     // Fill inputBuffer with random values between -kMaxAudioSample to kMaxAudioSample
     void generateInputBuffer() {
-        for (size_t i = 0; i < kBufferSize; i++) {
+        for (size_t i = 0; i < mBufferSize; i++) {
             mInputBuffer.push_back(((static_cast<float>(std::rand()) / RAND_MAX) * 2 - 1) *
                                    kMaxAudioSample);
         }
@@ -215,7 +220,7 @@
     }
 
     void assertSequentialGains(const std::vector<int>& gainValues, bool isIncreasing) {
-        std::vector<float> baseOutput(kBufferSize);
+        std::vector<float> baseOutput(mBufferSize);
 
         // Process a reference output buffer with 0 gain which gives compressed input values
         binder_exception_t expected;
@@ -252,7 +257,7 @@
 
     std::vector<float> mInputBuffer;
     std::vector<float> mOutputBuffer;
-    static constexpr float kBufferSize = 128;
+    size_t mBufferSize;
 };
 
 TEST_P(LoudnessEnhancerDataTest, IncreasingGains) {
diff --git a/nfc/aidl/vts/functional/Android.bp b/nfc/aidl/vts/functional/Android.bp
index d0b684b..d2508ce 100644
--- a/nfc/aidl/vts/functional/Android.bp
+++ b/nfc/aidl/vts/functional/Android.bp
@@ -49,6 +49,7 @@
 cc_test {
     name: "VtsNfcBehaviorChangesTest",
     defaults: [
+        "aconfig_lib_cc_shared_link.defaults",
         "VtsHalTargetTestDefaults",
         "use_libaidlvintf_gtest_helper_static",
     ],
@@ -65,6 +66,7 @@
         "system/nfc/utils/include",
     ],
     shared_libs: [
+        "liblog",
         "libbinder",
         "libbinder_ndk",
         "libnativehelper",
diff --git a/radio/aidl/vts/Android.bp b/radio/aidl/vts/Android.bp
index e83a7c1..9521068 100644
--- a/radio/aidl/vts/Android.bp
+++ b/radio/aidl/vts/Android.bp
@@ -25,6 +25,7 @@
 cc_test {
     name: "VtsHalRadioTargetTest",
     defaults: [
+        "aconfig_lib_cc_shared_link.defaults",
         "VtsHalTargetTestDefaults",
         "use_libaidlvintf_gtest_helper_static",
     ],
diff --git a/threadnetwork/aidl/default/socket_interface.cpp b/threadnetwork/aidl/default/socket_interface.cpp
index 0544502..339fd6b 100644
--- a/threadnetwork/aidl/default/socket_interface.cpp
+++ b/threadnetwork/aidl/default/socket_interface.cpp
@@ -33,6 +33,7 @@
 #include <unistd.h>
 
 #include <string>
+#include <vector>
 
 #include "common/code_utils.hpp"
 #include "openthread/openthread-system.h"
@@ -49,10 +50,8 @@
     : mReceiveFrameCallback(nullptr),
       mReceiveFrameContext(nullptr),
       mReceiveFrameBuffer(nullptr),
-      mSockFd(-1),
       mRadioUrl(aRadioUrl) {
-    memset(&mInterfaceMetrics, 0, sizeof(mInterfaceMetrics));
-    mInterfaceMetrics.mRcpInterfaceType = kSpinelInterfaceTypeVendor;
+    ResetStates();
 }
 
 otError SocketInterface::Init(ReceiveFrameCallback aCallback, void* aCallbackContext,
@@ -120,13 +119,50 @@
     } else if (rval == 0) {
         ExitNow(error = OT_ERROR_RESPONSE_TIMEOUT);
     } else {
-        DieNowWithMessage("wait response", OT_EXIT_FAILURE);
+        DieNowWithMessage("Wait response", OT_EXIT_FAILURE);
     }
 
 exit:
     return error;
 }
 
+otError SocketInterface::WaitForHardwareResetCompletion(uint32_t aTimeoutMs) {
+    otError error = OT_ERROR_NONE;
+    int retries = 0;
+    int rval;
+
+    while (mIsHardwareResetting && retries++ < kMaxRetriesForSocketCloseCheck) {
+        struct timeval timeout;
+        timeout.tv_sec = static_cast<time_t>(aTimeoutMs / MS_PER_S);
+        timeout.tv_usec = static_cast<suseconds_t>((aTimeoutMs % MS_PER_S) * MS_PER_S);
+
+        fd_set readFds;
+
+        FD_ZERO(&readFds);
+        FD_SET(mSockFd, &readFds);
+
+        rval = TEMP_FAILURE_RETRY(select(mSockFd + 1, &readFds, nullptr, nullptr, &timeout));
+
+        if (rval > 0) {
+            Read();
+        } else if (rval < 0) {
+            DieNowWithMessage("Wait response", OT_EXIT_ERROR_ERRNO);
+        } else {
+            LogInfo("Waiting for hardware reset, retry attempt: %d, max attempt: %d", retries,
+                    kMaxRetriesForSocketCloseCheck);
+        }
+    }
+
+    VerifyOrExit(!mIsHardwareResetting, error = OT_ERROR_FAILED);
+
+    WaitForSocketFileCreated(mRadioUrl.GetPath());
+    mSockFd = OpenFile(mRadioUrl);
+    VerifyOrExit(mSockFd != -1, error = OT_ERROR_FAILED);
+
+exit:
+    return error;
+}
+
 void SocketInterface::UpdateFdSet(void* aMainloopContext) {
     otSysMainloopContext* context = reinterpret_cast<otSysMainloopContext*>(aMainloopContext);
 
@@ -150,6 +186,16 @@
     }
 }
 
+otError SocketInterface::HardwareReset(void) {
+    otError error = OT_ERROR_NONE;
+    std::vector<uint8_t> resetCommand = {SPINEL_HEADER_FLAG, SPINEL_CMD_RESET, 0x04};
+
+    mIsHardwareResetting = true;
+    SendFrame(resetCommand.data(), resetCommand.size());
+
+    return WaitForHardwareResetCompletion(kMaxSelectTimeMs);
+}
+
 void SocketInterface::Read(void) {
     uint8_t buffer[kMaxFrameSize];
 
@@ -160,8 +206,13 @@
     } else if (rval < 0) {
         DieNow(OT_EXIT_ERROR_ERRNO);
     } else {
-        LogCrit("Socket connection is closed by remote.");
-        exit(OT_EXIT_FAILURE);
+        if (mIsHardwareResetting) {
+            LogInfo("Socket connection is closed due to hardware reset.");
+            ResetStates();
+        } else {
+            LogCrit("Socket connection is closed by remote.");
+            exit(OT_EXIT_FAILURE);
+        }
     }
 }
 
@@ -298,6 +349,13 @@
     return stat(aPath, &st) == 0 && S_ISSOCK(st.st_mode);
 }
 
+void SocketInterface::ResetStates() {
+    mSockFd = -1;
+    mIsHardwareResetting = false;
+    memset(&mInterfaceMetrics, 0, sizeof(mInterfaceMetrics));
+    mInterfaceMetrics.mRcpInterfaceType = kSpinelInterfaceTypeVendor;
+}
+
 }  // namespace threadnetwork
 }  // namespace hardware
 }  // namespace android
diff --git a/threadnetwork/aidl/default/socket_interface.hpp b/threadnetwork/aidl/default/socket_interface.hpp
index 6f3be7f..494d76a 100644
--- a/threadnetwork/aidl/default/socket_interface.hpp
+++ b/threadnetwork/aidl/default/socket_interface.hpp
@@ -136,10 +136,10 @@
      * Hardware resets the RCP.
      *
      * @retval OT_ERROR_NONE            Successfully reset the RCP.
-     * @retval OT_ERROR_NOT_IMPLEMENT   The hardware reset is not implemented.
+     * @retval OT_ERROR_FAILED          Hardware reset is failed.
      *
      */
-    otError HardwareReset(void) { return OT_ERROR_NOT_IMPLEMENTED; }
+    otError HardwareReset(void);
 
     /**
      * Returns the RCP interface metrics.
@@ -237,9 +237,26 @@
      */
     void WaitForSocketFileCreated(const char* aPath);
 
+    /**
+     * Wait for the hardware reset completion signal.
+     *
+     * @retval OT_ERROR_NONE       Hardware reset is successfully.
+     * @retval OT_ERROR_FAILED     Hardware reset is failed.
+     *
+     */
+    otError WaitForHardwareResetCompletion(uint32_t aTimeoutMs);
+
+    /**
+     * Reset socket interface to intitial state.
+     *
+     */
+    void ResetStates(void);
+
     enum {
-        kMaxSelectTimeMs = 2000,  ///< Maximum wait time in Milliseconds for file
-                                  ///< descriptor to become available.
+        kMaxSelectTimeMs = 2000,             ///< Maximum wait time in Milliseconds for file
+                                             ///< descriptor to become available.
+        kMaxRetriesForSocketCloseCheck = 3,  ///< Maximum retry times for checking
+                                             ///< if socket is closed.
     };
 
     ReceiveFrameCallback mReceiveFrameCallback;
@@ -249,6 +266,8 @@
     int mSockFd;
     const ot::Url::Url& mRadioUrl;
 
+    bool mIsHardwareResetting;
+
     otRcpInterfaceMetrics mInterfaceMetrics;
 
     // Non-copyable, intentionally not implemented.