Merge "audio: Add libaudioclient tests to postsubmit for the AIDL HAL" into main
diff --git a/audio/aidl/default/include/core-impl/ModuleRemoteSubmix.h b/audio/aidl/default/include/core-impl/ModuleRemoteSubmix.h
index 613ac62..9d8c027 100644
--- a/audio/aidl/default/include/core-impl/ModuleRemoteSubmix.h
+++ b/audio/aidl/default/include/core-impl/ModuleRemoteSubmix.h
@@ -57,7 +57,7 @@
     ndk::ScopedAStatus onMasterVolumeChanged(float volume) override;
     int32_t getNominalLatencyMs(
             const ::aidl::android::media::audio::common::AudioPortConfig& portConfig) override;
-    // TODO(b/307586684): Report proper minimum stream buffer size by overriding 'setAudioPatch'.
+    binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
 };
 
 }  // namespace aidl::android::hardware::audio::core
diff --git a/audio/aidl/default/include/core-impl/StreamRemoteSubmix.h b/audio/aidl/default/include/core-impl/StreamRemoteSubmix.h
index 477c30e..b2cdc28 100644
--- a/audio/aidl/default/include/core-impl/StreamRemoteSubmix.h
+++ b/audio/aidl/default/include/core-impl/StreamRemoteSubmix.h
@@ -67,6 +67,7 @@
     int64_t mStartTimeNs = 0;
     long mFramesSinceStart = 0;
     int mReadErrorCount = 0;
+    int mReadFailureCount = 0;
 };
 
 class StreamInRemoteSubmix final : public StreamIn, public StreamSwitcher {
diff --git a/audio/aidl/default/include/effect-impl/EffectContext.h b/audio/aidl/default/include/effect-impl/EffectContext.h
index 698e7a5..89d0c7c 100644
--- a/audio/aidl/default/include/effect-impl/EffectContext.h
+++ b/audio/aidl/default/include/effect-impl/EffectContext.h
@@ -46,6 +46,14 @@
         LOG_ALWAYS_FATAL_IF(output.base.format.pcm !=
                                     aidl::android::media::audio::common::PcmType::FLOAT_32_BIT,
                             "outputFormatNotFloat");
+
+        size_t inputChannelCount =
+                ::aidl::android::hardware::audio::common::getChannelCount(input.base.channelMask);
+        LOG_ALWAYS_FATAL_IF(inputChannelCount == 0, "inputChannelCountNotValid");
+        size_t outputChannelCount =
+                ::aidl::android::hardware::audio::common::getChannelCount(output.base.channelMask);
+        LOG_ALWAYS_FATAL_IF(outputChannelCount == 0, "outputChannelCountNotValid");
+
         mInputFrameSize = ::aidl::android::hardware::audio::common::getFrameSizeInBytes(
                 input.base.format, input.base.channelMask);
         mOutputFrameSize = ::aidl::android::hardware::audio::common::getFrameSizeInBytes(
diff --git a/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp b/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp
index 7bc783c..b44f37b 100644
--- a/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp
+++ b/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp
@@ -16,6 +16,7 @@
 
 #define LOG_TAG "AHAL_ModuleRemoteSubmix"
 
+#include <stdio.h>
 #include <vector>
 
 #include <android-base/logging.h>
@@ -174,4 +175,9 @@
     return kMinLatencyMs;
 }
 
+binder_status_t ModuleRemoteSubmix::dump(int fd, const char** /*args*/, uint32_t /*numArgs*/) {
+    dprintf(fd, "\nSubmixRoutes:\n%s\n", r_submix::SubmixRoute::dumpRoutes().c_str());
+    return STATUS_OK;
+}
+
 }  // namespace aidl::android::hardware::audio::core
diff --git a/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp b/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp
index 3ee354b..fa4135d 100644
--- a/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp
+++ b/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp
@@ -267,6 +267,7 @@
         }
         return ::android::OK;
     }
+    mReadErrorCount = 0;
 
     LOG(VERBOSE) << __func__ << ": " << mDeviceAddress.toString() << ", " << frameCount
                  << " frames";
@@ -294,7 +295,12 @@
         }
     }
     if (actuallyRead < frameCount) {
-        LOG(WARNING) << __func__ << ": read " << actuallyRead << " vs. requested " << frameCount;
+        if (++mReadFailureCount < kMaxReadFailureAttempts) {
+            LOG(WARNING) << __func__ << ": read " << actuallyRead << " vs. requested " << frameCount
+                         << " (not all errors will be logged)";
+        }
+    } else {
+        mReadFailureCount = 0;
     }
     mCurrentRoute->updateReadCounterFrames(*actualFrameCount);
     return ::android::OK;
