Snap for 12406339 from e1d7073f4d10715e2e2be81fe0d999a16db3bd86 to 24Q4-release
Change-Id: I135a8c5afd1eec82efc7acedccec648e9004eace
diff --git a/audio/aidl/default/EffectContext.cpp b/audio/aidl/default/EffectContext.cpp
index 5539177..26c88b2 100644
--- a/audio/aidl/default/EffectContext.cpp
+++ b/audio/aidl/default/EffectContext.cpp
@@ -63,13 +63,18 @@
}
void EffectContext::dupeFmqWithReopen(IEffect::OpenEffectReturn* effectRet) {
+ const size_t inBufferSizeInFloat = mCommon.input.frameCount * mInputFrameSize / sizeof(float);
+ const size_t outBufferSizeInFloat =
+ mCommon.output.frameCount * mOutputFrameSize / sizeof(float);
+ const size_t bufferSize = std::max(inBufferSizeInFloat, outBufferSizeInFloat);
if (!mInputMQ) {
- mInputMQ = std::make_shared<DataMQ>(mCommon.input.frameCount * mInputFrameSize /
- sizeof(float));
+ mInputMQ = std::make_shared<DataMQ>(inBufferSizeInFloat);
}
if (!mOutputMQ) {
- mOutputMQ = std::make_shared<DataMQ>(mCommon.output.frameCount * mOutputFrameSize /
- sizeof(float));
+ mOutputMQ = std::make_shared<DataMQ>(outBufferSizeInFloat);
+ }
+ if (mWorkBuffer.size() != bufferSize) {
+ mWorkBuffer.resize(bufferSize);
}
dupeFmq(effectRet);
}
@@ -222,8 +227,6 @@
}
if (needUpdateMq) {
- mWorkBuffer.resize(std::max(common.input.frameCount * mInputFrameSize / sizeof(float),
- common.output.frameCount * mOutputFrameSize / sizeof(float)));
return notifyDataMqUpdate();
}
return RetCode::SUCCESS;
diff --git a/audio/aidl/default/Stream.cpp b/audio/aidl/default/Stream.cpp
index eecc972..3e4650d 100644
--- a/audio/aidl/default/Stream.cpp
+++ b/audio/aidl/default/Stream.cpp
@@ -47,6 +47,17 @@
namespace aidl::android::hardware::audio::core {
+namespace {
+
+template <typename MQTypeError>
+auto fmqErrorHandler(const char* mqName) {
+ return [m = std::string(mqName)](MQTypeError fmqError, std::string&& errorMessage) {
+ CHECK_EQ(fmqError, MQTypeError::NONE) << m << ": " << errorMessage;
+ };
+}
+
+} // namespace
+
void StreamContext::fillDescriptor(StreamDescriptor* desc) {
if (mCommandMQ) {
desc->command = mCommandMQ->dupeDesc();
@@ -332,11 +343,7 @@
bool StreamInWorkerLogic::read(size_t clientSize, StreamDescriptor::Reply* reply) {
ATRACE_CALL();
StreamContext::DataMQ* const dataMQ = mContext->getDataMQ();
- StreamContext::DataMQ::Error fmqError = StreamContext::DataMQ::Error::NONE;
- std::string fmqErrorMsg;
- const size_t byteCount = std::min(
- {clientSize, dataMQ->availableToWrite(&fmqError, &fmqErrorMsg), mDataBufferSize});
- CHECK(fmqError == StreamContext::DataMQ::Error::NONE) << fmqErrorMsg;
+ const size_t byteCount = std::min({clientSize, dataMQ->availableToWrite(), mDataBufferSize});
const bool isConnected = mIsConnected;
const size_t frameSize = mContext->getFrameSize();
size_t actualFrameCount = 0;
@@ -612,10 +619,7 @@
bool StreamOutWorkerLogic::write(size_t clientSize, StreamDescriptor::Reply* reply) {
ATRACE_CALL();
StreamContext::DataMQ* const dataMQ = mContext->getDataMQ();
- StreamContext::DataMQ::Error fmqError = StreamContext::DataMQ::Error::NONE;
- std::string fmqErrorMsg;
- const size_t readByteCount = dataMQ->availableToRead(&fmqError, &fmqErrorMsg);
- CHECK(fmqError == StreamContext::DataMQ::Error::NONE) << fmqErrorMsg;
+ const size_t readByteCount = dataMQ->availableToRead();
const size_t frameSize = mContext->getFrameSize();
bool fatal = false;
int32_t latency = mContext->getNominalLatencyMs();
@@ -719,6 +723,14 @@
LOG(WARNING) << __func__ << ": invalid worker tid: " << workerTid;
}
}
+ getContext().getCommandMQ()->setErrorHandler(
+ fmqErrorHandler<StreamContext::CommandMQ::Error>("CommandMQ"));
+ getContext().getReplyMQ()->setErrorHandler(
+ fmqErrorHandler<StreamContext::ReplyMQ::Error>("ReplyMQ"));
+ if (getContext().getDataMQ() != nullptr) {
+ getContext().getDataMQ()->setErrorHandler(
+ fmqErrorHandler<StreamContext::DataMQ::Error>("DataMQ"));
+ }
return ndk::ScopedAStatus::ok();
}
diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h b/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h
index ad14a9b..5916307 100644
--- a/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h
+++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h
@@ -49,11 +49,6 @@
class FakeVehicleHardware : public IVehicleHardware {
public:
- // Supports Suspend_to_ram.
- static constexpr int32_t SUPPORT_S2R = 0x1;
- // Supports Suspend_to_disk.
- static constexpr int32_t SUPPORT_S2D = 0x4;
-
using ValueResultType = VhalResult<VehiclePropValuePool::RecyclableType>;
FakeVehicleHardware();
@@ -61,6 +56,13 @@
FakeVehicleHardware(std::string defaultConfigDir, std::string overrideConfigDir,
bool forceOverride);
+ // s2rS2dConfig is the config for whether S2R or S2D is supported, must be a bit flag combining
+ // values from VehicleApPowerStateConfigFlag.
+ // The default implementation is reading this from system property:
+ // "ro.vendor.fake_vhal.ap_power_state_req.config".
+ FakeVehicleHardware(std::string defaultConfigDir, std::string overrideConfigDir,
+ bool forceOverride, int32_t s2rS2dConfig);
+
~FakeVehicleHardware();
// Get all the property configs.
@@ -122,12 +124,6 @@
bool UseOverrideConfigDir();
- // Gets the config whether S2R or S2D is supported, must returns a bit flag made up of
- // SUPPORT_S2R and SUPPORT_S2D, for example, 0x0 means no support, 0x5 means support both.
- // The default implementation is reading this from system property:
- // "ro.vendor.fake_vhal.ap_power_state_req.config".
- int32_t getS2rS2dConfig();
-
private:
// Expose private methods to unit test.
friend class FakeVehicleHardwareTestHelper;
@@ -204,7 +200,7 @@
// provides power controlling related properties.
std::string mPowerControllerServiceAddress = "";
- void init();
+ void init(int32_t s2rS2dConfig);
// Stores the initial value to property store.
void storePropInitialValue(const ConfigDeclaration& config);
// The callback that would be called when a vehicle property value change happens.
diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp
index 80c9620..6695d7a 100644
--- a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp
+++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp
@@ -348,6 +348,13 @@
FakeVehicleHardware::FakeVehicleHardware(std::string defaultConfigDir,
std::string overrideConfigDir, bool forceOverride)
+ : FakeVehicleHardware(defaultConfigDir, overrideConfigDir, forceOverride,
+ /*s2rS2dConfig=*/
+ GetIntProperty(POWER_STATE_REQ_CONFIG_PROPERTY, /*default_value=*/0)) {}
+
+FakeVehicleHardware::FakeVehicleHardware(std::string defaultConfigDir,
+ std::string overrideConfigDir, bool forceOverride,
+ int32_t s2rS2dConfig)
: mValuePool(std::make_unique<VehiclePropValuePool>()),
mServerSidePropStore(new VehiclePropertyStore(mValuePool)),
mDefaultConfigDir(defaultConfigDir),
@@ -360,7 +367,7 @@
mPendingGetValueRequests(this),
mPendingSetValueRequests(this),
mForceOverride(forceOverride) {
- init();
+ init(s2rS2dConfig);
}
FakeVehicleHardware::~FakeVehicleHardware() {
@@ -388,7 +395,7 @@
return configsByPropId;
}
-void FakeVehicleHardware::init() {
+void FakeVehicleHardware::init(int32_t s2rS2dConfig) {
maybeGetGrpcServiceInfo(&mPowerControllerServiceAddress);
for (auto& [_, configDeclaration] : loadConfigDeclarations()) {
@@ -396,7 +403,7 @@
VehiclePropertyStore::TokenFunction tokenFunction = nullptr;
if (cfg.prop == toInt(VehicleProperty::AP_POWER_STATE_REQ)) {
- cfg.configArray[0] = getS2rS2dConfig();
+ cfg.configArray[0] = s2rS2dConfig;
} else if (cfg.prop == OBD2_FREEZE_FRAME) {
tokenFunction = [](const VehiclePropValue& propValue) { return propValue.timestamp; };
}
@@ -425,10 +432,6 @@
});
}
-int32_t FakeVehicleHardware::getS2rS2dConfig() {
- return GetIntProperty(POWER_STATE_REQ_CONFIG_PROPERTY, /*default_value=*/0);
-}
-
std::vector<VehiclePropConfig> FakeVehicleHardware::getAllPropertyConfigs() const {
std::vector<VehiclePropConfig> allConfigs = mServerSidePropStore->getAllConfigs();
if (mAddExtraTestVendorConfigs) {
diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp b/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp
index 95647df..f6098ca 100644
--- a/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp
+++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp
@@ -20,6 +20,7 @@
#include <FakeUserHal.h>
#include <PropertyUtils.h>
+#include <aidl/android/hardware/automotive/vehicle/VehicleApPowerStateConfigFlag.h>
#include <aidl/android/hardware/automotive/vehicle/VehicleApPowerStateShutdownParam.h>
#include <android/hardware/automotive/vehicle/TestVendorProperty.h>
@@ -73,6 +74,7 @@
using ::aidl::android::hardware::automotive::vehicle::SetValueResult;
using ::aidl::android::hardware::automotive::vehicle::StatusCode;
using ::aidl::android::hardware::automotive::vehicle::SubscribeOptions;
+using ::aidl::android::hardware::automotive::vehicle::VehicleApPowerStateConfigFlag;
using ::aidl::android::hardware::automotive::vehicle::VehicleApPowerStateReport;
using ::aidl::android::hardware::automotive::vehicle::VehicleApPowerStateReq;
using ::aidl::android::hardware::automotive::vehicle::VehicleApPowerStateShutdownParam;
@@ -3863,6 +3865,25 @@
}
}
+TEST_F(FakeVehicleHardwareTest, testOverrideApPowerStateReqConfig) {
+ auto hardware = std::make_unique<FakeVehicleHardware>(
+ android::base::GetExecutableDirectory(),
+ /*overrideConfigDir=*/"",
+ /*forceOverride=*/false,
+ toInt(VehicleApPowerStateConfigFlag::ENABLE_DEEP_SLEEP_FLAG) |
+ toInt(VehicleApPowerStateConfigFlag::ENABLE_HIBERNATION_FLAG));
+
+ std::vector<VehiclePropConfig> configs = hardware->getAllPropertyConfigs();
+
+ for (const auto& config : configs) {
+ if (config.prop != toInt(VehicleProperty::AP_POWER_STATE_REQ)) {
+ continue;
+ }
+ ASSERT_EQ(config.configArray[0], 0x5);
+ break;
+ }
+}
+
} // namespace fake
} // namespace vehicle
} // namespace automotive