Merge "Add apex_defaults for consumerir HAL APEX" into main
diff --git a/audio/aidl/default/Configuration.cpp b/audio/aidl/default/Configuration.cpp
index 85e4e24..635a25b 100644
--- a/audio/aidl/default/Configuration.cpp
+++ b/audio/aidl/default/Configuration.cpp
@@ -237,7 +237,7 @@
c.ports.push_back(primaryOutMix);
AudioPort primaryInMix =
- createPort(c.nextPortId++, "primary input", 0, true, createPortMixExt(0, 0));
+ createPort(c.nextPortId++, "primary input", 0, true, createPortMixExt(0, 1));
primaryInMix.profiles.push_back(
createProfile(PcmType::INT_16_BIT,
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO},
@@ -252,14 +252,14 @@
c.ports.push_back(telephonyTxOutMix);
AudioPort telephonyRxInMix =
- createPort(c.nextPortId++, "telephony_rx", 0, true, createPortMixExt(1, 1));
+ createPort(c.nextPortId++, "telephony_rx", 0, true, createPortMixExt(0, 1));
telephonyRxInMix.profiles.insert(telephonyRxInMix.profiles.begin(),
standardPcmAudioProfiles.begin(),
standardPcmAudioProfiles.end());
c.ports.push_back(telephonyRxInMix);
AudioPort fmTunerInMix =
- createPort(c.nextPortId++, "fm_tuner", 0, true, createPortMixExt(1, 1));
+ createPort(c.nextPortId++, "fm_tuner", 0, true, createPortMixExt(0, 1));
fmTunerInMix.profiles.insert(fmTunerInMix.profiles.begin(),
standardPcmAudioProfiles.begin(),
standardPcmAudioProfiles.end());
@@ -441,7 +441,7 @@
c.ports.push_back(usbDeviceOutMix);
AudioPort usbDeviceInMix =
- createPort(c.nextPortId++, "usb_device input", 0, true, createPortMixExt(1, 1));
+ createPort(c.nextPortId++, "usb_device input", 0, true, createPortMixExt(0, 1));
c.ports.push_back(usbDeviceInMix);
c.routes.push_back(createRoute({usbDeviceOutMix}, usbOutDevice));
diff --git a/audio/aidl/default/Module.cpp b/audio/aidl/default/Module.cpp
index 3117134..76132b3 100644
--- a/audio/aidl/default/Module.cpp
+++ b/audio/aidl/default/Module.cpp
@@ -340,21 +340,43 @@
ndk::ScopedAStatus Module::updateStreamsConnectedState(const AudioPatch& oldPatch,
const AudioPatch& newPatch) {
- // Streams from the old patch need to be disconnected, streams from the new
- // patch need to be connected. If the stream belongs to both patches, no need
- // to update it.
+ // Notify streams about the new set of devices they are connected to.
auto maybeFailure = ndk::ScopedAStatus::ok();
- std::set<int32_t> idsToDisconnect, idsToConnect, idsToDisconnectOnFailure;
- idsToDisconnect.insert(oldPatch.sourcePortConfigIds.begin(),
- oldPatch.sourcePortConfigIds.end());
- idsToDisconnect.insert(oldPatch.sinkPortConfigIds.begin(), oldPatch.sinkPortConfigIds.end());
- idsToConnect.insert(newPatch.sourcePortConfigIds.begin(), newPatch.sourcePortConfigIds.end());
- idsToConnect.insert(newPatch.sinkPortConfigIds.begin(), newPatch.sinkPortConfigIds.end());
- std::for_each(idsToDisconnect.begin(), idsToDisconnect.end(), [&](const auto& portConfigId) {
- if (idsToConnect.count(portConfigId) == 0 && mStreams.count(portConfigId) != 0) {
- if (auto status = mStreams.setStreamConnectedDevices(portConfigId, {}); status.isOk()) {
+ using Connections =
+ std::map<int32_t /*mixPortConfigId*/, std::set<int32_t /*devicePortConfigId*/>>;
+ Connections oldConnections, newConnections;
+ auto fillConnectionsHelper = [&](Connections& connections,
+ const std::vector<int32_t>& mixPortCfgIds,
+ const std::vector<int32_t>& devicePortCfgIds) {
+ for (int32_t mixPortCfgId : mixPortCfgIds) {
+ connections[mixPortCfgId].insert(devicePortCfgIds.begin(), devicePortCfgIds.end());
+ }
+ };
+ auto fillConnections = [&](Connections& connections, const AudioPatch& patch) {
+ if (std::find_if(patch.sourcePortConfigIds.begin(), patch.sourcePortConfigIds.end(),
+ [&](int32_t portConfigId) { return mStreams.count(portConfigId) > 0; }) !=
+ patch.sourcePortConfigIds.end()) {
+ // Sources are mix ports.
+ fillConnectionsHelper(connections, patch.sourcePortConfigIds, patch.sinkPortConfigIds);
+ } else if (std::find_if(patch.sinkPortConfigIds.begin(), patch.sinkPortConfigIds.end(),
+ [&](int32_t portConfigId) {
+ return mStreams.count(portConfigId) > 0;
+ }) != patch.sinkPortConfigIds.end()) {
+ // Sources are device ports.
+ fillConnectionsHelper(connections, patch.sinkPortConfigIds, patch.sourcePortConfigIds);
+ } // Otherwise, there are no streams to notify.
+ };
+ fillConnections(oldConnections, oldPatch);
+ fillConnections(newConnections, newPatch);
+
+ std::for_each(oldConnections.begin(), oldConnections.end(), [&](const auto& connectionPair) {
+ const int32_t mixPortConfigId = connectionPair.first;
+ if (auto it = newConnections.find(mixPortConfigId);
+ it == newConnections.end() || it->second != connectionPair.second) {
+ if (auto status = mStreams.setStreamConnectedDevices(mixPortConfigId, {});
+ status.isOk()) {
LOG(DEBUG) << "updateStreamsConnectedState: The stream on port config id "
- << portConfigId << " has been disconnected";
+ << mixPortConfigId << " has been disconnected";
} else {
// Disconnection is tricky to roll back, just register a failure.
maybeFailure = std::move(status);
@@ -362,23 +384,26 @@
}
});
if (!maybeFailure.isOk()) return maybeFailure;
- std::for_each(idsToConnect.begin(), idsToConnect.end(), [&](const auto& portConfigId) {
- if (idsToDisconnect.count(portConfigId) == 0 && mStreams.count(portConfigId) != 0) {
- const auto connectedDevices = findConnectedDevices(portConfigId);
+ std::set<int32_t> idsToDisconnectOnFailure;
+ std::for_each(newConnections.begin(), newConnections.end(), [&](const auto& connectionPair) {
+ const int32_t mixPortConfigId = connectionPair.first;
+ if (auto it = oldConnections.find(mixPortConfigId);
+ it == oldConnections.end() || it->second != connectionPair.second) {
+ const auto connectedDevices = findConnectedDevices(mixPortConfigId);
if (connectedDevices.empty()) {
// This is important as workers use the vector size to derive the connection status.
LOG(FATAL) << "updateStreamsConnectedState: No connected devices found for port "
"config id "
- << portConfigId;
+ << mixPortConfigId;
}
- if (auto status = mStreams.setStreamConnectedDevices(portConfigId, connectedDevices);
+ if (auto status = mStreams.setStreamConnectedDevices(mixPortConfigId, connectedDevices);
status.isOk()) {
LOG(DEBUG) << "updateStreamsConnectedState: The stream on port config id "
- << portConfigId << " has been connected to: "
+ << mixPortConfigId << " has been connected to: "
<< ::android::internal::ToString(connectedDevices);
} else {
maybeFailure = std::move(status);
- idsToDisconnectOnFailure.insert(portConfigId);
+ idsToDisconnectOnFailure.insert(mixPortConfigId);
}
}
});
@@ -515,7 +540,7 @@
}
}
- connectedPort.id = ++getConfig().nextPortId;
+ connectedPort.id = getConfig().nextPortId++;
auto [connectedPortsIt, _] =
mConnectedDevicePorts.insert(std::pair(connectedPort.id, std::set<int32_t>()));
LOG(DEBUG) << __func__ << ": template port " << templateId << " external device connected, "
@@ -865,6 +890,7 @@
patches.push_back(*_aidl_return);
} else {
oldPatch = *existing;
+ *existing = *_aidl_return;
}
patchesBackup = mPatches;
registerPatch(*_aidl_return);
@@ -1277,6 +1303,12 @@
mmapSources.insert(port.id);
}
}
+ if (mmapSources.empty() && mmapSinks.empty()) {
+ AudioMMapPolicyInfo never;
+ never.mmapPolicy = AudioMMapPolicy::NEVER;
+ _aidl_return->push_back(never);
+ return ndk::ScopedAStatus::ok();
+ }
for (const auto& route : getConfig().routes) {
if (mmapSinks.count(route.sinkPortId) != 0) {
// The sink is a mix port, add the sources if they are device ports.
diff --git a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
index cd765d2..04c827b 100644
--- a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
@@ -87,6 +87,7 @@
using aidl::android::media::audio::common::AudioFormatType;
using aidl::android::media::audio::common::AudioIoFlags;
using aidl::android::media::audio::common::AudioLatencyMode;
+using aidl::android::media::audio::common::AudioMMapPolicy;
using aidl::android::media::audio::common::AudioMMapPolicyInfo;
using aidl::android::media::audio::common::AudioMMapPolicyType;
using aidl::android::media::audio::common::AudioMode;
@@ -1237,11 +1238,25 @@
const AudioPortConfig& portConfig2)
: mSrcPortConfig(sinkIsCfg1 ? portConfig2 : portConfig1),
mSinkPortConfig(sinkIsCfg1 ? portConfig1 : portConfig2) {}
+ WithAudioPatch(const WithAudioPatch& patch, const AudioPortConfig& srcPortConfig,
+ const AudioPortConfig& sinkPortConfig)
+ : mInitialPatch(patch.mPatch),
+ mSrcPortConfig(srcPortConfig),
+ mSinkPortConfig(sinkPortConfig),
+ mModule(patch.mModule),
+ mPatch(patch.mPatch) {}
WithAudioPatch(const WithAudioPatch&) = delete;
WithAudioPatch& operator=(const WithAudioPatch&) = delete;
~WithAudioPatch() {
if (mModule != nullptr && mPatch.id != 0) {
- EXPECT_IS_OK(mModule->resetAudioPatch(mPatch.id)) << "patch id " << getId();
+ if (mInitialPatch.has_value()) {
+ AudioPatch ignored;
+ // This releases our port configs so that they can be reset.
+ EXPECT_IS_OK(mModule->setAudioPatch(*mInitialPatch, &ignored))
+ << "patch id " << mInitialPatch->id;
+ } else {
+ EXPECT_IS_OK(mModule->resetAudioPatch(mPatch.id)) << "patch id " << getId();
+ }
}
}
void SetUpPortConfigs(IModule* module) {
@@ -1263,6 +1278,16 @@
EXPECT_GT(latencyMs, 0) << "patch id " << getId();
}
}
+ void VerifyAgainstAllPatches(IModule* module) {
+ std::vector<AudioPatch> allPatches;
+ ASSERT_IS_OK(module->getAudioPatches(&allPatches));
+ const auto& patchIt = findById(allPatches, getId());
+ ASSERT_NE(patchIt, allPatches.end()) << "patch id " << getId();
+ if (get() != *patchIt) {
+ FAIL() << "Stored patch: " << get().toString() << " is not the same as returned "
+ << "by the HAL module: " << patchIt->toString();
+ }
+ }
int32_t getId() const { return mPatch.id; }
const AudioPatch& get() const { return mPatch; }
const AudioPortConfig& getSinkPortConfig() const { return mSinkPortConfig.get(); }
@@ -1272,6 +1297,7 @@
}
private:
+ std::optional<AudioPatch> mInitialPatch;
WithAudioPortConfig mSrcPortConfig;
WithAudioPortConfig mSinkPortConfig;
IModule* mModule = nullptr;
@@ -2133,7 +2159,13 @@
std::vector<AudioMMapPolicyInfo> policyInfos;
EXPECT_IS_OK(module->getMmapPolicyInfos(mmapPolicyType, &policyInfos))
<< toString(mmapPolicyType);
- EXPECT_EQ(isMmapSupported, !policyInfos.empty());
+ const bool isMMapSupportedByPolicyInfos =
+ std::find_if(policyInfos.begin(), policyInfos.end(), [](const auto& info) {
+ return info.mmapPolicy == AudioMMapPolicy::AUTO ||
+ info.mmapPolicy == AudioMMapPolicy::ALWAYS;
+ }) != policyInfos.end();
+ EXPECT_EQ(isMmapSupported, isMMapSupportedByPolicyInfos)
+ << ::android::internal::ToString(policyInfos);
}
}
@@ -3630,9 +3662,12 @@
patches.push_back(
std::make_unique<WithAudioPatch>(srcSink.first, srcSink.second));
EXPECT_NO_FATAL_FAILURE(patches[patches.size() - 1]->SetUp(module.get()));
+ EXPECT_NO_FATAL_FAILURE(
+ patches[patches.size() - 1]->VerifyAgainstAllPatches(module.get()));
} else {
WithAudioPatch patch(srcSink.first, srcSink.second);
EXPECT_NO_FATAL_FAILURE(patch.SetUp(module.get()));
+ EXPECT_NO_FATAL_FAILURE(patch.VerifyAgainstAllPatches(module.get()));
}
}
}
@@ -3653,6 +3688,29 @@
}
}
+ void UpdatePatchPorts(bool isInput) {
+ auto srcSinkGroups = moduleConfig->getRoutableSrcSinkGroups(isInput);
+ if (srcSinkGroups.empty()) {
+ GTEST_SKIP() << "No routes to any attached " << direction(isInput, false) << " devices";
+ }
+ bool hasAtLeastOnePair = false;
+ for (const auto& srcSinkGroup : srcSinkGroups) {
+ const auto& srcSinks = srcSinkGroup.second;
+ if (srcSinks.size() < 2) continue;
+ hasAtLeastOnePair = true;
+ const auto& pair1 = srcSinks[0];
+ const auto& pair2 = srcSinks[1];
+ WithAudioPatch patch(pair1.first, pair1.second);
+ ASSERT_NO_FATAL_FAILURE(patch.SetUp(module.get()));
+ WithAudioPatch update(patch, pair2.first, pair2.second);
+ EXPECT_NO_FATAL_FAILURE(update.SetUp(module.get()));
+ EXPECT_NO_FATAL_FAILURE(update.VerifyAgainstAllPatches(module.get()));
+ }
+ if (!hasAtLeastOnePair) {
+ GTEST_SKIP() << "No routes with multiple sources";
+ }
+ }
+
void UpdateInvalidPatchId(bool isInput) {
auto srcSinkGroups = moduleConfig->getRoutableSrcSinkGroups(isInput);
if (srcSinkGroups.empty()) {
@@ -3692,6 +3750,7 @@
TEST_PATCH_BOTH_DIRECTIONS(SetPatch);
TEST_PATCH_BOTH_DIRECTIONS(UpdateInvalidPatchId);
TEST_PATCH_BOTH_DIRECTIONS(UpdatePatch);
+TEST_PATCH_BOTH_DIRECTIONS(UpdatePatchPorts);
TEST_P(AudioModulePatch, ResetInvalidPatchId) {
std::set<int32_t> patchIds;
@@ -4167,58 +4226,32 @@
class WithRemoteSubmix {
public:
WithRemoteSubmix() = default;
- WithRemoteSubmix(AudioDeviceAddress address) : mAddress(address) {}
+ explicit WithRemoteSubmix(AudioDeviceAddress address) : mAddress(address) {}
WithRemoteSubmix(const WithRemoteSubmix&) = delete;
WithRemoteSubmix& operator=(const WithRemoteSubmix&) = delete;
- std::optional<AudioPort> getAudioPort() {
+ static std::optional<AudioPort> getRemoteSubmixAudioPort(
+ ModuleConfig* moduleConfig,
+ const std::optional<AudioDeviceAddress>& address = std::nullopt) {
AudioDeviceType deviceType = IOTraits<Stream>::is_input ? AudioDeviceType::IN_SUBMIX
: AudioDeviceType::OUT_SUBMIX;
- auto ports = mModuleConfig->getAudioPortsForDeviceTypes(
+ auto ports = moduleConfig->getAudioPortsForDeviceTypes(
std::vector<AudioDeviceType>{deviceType},
AudioDeviceDescription::CONNECTION_VIRTUAL);
- if (!ports.empty()) return ports.front();
- return {};
- }
- /* Connect remote submix external device */
- void SetUpPortConnection() {
- auto port = getAudioPort();
- ASSERT_TRUE(port.has_value()) << "Device AudioPort for remote submix not found";
- if (mAddress.has_value()) {
- port.value().ext.template get<AudioPortExt::Tag::device>().device.address =
- mAddress.value();
+ if (ports.empty()) return {};
+ AudioPort port = ports.front();
+ if (address) {
+ port.ext.template get<AudioPortExt::Tag::device>().device.address = address.value();
} else {
- port = GenerateUniqueDeviceAddress(port.value());
+ port = GenerateUniqueDeviceAddress(port);
}
- mConnectedPort = std::make_unique<WithDevicePortConnectedState>(port.value());
- ASSERT_NO_FATAL_FAILURE(mConnectedPort->SetUp(mModule, mModuleConfig));
+ return port;
}
- AudioDeviceAddress getAudioDeviceAddress() {
- if (!mAddress.has_value()) {
- mAddress = mConnectedPort->get()
- .ext.template get<AudioPortExt::Tag::device>()
- .device.address;
- }
- return mAddress.value();
- }
- /* Get mix port config for stream and setup patch for it. */
- void SetupPatch() {
- const auto portConfig =
- mModuleConfig->getSingleConfigForMixPort(IOTraits<Stream>::is_input);
- if (!portConfig.has_value()) {
- LOG(DEBUG) << __func__ << ": portConfig not found";
- mSkipTest = true;
- return;
- }
- auto devicePortConfig = mModuleConfig->getSingleConfigForDevicePort(mConnectedPort->get());
- mPatch = std::make_unique<WithAudioPatch>(IOTraits<Stream>::is_input, portConfig.value(),
- devicePortConfig);
- ASSERT_NO_FATAL_FAILURE(mPatch->SetUp(mModule));
- }
- void SetUp(IModule* module, ModuleConfig* moduleConfig) {
+ std::optional<AudioDeviceAddress> getAudioDeviceAddress() const { return mAddress; }
+ void SetUp(IModule* module, ModuleConfig* moduleConfig, const AudioPort& connectedPort) {
mModule = module;
mModuleConfig = moduleConfig;
- ASSERT_NO_FATAL_FAILURE(SetUpPortConnection());
- ASSERT_NO_FATAL_FAILURE(SetupPatch());
+
+ ASSERT_NO_FATAL_FAILURE(SetupPatch(connectedPort));
if (!mSkipTest) {
// open stream
mStream = std::make_unique<WithStream<Stream>>(
@@ -4226,6 +4259,11 @@
ASSERT_NO_FATAL_FAILURE(
mStream->SetUp(mModule, AudioCoreModuleBase::kDefaultBufferSizeFrames));
}
+ mAddress = connectedPort.ext.template get<AudioPortExt::Tag::device>().device.address;
+ }
+ void SetUp(IModule* module, ModuleConfig* moduleConfig) {
+ ASSERT_NO_FATAL_FAILURE(SetUpPortConnection(module, moduleConfig));
+ SetUp(module, moduleConfig, mConnectedPort->get());
}
void sendBurstCommands() {
const StreamContext* context = mStream->getContext();
@@ -4243,9 +4281,31 @@
}
EXPECT_FALSE(driver.hasRetrogradeObservablePosition());
}
- bool skipTest() { return mSkipTest; }
+ bool skipTest() const { return mSkipTest; }
private:
+ /* Connect remote submix external device */
+ void SetUpPortConnection(IModule* module, ModuleConfig* moduleConfig) {
+ auto port = getRemoteSubmixAudioPort(moduleConfig, mAddress);
+ ASSERT_TRUE(port.has_value()) << "Device AudioPort for remote submix not found";
+ mConnectedPort = std::make_unique<WithDevicePortConnectedState>(port.value());
+ ASSERT_NO_FATAL_FAILURE(mConnectedPort->SetUp(module, moduleConfig));
+ }
+ /* Get mix port config for stream and setup patch for it. */
+ void SetupPatch(const AudioPort& connectedPort) {
+ const auto portConfig =
+ mModuleConfig->getSingleConfigForMixPort(IOTraits<Stream>::is_input);
+ if (!portConfig.has_value()) {
+ LOG(DEBUG) << __func__ << ": portConfig not found";
+ mSkipTest = true;
+ return;
+ }
+ auto devicePortConfig = mModuleConfig->getSingleConfigForDevicePort(connectedPort);
+ mPatch = std::make_unique<WithAudioPatch>(IOTraits<Stream>::is_input, portConfig.value(),
+ devicePortConfig);
+ ASSERT_NO_FATAL_FAILURE(mPatch->SetUp(mModule));
+ }
+
bool mSkipTest = false;
IModule* mModule = nullptr;
ModuleConfig* mModuleConfig = nullptr;
@@ -4283,9 +4343,11 @@
if (streamOut.skipTest()) {
GTEST_SKIP() << "No mix port for attached devices";
}
+ auto address = streamOut.getAudioDeviceAddress();
+ ASSERT_TRUE(address.has_value());
// open input stream
- WithRemoteSubmix<IStreamIn> streamIn(streamOut.getAudioDeviceAddress());
+ WithRemoteSubmix<IStreamIn> streamIn(address.value());
ASSERT_NO_FATAL_FAILURE(streamIn.SetUp(module.get(), moduleConfig.get()));
if (streamIn.skipTest()) {
GTEST_SKIP() << "No mix port for attached devices";
@@ -4302,9 +4364,11 @@
if (streamOut.skipTest()) {
GTEST_SKIP() << "No mix port for attached devices";
}
+ auto address = streamOut.getAudioDeviceAddress();
+ ASSERT_TRUE(address.has_value());
// open input stream
- WithRemoteSubmix<IStreamIn> streamIn(streamOut.getAudioDeviceAddress());
+ WithRemoteSubmix<IStreamIn> streamIn(address.value());
ASSERT_NO_FATAL_FAILURE(streamIn.SetUp(module.get(), moduleConfig.get()));
if (streamIn.skipTest()) {
GTEST_SKIP() << "No mix port for attached devices";
@@ -4316,6 +4380,43 @@
ASSERT_NO_FATAL_FAILURE(streamIn.sendBurstCommands());
}
+TEST_P(AudioModuleRemoteSubmix, OpenInputMultipleTimes) {
+ // open output stream
+ WithRemoteSubmix<IStreamOut> streamOut;
+ ASSERT_NO_FATAL_FAILURE(streamOut.SetUp(module.get(), moduleConfig.get()));
+ if (streamOut.skipTest()) {
+ GTEST_SKIP() << "No mix port for attached devices";
+ }
+ auto address = streamOut.getAudioDeviceAddress();
+ ASSERT_TRUE(address.has_value());
+
+ // connect remote submix input device port
+ auto port = WithRemoteSubmix<IStreamIn>::getRemoteSubmixAudioPort(moduleConfig.get(),
+ address.value());
+ ASSERT_TRUE(port.has_value()) << "Device AudioPort for remote submix not found";
+ WithDevicePortConnectedState connectedInputPort(port.value());
+ ASSERT_NO_FATAL_FAILURE(connectedInputPort.SetUp(module.get(), moduleConfig.get()));
+
+ // open input streams
+ const int streamInCount = 3;
+ std::vector<std::unique_ptr<WithRemoteSubmix<IStreamIn>>> streamIns(streamInCount);
+ for (int i = 0; i < streamInCount; i++) {
+ streamIns[i] = std::make_unique<WithRemoteSubmix<IStreamIn>>();
+ ASSERT_NO_FATAL_FAILURE(
+ streamIns[i]->SetUp(module.get(), moduleConfig.get(), connectedInputPort.get()));
+ if (streamIns[i]->skipTest()) {
+ GTEST_SKIP() << "No mix port for attached devices";
+ }
+ }
+ // write something to output stream
+ ASSERT_NO_FATAL_FAILURE(streamOut.sendBurstCommands());
+
+ // read from input streams
+ for (int i = 0; i < streamInCount; i++) {
+ ASSERT_NO_FATAL_FAILURE(streamIns[i]->sendBurstCommands());
+ }
+}
+
INSTANTIATE_TEST_SUITE_P(AudioModuleRemoteSubmixTest, AudioModuleRemoteSubmix,
::testing::ValuesIn(getRemoteSubmixModuleInstance()));
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AudioModuleRemoteSubmix);
diff --git a/automotive/sv/1.0/default/tests/fuzzer/AutomotiveSvV1_0Fuzzer.cpp b/automotive/sv/1.0/default/tests/fuzzer/AutomotiveSvV1_0Fuzzer.cpp
index 98834f5..4c4cc70 100644
--- a/automotive/sv/1.0/default/tests/fuzzer/AutomotiveSvV1_0Fuzzer.cpp
+++ b/automotive/sv/1.0/default/tests/fuzzer/AutomotiveSvV1_0Fuzzer.cpp
@@ -41,35 +41,32 @@
void SurroundViewFuzzer::invoke2dSessionAPI() {
sp<ISurroundView2dSession> surroundView2dSession;
+ sp<SurroundViewStream> handler;
+ mSurroundViewService->start2dSession(
+ [&surroundView2dSession](const sp<ISurroundView2dSession>& session, SvResult result) {
+ if (result == SvResult::OK) {
+ surroundView2dSession = session;
+ }
+ });
+
+ if (surroundView2dSession && !mIs2dStreamStarted) {
+ handler = sp<SurroundViewStream>::make(surroundView2dSession);
+ if (surroundView2dSession->startStream(handler) == SvResult::OK) {
+ mIs2dStreamStarted = true;
+ }
+ }
while (mFuzzedDataProvider.remaining_bytes() > 0) {
auto surroundView2dFunc = mFuzzedDataProvider.PickValueInArray<
const std::function<void()>>({
[&]() {
- mSurroundViewService->start2dSession(
- [&surroundView2dSession](const sp<ISurroundView2dSession>& session,
- SvResult result) {
- if (result == SvResult::OK) {
- surroundView2dSession = session;
- }
- });
- },
- [&]() {
- if (surroundView2dSession) {
- sp<SurroundViewStream> handler =
- sp<SurroundViewStream>::make(surroundView2dSession);
- surroundView2dSession->startStream(handler);
- mIs2dStreamStarted = true;
- }
- },
- [&]() {
if (surroundView2dSession) {
surroundView2dSession->get2dMappingInfo(
[]([[maybe_unused]] Sv2dMappingInfo info) {});
}
},
[&]() {
- if (surroundView2dSession) {
+ if (surroundView2dSession && mIs2dStreamStarted) {
Sv2dConfig config;
config.width = mFuzzedDataProvider.ConsumeIntegralInRange<uint32_t>(
kMinConfigDimension, kMaxConfigDimension);
@@ -149,8 +146,11 @@
}
},
[&]() {
- mSurroundViewService->stop2dSession(
+ SvResult result = mSurroundViewService->stop2dSession(
mFuzzedDataProvider.ConsumeBool() ? surroundView2dSession : nullptr);
+ if (result == SvResult::OK) {
+ mIs2dStreamStarted = false;
+ }
},
});
surroundView2dFunc();
@@ -159,31 +159,40 @@
if (surroundView2dSession && mIs2dStreamStarted) {
surroundView2dSession->stopStream();
}
+
+ if (surroundView2dSession) {
+ mSurroundViewService->stop2dSession(surroundView2dSession);
+ }
}
void SurroundViewFuzzer::invoke3dSessionAPI() {
sp<ISurroundView3dSession> surroundView3dSession;
+ sp<SurroundViewStream> handler;
+ mSurroundViewService->start3dSession(
+ [&surroundView3dSession](const sp<ISurroundView3dSession>& session, SvResult result) {
+ if (result == SvResult::OK) {
+ surroundView3dSession = session;
+ }
+ });
+
+ const size_t numViews = mFuzzedDataProvider.ConsumeIntegralInRange<size_t>(1, kMaxViews);
+ std::vector<View3d> views(numViews);
+ for (size_t i = 0; i < numViews; ++i) {
+ views[i].viewId = mFuzzedDataProvider.ConsumeIntegral<uint32_t>();
+ }
+ surroundView3dSession->setViews(views);
+
+ if (surroundView3dSession) {
+ handler = sp<SurroundViewStream>::make(surroundView3dSession);
+
+ if (surroundView3dSession->startStream(handler) == SvResult::OK) {
+ mIs3dStreamStarted = true;
+ }
+ }
while (mFuzzedDataProvider.remaining_bytes() > 0) {
auto surroundView3dFunc = mFuzzedDataProvider.PickValueInArray<
const std::function<void()>>({
[&]() {
- mSurroundViewService->start3dSession(
- [&surroundView3dSession](const sp<ISurroundView3dSession>& session,
- SvResult result) {
- if (result == SvResult::OK) {
- surroundView3dSession = session;
- }
- });
- },
- [&]() {
- if (surroundView3dSession) {
- sp<SurroundViewStream> handler =
- sp<SurroundViewStream>::make(surroundView3dSession);
- surroundView3dSession->startStream(handler);
- mIs3dStreamStarted = true;
- }
- },
- [&]() {
if (surroundView3dSession) {
const size_t numViews =
mFuzzedDataProvider.ConsumeIntegralInRange<size_t>(1, kMaxViews);
@@ -195,7 +204,7 @@
}
},
[&]() {
- if (surroundView3dSession) {
+ if (surroundView3dSession && mIs3dStreamStarted) {
Sv3dConfig config;
config.width = mFuzzedDataProvider.ConsumeIntegralInRange<uint32_t>(
kMinConfigDimension, kMaxConfigDimension);
@@ -306,8 +315,11 @@
}
},
[&]() {
- mSurroundViewService->stop3dSession(
+ SvResult result = mSurroundViewService->stop3dSession(
mFuzzedDataProvider.ConsumeBool() ? surroundView3dSession : nullptr);
+ if (result == SvResult::OK) {
+ mIs3dStreamStarted = false;
+ }
},
});
surroundView3dFunc();
@@ -315,6 +327,10 @@
if (surroundView3dSession && mIs3dStreamStarted) {
surroundView3dSession->stopStream();
}
+
+ if (surroundView3dSession) {
+ mSurroundViewService->stop3dSession(surroundView3dSession);
+ }
}
void SurroundViewFuzzer::process() {
diff --git a/automotive/vehicle/OWNERS b/automotive/vehicle/OWNERS
index 429ec39..d6969e5 100644
--- a/automotive/vehicle/OWNERS
+++ b/automotive/vehicle/OWNERS
@@ -1,3 +1,2 @@
ericjeong@google.com
-keunyoung@google.com
shanyu@google.com
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
index 3ed9e07..b4cba49 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
@@ -20,8 +20,6 @@
#include <aidl/android/hardware/bluetooth/audio/AacCapabilities.h>
#include <aidl/android/hardware/bluetooth/audio/AacObjectType.h>
-#include <aidl/android/hardware/bluetooth/audio/AptxAdaptiveLeCapabilities.h>
-#include <aidl/android/hardware/bluetooth/audio/AptxAdaptiveLeConfiguration.h>
#include <aidl/android/hardware/bluetooth/audio/AptxCapabilities.h>
#include <aidl/android/hardware/bluetooth/audio/ChannelMode.h>
#include <aidl/android/hardware/bluetooth/audio/LdacCapabilities.h>
@@ -100,55 +98,6 @@
std::vector<LeAudioCodecCapabilitiesSetting> kDefaultOffloadLeAudioCapabilities;
-static const UnicastCapability kInvalidUnicastCapability = {
- .codecType = CodecType::UNKNOWN};
-
-static const AptxAdaptiveLeCapabilities
- kDefaultOffloadAptxAdaptiveLeCapability_48k = {
- .samplingFrequencyHz = {48000},
- .frameDurationUs = {10000},
- .octetsPerFrame = {816}};
-
-static const AptxAdaptiveLeCapabilities
- kDefaultOffloadAptxAdaptiveLeCapability_96k = {
- .samplingFrequencyHz = {96000},
- .frameDurationUs = {10000},
- .octetsPerFrame = {816}};
-
-static const AptxAdaptiveLeCapabilities
- kDefaultOffloadAptxAdaptiveLeXCapability_48k = {
- .samplingFrequencyHz = {48000},
- .frameDurationUs = {10000},
- .octetsPerFrame = {816}};
-
-static const AptxAdaptiveLeCapabilities
- kDefaultOffloadAptxAdaptiveLeXCapability_96k = {
- .samplingFrequencyHz = {96000},
- .frameDurationUs = {10000},
- .octetsPerFrame = {816}};
-
-static const BroadcastCapability kInvalidBroadcastCapability = {
- .codecType = CodecType::UNKNOWN};
-
-static AudioLocation stereoAudio = static_cast<AudioLocation>(
- static_cast<uint8_t>(AudioLocation::FRONT_LEFT) |
- static_cast<uint8_t>(AudioLocation::FRONT_RIGHT));
-
-static const std::vector<AptxAdaptiveLeCapabilities>
- supportedAptxAdaptiveLeCapabilityList = {
- kDefaultOffloadAptxAdaptiveLeCapability_48k,
- kDefaultOffloadAptxAdaptiveLeCapability_96k,
- kDefaultOffloadAptxAdaptiveLeXCapability_48k,
- kDefaultOffloadAptxAdaptiveLeXCapability_96k};
-
-// Stores the supported setting of audio location, connected device, and the
-// channel count for each device
-std::vector<std::tuple<AudioLocation, uint8_t, uint8_t>>
- supportedDeviceSetting = {
- // Stereo, one connected device for both L and R
- std::make_tuple(stereoAudio, 1, 2),
-};
-
template <class T>
bool BluetoothAudioCodecs::ContainedInVector(
const std::vector<T>& vector, const typename identity<T>::type& target) {
@@ -458,32 +407,6 @@
kDefaultOffloadLeAudioCapabilities =
BluetoothLeAudioCodecsProvider::GetLeAudioCodecCapabilities(
le_audio_offload_setting);
-
- for (auto [audioLocation, deviceCnt, channelCount] :
- supportedDeviceSetting) {
- for (auto capability : supportedAptxAdaptiveLeCapabilityList) {
- for (auto codec_type :
- {CodecType::APTX_ADAPTIVE_LE, CodecType::APTX_ADAPTIVE_LEX}) {
- if (session_type ==
- SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
- UnicastCapability aptx_adaptive_le_cap = {
- .codecType = codec_type,
- .supportedChannel = audioLocation,
- .deviceCount = deviceCnt,
- .channelCountPerDevice = channelCount,
- .leAudioCodecCapabilities =
- UnicastCapability::LeAudioCodecCapabilities(capability),
- };
-
- // Adds the capability for encode only
- kDefaultOffloadLeAudioCapabilities.push_back(
- {.unicastEncodeCapability = aptx_adaptive_le_cap,
- .unicastDecodeCapability = kInvalidUnicastCapability,
- .broadcastCapability = kInvalidBroadcastCapability});
- }
- }
- }
- }
}
return kDefaultOffloadLeAudioCapabilities;
}
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp
index 0a804bb..26da5fb 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp
@@ -256,6 +256,15 @@
strategy_configuration_iter->second.getConnectedDevice(),
strategy_configuration_iter->second.getChannelCount(),
ComposeLc3Capability(codec_configuration_iter->second));
+ } else if (codec_type == CodecType::APTX_ADAPTIVE_LE ||
+ codec_type == CodecType::APTX_ADAPTIVE_LEX) {
+ return ComposeUnicastCapability(
+ codec_type,
+ GetAudioLocation(
+ strategy_configuration_iter->second.getAudioLocation()),
+ strategy_configuration_iter->second.getConnectedDevice(),
+ strategy_configuration_iter->second.getChannelCount(),
+ ComposeAptxAdaptiveLeCapability(codec_configuration_iter->second));
}
return {.codecType = CodecType::UNKNOWN};
}
@@ -330,6 +339,14 @@
.octetsPerFrame = {codec_configuration.getOctetsPerCodecFrame()}};
}
+AptxAdaptiveLeCapabilities
+BluetoothLeAudioCodecsProvider::ComposeAptxAdaptiveLeCapability(
+ const setting::CodecConfiguration& codec_configuration) {
+ return {.samplingFrequencyHz = {codec_configuration.getSamplingFrequency()},
+ .frameDurationUs = {codec_configuration.getFrameDurationUs()},
+ .octetsPerFrame = {codec_configuration.getOctetsPerCodecFrame()}};
+}
+
AudioLocation BluetoothLeAudioCodecsProvider::GetAudioLocation(
const setting::AudioLocation& audio_location) {
switch (audio_location) {
@@ -347,6 +364,10 @@
switch (codec_type) {
case setting::CodecType::LC3:
return CodecType::LC3;
+ case setting::CodecType::APTX_ADAPTIVE_LE:
+ return CodecType::APTX_ADAPTIVE_LE;
+ case setting::CodecType::APTX_ADAPTIVE_LEX:
+ return CodecType::APTX_ADAPTIVE_LEX;
default:
return CodecType::UNKNOWN;
}
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h
index 06e4595..654e70c 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h
+++ b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h
@@ -84,6 +84,9 @@
static inline Lc3Capabilities ComposeLc3Capability(
const setting::CodecConfiguration& codec_configuration);
+ static inline AptxAdaptiveLeCapabilities ComposeAptxAdaptiveLeCapability(
+ const setting::CodecConfiguration& codec_configuration);
+
static inline AudioLocation GetAudioLocation(
const setting::AudioLocation& audio_location);
static inline CodecType GetCodecType(const setting::CodecType& codec_type);
diff --git a/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xml b/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xml
index c8d1af0..eaace78 100644
--- a/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xml
+++ b/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xml
@@ -31,6 +31,10 @@
<scenario encode="OneChanMono_16_2" decode="invalid"/>
<scenario encode="TwoChanStereo_16_2" decode="invalid"/>
<scenario encode="OneChanStereo_16_2" decode="invalid"/>
+ <scenario encode="APEX_ADAPTIVE_LE_TwoChanStereo_48" decode="invalid"/>
+ <scenario encode="APEX_ADAPTIVE_LE_TwoChanStereo_96" decode="invalid"/>
+ <scenario encode="APEX_ADAPTIVE_LEX_TwoChanStereo_48" decode="invalid"/>
+ <scenario encode="APEX_ADAPTIVE_LEX_TwoChanStereo_96" decode="invalid"/>
<!-- encode and decode -->
<scenario encode="OneChanStereo_16_1" decode="OneChanStereo_16_1"/>
<scenario encode="OneChanStereo_16_1" decode="OneChanMono_16_1"/>
@@ -51,10 +55,18 @@
<configuration name="TwoChanStereo_16_2" codecConfiguration="LC3_16k_2" strategyConfiguration="STEREO_TWO_CISES_PER_DEVICE"/>
<configuration name="OneChanStereo_16_2" codecConfiguration="LC3_16k_2" strategyConfiguration="STEREO_ONE_CIS_PER_DEVICE"/>
<configuration name="BcastStereo_16_2" codecConfiguration="LC3_16k_2" strategyConfiguration="BROADCAST_STEREO"/>
+ <configuration name="APEX_ADAPTIVE_LE_TwoChanStereo_48" codecConfiguration="APTX_ADAPTIVE_LE_48k" strategyConfiguration="STEREO_TWO_CISES_PER_DEVICE"/>
+ <configuration name="APEX_ADAPTIVE_LE_TwoChanStereo_96" codecConfiguration="APTX_ADAPTIVE_LE_96k" strategyConfiguration="STEREO_TWO_CISES_PER_DEVICE"/>
+ <configuration name="APEX_ADAPTIVE_LEX_TwoChanStereo_48" codecConfiguration="APTX_ADAPTIVE_LEX_48k" strategyConfiguration="STEREO_TWO_CISES_PER_DEVICE"/>
+ <configuration name="APEX_ADAPTIVE_LEX_TwoChanStereo_96" codecConfiguration="APTX_ADAPTIVE_LEX_96k" strategyConfiguration="STEREO_TWO_CISES_PER_DEVICE"/>
</configurationList>
<codecConfigurationList>
<codecConfiguration name="LC3_16k_1" codec="LC3" samplingFrequency="16000" frameDurationUs="7500" octetsPerCodecFrame="30"/>
<codecConfiguration name="LC3_16k_2" codec="LC3" samplingFrequency="16000" frameDurationUs="10000" octetsPerCodecFrame="40"/>
+ <codecConfiguration name="APTX_ADAPTIVE_LE_48k" codec="APTX_ADAPTIVE_LE" samplingFrequency="48000" frameDurationUs="10000" octetsPerCodecFrame="816"/>
+ <codecConfiguration name="APTX_ADAPTIVE_LE_96k" codec="APTX_ADAPTIVE_LE" samplingFrequency="96000" frameDurationUs="10000" octetsPerCodecFrame="816"/>
+ <codecConfiguration name="APTX_ADAPTIVE_LEX_48k" codec="APTX_ADAPTIVE_LEX" samplingFrequency="48000" frameDurationUs="10000" octetsPerCodecFrame="816"/>
+ <codecConfiguration name="APTX_ADAPTIVE_LEX_96k" codec="APTX_ADAPTIVE_LEX" samplingFrequency="96000" frameDurationUs="10000" octetsPerCodecFrame="816"/>
</codecConfigurationList>
<strategyConfigurationList>
<strategyConfiguration name="STEREO_ONE_CIS_PER_DEVICE" audioLocation="STEREO" connectedDevice="2" channelCount="1"/>
diff --git a/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xsd b/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xsd
index 8c2d6a1..03c8ade 100644
--- a/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xsd
+++ b/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xsd
@@ -70,6 +70,8 @@
<xs:simpleType name="codecType">
<xs:restriction base="xs:string">
<xs:enumeration value="LC3"/>
+ <xs:enumeration value="APTX_ADAPTIVE_LE"/>
+ <xs:enumeration value="APTX_ADAPTIVE_LEX"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
diff --git a/bluetooth/audio/utils/le_audio_codec_capabilities/schema/current.txt b/bluetooth/audio/utils/le_audio_codec_capabilities/schema/current.txt
index 3cef417..a882174 100644
--- a/bluetooth/audio/utils/le_audio_codec_capabilities/schema/current.txt
+++ b/bluetooth/audio/utils/le_audio_codec_capabilities/schema/current.txt
@@ -32,6 +32,8 @@
public enum CodecType {
method public String getRawName();
+ enum_constant public static final aidl.android.hardware.bluetooth.audio.setting.CodecType APTX_ADAPTIVE_LE;
+ enum_constant public static final aidl.android.hardware.bluetooth.audio.setting.CodecType APTX_ADAPTIVE_LEX;
enum_constant public static final aidl.android.hardware.bluetooth.audio.setting.CodecType LC3;
}
diff --git a/boot/1.1/default/Android.bp b/boot/1.1/default/Android.bp
index e7a8d6e..0b0a5b7 100644
--- a/boot/1.1/default/Android.bp
+++ b/boot/1.1/default/Android.bp
@@ -20,7 +20,6 @@
srcs: ["BootControl.cpp"],
shared_libs: [
- "libbase",
"liblog",
"libhidlbase",
"libhardware",
diff --git a/boot/1.1/default/boot_control/Android.bp b/boot/1.1/default/boot_control/Android.bp
index d0dcb59..6aa30c2 100644
--- a/boot/1.1/default/boot_control/Android.bp
+++ b/boot/1.1/default/boot_control/Android.bp
@@ -35,13 +35,14 @@
],
shared_libs: [
+ "android.hardware.boot@1.1",
+ "libbase",
"liblog",
],
static_libs: [
"libbootloader_message",
"libfstab",
],
-
}
cc_library_static {
@@ -51,13 +52,7 @@
recovery_available: true,
vendor_available: true,
- srcs: [
- "libboot_control.cpp",
- ],
- static_libs: [
- "android.hardware.boot@1.1",
- "libbase",
- ],
+ srcs: ["libboot_control.cpp"],
}
cc_library_shared {
@@ -72,8 +67,6 @@
"libboot_control",
],
shared_libs: [
- "android.hardware.boot@1.1",
- "libbase",
"libhardware",
],
}
diff --git a/boot/1.2/default/Android.bp b/boot/1.2/default/Android.bp
index f1e9c34..4e1c35e 100644
--- a/boot/1.2/default/Android.bp
+++ b/boot/1.2/default/Android.bp
@@ -20,7 +20,6 @@
srcs: ["BootControl.cpp"],
shared_libs: [
- "libbase",
"liblog",
"libhidlbase",
"libhardware",
diff --git a/boot/aidl/default/Android.bp b/boot/aidl/default/Android.bp
index c1d3c57..dcb40db 100644
--- a/boot/aidl/default/Android.bp
+++ b/boot/aidl/default/Android.bp
@@ -27,77 +27,29 @@
name: "android.hardware.boot-service_common",
relative_install_path: "hw",
defaults: ["libboot_control_defaults"],
- srcs: [
- "main.cpp",
- "BootControl.cpp",
+ vintf_fragments: ["android.hardware.boot-service.default.xml"],
+ shared_libs: [
+ "libbase",
+ "libbinder_ndk",
+ "android.hardware.boot@1.1",
+ "android.hardware.boot-V1-ndk",
],
+ static_libs: [
+ "libboot_control",
+ ],
+ srcs: ["main.cpp", "BootControl.cpp"],
}
cc_binary {
name: "android.hardware.boot-service.default",
defaults: ["android.hardware.boot-service_common"],
+ init_rc: ["android.hardware.boot-service.default.rc"],
vendor: true,
-
- stl: "c++_static",
- shared_libs: [
- "libbinder_ndk",
- "liblog",
- ],
- static_libs: [
- "android.hardware.boot@1.1",
- "android.hardware.boot-V1-ndk",
- "libbase",
- "libboot_control",
- ],
-
- installable: false, // installed in APEX
}
cc_binary {
name: "android.hardware.boot-service.default_recovery",
defaults: ["android.hardware.boot-service_common"],
init_rc: ["android.hardware.boot-service.default_recovery.rc"],
- vintf_fragments: ["android.hardware.boot-service.default.xml"],
recovery: true,
-
- shared_libs: [
- "libbase",
- "libbinder_ndk",
- "android.hardware.boot@1.1",
- "android.hardware.boot-V1-ndk",
- ],
- static_libs: [
- "libboot_control",
- ],
-}
-
-prebuilt_etc {
- name: "android.hardware.boot-service.default.rc",
- src: "android.hardware.boot-service.default.rc",
- installable: false,
-}
-
-prebuilt_etc {
- name: "android.hardware.boot-service.default.xml",
- src: "android.hardware.boot-service.default.xml",
- sub_dir: "vintf",
- installable: false,
-}
-
-apex {
- name: "com.android.hardware.boot",
- vendor: true,
- manifest: "apex_manifest.json",
- file_contexts: "apex_file_contexts",
- key: "com.android.hardware.key",
- certificate: ":com.android.hardware.certificate",
- updatable: false,
-
- binaries: [
- "android.hardware.boot-service.default",
- ],
- prebuilts: [
- "android.hardware.boot-service.default.rc",
- "android.hardware.boot-service.default.xml",
- ],
}
diff --git a/boot/aidl/default/android.hardware.boot-service.default.rc b/boot/aidl/default/android.hardware.boot-service.default.rc
index 5090e2c..589f803 100644
--- a/boot/aidl/default/android.hardware.boot-service.default.rc
+++ b/boot/aidl/default/android.hardware.boot-service.default.rc
@@ -1,4 +1,4 @@
-service vendor.boot-default /apex/com.android.hardware.boot/bin/hw/android.hardware.boot-service.default
+service vendor.boot-default /vendor/bin/hw/android.hardware.boot-service.default
class early_hal
user root
group root
diff --git a/boot/aidl/default/apex_file_contexts b/boot/aidl/default/apex_file_contexts
deleted file mode 100644
index bf03585..0000000
--- a/boot/aidl/default/apex_file_contexts
+++ /dev/null
@@ -1,3 +0,0 @@
-(/.*)? u:object_r:vendor_file:s0
-/etc(/.*)? u:object_r:vendor_configs_file:s0
-/bin/hw/android\.hardware\.boot-service\.default u:object_r:hal_bootctl_default_exec:s0
diff --git a/boot/aidl/default/apex_manifest.json b/boot/aidl/default/apex_manifest.json
deleted file mode 100644
index 92661c9..0000000
--- a/boot/aidl/default/apex_manifest.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "name": "com.android.hardware.boot",
- "version": 1,
- "vendorBootstrap": true
-}
\ No newline at end of file
diff --git a/common/aidl/Android.bp b/common/aidl/Android.bp
index 7f6890c..1457b8a 100644
--- a/common/aidl/Android.bp
+++ b/common/aidl/Android.bp
@@ -36,6 +36,9 @@
],
min_sdk_version: "29",
},
+ rust: {
+ enabled: true,
+ },
},
frozen: true,
versions: [
diff --git a/common/fmq/aidl/Android.bp b/common/fmq/aidl/Android.bp
index 148c63c..ad86aaf 100644
--- a/common/fmq/aidl/Android.bp
+++ b/common/fmq/aidl/Android.bp
@@ -37,6 +37,9 @@
],
min_sdk_version: "29",
},
+ rust: {
+ enabled: true,
+ },
},
frozen: true,
versions_with_info: [
diff --git a/drm/1.0/vts/functional/Android.bp b/drm/1.0/vts/functional/Android.bp
index d6c37c5..e0c6fa5 100644
--- a/drm/1.0/vts/functional/Android.bp
+++ b/drm/1.0/vts/functional/Android.bp
@@ -111,13 +111,13 @@
data: [":libvtswidevine-arm-prebuilts"],
},
arm64: {
- data: [":libvtswidevine-arm64-prebuilts"],
+ data: [":libvtswidevine-arm64-prebuilts",":libvtswidevine-arm-prebuilts"],
},
x86: {
data: [":libvtswidevine-x86-prebuilts"],
},
x86_64: {
- data: [":libvtswidevine-x86_64-prebuilts"],
+ data: [":libvtswidevine-x86_64-prebuilts",":libvtswidevine-x86-prebuilts"],
},
},
test_suites: [
diff --git a/drm/1.1/vts/functional/Android.bp b/drm/1.1/vts/functional/Android.bp
index 760b67e..b539fa2 100644
--- a/drm/1.1/vts/functional/Android.bp
+++ b/drm/1.1/vts/functional/Android.bp
@@ -82,13 +82,13 @@
data: [":libvtswidevine-arm-prebuilts"],
},
arm64: {
- data: [":libvtswidevine-arm64-prebuilts"],
+ data: [":libvtswidevine-arm64-prebuilts",":libvtswidevine-arm-prebuilts"],
},
x86: {
data: [":libvtswidevine-x86-prebuilts"],
},
x86_64: {
- data: [":libvtswidevine-x86_64-prebuilts"],
+ data: [":libvtswidevine-x86_64-prebuilts",":libvtswidevine-x86-prebuilts"],
},
},
test_suites: [
diff --git a/drm/1.2/vts/functional/Android.bp b/drm/1.2/vts/functional/Android.bp
index 9a45051..9ceb1a3 100644
--- a/drm/1.2/vts/functional/Android.bp
+++ b/drm/1.2/vts/functional/Android.bp
@@ -100,13 +100,13 @@
data: [":libvtswidevine-arm-prebuilts"],
},
arm64: {
- data: [":libvtswidevine-arm64-prebuilts"],
+ data: [":libvtswidevine-arm64-prebuilts",":libvtswidevine-arm-prebuilts"],
},
x86: {
data: [":libvtswidevine-x86-prebuilts"],
},
x86_64: {
- data: [":libvtswidevine-x86_64-prebuilts"],
+ data: [":libvtswidevine-x86_64-prebuilts",":libvtswidevine-x86-prebuilts"],
},
},
test_suites: [
diff --git a/drm/1.3/vts/functional/Android.bp b/drm/1.3/vts/functional/Android.bp
index cd1cc0f..3db23e3 100644
--- a/drm/1.3/vts/functional/Android.bp
+++ b/drm/1.3/vts/functional/Android.bp
@@ -85,13 +85,13 @@
data: [":libvtswidevine-arm-prebuilts"],
},
arm64: {
- data: [":libvtswidevine-arm64-prebuilts"],
+ data: [":libvtswidevine-arm64-prebuilts",":libvtswidevine-arm-prebuilts"],
},
x86: {
data: [":libvtswidevine-x86-prebuilts"],
},
x86_64: {
- data: [":libvtswidevine-x86_64-prebuilts"],
+ data: [":libvtswidevine-x86_64-prebuilts",":libvtswidevine-x86-prebuilts"],
},
},
test_suites: [
diff --git a/drm/1.4/vts/functional/Android.bp b/drm/1.4/vts/functional/Android.bp
index e18d088..89edab7 100644
--- a/drm/1.4/vts/functional/Android.bp
+++ b/drm/1.4/vts/functional/Android.bp
@@ -88,13 +88,13 @@
data: [":libvtswidevine-arm-prebuilts"],
},
arm64: {
- data: [":libvtswidevine-arm64-prebuilts"],
+ data: [":libvtswidevine-arm64-prebuilts",":libvtswidevine-arm-prebuilts"],
},
x86: {
data: [":libvtswidevine-x86-prebuilts"],
},
x86_64: {
- data: [":libvtswidevine-x86_64-prebuilts"],
+ data: [":libvtswidevine-x86_64-prebuilts",":libvtswidevine-x86-prebuilts"],
},
},
test_suites: [
diff --git a/drm/aidl/vts/Android.bp b/drm/aidl/vts/Android.bp
index 190f60d..5139036 100644
--- a/drm/aidl/vts/Android.bp
+++ b/drm/aidl/vts/Android.bp
@@ -59,13 +59,13 @@
data: [":libvtswidevine-arm-prebuilts"],
},
arm64: {
- data: [":libvtswidevine-arm64-prebuilts"],
+ data: [":libvtswidevine-arm64-prebuilts", ":libvtswidevine-arm-prebuilts"],
},
x86: {
data: [":libvtswidevine-x86-prebuilts"],
},
x86_64: {
- data: [":libvtswidevine-x86_64-prebuilts"],
+ data: [":libvtswidevine-x86_64-prebuilts", ":libvtswidevine-x86-prebuilts"],
},
},
test_suites: [
diff --git a/health/1.0/default/convert.cpp b/health/1.0/default/convert.cpp
index 31b4679..e12e197 100644
--- a/health/1.0/default/convert.cpp
+++ b/health/1.0/default/convert.cpp
@@ -117,7 +117,7 @@
info.batteryCycleCount = p->batteryCycleCount;
info.batteryFullCharge = p->batteryFullCharge;
info.batteryChargeCounter = p->batteryChargeCounter;
- info.batteryTechnology = p->batteryTechnology;
+ info.batteryTechnology = p->batteryTechnology.c_str();
}
void convertFromHealthInfo(const HealthInfo& info,
diff --git a/media/bufferpool/aidl/Android.bp b/media/bufferpool/aidl/Android.bp
index b01cdbe..10de755 100644
--- a/media/bufferpool/aidl/Android.bp
+++ b/media/bufferpool/aidl/Android.bp
@@ -46,5 +46,8 @@
],
min_sdk_version: "29",
},
+ rust: {
+ enabled: true,
+ },
},
}
diff --git a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IGraphicBufferAllocator.aidl b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IGraphicBufferAllocator.aidl
index da3d5ff..3e460dd 100644
--- a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IGraphicBufferAllocator.aidl
+++ b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IGraphicBufferAllocator.aidl
@@ -36,7 +36,7 @@
interface IGraphicBufferAllocator {
android.hardware.media.c2.IGraphicBufferAllocator.Allocation allocate(in android.hardware.media.c2.IGraphicBufferAllocator.Description desc);
boolean deallocate(in long id);
- android.hardware.media.c2.IGraphicBufferAllocator.WaitableFds getWaitableFds();
+ ParcelFileDescriptor getWaitableFd();
parcelable Allocation {
android.hardware.HardwareBuffer buffer;
ParcelFileDescriptor fence;
@@ -47,8 +47,4 @@
int format;
long usage;
}
- parcelable WaitableFds {
- ParcelFileDescriptor allocEvent;
- ParcelFileDescriptor statusEvent;
- }
}
diff --git a/media/c2/aidl/android/hardware/media/c2/IGraphicBufferAllocator.aidl b/media/c2/aidl/android/hardware/media/c2/IGraphicBufferAllocator.aidl
index 1c97214..49c4ea4 100644
--- a/media/c2/aidl/android/hardware/media/c2/IGraphicBufferAllocator.aidl
+++ b/media/c2/aidl/android/hardware/media/c2/IGraphicBufferAllocator.aidl
@@ -75,31 +75,22 @@
boolean deallocate(in long id);
/**
- * Fds for waitable object events.
- *
- * Fds are created by eventfd() with semaphore mode.
- * For allocEvent, An integer counter regarding dequeuable buffer count is maintained
- * by client using read()/write() to the fd. The fd can be checked whether it is
- * readable via poll(). When in readable status, the specified counter is positive
- * so allocate/dequeue can happen.
- *
- * For statusEvent, the client can notify further allocation is not feasible.
- * e.g.) life-cycle of the underlying allocator is ended.
- *
- * C2Fence object should be implemented based on this Fds. Thus, C2Fence can return
- * either by allocation being ready or allocation being infeasible by the client status
- * change.
- */
- parcelable WaitableFds {
- ParcelFileDescriptor allocEvent;
- ParcelFileDescriptor statusEvent;
- }
-
- /**
- * Gets waiable file descriptors.
+ * Gets a waitable file descriptor.
*
* Use this method once and cache it in order not to create unnecessary duplicated fds.
- * The returned array will have two fds.
+ *
+ * Two file descriptors are created by pipe2(), and the reading end will be returned
+ * and shared by this method. Whenever a dequeuable buffer is ready a byte will be
+ * written to the writing end. Whenever a buffer is allocated(or dequeued) a byte will
+ * be read from the reading end.
+ *
+ * The returned file descriptor(the reading end) can be polled whether the read is ready
+ * via ::poll(). If no more allocate() can be fulfilled(by status change or etc.), the
+ * writing end will be closed. In the case, POLLHUP event can be retrieved via ::poll().
+ *
+ * C2Fence object should be implemented based on this Fd. Thus, C2Fence can return
+ * either by allocation being ready or allocation being infeasible by the client status
+ * change.
*
* If many waitable objects based on the same fd are competing, all watiable objects will be
* notified. After being notified, they should invoke allocate(). At least one of them can
@@ -110,5 +101,5 @@
* @return an fd array which will be wrapped to C2Fence and will be waited for
* until allocating is unblocked.
*/
- WaitableFds getWaitableFds();
+ ParcelFileDescriptor getWaitableFd();
}
diff --git a/uwb/aidl/default/Android.bp b/uwb/aidl/default/Android.bp
index c6d1a52..2b7ef57 100644
--- a/uwb/aidl/default/Android.bp
+++ b/uwb/aidl/default/Android.bp
@@ -20,6 +20,7 @@
"libbinder_rs",
"libbinder_tokio_rs",
"libtokio",
+ "libtokio_util",
"libnix",
"libanyhow",
],
diff --git a/uwb/aidl/default/src/uwb_chip.rs b/uwb/aidl/default/src/uwb_chip.rs
index 9587efb..b63aabe 100644
--- a/uwb/aidl/default/src/uwb_chip.rs
+++ b/uwb/aidl/default/src/uwb_chip.rs
@@ -4,32 +4,34 @@
};
use android_hardware_uwb::binder;
use async_trait::async_trait;
-use binder::{Result, Strong};
+use binder::{DeathRecipient, IBinder, Result, Strong};
-use tokio::fs::{File, OpenOptions};
-use tokio::io::{AsyncReadExt, AsyncWriteExt};
+use log::info;
+use std::sync::Arc;
+use tokio::io::unix::AsyncFd;
+use tokio::select;
use tokio::sync::Mutex;
+use tokio_util::sync::CancellationToken;
+use std::fs::{File, OpenOptions};
+use std::io::{self, Read, Write};
use std::os::fd::AsRawFd;
-use std::io;
-
-use nix::sys::termios;
-
enum State {
Closed,
Opened {
callbacks: Strong<dyn IUwbClientCallback>,
- #[allow(dead_code)]
- tasks: tokio::task::JoinSet<()>,
+ _handle: tokio::task::JoinHandle<()>,
serial: File,
+ death_recipient: DeathRecipient,
+ token: CancellationToken,
},
}
pub struct UwbChip {
name: String,
path: String,
- state: Mutex<State>,
+ state: Arc<Mutex<State>>,
}
impl UwbChip {
@@ -37,23 +39,59 @@
Self {
name,
path,
- state: Mutex::new(State::Closed),
+ state: Arc::new(Mutex::new(State::Closed)),
}
}
}
+impl State {
+ /// Terminate the reader task.
+ #[allow(dead_code)]
+ fn close(&mut self) -> Result<()> {
+ if let State::Opened { ref mut token, ref callbacks, ref mut death_recipient, .. } = *self {
+ log::info!("waiting for task cancellation");
+ callbacks.as_binder().unlink_to_death(death_recipient)?;
+ token.cancel();
+ log::info!("task successfully cancelled");
+ callbacks.onHalEvent(UwbEvent::CLOSE_CPLT, UwbStatus::OK)?;
+ *self = State::Closed;
+ }
+ Ok(())
+ }
+}
+
pub fn makeraw(file: File) -> io::Result<File> {
let fd = file.as_raw_fd();
- let mut attrs = termios::tcgetattr(fd)?;
+ // Configure the file descritpro as raw fd.
+ use nix::sys::termios::*;
+ let mut attrs = tcgetattr(fd)?;
+ cfmakeraw(&mut attrs);
+ tcsetattr(fd, SetArg::TCSANOW, &attrs)?;
- termios::cfmakeraw(&mut attrs);
-
- termios::tcsetattr(fd, termios::SetArg::TCSANOW, &attrs)?;
+ // Configure the file descriptor as non blocking.
+ use nix::fcntl::*;
+ let flags = OFlag::from_bits(fcntl(fd, FcntlArg::F_GETFL)?).unwrap();
+ fcntl(fd, FcntlArg::F_SETFL(flags | OFlag::O_NONBLOCK))?;
Ok(file)
}
+/// Wrapper around Read::read to handle EWOULDBLOCK.
+/// /!\ will actively wait for more data, make sure to call
+/// this method only when data is immediately expected.
+fn read_exact(file: &mut File, mut buf: &mut [u8]) -> io::Result<()> {
+ while buf.len() > 0 {
+ match file.read(buf) {
+ Ok(0) => panic!("unexpectedly reached end of file"),
+ Ok(read_len) => buf = &mut buf[read_len..],
+ Err(err) if err.kind() == io::ErrorKind::WouldBlock => continue,
+ Err(err) => return Err(err),
+ }
+ }
+ Ok(())
+}
+
impl binder::Interface for UwbChip {}
#[async_trait]
@@ -65,60 +103,109 @@
async fn open(&self, callbacks: &Strong<dyn IUwbClientCallback>) -> Result<()> {
log::debug!("open: {:?}", &self.path);
+ let mut state = self.state.lock().await;
+
+ if matches!(*state, State::Opened { .. }) {
+ log::error!("the state is already opened");
+ return Err(binder::ExceptionCode::ILLEGAL_STATE.into());
+ }
+
let serial = OpenOptions::new()
.read(true)
.write(true)
.create(false)
.open(&self.path)
- .await
.and_then(makeraw)
.map_err(|_| binder::StatusCode::UNKNOWN_ERROR)?;
- let mut state = self.state.lock().await;
+ let state_death_recipient = self.state.clone();
+ let mut death_recipient = DeathRecipient::new(move || {
+ let mut state = state_death_recipient.blocking_lock();
+ log::info!("Uwb service has died");
+ state.close().unwrap();
+ });
- if let State::Closed = *state {
- let client_callbacks = callbacks.clone();
+ callbacks.as_binder().link_to_death(&mut death_recipient)?;
- let mut tasks = tokio::task::JoinSet::new();
- let mut reader = serial
- .try_clone()
- .await
- .map_err(|_| binder::StatusCode::UNKNOWN_ERROR)?;
+ let token = CancellationToken::new();
+ let cloned_token = token.clone();
- tasks.spawn(async move {
- loop {
- const UWB_HEADER_SIZE: usize = 4;
+ let client_callbacks = callbacks.clone();
- let mut buffer = vec![0; UWB_HEADER_SIZE];
- reader
- .read_exact(&mut buffer[0..UWB_HEADER_SIZE])
- .await
- .unwrap();
+ let reader = serial
+ .try_clone()
+ .map_err(|_| binder::StatusCode::UNKNOWN_ERROR)?;
- let length = buffer[3] as usize + UWB_HEADER_SIZE;
+ let join_handle = tokio::task::spawn(async move {
+ info!("UCI reader task started");
+ let mut reader = AsyncFd::new(reader).unwrap();
- buffer.resize(length, 0);
- reader
- .read_exact(&mut buffer[UWB_HEADER_SIZE..length])
- .await
- .unwrap();
+ loop {
+ const UWB_HEADER_SIZE: usize = 4;
+ let mut buffer = vec![0; UWB_HEADER_SIZE];
- client_callbacks.onUciMessage(&buffer[..]).unwrap();
- }
- });
+ // The only time where the task can be safely
+ // cancelled is when no packet bytes have been read.
+ //
+ // - read_exact() cannot be used here since it is not
+ // cancellation safe.
+ // - read() cannot be used because it cannot be cancelled:
+ // the syscall is executed blocking on the threadpool
+ // and completes after termination of the task when
+ // the pipe receives more data.
+ let read_len = loop {
+ // On some platforms, the readiness detecting mechanism
+ // relies on edge-triggered notifications. This means that
+ // the OS will only notify Tokio when the file descriptor
+ // transitions from not-ready to ready. For this to work
+ // you should first try to read or write and only poll for
+ // readiness if that fails with an error of
+ // std::io::ErrorKind::WouldBlock.
+ match reader.get_mut().read(&mut buffer) {
+ Ok(0) => {
+ log::error!("file unexpectedly closed");
+ return;
+ }
+ Ok(read_len) => break read_len,
+ Err(err) if err.kind() == io::ErrorKind::WouldBlock => (),
+ Err(_) => panic!("unexpected read failure"),
+ }
- callbacks.onHalEvent(UwbEvent::OPEN_CPLT, UwbStatus::OK)?;
+ let mut guard = select! {
+ _ = cloned_token.cancelled() => {
+ info!("task is cancelled!");
+ return;
+ },
+ result = reader.readable() => result.unwrap()
+ };
- *state = State::Opened {
- callbacks: callbacks.clone(),
- tasks,
- serial,
- };
+ guard.clear_ready();
+ };
- Ok(())
- } else {
- Err(binder::ExceptionCode::ILLEGAL_STATE.into())
- }
+ // Read the remaining header bytes, if truncated.
+ read_exact(reader.get_mut(), &mut buffer[read_len..]).unwrap();
+
+ let length = buffer[3] as usize + UWB_HEADER_SIZE;
+ buffer.resize(length, 0);
+
+ // Read the payload bytes.
+ read_exact(reader.get_mut(), &mut buffer[UWB_HEADER_SIZE..]).unwrap();
+
+ client_callbacks.onUciMessage(&buffer).unwrap();
+ }
+ });
+
+ callbacks.onHalEvent(UwbEvent::OPEN_CPLT, UwbStatus::OK)?;
+
+ *state = State::Opened {
+ callbacks: callbacks.clone(),
+ _handle: join_handle,
+ serial,
+ death_recipient,
+ token,
+ };
+
+ Ok(())
}
async fn close(&self) -> Result<()> {
@@ -126,10 +213,8 @@
let mut state = self.state.lock().await;
- if let State::Opened { ref callbacks, .. } = *state {
- callbacks.onHalEvent(UwbEvent::CLOSE_CPLT, UwbStatus::OK)?;
- *state = State::Closed;
- Ok(())
+ if matches!(*state, State::Opened { .. }) {
+ state.close()
} else {
Err(binder::ExceptionCode::ILLEGAL_STATE.into())
}
@@ -162,7 +247,6 @@
if let State::Opened { ref mut serial, .. } = &mut *self.state.lock().await {
serial
.write(data)
- .await
.map(|written| written as i32)
.map_err(|_| binder::StatusCode::UNKNOWN_ERROR.into())
} else {