diff --git a/audio/aidl/default/r_submix/SubmixRoute.cpp b/audio/aidl/default/r_submix/SubmixRoute.cpp
index 7d706c2..325a012 100644
--- a/audio/aidl/default/r_submix/SubmixRoute.cpp
+++ b/audio/aidl/default/r_submix/SubmixRoute.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#include <mutex>
+
 #define LOG_TAG "AHAL_SubmixRoute"
 #include <android-base/logging.h>
 #include <media/AidlConversionCppNdk.h>
@@ -28,10 +30,11 @@
 namespace aidl::android::hardware::audio::core::r_submix {
 
 // static
-SubmixRoute::RoutesMonitor SubmixRoute::getRoutes() {
+SubmixRoute::RoutesMonitor SubmixRoute::getRoutes(bool tryLock) {
     static std::mutex submixRoutesLock;
     static RoutesMap submixRoutes;
-    return RoutesMonitor(submixRoutesLock, submixRoutes);
+    return !tryLock ? RoutesMonitor(submixRoutesLock, submixRoutes)
+                    : RoutesMonitor(submixRoutesLock, submixRoutes, tryLock);
 }
 
 // static
@@ -66,6 +69,21 @@
     getRoutes()->erase(deviceAddress);
 }
 
+// static
+std::string SubmixRoute::dumpRoutes() {
+    auto routes = getRoutes(true /*tryLock*/);
+    std::string result;
+    if (routes->empty()) result.append(" <Empty>");
+    for (const auto& r : *(routes.operator->())) {
+        result.append(" - ")
+                .append(r.first.toString())
+                .append(": ")
+                .append(r.second->dump())
+                .append("\n");
+    }
+    return result;
+}
+
 // Verify a submix input or output stream can be opened.
 bool SubmixRoute::isStreamConfigValid(bool isInput, const AudioConfig& streamConfig) {
     // If the stream is already open, don't open it again.
@@ -258,4 +276,23 @@
     }
 }
 
+std::string SubmixRoute::dump() NO_THREAD_SAFETY_ANALYSIS {
+    const bool isLocked = mLock.try_lock();
+    std::string result = std::string(isLocked ? "" : "! ")
+                                 .append("Input ")
+                                 .append(mStreamInOpen ? "open" : "closed")
+                                 .append(mStreamInStandby ? ", standby" : ", active")
+                                 .append(", refcount: ")
+                                 .append(std::to_string(mInputRefCount))
+                                 .append(", framesRead: ")
+                                 .append(mSource ? std::to_string(mSource->framesRead()) : "<null>")
+                                 .append("; Output ")
+                                 .append(mStreamOutOpen ? "open" : "closed")
+                                 .append(mStreamOutStandby ? ", standby" : ", active")
+                                 .append(", framesWritten: ")
+                                 .append(mSink ? std::to_string(mSink->framesWritten()) : "<null>");
+    if (isLocked) mLock.unlock();
+    return result;
+}
+
 }  // namespace aidl::android::hardware::audio::core::r_submix
diff --git a/audio/aidl/default/r_submix/SubmixRoute.h b/audio/aidl/default/r_submix/SubmixRoute.h
index 160df41..5425f12 100644
--- a/audio/aidl/default/r_submix/SubmixRoute.h
+++ b/audio/aidl/default/r_submix/SubmixRoute.h
@@ -17,6 +17,7 @@
 #pragma once
 
 #include <mutex>
+#include <string>
 
 #include <android-base/thread_annotations.h>
 #include <audio_utils/clock.h>
@@ -68,6 +69,7 @@
             const ::aidl::android::media::audio::common::AudioDeviceAddress& deviceAddress);
     static void removeRoute(
             const ::aidl::android::media::audio::common::AudioDeviceAddress& deviceAddress);
