[automerger skipped] Merge "KeyMint VTS: x25519 pubkey as SubjectPublicKeyInfo" into tm-dev am: 0df4365ca5 am: 65569764e1 -s ours am: 2f9e23116e -s ours

am skip reason: Merged-In Ib5157da6a986d957162fab60dbe927017cfdd703 with SHA-1 857158ba12 is already in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/18280783

Change-Id: I4546f97c3512fe5b1b333a602338841a50035618
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/automotive/evs/aidl/vts/VtsHalEvsTargetTest.cpp b/automotive/evs/aidl/vts/VtsHalEvsTargetTest.cpp
index 09e1088..9c6c573 100644
--- a/automotive/evs/aidl/vts/VtsHalEvsTargetTest.cpp
+++ b/automotive/evs/aidl/vts/VtsHalEvsTargetTest.cpp
@@ -19,9 +19,11 @@
 
 #include <aidl/Gtest.h>
 #include <aidl/Vintf.h>
+#include <aidl/android/hardware/automotive/evs/BnEvsEnumeratorStatusCallback.h>
 #include <aidl/android/hardware/automotive/evs/BufferDesc.h>
 #include <aidl/android/hardware/automotive/evs/CameraDesc.h>
 #include <aidl/android/hardware/automotive/evs/CameraParam.h>
+#include <aidl/android/hardware/automotive/evs/DeviceStatus.h>
 #include <aidl/android/hardware/automotive/evs/DisplayDesc.h>
 #include <aidl/android/hardware/automotive/evs/DisplayState.h>
 #include <aidl/android/hardware/automotive/evs/EvsEventDesc.h>
@@ -30,6 +32,7 @@
 #include <aidl/android/hardware/automotive/evs/IEvsCamera.h>
 #include <aidl/android/hardware/automotive/evs/IEvsDisplay.h>
 #include <aidl/android/hardware/automotive/evs/IEvsEnumerator.h>
+#include <aidl/android/hardware/automotive/evs/IEvsEnumeratorStatusCallback.h>
 #include <aidl/android/hardware/automotive/evs/IEvsUltrasonicsArray.h>
 #include <aidl/android/hardware/automotive/evs/ParameterRange.h>
 #include <aidl/android/hardware/automotive/evs/Stream.h>
@@ -77,11 +80,11 @@
 } RawStreamConfig;
 constexpr size_t kStreamCfgSz = sizeof(RawStreamConfig) / sizeof(int32_t);
 
-}  // namespace
-
+using ::aidl::android::hardware::automotive::evs::BnEvsEnumeratorStatusCallback;
 using ::aidl::android::hardware::automotive::evs::BufferDesc;
 using ::aidl::android::hardware::automotive::evs::CameraDesc;
 using ::aidl::android::hardware::automotive::evs::CameraParam;
+using ::aidl::android::hardware::automotive::evs::DeviceStatus;
 using ::aidl::android::hardware::automotive::evs::DisplayDesc;
 using ::aidl::android::hardware::automotive::evs::DisplayState;
 using ::aidl::android::hardware::automotive::evs::EvsEventDesc;
@@ -90,6 +93,7 @@
 using ::aidl::android::hardware::automotive::evs::IEvsCamera;
 using ::aidl::android::hardware::automotive::evs::IEvsDisplay;
 using ::aidl::android::hardware::automotive::evs::IEvsEnumerator;
+using ::aidl::android::hardware::automotive::evs::IEvsEnumeratorStatusCallback;
 using ::aidl::android::hardware::automotive::evs::IEvsUltrasonicsArray;
 using ::aidl::android::hardware::automotive::evs::ParameterRange;
 using ::aidl::android::hardware::automotive::evs::Stream;
@@ -99,6 +103,8 @@
 using ::aidl::android::hardware::graphics::common::PixelFormat;
 using std::chrono_literals::operator""s;
 
+}  // namespace
+
 // The main test class for EVS
 class EvsAidlTest : public ::testing::TestWithParam<std::string> {
   public:
@@ -239,6 +245,13 @@
         return targetCfg;
     }
 
+    class DeviceStatusCallback : public BnEvsEnumeratorStatusCallback {
+        ndk::ScopedAStatus deviceStatusChanged(const std::vector<DeviceStatus>&) override {
+            // This empty implementation returns always ok().
+            return ndk::ScopedAStatus::ok();
+        }
+    };
+
     // Every test needs access to the service
     std::shared_ptr<IEvsEnumerator> mEnumerator;
     // Empty unless/util loadCameraList() is called
@@ -528,7 +541,7 @@
         // Ask for a very large number of buffers in flight to ensure it errors correctly
         auto badResult = pCam->setMaxFramesInFlight(std::numeric_limits<int32_t>::max());
         EXPECT_TRUE(!badResult.isOk() && badResult.getServiceSpecificError() ==
-                                                 static_cast<int>(EvsResult::INVALID_ARG));
+                                                 static_cast<int>(EvsResult::BUFFER_NOT_AVAILABLE));
 
         // Now ask for exactly two buffers in flight as we'll test behavior in that case
         ASSERT_TRUE(pCam->setMaxFramesInFlight(kBuffersToHold).isOk());
@@ -2064,6 +2077,20 @@
     }
 }
 
+TEST_P(EvsAidlTest, DeviceStatusCallbackRegistration) {
+    std::shared_ptr<IEvsEnumeratorStatusCallback> cb =
+            ndk::SharedRefBase::make<DeviceStatusCallback>();
+    ndk::ScopedAStatus status = mEnumerator->registerStatusCallback(cb);
+    if (mIsHwModule) {
+        ASSERT_TRUE(status.isOk());
+    } else {
+        // A callback registration may fail if a HIDL EVS HAL implementation is
+        // running.
+        ASSERT_TRUE(status.isOk() ||
+                    status.getServiceSpecificError() == static_cast<int>(EvsResult::NOT_SUPPORTED));
+    }
+}
+
 /*
  * UltrasonicsArrayOpenClean:
  * Opens each ultrasonics arrays reported by the enumerator and then explicitly closes it via a
diff --git a/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.cpp b/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.cpp
index 911c928..c16ff54 100644
--- a/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.cpp
+++ b/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.cpp
@@ -91,17 +91,21 @@
   else if (session_type_ == SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH)
     buffer_modifier = kBufferInCount;
 
+  // 24 bit audio stream is sent as unpacked
+  int bytes_per_sample =
+      (pcm_config.bitsPerSample == 24) ? 4 : (pcm_config.bitsPerSample / 8);
+
   uint32_t data_mq_size =
       (ceil(pcm_config.sampleRateHz) / 1000) *
-      channel_mode_to_channel_count(pcm_config.channelMode) *
-      (pcm_config.bitsPerSample / 8) * (pcm_config.dataIntervalUs / 1000) *
-      buffer_modifier;
+      channel_mode_to_channel_count(pcm_config.channelMode) * bytes_per_sample *
+      (pcm_config.dataIntervalUs / 1000) * buffer_modifier;
   if (data_mq_size <= 0) {
     LOG(ERROR) << __func__ << "Unexpected audio buffer size: " << data_mq_size
                << ", SampleRateHz: " << pcm_config.sampleRateHz
                << ", ChannelMode: " << toString(pcm_config.channelMode)
                << ", BitsPerSample: "
                << static_cast<int>(pcm_config.bitsPerSample)
+               << ", BytesPerSample: " << bytes_per_sample
                << ", DataIntervalUs: " << pcm_config.dataIntervalUs
                << ", SessionType: " << toString(session_type_);
     return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);