+    static std::string dumpRoutes();
 
     bool isStreamInOpen() {
         std::lock_guard guard(mLock);
@@ -115,20 +117,24 @@
     void standby(bool isInput);
     long updateReadCounterFrames(size_t frameCount);
 
+    std::string dump();
+
   private:
     using RoutesMap = std::map<::aidl::android::media::audio::common::AudioDeviceAddress,
                                std::shared_ptr<r_submix::SubmixRoute>>;
     class RoutesMonitor {
       public:
         RoutesMonitor(std::mutex& mutex, RoutesMap& routes) : mLock(mutex), mRoutes(routes) {}
+        RoutesMonitor(std::mutex& mutex, RoutesMap& routes, bool /*tryLock*/)
+            : mLock(mutex, std::try_to_lock), mRoutes(routes) {}
         RoutesMap* operator->() { return &mRoutes; }
 
       private:
-        std::lock_guard<std::mutex> mLock;
+        std::unique_lock<std::mutex> mLock;
         RoutesMap& mRoutes;
     };
 
-    static RoutesMonitor getRoutes();
+    static RoutesMonitor getRoutes(bool tryLock = false);
 
     bool isStreamConfigCompatible(const AudioConfig& streamConfig);
 
diff --git a/automotive/audiocontrol/aidl/default/AudioControl.cpp b/automotive/audiocontrol/aidl/default/AudioControl.cpp
index cf7307d..7e7e145 100644
--- a/automotive/audiocontrol/aidl/default/AudioControl.cpp
+++ b/automotive/audiocontrol/aidl/default/AudioControl.cpp
@@ -244,15 +244,15 @@
 template <typename aidl_type>
 static inline std::string toString(const std::vector<aidl_type>& in_values) {
     return std::accumulate(std::begin(in_values), std::end(in_values), std::string{},
-                           [](std::string& ls, const aidl_type& rs) {
-                               return ls += (ls.empty() ? "" : ",") + rs.toString();
+                           [](const std::string& ls, const aidl_type& rs) {
+                               return ls + (ls.empty() ? "" : ",") + rs.toString();
                            });
 }
 template <typename aidl_enum_type>
 static inline std::string toEnumString(const std::vector<aidl_enum_type>& in_values) {
     return std::accumulate(std::begin(in_values), std::end(in_values), std::string{},
-                           [](std::string& ls, const aidl_enum_type& rs) {
-                               return ls += (ls.empty() ? "" : ",") + toString(rs);
+                           [](const std::string& ls, const aidl_enum_type& rs) {
+                               return ls + (ls.empty() ? "" : ",") + toString(rs);
                            });
 }
 
diff --git a/automotive/evs/aidl/vts/VtsHalEvsTargetTest.cpp b/automotive/evs/aidl/vts/VtsHalEvsTargetTest.cpp
index 3419b3c..477de31 100644
--- a/automotive/evs/aidl/vts/VtsHalEvsTargetTest.cpp
+++ b/automotive/evs/aidl/vts/VtsHalEvsTargetTest.cpp
@@ -1399,6 +1399,12 @@
 
     // Test each reported camera
     for (auto&& cam : mCameraInfo) {
+        bool isLogicalCam = false;
+        if (getPhysicalCameraIds(cam.id, isLogicalCam); isLogicalCam) {
+            LOG(INFO) << "Skip a logical device, " << cam.id;
+            continue;
+        }
+
         // Request available display IDs
         uint8_t targetDisplayId = 0;
         std::vector<uint8_t> displayIds;
@@ -1973,6 +1979,13 @@
 
     // Test each reported camera
     for (auto&& cam : mCameraInfo) {
+        bool isLogicalCam = false;
+        getPhysicalCameraIds(cam.id, isLogicalCam);
+        if (isLogicalCam) {
+            LOG(INFO) << "Skip a logical device, " << cam.id;
+            continue;
+        }
+
         // Read a target resolution from the metadata
         Stream targetCfg = getFirstStreamConfiguration(
                 reinterpret_cast<camera_metadata_t*>(cam.metadata.data()));
@@ -2014,9 +2027,6 @@
             }
         }
 
-        bool isLogicalCam = false;
-        getPhysicalCameraIds(cam.id, isLogicalCam);
-
         std::shared_ptr<IEvsCamera> pCam;
         ASSERT_TRUE(mEnumerator->openCamera(cam.id, targetCfg, &pCam).isOk());
         EXPECT_NE(pCam, nullptr);
@@ -2027,11 +2037,6 @@
         // Request to import buffers
         int delta = 0;
         auto status = pCam->importExternalBuffers(buffers, &delta);
-        if (isLogicalCam) {
-            ASSERT_FALSE(status.isOk());
-            continue;
-        }
-
         ASSERT_TRUE(status.isOk());
         EXPECT_GE(delta, kBuffersToHold);
 
diff --git a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
index be49a74..b598044 100644
--- a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
+++ b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
@@ -736,8 +736,7 @@
       ASSERT_NE(codec_info.id.getTag(), CodecId::a2dp);
       // The codec info must contain the information
       // for le audio transport.
-      // ASSERT_EQ(codec_info.transport.getTag(),
-      // CodecInfo::Transport::le_audio);
+      ASSERT_EQ(codec_info.transport.getTag(), CodecInfo::Transport::leAudio);
     }
   }
 }
@@ -1664,7 +1663,7 @@
 TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,
        StartAndEndA2dpSbcEncodingHardwareSession) {
   if (!IsOffloadSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   CodecConfiguration codec_config = {
@@ -1694,7 +1693,7 @@
 TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,
        StartAndEndA2dpAacEncodingHardwareSession) {
   if (!IsOffloadSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   CodecConfiguration codec_config = {
@@ -1724,7 +1723,7 @@
 TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,
        StartAndEndA2dpLdacEncodingHardwareSession) {
   if (!IsOffloadSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   CodecConfiguration codec_config = {
@@ -1754,7 +1753,7 @@
 TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,
        StartAndEndA2dpOpusEncodingHardwareSession) {
   if (!IsOffloadSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   CodecConfiguration codec_config = {
@@ -1784,7 +1783,7 @@
 TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,
        StartAndEndA2dpAptxEncodingHardwareSession) {
   if (!IsOffloadSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   for (auto codec_type : {CodecType::APTX, CodecType::APTX_HD}) {
@@ -1820,7 +1819,7 @@
 TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,
        StartAndEndA2dpEncodingHardwareSessionInvalidCodecConfig) {
   if (!IsOffloadSupported()) {
-    return;
+    GTEST_SKIP();
   }
   ASSERT_NE(audio_provider_, nullptr);
 
@@ -2420,7 +2419,7 @@
     BluetoothAudioProviderLeAudioOutputHardwareAidl,
     StartAndEndLeAudioOutputSessionWithPossibleUnicastConfigFromProviderInfo) {
   if (!IsOffloadOutputProviderInfoSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   auto lc3_codec_configs = GetUnicastLc3SupportedListFromProviderInfo();
@@ -2548,7 +2547,7 @@
 TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl,
        StartAndEndLeAudioOutputSessionWithPossibleUnicastConfig) {
   if (!IsOffloadOutputSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   auto lc3_codec_configs =
@@ -2581,7 +2580,7 @@
 TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl,
        DISABLED_StartAndEndLeAudioOutputSessionWithInvalidAudioConfiguration) {
   if (!IsOffloadOutputSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   auto lc3_codec_configs =
@@ -2619,7 +2618,7 @@
 TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl,
        StartAndEndLeAudioOutputSessionWithAptxAdaptiveLeUnicastConfig) {
   if (!IsOffloadOutputSupported()) {
-    return;
+    GTEST_SKIP();
   }
   for (auto codec_type :
        {CodecType::APTX_ADAPTIVE_LE, CodecType::APTX_ADAPTIVE_LEX}) {
@@ -2656,7 +2655,7 @@
     BluetoothAudioProviderLeAudioOutputHardwareAidl,
     BluetoothAudioProviderLeAudioOutputHardwareAidl_StartAndEndLeAudioOutputSessionWithInvalidAptxAdaptiveLeAudioConfiguration) {
   if (!IsOffloadOutputSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   for (auto codec_type :
@@ -2742,7 +2741,7 @@
     BluetoothAudioProviderLeAudioInputHardwareAidl,
     StartAndEndLeAudioInputSessionWithPossibleUnicastConfigFromProviderInfo) {
   if (!IsOffloadOutputProviderInfoSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   auto lc3_codec_configs = GetUnicastLc3SupportedListFromProviderInfo();
@@ -2772,7 +2771,7 @@
 TEST_P(BluetoothAudioProviderLeAudioInputHardwareAidl,
        StartAndEndLeAudioInputSessionWithPossibleUnicastConfig) {
   if (!IsOffloadInputSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   auto lc3_codec_configs =
@@ -2805,7 +2804,7 @@
 TEST_P(BluetoothAudioProviderLeAudioInputHardwareAidl,
        DISABLED_StartAndEndLeAudioInputSessionWithInvalidAudioConfiguration) {
   if (!IsOffloadInputSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   auto lc3_codec_configs =
@@ -3259,7 +3258,7 @@
 TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,
        StartAndEndA2dpSbcDecodingHardwareSession) {
   if (!IsOffloadSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   CodecConfiguration codec_config = {
@@ -3289,7 +3288,7 @@
 TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,
        StartAndEndA2dpAacDecodingHardwareSession) {
   if (!IsOffloadSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   CodecConfiguration codec_config = {
@@ -3319,7 +3318,7 @@
 TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,
        StartAndEndA2dpLdacDecodingHardwareSession) {
   if (!IsOffloadSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   CodecConfiguration codec_config = {
@@ -3349,7 +3348,7 @@
 TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,
        StartAndEndA2dpOpusDecodingHardwareSession) {
   if (!IsOffloadSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   CodecConfiguration codec_config = {
@@ -3379,7 +3378,7 @@
 TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,
        StartAndEndA2dpAptxDecodingHardwareSession) {
   if (!IsOffloadSupported()) {
-    return;
+    GTEST_SKIP();
   }
 
   for (auto codec_type : {CodecType::APTX, CodecType::APTX_HD}) {
@@ -3415,7 +3414,7 @@
 TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,
        StartAndEndA2dpDecodingHardwareSessionInvalidCodecConfig) {
   if (!IsOffloadSupported()) {
-    return;
+    GTEST_SKIP();
   }
   ASSERT_NE(audio_provider_, nullptr);
 
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
index 216e169..d37825a 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
@@ -428,7 +428,7 @@
   if (kDefaultOffloadLeAudioCodecInfoMap.empty()) {
     auto le_audio_offload_setting =
         BluetoothLeAudioCodecsProvider::ParseFromLeAudioOffloadSettingFile();
-    auto kDefaultOffloadLeAudioCodecInfoMap =
+    kDefaultOffloadLeAudioCodecInfoMap =
         BluetoothLeAudioCodecsProvider::GetLeAudioCodecInfo(
             le_audio_offload_setting);
   }
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp
index b6df67e..473777c 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp
@@ -43,9 +43,6 @@
 
 std::optional<setting::LeAudioOffloadSetting>
 BluetoothLeAudioCodecsProvider::ParseFromLeAudioOffloadSettingFile() {
-  if (!leAudioCodecCapabilities.empty() || isInvalidFileContent) {
-    return std::nullopt;
-  }
   auto le_audio_offload_setting =
       setting::readLeAudioOffloadSetting(kLeAudioCodecCapabilitiesFile);
   if (!le_audio_offload_setting.has_value()) {
@@ -77,8 +74,6 @@
   for (auto& p : configuration_map_) {
     // Initialize new CodecInfo for the config
     auto config_name = p.first;
-    if (config_codec_info_map_.count(config_name) == 0)
-      config_codec_info_map_[config_name] = CodecInfo();
 
     // Getting informations from codecConfig and strategyConfig
     const auto codec_config_name = p.second.getCodecConfiguration();
@@ -92,6 +87,9 @@
     if (strategy_configuration_map_iter == strategy_configuration_map_.end())
       continue;
 
+    if (config_codec_info_map_.count(config_name) == 0)
+      config_codec_info_map_[config_name] = CodecInfo();
+
     const auto& codec_config = codec_configuration_map_iter->second;
     const auto codec = codec_config.getCodec();
     const auto& strategy_config = strategy_configuration_map_iter->second;
@@ -137,12 +135,19 @@
     }
   }
 
-  // Goes through every scenario, deduplicate configuration
+  // Goes through every scenario, deduplicate configuration, skip the invalid
+  // config references (e.g. the "invalid" entries in the xml file).
   std::set<std::string> encoding_config, decoding_config, broadcast_config;
   for (auto& s : supported_scenarios_) {
-    if (s.hasEncode()) encoding_config.insert(s.getEncode());
-    if (s.hasDecode()) decoding_config.insert(s.getDecode());
-    if (s.hasBroadcast()) broadcast_config.insert(s.getBroadcast());
+    if (s.hasEncode() && config_codec_info_map_.count(s.getEncode())) {
+      encoding_config.insert(s.getEncode());
+    }
+    if (s.hasDecode() && config_codec_info_map_.count(s.getDecode())) {
+      decoding_config.insert(s.getDecode());
+    }
+    if (s.hasBroadcast() && config_codec_info_map_.count(s.getBroadcast())) {
+      broadcast_config.insert(s.getBroadcast());
+    }
   }
 
   // Split by session types and add results
diff --git a/media/c2/aidl/Android.bp b/media/c2/aidl/Android.bp
index 84cb382..b511e45 100644
--- a/media/c2/aidl/Android.bp
+++ b/media/c2/aidl/Android.bp
@@ -22,6 +22,9 @@
         "android.hardware.common-V2",
         "android.hardware.media.bufferpool2-V1",
     ],
+    include_dirs: [
+        "frameworks/native/aidl/gui",
+    ],
     stability: "vintf",
     backend: {
         cpp: {
diff --git a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponent.aidl b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponent.aidl
index 7d58340..4439bc5 100644
--- a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponent.aidl
+++ b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponent.aidl
@@ -45,6 +45,8 @@
   void reset();
   void start();
   void stop();
+  android.hardware.media.c2.IInputSurfaceConnection connectToInputSurface(in android.hardware.media.c2.IInputSurface inputSurface);
+  android.hardware.media.c2.IInputSink asInputSink();
   parcelable BlockPool {
     long blockPoolId;
     android.hardware.media.c2.IConfigurable configurable;
diff --git a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponentStore.aidl b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponentStore.aidl
index d1b5915..d7a4706 100644
--- a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponentStore.aidl
+++ b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponentStore.aidl
@@ -41,6 +41,7 @@
   android.hardware.media.bufferpool2.IClientManager getPoolClientManager();
   android.hardware.media.c2.StructDescriptor[] getStructDescriptors(in int[] indices);
   android.hardware.media.c2.IComponentStore.ComponentTraits[] listComponents();
+  android.hardware.media.c2.IInputSurface createInputSurface();
   @VintfStability
   parcelable ComponentTraits {
     String name;
diff --git a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSink.aidl b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSink.aidl
new file mode 100644
index 0000000..e6ea4d5
--- /dev/null
+++ b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSink.aidl
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.media.c2;
+@VintfStability
+interface IInputSink {
+  void queue(in android.hardware.media.c2.WorkBundle workBundle);
+}
diff --git a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSurface.aidl b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSurface.aidl
new file mode 100644
index 0000000..14455cb
--- /dev/null
+++ b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSurface.aidl
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.media.c2;
+@VintfStability
+interface IInputSurface {
+  android.view.Surface getSurface();
+  android.hardware.media.c2.IConfigurable getConfigurable();
+  android.hardware.media.c2.IInputSurfaceConnection connect(in android.hardware.media.c2.IInputSink sink);
+}
diff --git a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSurfaceConnection.aidl b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSurfaceConnection.aidl
new file mode 100644
index 0000000..28fff65
--- /dev/null
+++ b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSurfaceConnection.aidl
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.media.c2;
+@VintfStability
+interface IInputSurfaceConnection {
+  void disconnect();
+  void signalEndOfStream();
+}
diff --git a/media/c2/aidl/android/hardware/media/c2/IComponent.aidl b/media/c2/aidl/android/hardware/media/c2/IComponent.aidl
index e96cae5..6bd30b4 100644
--- a/media/c2/aidl/android/hardware/media/c2/IComponent.aidl
+++ b/media/c2/aidl/android/hardware/media/c2/IComponent.aidl
@@ -20,6 +20,9 @@
 import android.hardware.media.c2.IComponentInterface;
 import android.hardware.media.c2.IConfigurable;
 import android.hardware.media.c2.IGraphicBufferAllocator;
+import android.hardware.media.c2.IInputSink;
+import android.hardware.media.c2.IInputSurface;
+import android.hardware.media.c2.IInputSurfaceConnection;
 import android.hardware.media.c2.WorkBundle;
 import android.os.ParcelFileDescriptor;
 
@@ -307,4 +310,32 @@
      *   - `Status::CORRUPTED` - Some unknown error occurred.
      */
     void stop();
+
+    /**
+     * Starts using an input surface.
+     *
+     * The component must be in running state.
+     *
+     * @param inputSurface Input surface to connect to.
+     * @return connection `IInputSurfaceConnection` object, which can be used to
+     *     query and configure properties of the connection. This cannot be
+     *     null.
+     * @throws ServiceSpecificException with one of the following values:
+     *   - `Status::CANNOT_DO` - The component does not support an input surface.
+     *   - `Status::BAD_STATE` - The component is not in running state.
+     *   - `Status::DUPLICATE` - The component is already connected to an input surface.
+     *   - `Status::REFUSED`   - The input surface is already in use.
+     *   - `Status::NO_MEMORY` - Not enough memory to start the component.
+     *   - `Status::TIMED_OUT` - The operation cannot be finished in a timely manner.
+     *   - `Status::CORRUPTED` - Some unknown error occurred.
+     */
+    IInputSurfaceConnection connectToInputSurface(in IInputSurface inputSurface);
+
+    /**
+     * Returns an @ref IInputSink instance that has the component as the
+     * underlying implementation.
+     *
+     * @return sink `IInputSink` instance.
+     */
+    IInputSink asInputSink();
 }
diff --git a/media/c2/aidl/android/hardware/media/c2/IComponentStore.aidl b/media/c2/aidl/android/hardware/media/c2/IComponentStore.aidl
index 1435a7e..019405d 100644
--- a/media/c2/aidl/android/hardware/media/c2/IComponentStore.aidl
+++ b/media/c2/aidl/android/hardware/media/c2/IComponentStore.aidl
@@ -21,6 +21,7 @@
 import android.hardware.media.c2.IComponentInterface;
 import android.hardware.media.c2.IComponentListener;
 import android.hardware.media.c2.IConfigurable;
+import android.hardware.media.c2.IInputSurface;
 import android.hardware.media.c2.StructDescriptor;
 
 /**
@@ -182,4 +183,16 @@
      *   - `Status::CORRUPTED` - Some unknown error occurred.
      */
     ComponentTraits[] listComponents();
+
+    /**
+     * Creates a persistent input surface that can be used as an input surface
+     * for any IComponent instance
+     *
+     * @return IInputSurface A persistent input surface.
+     * @throws ServiceSpecificException with one of following values:
+     *   - `Status::NO_MEMORY` - Not enough memory to complete this method.
+     *   - `Status::TIMED_OUT` - The operation cannot be finished in a timely manner.
+     *   - `Status::CORRUPTED` - Some unknown error occurred.
+     */
+    IInputSurface createInputSurface();
 }
diff --git a/media/c2/aidl/android/hardware/media/c2/IInputSink.aidl b/media/c2/aidl/android/hardware/media/c2/IInputSink.aidl
new file mode 100644
index 0000000..eb8ad3d
--- /dev/null
+++ b/media/c2/aidl/android/hardware/media/c2/IInputSink.aidl
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+package android.hardware.media.c2;
+
+import android.hardware.media.c2.WorkBundle;
+
+/**
+ * An `IInputSink` is a receiver of work items.
+ *
+ * An @ref IComponent instance can present itself as an `IInputSink` via a thin
+ * wrapper.
+ *
+ * @sa IInputSurface, IComponent.
+ */
+@VintfStability
+interface IInputSink {
+    /**
+     * Feeds work to the sink.
+     *
+     * @param workBundle `WorkBundle` object containing a list of `Work` objects
+     *     to queue to the component.
+     * @throws ServiceSpecificException with one of the following values:
+     *   - `Status::BAD_INDEX` - Some component id in some `Worklet` is not valid.
+     *   - `Status::CANNOT_DO` - Tunneling has not been set up for this sink, but some
+     *                   `Work` object contains tunneling information.
+     *   - `Status::NO_MEMORY` - Not enough memory to queue @p workBundle.
+     *   - `Status::TIMED_OUT` - The operation cannot be finished in a timely manner.
+     *   - `Status::CORRUPTED` - Some unknown error occurred.
+     */
+    void queue(in WorkBundle workBundle);
+}
diff --git a/media/c2/aidl/android/hardware/media/c2/IInputSurface.aidl b/media/c2/aidl/android/hardware/media/c2/IInputSurface.aidl
new file mode 100644
index 0000000..77cb1fd
--- /dev/null
+++ b/media/c2/aidl/android/hardware/media/c2/IInputSurface.aidl
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+package android.hardware.media.c2;
+
+import android.hardware.media.c2.IConfigurable;
+import android.hardware.media.c2.IInputSink;
+import android.hardware.media.c2.IInputSurfaceConnection;
+import android.view.Surface;
+
+/**
+ * Input surface for a Codec2 component.
+ *
+ * An <em>input surface</em> is an instance of `IInputSurface`, which may be
+ * created by calling IComponentStore::createInputSurface(). Once created, the
+ * client may
+ *   1. write data to it via the `NativeWindow` interface; and
+ *   2. use it as input to a Codec2 encoder.
+ *
+ * @sa IInputSurfaceConnection, IComponentStore::createInputSurface(),
+ *     IComponent::connectToInputSurface().
+ */
+@VintfStability
+interface IInputSurface {
+    /**
+     * Returns the producer interface into the internal buffer queue.
+     *
+     * @return producer `Surface` instance(actually ANativeWindow). This must not
+     * be null.
+     */
+    Surface getSurface();
+
+    /**
+     * Returns the @ref IConfigurable instance associated to this input surface.
+     *
+     * @return configurable `IConfigurable` instance. This must not be null.
+     */
+    IConfigurable getConfigurable();
+
+    /**
+     * Connects the input surface to an input sink.
+     *
+     * This function is generally called from inside the implementation of
+     * IComponent::connectToInputSurface(), where @p sink is a thin wrapper of
+     * the component that consumes buffers from this surface.
+     *
+     * @param sink Input sink. See `IInputSink` for more information.
+     * @return connection `IInputSurfaceConnection` object. This must not be
+     *     null if @p status is `OK`.
+     * @throws ServiceSpecificException with one of following values:
+     *   - `Status::BAD_VALUE` - @p sink is invalid.
+     *   - `Status::CORRUPTED` - Some unknown error occurred.
+     */
+    IInputSurfaceConnection connect(in IInputSink sink);
+}
diff --git a/media/c2/aidl/android/hardware/media/c2/IInputSurfaceConnection.aidl b/media/c2/aidl/android/hardware/media/c2/IInputSurfaceConnection.aidl
new file mode 100644
index 0000000..36524eb
--- /dev/null
+++ b/media/c2/aidl/android/hardware/media/c2/IInputSurfaceConnection.aidl
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+package android.hardware.media.c2;
+
+/**
+ * Connection between an IInputSink and an IInpuSurface.
+ */
+@VintfStability
+interface IInputSurfaceConnection {
+    /**
+     * Destroys the connection between an input surface and a component.
+     *
+     * @throws ServiceSpecificException with one of following values:
+     *   - `Status::BAD_STATE` - The component is not in running state.
+     *   - `Status::NOT_FOUND` - The surface is not connected to a component.
+     *   - `Status::CORRUPTED` - Some unknown error occurred.
+     */
+    void disconnect();
+
+    /**
+     * Signal the end of stream.
+
+     * @throws ServiceSpecificException with one of following values:
+     *   - `Status::BAD_STATE` - The component is not in running state.
+     */
+    void signalEndOfStream();
+}
diff --git a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
index 4d997e6..b36735f 100644
--- a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
+++ b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
@@ -296,12 +296,6 @@
     res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
     EXPECT_TRUE(res.no_timeout);
     EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
-    if (nci_version == NCI_VERSION_2 && res.args->last_data_.size() > 13 &&
-        res.args->last_data_[13] == 0x00) {
-        // Wait for CORE_CONN_CREDITS_NTF
-        res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
-        EXPECT_TRUE(res.no_timeout);
-    }
     // Send an Error Data Packet
     cmd = INVALID_COMMAND;
     data = cmd;
diff --git a/power/aidl/vts/VtsHalPowerTargetTest.cpp b/power/aidl/vts/VtsHalPowerTargetTest.cpp
index c2216f8..907cf00 100644
--- a/power/aidl/vts/VtsHalPowerTargetTest.cpp
+++ b/power/aidl/vts/VtsHalPowerTargetTest.cpp
@@ -73,8 +73,6 @@
 
 const std::vector<int32_t> kEmptyTids = {};
 
-const std::vector<WorkDuration> kNoDurations = {};
-
 const std::vector<WorkDuration> kDurationsWithZero = {
         DurationWrapper(1000L, 1L),
         DurationWrapper(0L, 2L),
diff --git a/security/secretkeeper/default/Android.bp b/security/secretkeeper/default/Android.bp
index 1d75c74..d8ccb63 100644
--- a/security/secretkeeper/default/Android.bp
+++ b/security/secretkeeper/default/Android.bp
@@ -34,6 +34,7 @@
         "libauthgraph_core",
         "libauthgraph_hal",
         "libbinder_rs",
+        "libcoset",
         "liblog_rust",
         "libsecretkeeper_core_nostd",
         "libsecretkeeper_comm_nostd",
diff --git a/security/secretkeeper/default/src/lib.rs b/security/secretkeeper/default/src/lib.rs
index 412ad45..eb7817c 100644
--- a/security/secretkeeper/default/src/lib.rs
+++ b/security/secretkeeper/default/src/lib.rs
@@ -53,8 +53,12 @@
             let mut crypto_impls = boring::crypto_trait_impls();
             let storage_impl = Box::new(store::InMemoryStore::default());
             let sk_ta = Rc::new(RefCell::new(
-                SecretkeeperTa::new(&mut crypto_impls, storage_impl)
-                    .expect("Failed to create local Secretkeeper TA"),
+                SecretkeeperTa::new(
+                    &mut crypto_impls,
+                    storage_impl,
+                    coset::iana::EllipticCurve::Ed25519,
+                )
+                .expect("Failed to create local Secretkeeper TA"),
             ));
             let mut ag_ta = AuthGraphTa::new(
                 AuthGraphParticipant::new(crypto_impls, sk_ta.clone(), MAX_OPENED_SESSIONS)
diff --git a/wifi/netlinkinterceptor/aidl/default/InterceptorRelay.h b/wifi/netlinkinterceptor/aidl/default/InterceptorRelay.h
index 0178c90..915b5ff 100644
--- a/wifi/netlinkinterceptor/aidl/default/InterceptorRelay.h
+++ b/wifi/netlinkinterceptor/aidl/default/InterceptorRelay.h
@@ -18,6 +18,7 @@
 
 #include <libnl++/Socket.h>
 
+#include <atomic>
 #include <mutex>
 #include <thread>