Merge "Remove deprecated warnings for SKIP_VALIDATE" into main
diff --git a/audio/aidl/default/Android.bp b/audio/aidl/default/Android.bp
index bb8d76f..af12e75 100644
--- a/audio/aidl/default/Android.bp
+++ b/audio/aidl/default/Android.bp
@@ -46,11 +46,20 @@
"SoundDose.cpp",
],
shared_libs: [
+ "libaudio_aidl_conversion_common_ndk",
+ "libaudioutils",
"libbase",
"libbinder_ndk",
"libcutils",
"libutils",
],
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ "-Wthread-safety",
+ "-DBACKEND_NDK",
+ ],
visibility: [
"//hardware/interfaces/audio/aidl/sounddose/default",
],
@@ -111,8 +120,12 @@
shared_libs: [
"android.hardware.bluetooth.audio-V3-ndk",
"libaudio_aidl_conversion_common_ndk",
+ "libaudioutils",
+ "libaudioutils_nonvndk",
"libbluetooth_audio_session_aidl",
+ "liblog",
"libmedia_helper",
+ "libmediautils_vendor",
"libstagefright_foundation",
],
export_shared_lib_headers: [
@@ -143,8 +156,10 @@
],
shared_libs: [
"android.hardware.bluetooth.audio-V3-ndk",
+ "libaudioutils_nonvndk",
"libaudio_aidl_conversion_common_ndk",
"libbluetooth_audio_session_aidl",
+ "liblog",
"libmedia_helper",
"libstagefright_foundation",
],
diff --git a/audio/aidl/default/Configuration.cpp b/audio/aidl/default/Configuration.cpp
index 635a25b..3c3dadb 100644
--- a/audio/aidl/default/Configuration.cpp
+++ b/audio/aidl/default/Configuration.cpp
@@ -105,15 +105,11 @@
return port;
}
-static AudioPortConfig createPortConfig(int32_t id, int32_t portId, PcmType pcmType, int32_t layout,
- int32_t sampleRate, int32_t flags, bool isInput,
- const AudioPortExt& ext) {
+static AudioPortConfig createDynamicPortConfig(int32_t id, int32_t portId, int32_t flags,
+ bool isInput, const AudioPortExt& ext) {
AudioPortConfig config;
config.id = id;
config.portId = portId;
- config.sampleRate = Int{.value = sampleRate};
- config.channelMask = AudioChannelLayout::make<AudioChannelLayout::layoutMask>(layout);
- config.format = AudioFormatDescription{.type = AudioFormatType::PCM, .pcm = pcmType};
config.gain = AudioGainConfig();
config.flags = isInput ? AudioIoFlags::make<AudioIoFlags::Tag::input>(flags)
: AudioIoFlags::make<AudioIoFlags::Tag::output>(flags);
@@ -121,6 +117,16 @@
return config;
}
+static AudioPortConfig createPortConfig(int32_t id, int32_t portId, PcmType pcmType, int32_t layout,
+ int32_t sampleRate, int32_t flags, bool isInput,
+ const AudioPortExt& ext) {
+ AudioPortConfig config = createDynamicPortConfig(id, portId, flags, isInput, ext);
+ config.sampleRate = Int{.value = sampleRate};
+ config.channelMask = AudioChannelLayout::make<AudioChannelLayout::layoutMask>(layout);
+ config.format = AudioFormatDescription{.type = AudioFormatType::PCM, .pcm = pcmType};
+ return config;
+}
+
static AudioRoute createRoute(const std::vector<AudioPort>& sources, const AudioPort& sink) {
AudioRoute route;
route.sinkPortId = sink.id;
@@ -147,8 +153,7 @@
// * "primary output", PRIMARY, 1 max open, 1 max active stream
// - profile PCM 16-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
// * "primary input", 1 max open, 1 max active stream
-// - profile PCM 16-bit; MONO, STEREO;
-// 8000, 11025, 16000, 32000, 44100, 48000
+// - profile PCM 16-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
// * "telephony_tx", 1 max open, 1 max active stream
// - profile PCM 16-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
// * "telephony_rx", 1 max open, 1 max active stream
@@ -164,11 +169,11 @@
// "FM Tuner" -> "fm_tuner"
//
// Initial port configs:
-// * "Speaker" device port: PCM 16-bit; STEREO; 48000
-// * "Built-In Mic" device port: PCM 16-bit; MONO; 48000
-// * "Telephony Tx" device port: PCM 16-bit; MONO; 48000
-// * "Telephony Rx" device port: PCM 16-bit; MONO; 48000
-// * "FM Tuner" device port: PCM 16-bit; STEREO; 48000
+// * "Speaker" device port: dynamic configuration
+// * "Built-In Mic" device port: dynamic configuration
+// * "Telephony Tx" device port: dynamic configuration
+// * "Telephony Rx" device port: dynamic configuration
+// * "FM Tuner" device port: dynamic configuration
//
std::unique_ptr<Configuration> getPrimaryConfiguration() {
static const Configuration configuration = []() {
@@ -186,9 +191,8 @@
1 << AudioPortDeviceExt::FLAG_INDEX_DEFAULT_DEVICE));
c.ports.push_back(speakerOutDevice);
c.initialConfigs.push_back(
- createPortConfig(speakerOutDevice.id, speakerOutDevice.id, PcmType::INT_16_BIT,
- AudioChannelLayout::LAYOUT_STEREO, 48000, 0, false,
- createDeviceExt(AudioDeviceType::OUT_SPEAKER, 0)));
+ createDynamicPortConfig(speakerOutDevice.id, speakerOutDevice.id, 0, false,
+ createDeviceExt(AudioDeviceType::OUT_SPEAKER, 0)));
AudioPort micInDevice =
createPort(c.nextPortId++, "Built-In Mic", 0, true,
@@ -196,35 +200,31 @@
1 << AudioPortDeviceExt::FLAG_INDEX_DEFAULT_DEVICE));
c.ports.push_back(micInDevice);
c.initialConfigs.push_back(
- createPortConfig(micInDevice.id, micInDevice.id, PcmType::INT_16_BIT,
- AudioChannelLayout::LAYOUT_MONO, 48000, 0, true,
- createDeviceExt(AudioDeviceType::IN_MICROPHONE, 0)));
+ createDynamicPortConfig(micInDevice.id, micInDevice.id, 0, true,
+ createDeviceExt(AudioDeviceType::IN_MICROPHONE, 0)));
AudioPort telephonyTxOutDevice =
createPort(c.nextPortId++, "Telephony Tx", 0, false,
createDeviceExt(AudioDeviceType::OUT_TELEPHONY_TX, 0));
c.ports.push_back(telephonyTxOutDevice);
c.initialConfigs.push_back(
- createPortConfig(telephonyTxOutDevice.id, telephonyTxOutDevice.id,
- PcmType::INT_16_BIT, AudioChannelLayout::LAYOUT_MONO, 48000, 0,
- false, createDeviceExt(AudioDeviceType::OUT_TELEPHONY_TX, 0)));
+ createDynamicPortConfig(telephonyTxOutDevice.id, telephonyTxOutDevice.id, 0, false,
+ createDeviceExt(AudioDeviceType::OUT_TELEPHONY_TX, 0)));
AudioPort telephonyRxInDevice =
createPort(c.nextPortId++, "Telephony Rx", 0, true,
createDeviceExt(AudioDeviceType::IN_TELEPHONY_RX, 0));
c.ports.push_back(telephonyRxInDevice);
c.initialConfigs.push_back(
- createPortConfig(telephonyRxInDevice.id, telephonyRxInDevice.id,
- PcmType::INT_16_BIT, AudioChannelLayout::LAYOUT_MONO, 48000, 0,
- true, createDeviceExt(AudioDeviceType::IN_TELEPHONY_RX, 0)));
+ createDynamicPortConfig(telephonyRxInDevice.id, telephonyRxInDevice.id, 0, true,
+ createDeviceExt(AudioDeviceType::IN_TELEPHONY_RX, 0)));
AudioPort fmTunerInDevice = createPort(c.nextPortId++, "FM Tuner", 0, true,
createDeviceExt(AudioDeviceType::IN_FM_TUNER, 0));
c.ports.push_back(fmTunerInDevice);
c.initialConfigs.push_back(
- createPortConfig(fmTunerInDevice.id, fmTunerInDevice.id, PcmType::INT_16_BIT,
- AudioChannelLayout::LAYOUT_STEREO, 48000, 0, true,
- createDeviceExt(AudioDeviceType::IN_FM_TUNER, 0)));
+ createDynamicPortConfig(fmTunerInDevice.id, fmTunerInDevice.id, 0, true,
+ createDeviceExt(AudioDeviceType::IN_FM_TUNER, 0)));
// Mix ports
@@ -287,13 +287,15 @@
// Note: When transitioning to loading of XML configs, either keep the configuration
// of the remote submix sources from this static configuration, or update the XML
-// config to match it. There are two reasons for that:
-// 1. The canonical r_submix configuration only lists 'STEREO' and '48000',
+// config to match it. There are several reasons for that:
+// 1. The "Remote Submix In" device is listed in the XML config as "attached",
+// however in the AIDL scheme its device type has a "virtual" connection.
+// 2. The canonical r_submix configuration only lists 'STEREO' and '48000',
// however the framework attempts to open streams for other sample rates
// as well. The legacy r_submix implementation allowed that, but libaudiohal@aidl
// will not find a mix port to use. Because of that, list all channel
// masks and sample rates that the legacy implementation allowed.
-// 2. The legacy implementation had a hard limit on the number of routes (10),
+// 3. The legacy implementation had a hard limit on the number of routes (10),
// and this is checked indirectly by AudioPlaybackCaptureTest#testPlaybackCaptureDoS
// CTS test. Instead of hardcoding the number of routes, we can use
// "maxOpen/ActiveStreamCount" to enforce a similar limit. However, the canonical
@@ -331,15 +333,15 @@
createPort(c.nextPortId++, "Remote Submix Out", 0, false,
createDeviceExt(AudioDeviceType::OUT_SUBMIX, 0,
AudioDeviceDescription::CONNECTION_VIRTUAL));
- rsubmixOutDevice.profiles = standardPcmAudioProfiles;
c.ports.push_back(rsubmixOutDevice);
+ c.connectedProfiles[rsubmixOutDevice.id] = standardPcmAudioProfiles;
AudioPort rsubmixInDevice =
createPort(c.nextPortId++, "Remote Submix In", 0, true,
createDeviceExt(AudioDeviceType::IN_SUBMIX, 0,
AudioDeviceDescription::CONNECTION_VIRTUAL));
- rsubmixInDevice.profiles = standardPcmAudioProfiles;
c.ports.push_back(rsubmixInDevice);
+ c.connectedProfiles[rsubmixInDevice.id] = standardPcmAudioProfiles;
// Mix ports
@@ -384,7 +386,7 @@
// * "usb_device output" -> "USB Headset Out"
// * "USB Device In", "USB Headset In" -> "usb_device input"
//
-// Profiles for device port connected state:
+// Profiles for device port connected state (when simulating connections):
// * "USB Device Out", "USB Headset Out":
// - profile PCM 16-bit; MONO, STEREO, INDEX_MASK_1, INDEX_MASK_2; 44100, 48000
// - profile PCM 24-bit; MONO, STEREO, INDEX_MASK_1, INDEX_MASK_2; 44100, 48000
@@ -461,9 +463,9 @@
// * "Test In", IN_AFE_PROXY
// - no profiles specified
// * "Wired Headset", OUT_HEADSET
-// - profile PCM 24-bit; STEREO; 48000
+// - no profiles specified
// * "Wired Headset Mic", IN_HEADSET
-// - profile PCM 24-bit; MONO; 48000
+// - no profiles specified
//
// Mix ports:
// * "test output", 1 max open, 1 max active stream
@@ -486,6 +488,10 @@
// * "Test Out" device port: PCM 24-bit; STEREO; 48000
// * "Test In" device port: PCM 24-bit; MONO; 48000
//
+// Profiles for device port connected state (when simulating connections):
+// * "Wired Headset": dynamic profiles
+// * "Wired Headset Mic": dynamic profiles
+//
std::unique_ptr<Configuration> getStubConfiguration() {
static const Configuration configuration = []() {
Configuration c;
@@ -504,8 +510,6 @@
createPort(c.nextPortId++, "Wired Headset", 0, false,
createDeviceExt(AudioDeviceType::OUT_HEADSET, 0,
AudioDeviceDescription::CONNECTION_ANALOG));
- headsetOutDevice.profiles.push_back(
- createProfile(PcmType::INT_24_BIT, {AudioChannelLayout::LAYOUT_STEREO}, {48000}));
c.ports.push_back(headsetOutDevice);
AudioPort testInDevice = createPort(c.nextPortId++, "Test In", 0, true,
@@ -520,8 +524,6 @@
createPort(c.nextPortId++, "Wired Headset Mic", 0, true,
createDeviceExt(AudioDeviceType::IN_HEADSET, 0,
AudioDeviceDescription::CONNECTION_ANALOG));
- headsetInDevice.profiles.push_back(
- createProfile(PcmType::INT_24_BIT, {AudioChannelLayout::LAYOUT_MONO}, {48000}));
c.ports.push_back(headsetInDevice);
// Mix ports
@@ -553,24 +555,24 @@
{44100, 48000}));
c.ports.push_back(compressedOffloadOutMix);
- AudioPort testInMIx =
+ AudioPort testInMix =
createPort(c.nextPortId++, "test input", 0, true, createPortMixExt(2, 2));
- testInMIx.profiles.push_back(
+ testInMix.profiles.push_back(
createProfile(PcmType::INT_16_BIT,
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO,
AudioChannelLayout::LAYOUT_FRONT_BACK},
{8000, 11025, 16000, 22050, 32000, 44100, 48000}));
- testInMIx.profiles.push_back(
+ testInMix.profiles.push_back(
createProfile(PcmType::INT_24_BIT,
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO,
AudioChannelLayout::LAYOUT_FRONT_BACK},
{8000, 11025, 16000, 22050, 32000, 44100, 48000}));
- c.ports.push_back(testInMIx);
+ c.ports.push_back(testInMix);
c.routes.push_back(
createRoute({testOutMix, testFastOutMix, compressedOffloadOutMix}, testOutDevice));
c.routes.push_back(createRoute({testOutMix}, headsetOutDevice));
- c.routes.push_back(createRoute({testInDevice, headsetInDevice}, testInMIx));
+ c.routes.push_back(createRoute({testInDevice, headsetInDevice}, testInMix));
c.portConfigs.insert(c.portConfigs.end(), c.initialConfigs.begin(), c.initialConfigs.end());
@@ -603,11 +605,19 @@
// "a2dp output" -> "BT A2DP Speaker"
// "hearing aid output" -> "BT Hearing Aid Out"
//
+// Profiles for device port connected state (when simulating connections):
+// * "BT A2DP Out", "BT A2DP Headphones", "BT A2DP Speaker":
+// - profile PCM 16-bit; STEREO; 44100, 48000, 88200, 96000
+// * "BT Hearing Aid Out":
+// - profile PCM 16-bit; STEREO; 16000, 24000
+//
std::unique_ptr<Configuration> getBluetoothConfiguration() {
static const Configuration configuration = []() {
const std::vector<AudioProfile> standardPcmAudioProfiles = {
createProfile(PcmType::INT_16_BIT, {AudioChannelLayout::LAYOUT_STEREO},
{44100, 48000, 88200, 96000})};
+ const std::vector<AudioProfile> hearingAidAudioProfiles = {createProfile(
+ PcmType::INT_16_BIT, {AudioChannelLayout::LAYOUT_STEREO}, {16000, 24000})};
Configuration c;
// Device ports
@@ -645,8 +655,7 @@
createDeviceExt(AudioDeviceType::OUT_HEARING_AID, 0,
AudioDeviceDescription::CONNECTION_WIRELESS));
c.ports.push_back(btOutHearingAid);
- c.connectedProfiles[btOutHearingAid.id] = std::vector<AudioProfile>(
- {createProfile(PcmType::INT_16_BIT, {AudioChannelLayout::LAYOUT_STEREO}, {16000})});
+ c.connectedProfiles[btOutHearingAid.id] = hearingAidAudioProfiles;
// Mix ports
AudioPort btOutMix =
@@ -655,8 +664,7 @@
AudioPort btHearingOutMix =
createPort(c.nextPortId++, "hearing aid output", 0, false, createPortMixExt(1, 1));
- btHearingOutMix.profiles.push_back(createProfile(
- PcmType::INT_16_BIT, {AudioChannelLayout::LAYOUT_STEREO}, {16000, 24000}));
+ btHearingOutMix.profiles = hearingAidAudioProfiles;
c.ports.push_back(btHearingOutMix);
c.routes.push_back(createRoute({btOutMix}, btOutDevice));
diff --git a/audio/aidl/default/Module.cpp b/audio/aidl/default/Module.cpp
index 76132b3..9fc99d4 100644
--- a/audio/aidl/default/Module.cpp
+++ b/audio/aidl/default/Module.cpp
@@ -65,32 +65,56 @@
namespace {
+inline bool hasDynamicChannelMasks(const std::vector<AudioChannelLayout>& channelMasks) {
+ return channelMasks.empty() ||
+ std::all_of(channelMasks.begin(), channelMasks.end(),
+ [](const auto& channelMask) { return channelMask == AudioChannelLayout{}; });
+}
+
+inline bool hasDynamicFormat(const AudioFormatDescription& format) {
+ return format == AudioFormatDescription{};
+}
+
+inline bool hasDynamicSampleRates(const std::vector<int32_t>& sampleRates) {
+ return sampleRates.empty() ||
+ std::all_of(sampleRates.begin(), sampleRates.end(),
+ [](const auto& sampleRate) { return sampleRate == 0; });
+}
+
+inline bool isDynamicProfile(const AudioProfile& profile) {
+ return hasDynamicFormat(profile.format) || hasDynamicChannelMasks(profile.channelMasks) ||
+ hasDynamicSampleRates(profile.sampleRates);
+}
+
+bool hasDynamicProfilesOnly(const std::vector<AudioProfile>& profiles) {
+ if (profiles.empty()) return true;
+ return std::all_of(profiles.begin(), profiles.end(), isDynamicProfile);
+}
+
+// Note: does not assign an ID to the config.
bool generateDefaultPortConfig(const AudioPort& port, AudioPortConfig* config) {
+ const bool allowDynamicConfig = port.ext.getTag() == AudioPortExt::device;
*config = {};
config->portId = port.id;
- if (port.profiles.empty()) {
- LOG(ERROR) << __func__ << ": port " << port.id << " has no profiles";
- return false;
+ for (const auto& profile : port.profiles) {
+ if (isDynamicProfile(profile)) continue;
+ config->format = profile.format;
+ config->channelMask = *profile.channelMasks.begin();
+ config->sampleRate = Int{.value = *profile.sampleRates.begin()};
+ config->flags = port.flags;
+ config->ext = port.ext;
+ return true;
}
- const auto& profile = port.profiles.begin();
- config->format = profile->format;
- if (profile->channelMasks.empty()) {
- LOG(ERROR) << __func__ << ": the first profile in port " << port.id
- << " has no channel masks";
- return false;
+ if (allowDynamicConfig) {
+ config->format = AudioFormatDescription{};
+ config->channelMask = AudioChannelLayout{};
+ config->sampleRate = Int{.value = 0};
+ config->flags = port.flags;
+ config->ext = port.ext;
+ return true;
}
- config->channelMask = *profile->channelMasks.begin();
- if (profile->sampleRates.empty()) {
- LOG(ERROR) << __func__ << ": the first profile in port " << port.id
- << " has no sample rates";
- return false;
- }
- Int sampleRate;
- sampleRate.value = *profile->sampleRates.begin();
- config->sampleRate = sampleRate;
- config->flags = port.flags;
- config->ext = port.ext;
- return true;
+ LOG(ERROR) << __func__ << ": port " << port.id << " only has dynamic profiles";
+ return false;
}
bool findAudioProfile(const AudioPort& port, const AudioFormatDescription& format,
@@ -189,6 +213,11 @@
StreamContext::DebugParameters params{mDebug.streamTransientStateDelayMs,
mVendorDebug.forceTransientBurst,
mVendorDebug.forceSynchronousDrain};
+ std::shared_ptr<ISoundDose> soundDose;
+ if (!getSoundDose(&soundDose).isOk()) {
+ LOG(ERROR) << __func__ << ": could not create sound dose instance";
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
+ }
StreamContext temp(
std::make_unique<StreamContext::CommandMQ>(1, true /*configureEventFlagWord*/),
std::make_unique<StreamContext::ReplyMQ>(1, true /*configureEventFlagWord*/),
@@ -196,7 +225,7 @@
portConfigIt->channelMask.value(), portConfigIt->sampleRate.value().value, flags,
portConfigIt->ext.get<AudioPortExt::mix>().handle,
std::make_unique<StreamContext::DataMQ>(frameSize * in_bufferSizeFrames),
- asyncCallback, outEventCallback, params);
+ asyncCallback, outEventCallback, mSoundDose.getInstance(), params);
if (temp.isValid()) {
*out_context = std::move(temp);
} else {
@@ -314,6 +343,18 @@
return config;
}
+std::vector<AudioRoute*> Module::getAudioRoutesForAudioPortImpl(int32_t portId) {
+ std::vector<AudioRoute*> result;
+ auto& routes = getConfig().routes;
+ for (auto& r : routes) {
+ const auto& srcs = r.sourcePortIds;
+ if (r.sinkPortId == portId || std::find(srcs.begin(), srcs.end(), portId) != srcs.end()) {
+ result.push_back(&r);
+ }
+ }
+ return result;
+}
+
internal::Configuration& Module::getConfig() {
if (!mConfig) {
mConfig = std::move(initializeConfig());
@@ -321,6 +362,24 @@
return *mConfig;
}
+std::set<int32_t> Module::getRoutableAudioPortIds(int32_t portId,
+ std::vector<AudioRoute*>* routes) {
+ std::vector<AudioRoute*> routesStorage;
+ if (routes == nullptr) {
+ routesStorage = getAudioRoutesForAudioPortImpl(portId);
+ routes = &routesStorage;
+ }
+ std::set<int32_t> result;
+ for (AudioRoute* r : *routes) {
+ if (r->sinkPortId == portId) {
+ result.insert(r->sourcePortIds.begin(), r->sourcePortIds.end());
+ } else {
+ result.insert(r->sinkPortId);
+ }
+ }
+ return result;
+}
+
void Module::registerPatch(const AudioPatch& patch) {
auto& configs = getConfig().portConfigs;
auto do_insert = [&](const std::vector<int32_t>& portConfigIds) {
@@ -510,7 +569,31 @@
}
}
- if (connectedPort.profiles.empty()) {
+ // Two main cases are considered with regard to the profiles of the connected device port:
+ //
+ // 1. If the template device port has dynamic profiles, and at least one routable mix
+ // port also has dynamic profiles, it means that after connecting the device, the
+ // connected device port must have profiles populated with actual capabilities of
+ // the connected device, and dynamic of routable mix ports will be filled
+ // according to these capabilities. An example of this case is connection of an
+ // HDMI or USB device. For USB handled by ADSP, there can be mix ports with static
+ // profiles, and one dedicated mix port for "hi-fi" playback. The latter is left with
+ // dynamic profiles so that they can be populated with actual capabilities of
+ // the connected device.
+ //
+ // 2. If the template device port has dynamic profiles, while all routable mix ports
+ // have static profiles, it means that after connecting the device, the connected
+ // device port can be left with dynamic profiles, and profiles of mix ports are
+ // left untouched. An example of this case is connection of an analog wired
+ // headset, it should be treated in the same way as a speaker.
+ //
+ // Yet another possible case is when both the template device port and all routable
+ // mix ports have static profiles. This is allowed and handled correctly, however, it
+ // is not very practical, since these profiles are likely duplicates of each other.
+
+ std::vector<AudioRoute*> routesToMixPorts = getAudioRoutesForAudioPortImpl(templateId);
+ std::set<int32_t> routableMixPortIds = getRoutableAudioPortIds(templateId, &routesToMixPorts);
+ if (hasDynamicProfilesOnly(connectedPort.profiles)) {
if (!mDebug.simulateDeviceConnections) {
RETURN_STATUS_IF_ERROR(populateConnectedDevicePort(&connectedPort));
} else {
@@ -520,23 +603,22 @@
connectedPort.profiles = connectedProfilesIt->second;
}
}
- if (connectedPort.profiles.empty()) {
- LOG(ERROR) << __func__
- << ": profiles of a connected port still empty after connecting external "
- "device "
- << connectedPort.toString();
- return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
- }
- }
-
- for (auto profile : connectedPort.profiles) {
- if (profile.channelMasks.empty()) {
- LOG(ERROR) << __func__ << ": the profile " << profile.name << " has no channel masks";
- return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
- }
- if (profile.sampleRates.empty()) {
- LOG(ERROR) << __func__ << ": the profile " << profile.name << " has no sample rates";
- return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
+ if (hasDynamicProfilesOnly(connectedPort.profiles)) {
+ // Possible case 2. Check if all routable mix ports have static profiles.
+ if (auto dynamicMixPortIt = std::find_if(ports.begin(), ports.end(),
+ [&routableMixPortIds](const auto& p) {
+ return routableMixPortIds.count(p.id) >
+ 0 &&
+ hasDynamicProfilesOnly(p.profiles);
+ });
+ dynamicMixPortIt != ports.end()) {
+ LOG(ERROR) << __func__
+ << ": connected port only has dynamic profiles after connecting "
+ << "external device " << connectedPort.toString() << ", and there exist "
+ << "a routable mix port with dynamic profiles: "
+ << dynamicMixPortIt->toString();
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
+ }
}
}
@@ -548,44 +630,36 @@
ports.push_back(connectedPort);
onExternalDeviceConnectionChanged(connectedPort, true /*connected*/);
- std::vector<int32_t> routablePortIds;
+ // For routes where the template port is a source, add the connected port to sources,
+ // otherwise, create a new route by copying from the route for the template port.
std::vector<AudioRoute> newRoutes;
- auto& routes = getConfig().routes;
- for (auto& r : routes) {
- if (r.sinkPortId == templateId) {
- AudioRoute newRoute;
- newRoute.sourcePortIds = r.sourcePortIds;
- newRoute.sinkPortId = connectedPort.id;
- newRoute.isExclusive = r.isExclusive;
- newRoutes.push_back(std::move(newRoute));
- routablePortIds.insert(routablePortIds.end(), r.sourcePortIds.begin(),
- r.sourcePortIds.end());
+ for (AudioRoute* r : routesToMixPorts) {
+ if (r->sinkPortId == templateId) {
+ newRoutes.push_back(AudioRoute{.sourcePortIds = r->sourcePortIds,
+ .sinkPortId = connectedPort.id,
+ .isExclusive = r->isExclusive});
} else {
- auto& srcs = r.sourcePortIds;
- if (std::find(srcs.begin(), srcs.end(), templateId) != srcs.end()) {
- srcs.push_back(connectedPort.id);
- routablePortIds.push_back(r.sinkPortId);
- }
+ r->sourcePortIds.push_back(connectedPort.id);
}
}
+ auto& routes = getConfig().routes;
routes.insert(routes.end(), newRoutes.begin(), newRoutes.end());
- // Note: this is a simplistic approach assuming that a mix port can only be populated
- // from a single device port. Implementing support for stuffing dynamic profiles with a superset
- // of all profiles from all routable dynamic device ports would be more involved.
- for (const auto mixPortId : routablePortIds) {
- auto portsIt = findById<AudioPort>(ports, mixPortId);
- if (portsIt != ports.end()) {
- if (portsIt->profiles.empty()) {
- portsIt->profiles = connectedPort.profiles;
- connectedPortsIt->second.insert(portsIt->id);
+ if (!hasDynamicProfilesOnly(connectedPort.profiles) && !routableMixPortIds.empty()) {
+ // Note: this is a simplistic approach assuming that a mix port can only be populated
+ // from a single device port. Implementing support for stuffing dynamic profiles with
+ // a superset of all profiles from all routable dynamic device ports would be more involved.
+ for (auto& port : ports) {
+ if (routableMixPortIds.count(port.id) == 0) continue;
+ if (hasDynamicProfilesOnly(port.profiles)) {
+ port.profiles = connectedPort.profiles;
+ connectedPortsIt->second.insert(port.id);
} else {
- // Check if profiles are non empty because they were populated by
- // a previous connection. Otherwise, it means that they are not empty because
- // the mix port has static profiles.
- for (const auto cp : mConnectedDevicePorts) {
- if (cp.second.count(portsIt->id) > 0) {
- connectedPortsIt->second.insert(portsIt->id);
+ // Check if profiles are not all dynamic because they were populated by
+ // a previous connection. Otherwise, it means that they are actually static.
+ for (const auto& cp : mConnectedDevicePorts) {
+ if (cp.second.count(port.id) > 0) {
+ connectedPortsIt->second.insert(port.id);
break;
}
}
@@ -705,13 +779,9 @@
LOG(ERROR) << __func__ << ": port id " << in_portId << " not found";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
- auto& routes = getConfig().routes;
- std::copy_if(routes.begin(), routes.end(), std::back_inserter(*_aidl_return),
- [&](const auto& r) {
- const auto& srcs = r.sourcePortIds;
- return r.sinkPortId == in_portId ||
- std::find(srcs.begin(), srcs.end(), in_portId) != srcs.end();
- });
+ std::vector<AudioRoute*> routes = getAudioRoutesForAudioPortImpl(in_portId);
+ std::transform(routes.begin(), routes.end(), std::back_inserter(*_aidl_return),
+ [](auto rptr) { return *rptr; });
return ndk::ScopedAStatus::ok();
}
@@ -925,13 +995,14 @@
const int portId = existing != configs.end() ? existing->portId : in_requested.portId;
if (portId == 0) {
- LOG(ERROR) << __func__ << ": input port config does not specify portId";
+ LOG(ERROR) << __func__ << ": requested port config does not specify portId";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
auto& ports = getConfig().ports;
auto portIt = findById<AudioPort>(ports, portId);
if (portIt == ports.end()) {
- LOG(ERROR) << __func__ << ": input port config points to non-existent portId " << portId;
+ LOG(ERROR) << __func__ << ": requested port config points to non-existent portId "
+ << portId;
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
if (existing != configs.end()) {
@@ -949,6 +1020,10 @@
// or a new generated config. Now attempt to update it according to the specified
// fields of 'in_requested'.
+ // Device ports with only dynamic profiles are used for devices that are connected via ADSP,
+ // which takes care of their actual configuration automatically.
+ const bool allowDynamicConfig = portIt->ext.getTag() == AudioPortExt::device &&
+ hasDynamicProfilesOnly(portIt->profiles);
bool requestedIsValid = true, requestedIsFullySpecified = true;
AudioIoFlags portFlags = portIt->flags;
@@ -966,17 +1041,19 @@
AudioProfile portProfile;
if (in_requested.format.has_value()) {
const auto& format = in_requested.format.value();
- if (findAudioProfile(*portIt, format, &portProfile)) {
+ if ((format == AudioFormatDescription{} && allowDynamicConfig) ||
+ findAudioProfile(*portIt, format, &portProfile)) {
out_suggested->format = format;
} else {
LOG(WARNING) << __func__ << ": requested format " << format.toString()
- << " is not found in port's " << portId << " profiles";
+ << " is not found in the profiles of port " << portId;
requestedIsValid = false;
}
} else {
requestedIsFullySpecified = false;
}
- if (!findAudioProfile(*portIt, out_suggested->format.value(), &portProfile)) {
+ if (!(out_suggested->format.value() == AudioFormatDescription{} && allowDynamicConfig) &&
+ !findAudioProfile(*portIt, out_suggested->format.value(), &portProfile)) {
LOG(ERROR) << __func__ << ": port " << portId << " does not support format "
<< out_suggested->format.value().toString() << " anymore";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
@@ -984,8 +1061,9 @@
if (in_requested.channelMask.has_value()) {
const auto& channelMask = in_requested.channelMask.value();
- if (find(portProfile.channelMasks.begin(), portProfile.channelMasks.end(), channelMask) !=
- portProfile.channelMasks.end()) {
+ if ((channelMask == AudioChannelLayout{} && allowDynamicConfig) ||
+ find(portProfile.channelMasks.begin(), portProfile.channelMasks.end(), channelMask) !=
+ portProfile.channelMasks.end()) {
out_suggested->channelMask = channelMask;
} else {
LOG(WARNING) << __func__ << ": requested channel mask " << channelMask.toString()
@@ -999,7 +1077,8 @@
if (in_requested.sampleRate.has_value()) {
const auto& sampleRate = in_requested.sampleRate.value();
- if (find(portProfile.sampleRates.begin(), portProfile.sampleRates.end(),
+ if ((sampleRate.value == 0 && allowDynamicConfig) ||
+ find(portProfile.sampleRates.begin(), portProfile.sampleRates.end(),
sampleRate.value) != portProfile.sampleRates.end()) {
out_suggested->sampleRate = sampleRate;
} else {
@@ -1397,7 +1476,18 @@
return mIsMmapSupported.value();
}
-ndk::ScopedAStatus Module::populateConnectedDevicePort(AudioPort* audioPort __unused) {
+ndk::ScopedAStatus Module::populateConnectedDevicePort(AudioPort* audioPort) {
+ if (audioPort->ext.getTag() != AudioPortExt::device) {
+ LOG(ERROR) << __func__ << ": not a device port: " << audioPort->toString();
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ }
+ const auto& devicePort = audioPort->ext.get<AudioPortExt::device>();
+ if (!devicePort.device.type.connection.empty()) {
+ LOG(ERROR) << __func__
+ << ": module implementation must override 'populateConnectedDevicePort' "
+ << "to handle connection of external devices.";
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
+ }
LOG(VERBOSE) << __func__ << ": do nothing and return ok";
return ndk::ScopedAStatus::ok();
}
diff --git a/audio/aidl/default/SoundDose.cpp b/audio/aidl/default/SoundDose.cpp
index f12ce5d..1c9e081 100644
--- a/audio/aidl/default/SoundDose.cpp
+++ b/audio/aidl/default/SoundDose.cpp
@@ -18,7 +18,15 @@
#include "core-impl/SoundDose.h"
+#include <aidl/android/hardware/audio/core/sounddose/ISoundDose.h>
#include <android-base/logging.h>
+#include <media/AidlConversionCppNdk.h>
+#include <utils/Timers.h>
+
+using aidl::android::hardware::audio::core::sounddose::ISoundDose;
+using aidl::android::media::audio::common::AudioDevice;
+using aidl::android::media::audio::common::AudioDeviceDescription;
+using aidl::android::media::audio::common::AudioFormatDescription;
namespace aidl::android::hardware::audio::core::sounddose {
@@ -28,11 +36,16 @@
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
+ ::android::audio_utils::lock_guard l(mMutex);
mRs2Value = in_rs2ValueDbA;
+ if (mMelProcessor != nullptr) {
+ mMelProcessor->setOutputRs2UpperBound(in_rs2ValueDbA);
+ }
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus SoundDose::getOutputRs2UpperBound(float* _aidl_return) {
+ ::android::audio_utils::lock_guard l(mMutex);
*_aidl_return = mRs2Value;
LOG(DEBUG) << __func__ << ": returning " << *_aidl_return;
return ndk::ScopedAStatus::ok();
@@ -44,6 +57,8 @@
LOG(ERROR) << __func__ << ": Callback is nullptr";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
+
+ ::android::audio_utils::lock_guard l(mCbMutex);
if (mCallback != nullptr) {
LOG(ERROR) << __func__ << ": Sound dose callback was already registered";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
@@ -51,7 +66,81 @@
mCallback = in_callback;
LOG(DEBUG) << __func__ << ": Registered sound dose callback ";
+
return ndk::ScopedAStatus::ok();
}
+void SoundDose::setAudioDevice(const AudioDevice& audioDevice) {
+ ::android::audio_utils::lock_guard l(mCbMutex);
+ mAudioDevice = audioDevice;
+}
+
+void SoundDose::startDataProcessor(uint32_t sampleRate, uint32_t channelCount,
+ const AudioFormatDescription& aidlFormat) {
+ ::android::audio_utils::lock_guard l(mMutex);
+ const auto result = aidl2legacy_AudioFormatDescription_audio_format_t(aidlFormat);
+ const audio_format_t format = result.value_or(AUDIO_FORMAT_INVALID);
+
+ if (mMelProcessor == nullptr) {
+ // we don't have the deviceId concept on the vendor side so just pass 0
+ mMelProcessor = ::android::sp<::android::audio_utils::MelProcessor>::make(
+ sampleRate, channelCount, format, mMelCallback, /*deviceId=*/0, mRs2Value);
+ } else {
+ mMelProcessor->updateAudioFormat(sampleRate, channelCount, format);
+ }
+}
+
+void SoundDose::process(const void* buffer, size_t bytes) {
+ ::android::audio_utils::lock_guard l(mMutex);
+ if (mMelProcessor != nullptr) {
+ mMelProcessor->process(buffer, bytes);
+ }
+}
+
+void SoundDose::onNewMelValues(const std::vector<float>& mels, size_t offset, size_t length,
+ audio_port_handle_t deviceId __attribute__((__unused__))) const {
+ ::android::audio_utils::lock_guard l(mCbMutex);
+ if (!mAudioDevice.has_value()) {
+ LOG(WARNING) << __func__ << ": New mel values without a registered device";
+ return;
+ }
+ if (mCallback == nullptr) {
+ LOG(ERROR) << __func__ << ": New mel values without a registered callback";
+ return;
+ }
+
+ ISoundDose::IHalSoundDoseCallback::MelRecord melRecord;
+ melRecord.timestamp = nanoseconds_to_seconds(systemTime());
+ melRecord.melValues = std::vector<float>(mels.begin() + offset, mels.begin() + offset + length);
+
+ mCallback->onNewMelValues(melRecord, mAudioDevice.value());
+}
+
+void SoundDose::MelCallback::onNewMelValues(const std::vector<float>& mels, size_t offset,
+ size_t length,
+ audio_port_handle_t deviceId
+ __attribute__((__unused__))) const {
+ mSoundDose.onNewMelValues(mels, offset, length, deviceId);
+}
+
+void SoundDose::onMomentaryExposure(float currentMel, audio_port_handle_t deviceId
+ __attribute__((__unused__))) const {
+ ::android::audio_utils::lock_guard l(mCbMutex);
+ if (!mAudioDevice.has_value()) {
+ LOG(WARNING) << __func__ << ": Momentary exposure without a registered device";
+ return;
+ }
+ if (mCallback == nullptr) {
+ LOG(ERROR) << __func__ << ": Momentary exposure without a registered callback";
+ return;
+ }
+
+ mCallback->onMomentaryExposureWarning(currentMel, mAudioDevice.value());
+}
+
+void SoundDose::MelCallback::onMomentaryExposure(float currentMel, audio_port_handle_t deviceId
+ __attribute__((__unused__))) const {
+ mSoundDose.onMomentaryExposure(currentMel, deviceId);
+}
+
} // namespace aidl::android::hardware::audio::core::sounddose
diff --git a/audio/aidl/default/Stream.cpp b/audio/aidl/default/Stream.cpp
index f7298c0..f00e358 100644
--- a/audio/aidl/default/Stream.cpp
+++ b/audio/aidl/default/Stream.cpp
@@ -90,6 +90,14 @@
return true;
}
+void StreamContext::startStreamDataProcessor() {
+ auto streamDataProcessor = mStreamDataProcessor.lock();
+ if (streamDataProcessor != nullptr) {
+ streamDataProcessor->startDataProcessor(mSampleRate, getChannelCount(mChannelLayout),
+ mFormat);
+ }
+}
+
void StreamContext::reset() {
mCommandMQ.reset();
mReplyMQ.reset();
@@ -593,6 +601,10 @@
fatal = true;
LOG(ERROR) << __func__ << ": write failed: " << status;
}
+ auto streamDataProcessor = mContext->getStreamDataProcessor().lock();
+ if (streamDataProcessor != nullptr) {
+ streamDataProcessor->process(mDataBuffer.get(), actualFrameCount * frameSize);
+ }
} else {
if (mContext->getAsyncCallback() == nullptr) {
usleep(3000); // Simulate blocking transfer delay.
diff --git a/audio/aidl/default/bluetooth/ModuleBluetooth.cpp b/audio/aidl/default/bluetooth/ModuleBluetooth.cpp
index bfe7ca0..3c33207 100644
--- a/audio/aidl/default/bluetooth/ModuleBluetooth.cpp
+++ b/audio/aidl/default/bluetooth/ModuleBluetooth.cpp
@@ -18,15 +18,23 @@
#include <android-base/logging.h>
+#include "BluetoothAudioSessionControl.h"
#include "core-impl/ModuleBluetooth.h"
#include "core-impl/StreamBluetooth.h"
namespace aidl::android::hardware::audio::core {
-using aidl::android::hardware::audio::common::SinkMetadata;
-using aidl::android::hardware::audio::common::SourceMetadata;
-using aidl::android::media::audio::common::AudioOffloadInfo;
-using aidl::android::media::audio::common::MicrophoneInfo;
+using ::aidl::android::hardware::audio::common::SinkMetadata;
+using ::aidl::android::hardware::audio::common::SourceMetadata;
+using ::aidl::android::hardware::bluetooth::audio::BluetoothAudioSession;
+using ::aidl::android::media::audio::common::AudioDeviceDescription;
+using ::aidl::android::media::audio::common::AudioDeviceType;
+using ::aidl::android::media::audio::common::AudioOffloadInfo;
+using ::aidl::android::media::audio::common::AudioPort;
+using ::aidl::android::media::audio::common::AudioPortExt;
+using ::aidl::android::media::audio::common::MicrophoneInfo;
+using ::android::bluetooth::audio::aidl::BluetoothAudioPortAidl;
+using ::android::bluetooth::audio::aidl::BluetoothAudioPortAidlOut;
ndk::ScopedAStatus ModuleBluetooth::getBluetoothA2dp(
std::shared_ptr<IBluetoothA2dp>* _aidl_return) {
@@ -80,6 +88,49 @@
offloadInfo, getBtProfileManagerHandles());
}
+ndk::ScopedAStatus ModuleBluetooth::populateConnectedDevicePort(AudioPort* audioPort) {
+ if (audioPort->ext.getTag() != AudioPortExt::device) {
+ LOG(ERROR) << __func__ << ": not a device port: " << audioPort->toString();
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ }
+ const auto& devicePort = audioPort->ext.get<AudioPortExt::device>();
+ const auto& description = devicePort.device.type;
+ // Since the configuration of the BT module is static, there is nothing to populate here.
+ // However, this method must return an error when the device can not be connected,
+ // this is determined by the status of BT profiles.
+ if (description.connection == AudioDeviceDescription::CONNECTION_BT_A2DP) {
+ bool isA2dpEnabled = false;
+ if (!!mBluetoothA2dp) {
+ RETURN_STATUS_IF_ERROR(mBluetoothA2dp.getInstance()->isEnabled(&isA2dpEnabled));
+ }
+ return isA2dpEnabled ? ndk::ScopedAStatus::ok()
+ : ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
+ } else if (description.connection == AudioDeviceDescription::CONNECTION_BT_LE) {
+ bool isLeEnabled = false;
+ if (!!mBluetoothLe) {
+ RETURN_STATUS_IF_ERROR(mBluetoothLe.getInstance()->isEnabled(&isLeEnabled));
+ }
+ return isLeEnabled ? ndk::ScopedAStatus::ok()
+ : ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
+ } else if (description.connection == AudioDeviceDescription::CONNECTION_WIRELESS &&
+ description.type == AudioDeviceType::OUT_HEARING_AID) {
+ // Hearing aids can use a number of profiles, thus the only way to check
+ // connectivity is to try to talk to the BT HAL.
+ if (!BluetoothAudioSession::IsAidlAvailable()) {
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
+ }
+ std::shared_ptr<BluetoothAudioPortAidl> proxy = std::shared_ptr<BluetoothAudioPortAidl>(
+ std::make_shared<BluetoothAudioPortAidlOut>());
+ if (proxy->registerPort(description)) {
+ proxy->unregisterPort();
+ return ndk::ScopedAStatus::ok();
+ }
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
+ }
+ LOG(ERROR) << __func__ << ": unsupported device type: " << audioPort->toString();
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+}
+
ndk::ScopedAStatus ModuleBluetooth::onMasterMuteChanged(bool) {
LOG(DEBUG) << __func__ << ": is not supported";
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
diff --git a/audio/aidl/default/include/core-impl/Module.h b/audio/aidl/default/include/core-impl/Module.h
index bfdab51..f407e25 100644
--- a/audio/aidl/default/include/core-impl/Module.h
+++ b/audio/aidl/default/include/core-impl/Module.h
@@ -157,7 +157,7 @@
bool mMicMute = false;
bool mMasterMute = false;
float mMasterVolume = 1.0f;
- ChildInterface<sounddose::ISoundDose> mSoundDose;
+ ChildInterface<sounddose::SoundDose> mSoundDose;
std::optional<bool> mIsMmapSupported;
protected:
@@ -202,6 +202,7 @@
std::set<int32_t> findConnectedPortConfigIds(int32_t portConfigId);
ndk::ScopedAStatus findPortIdForNewStream(
int32_t in_portConfigId, ::aidl::android::media::audio::common::AudioPort** port);
+ std::vector<AudioRoute*> getAudioRoutesForAudioPortImpl(int32_t portId);
virtual BtProfileHandles getBtProfileManagerHandles();
internal::Configuration& getConfig();
const ConnectedDevicePorts& getConnectedDevicePorts() const { return mConnectedDevicePorts; }
@@ -209,6 +210,8 @@
bool getMasterVolume() const { return mMasterVolume; }
bool getMicMute() const { return mMicMute; }
const Patches& getPatches() const { return mPatches; }
+ std::set<int32_t> getRoutableAudioPortIds(int32_t portId,
+ std::vector<AudioRoute*>* routes = nullptr);
const Streams& getStreams() const { return mStreams; }
Type getType() const { return mType; }
bool isMmapSupported();
diff --git a/audio/aidl/default/include/core-impl/ModuleBluetooth.h b/audio/aidl/default/include/core-impl/ModuleBluetooth.h
index 68b4e6b..526a809 100644
--- a/audio/aidl/default/include/core-impl/ModuleBluetooth.h
+++ b/audio/aidl/default/include/core-impl/ModuleBluetooth.h
@@ -44,6 +44,8 @@
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
offloadInfo,
std::shared_ptr<StreamOut>* result) override;
+ ndk::ScopedAStatus populateConnectedDevicePort(
+ ::aidl::android::media::audio::common::AudioPort* audioPort) override;
ndk::ScopedAStatus onMasterMuteChanged(bool mute) override;
ndk::ScopedAStatus onMasterVolumeChanged(float volume) override;
@@ -51,4 +53,4 @@
ChildInterface<IBluetoothLe> mBluetoothLe;
};
-} // namespace aidl::android::hardware::audio::core
\ No newline at end of file
+} // namespace aidl::android::hardware::audio::core
diff --git a/audio/aidl/default/include/core-impl/SoundDose.h b/audio/aidl/default/include/core-impl/SoundDose.h
index 2a069d9..82c1077 100644
--- a/audio/aidl/default/include/core-impl/SoundDose.h
+++ b/audio/aidl/default/include/core-impl/SoundDose.h
@@ -20,23 +20,68 @@
#include <aidl/android/hardware/audio/core/sounddose/BnSoundDose.h>
#include <aidl/android/media/audio/common/AudioDevice.h>
-
-using aidl::android::media::audio::common::AudioDevice;
+#include <aidl/android/media/audio/common/AudioFormatDescription.h>
+#include <audio_utils/MelProcessor.h>
+#include <audio_utils/mutex.h>
namespace aidl::android::hardware::audio::core::sounddose {
-class SoundDose : public BnSoundDose {
+// Interface used for processing the data received by a stream.
+class StreamDataProcessorInterface {
public:
- SoundDose() : mRs2Value(DEFAULT_MAX_RS2){};
+ virtual ~StreamDataProcessorInterface() = default;
+ virtual void startDataProcessor(
+ uint32_t samplerate, uint32_t channelCount,
+ const ::aidl::android::media::audio::common::AudioFormatDescription& format) = 0;
+ virtual void setAudioDevice(
+ const ::aidl::android::media::audio::common::AudioDevice& audioDevice) = 0;
+ virtual void process(const void* buffer, size_t size) = 0;
+};
+
+class SoundDose final : public BnSoundDose, public StreamDataProcessorInterface {
+ public:
+ SoundDose() : mMelCallback(::android::sp<MelCallback>::make(this)){};
+
+ // -------------------------------------- BnSoundDose ------------------------------------------
ndk::ScopedAStatus setOutputRs2UpperBound(float in_rs2ValueDbA) override;
ndk::ScopedAStatus getOutputRs2UpperBound(float* _aidl_return) override;
ndk::ScopedAStatus registerSoundDoseCallback(
const std::shared_ptr<ISoundDose::IHalSoundDoseCallback>& in_callback) override;
+ // ----------------------------- StreamDataProcessorInterface ----------------------------------
+ void setAudioDevice(
+ const ::aidl::android::media::audio::common::AudioDevice& audioDevice) override;
+ void startDataProcessor(
+ uint32_t samplerate, uint32_t channelCount,
+ const ::aidl::android::media::audio::common::AudioFormatDescription& format) override;
+ void process(const void* buffer, size_t size) override;
+
private:
- std::shared_ptr<ISoundDose::IHalSoundDoseCallback> mCallback;
- float mRs2Value;
+ class MelCallback : public ::android::audio_utils::MelProcessor::MelCallback {
+ public:
+ explicit MelCallback(SoundDose* soundDose) : mSoundDose(*soundDose) {}
+
+ // ------------------------------------ MelCallback ----------------------------------------
+ void onNewMelValues(const std::vector<float>& mels, size_t offset, size_t length,
+ audio_port_handle_t deviceId) const override;
+ void onMomentaryExposure(float currentMel, audio_port_handle_t deviceId) const override;
+
+ SoundDose& mSoundDose; // must outlive MelCallback, not owning
+ };
+
+ void onNewMelValues(const std::vector<float>& mels, size_t offset, size_t length,
+ audio_port_handle_t deviceId) const;
+ void onMomentaryExposure(float currentMel, audio_port_handle_t deviceId) const;
+
+ mutable ::android::audio_utils::mutex mCbMutex;
+ std::shared_ptr<ISoundDose::IHalSoundDoseCallback> mCallback GUARDED_BY(mCbMutex);
+ std::optional<::aidl::android::media::audio::common::AudioDevice> mAudioDevice
+ GUARDED_BY(mCbMutex);
+ mutable ::android::audio_utils::mutex mMutex;
+ float mRs2Value GUARDED_BY(mMutex) = DEFAULT_MAX_RS2;
+ ::android::sp<::android::audio_utils::MelProcessor> mMelProcessor GUARDED_BY(mMutex);
+ ::android::sp<MelCallback> mMelCallback GUARDED_BY(mMutex);
};
} // namespace aidl::android::hardware::audio::core::sounddose
diff --git a/audio/aidl/default/include/core-impl/Stream.h b/audio/aidl/default/include/core-impl/Stream.h
index 88fddec..daa920d 100644
--- a/audio/aidl/default/include/core-impl/Stream.h
+++ b/audio/aidl/default/include/core-impl/Stream.h
@@ -44,6 +44,7 @@
#include <utils/Errors.h>
#include "core-impl/ChildInterface.h"
+#include "core-impl/SoundDose.h"
#include "core-impl/utils.h"
namespace aidl::android::hardware::audio::core {
@@ -87,6 +88,7 @@
int32_t mixPortHandle, std::unique_ptr<DataMQ> dataMQ,
std::shared_ptr<IStreamCallback> asyncCallback,
std::shared_ptr<IStreamOutEventCallback> outEventCallback,
+ std::weak_ptr<sounddose::StreamDataProcessorInterface> streamDataProcessor,
DebugParameters debugParameters)
: mCommandMQ(std::move(commandMQ)),
mInternalCommandCookie(std::rand()),
@@ -100,6 +102,7 @@
mDataMQ(std::move(dataMQ)),
mAsyncCallback(asyncCallback),
mOutEventCallback(outEventCallback),
+ mStreamDataProcessor(streamDataProcessor),
mDebugParameters(debugParameters) {}
StreamContext(StreamContext&& other)
: mCommandMQ(std::move(other.mCommandMQ)),
@@ -114,6 +117,7 @@
mDataMQ(std::move(other.mDataMQ)),
mAsyncCallback(std::move(other.mAsyncCallback)),
mOutEventCallback(std::move(other.mOutEventCallback)),
+ mStreamDataProcessor(std::move(other.mStreamDataProcessor)),
mDebugParameters(std::move(other.mDebugParameters)),
mFrameCount(other.mFrameCount) {}
StreamContext& operator=(StreamContext&& other) {
@@ -129,6 +133,7 @@
mDataMQ = std::move(other.mDataMQ);
mAsyncCallback = std::move(other.mAsyncCallback);
mOutEventCallback = std::move(other.mOutEventCallback);
+ mStreamDataProcessor = std::move(other.mStreamDataProcessor);
mDebugParameters = std::move(other.mDebugParameters);
mFrameCount = other.mFrameCount;
return *this;
@@ -154,6 +159,10 @@
std::shared_ptr<IStreamOutEventCallback> getOutEventCallback() const {
return mOutEventCallback;
}
+ std::weak_ptr<sounddose::StreamDataProcessorInterface> getStreamDataProcessor() const {
+ return mStreamDataProcessor;
+ }
+ void startStreamDataProcessor();
int getPortId() const { return mPortId; }
ReplyMQ* getReplyMQ() const { return mReplyMQ.get(); }
int getTransientStateDelayMs() const { return mDebugParameters.transientStateDelayMs; }
@@ -179,6 +188,7 @@
std::unique_ptr<DataMQ> mDataMQ;
std::shared_ptr<IStreamCallback> mAsyncCallback;
std::shared_ptr<IStreamOutEventCallback> mOutEventCallback; // Only used by output streams
+ std::weak_ptr<sounddose::StreamDataProcessorInterface> mStreamDataProcessor;
DebugParameters mDebugParameters;
long mFrameCount = 0;
};
diff --git a/audio/aidl/default/include/core-impl/StreamPrimary.h b/audio/aidl/default/include/core-impl/StreamPrimary.h
index b3ddd0b..b64b749 100644
--- a/audio/aidl/default/include/core-impl/StreamPrimary.h
+++ b/audio/aidl/default/include/core-impl/StreamPrimary.h
@@ -79,6 +79,10 @@
ndk::ScopedAStatus getHwVolume(std::vector<float>* _aidl_return) override;
ndk::ScopedAStatus setHwVolume(const std::vector<float>& in_channelVolumes) override;
+
+ ndk::ScopedAStatus setConnectedDevices(
+ const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices)
+ override;
};
} // namespace aidl::android::hardware::audio::core
diff --git a/audio/aidl/default/primary/StreamPrimary.cpp b/audio/aidl/default/primary/StreamPrimary.cpp
index e01be8a..17de2ba 100644
--- a/audio/aidl/default/primary/StreamPrimary.cpp
+++ b/audio/aidl/default/primary/StreamPrimary.cpp
@@ -37,7 +37,9 @@
namespace aidl::android::hardware::audio::core {
StreamPrimary::StreamPrimary(StreamContext* context, const Metadata& metadata)
- : StreamAlsa(context, metadata, 3 /*readWriteRetries*/), mIsInput(isInput(metadata)) {}
+ : StreamAlsa(context, metadata, 3 /*readWriteRetries*/), mIsInput(isInput(metadata)) {
+ context->startStreamDataProcessor();
+}
std::vector<alsa::DeviceProfile> StreamPrimary::getDeviceProfiles() {
static const std::vector<alsa::DeviceProfile> kBuiltInSource{
@@ -183,4 +185,15 @@
return ndk::ScopedAStatus::ok();
}
+ndk::ScopedAStatus StreamOutPrimary::setConnectedDevices(
+ const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices) {
+ if (!devices.empty()) {
+ auto streamDataProcessor = mContextInstance.getStreamDataProcessor().lock();
+ if (streamDataProcessor != nullptr) {
+ streamDataProcessor->setAudioDevice(devices[0]);
+ }
+ }
+ return StreamSwitcher::setConnectedDevices(devices);
+}
+
} // namespace aidl::android::hardware::audio::core
diff --git a/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp b/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp
index adea877..f8c775f 100644
--- a/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp
+++ b/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp
@@ -59,23 +59,22 @@
ndk::ScopedAStatus ModuleRemoteSubmix::populateConnectedDevicePort(AudioPort* audioPort) {
// Find the corresponding mix port and copy its profiles.
- std::vector<AudioRoute> routes;
// At this moment, the port has the same ID as the template port, see connectExternalDevice.
- RETURN_STATUS_IF_ERROR(getAudioRoutesForAudioPort(audioPort->id, &routes));
+ std::vector<AudioRoute*> routes = getAudioRoutesForAudioPortImpl(audioPort->id);
if (routes.empty()) {
LOG(ERROR) << __func__ << ": no routes found for the port " << audioPort->toString();
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
const auto& route = *routes.begin();
AudioPort mixPort;
- if (route.sinkPortId == audioPort->id) {
- if (route.sourcePortIds.empty()) {
- LOG(ERROR) << __func__ << ": invalid route " << route.toString();
+ if (route->sinkPortId == audioPort->id) {
+ if (route->sourcePortIds.empty()) {
+ LOG(ERROR) << __func__ << ": invalid route " << route->toString();
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
- RETURN_STATUS_IF_ERROR(getAudioPort(*route.sourcePortIds.begin(), &mixPort));
+ RETURN_STATUS_IF_ERROR(getAudioPort(*route->sourcePortIds.begin(), &mixPort));
} else {
- RETURN_STATUS_IF_ERROR(getAudioPort(route.sinkPortId, &mixPort));
+ RETURN_STATUS_IF_ERROR(getAudioPort(route->sinkPortId, &mixPort));
}
audioPort->profiles = mixPort.profiles;
return ndk::ScopedAStatus::ok();
diff --git a/audio/aidl/vts/ModuleConfig.cpp b/audio/aidl/vts/ModuleConfig.cpp
index af3597d..8f19547 100644
--- a/audio/aidl/vts/ModuleConfig.cpp
+++ b/audio/aidl/vts/ModuleConfig.cpp
@@ -281,6 +281,22 @@
return {};
}
+std::vector<AudioPort> ModuleConfig::getRoutableMixPortsForDevicePort(const AudioPort& port) const {
+ std::set<int32_t> portIds;
+ for (const auto& route : mRoutes) {
+ if (port.id == route.sinkPortId) {
+ portIds.insert(route.sourcePortIds.begin(), route.sourcePortIds.end());
+ } else if (auto it = std::find(route.sourcePortIds.begin(), route.sourcePortIds.end(),
+ port.id);
+ it != route.sourcePortIds.end()) {
+ portIds.insert(route.sinkPortId);
+ }
+ }
+ const bool isInput = port.flags.getTag() == AudioIoFlags::input;
+ return findMixPorts(isInput, false /*connectedOnly*/, false /*singlePort*/,
+ [&portIds](const AudioPort& p) { return portIds.count(p.id) > 0; });
+}
+
std::optional<ModuleConfig::SrcSinkPair> ModuleConfig::getNonRoutableSrcSinkPair(
bool isInput) const {
const auto mixPorts = getMixPorts(isInput, false /*connectedOnly*/);
diff --git a/audio/aidl/vts/ModuleConfig.h b/audio/aidl/vts/ModuleConfig.h
index 0cbf24d..b89adc0 100644
--- a/audio/aidl/vts/ModuleConfig.h
+++ b/audio/aidl/vts/ModuleConfig.h
@@ -103,6 +103,9 @@
std::optional<aidl::android::media::audio::common::AudioPort>
getSourceMixPortForConnectedDevice() const;
+ std::vector<aidl::android::media::audio::common::AudioPort> getRoutableMixPortsForDevicePort(
+ const aidl::android::media::audio::common::AudioPort& port) const;
+
std::optional<SrcSinkPair> getNonRoutableSrcSinkPair(bool isInput) const;
std::optional<SrcSinkPair> getRoutableSrcSinkPair(bool isInput) const;
std::vector<SrcSinkGroup> getRoutableSrcSinkGroups(bool isInput) const;
diff --git a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
index 621d200..9c52d19 100644
--- a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
@@ -1501,8 +1501,25 @@
<< "port ID " << connectedPortId;
EXPECT_EQ(portConnected.get(), connectedPort);
const auto& portProfiles = connectedPort.profiles;
- EXPECT_NE(0UL, portProfiles.size())
- << "Connected port has no profiles: " << connectedPort.toString();
+ if (portProfiles.empty()) {
+ const auto routableMixPorts =
+ moduleConfig->getRoutableMixPortsForDevicePort(connectedPort);
+ bool hasMixPortWithStaticProfile = false;
+ for (const auto& mixPort : routableMixPorts) {
+ const auto& mixPortProfiles = mixPort.profiles;
+ if (!mixPortProfiles.empty() &&
+ !std::all_of(mixPortProfiles.begin(), mixPortProfiles.end(),
+ [](const auto& profile) {
+ return profile.format.type == AudioFormatType::DEFAULT;
+ })) {
+ hasMixPortWithStaticProfile = true;
+ break;
+ }
+ }
+ EXPECT_TRUE(hasMixPortWithStaticProfile)
+ << "Connected port has no profiles and no routable mix ports with profiles: "
+ << connectedPort.toString();
+ }
const auto dynamicProfileIt =
std::find_if(portProfiles.begin(), portProfiles.end(), [](const auto& profile) {
return profile.format.type == AudioFormatType::DEFAULT;
@@ -1586,7 +1603,8 @@
EXPECT_NE(portConfigsAfter.end(), afterIt)
<< " port config ID " << c.id << " was removed by reset";
if (afterIt != portConfigsAfter.end()) {
- EXPECT_EQ(c, *afterIt);
+ EXPECT_TRUE(c == *afterIt)
+ << "Expected: " << c.toString() << "; Actual: " << afterIt->toString();
}
}
}
diff --git a/automotive/vehicle/aidl/generated_lib/cpp/AccessForVehicleProperty.h b/automotive/vehicle/aidl/generated_lib/cpp/AccessForVehicleProperty.h
index 92c2707..c4e2c64 100644
--- a/automotive/vehicle/aidl/generated_lib/cpp/AccessForVehicleProperty.h
+++ b/automotive/vehicle/aidl/generated_lib/cpp/AccessForVehicleProperty.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 The Android Open Source Project
+ * 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.
diff --git a/automotive/vehicle/aidl/generated_lib/cpp/ChangeModeForVehicleProperty.h b/automotive/vehicle/aidl/generated_lib/cpp/ChangeModeForVehicleProperty.h
index e1bdf7d..bd6c705 100644
--- a/automotive/vehicle/aidl/generated_lib/cpp/ChangeModeForVehicleProperty.h
+++ b/automotive/vehicle/aidl/generated_lib/cpp/ChangeModeForVehicleProperty.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 The Android Open Source Project
+ * 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.
diff --git a/automotive/vehicle/aidl/generated_lib/java/AccessForVehicleProperty.java b/automotive/vehicle/aidl/generated_lib/java/AccessForVehicleProperty.java
index b5c3de9..6e66632 100644
--- a/automotive/vehicle/aidl/generated_lib/java/AccessForVehicleProperty.java
+++ b/automotive/vehicle/aidl/generated_lib/java/AccessForVehicleProperty.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 The Android Open Source Project
+ * 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.
diff --git a/automotive/vehicle/aidl/generated_lib/java/ChangeModeForVehicleProperty.java b/automotive/vehicle/aidl/generated_lib/java/ChangeModeForVehicleProperty.java
index 0f126e7..522c82f 100644
--- a/automotive/vehicle/aidl/generated_lib/java/ChangeModeForVehicleProperty.java
+++ b/automotive/vehicle/aidl/generated_lib/java/ChangeModeForVehicleProperty.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 The Android Open Source Project
+ * 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.
diff --git a/automotive/vehicle/aidl/generated_lib/java/EnumForVehicleProperty.java b/automotive/vehicle/aidl/generated_lib/java/EnumForVehicleProperty.java
new file mode 100644
index 0000000..144d0e1
--- /dev/null
+++ b/automotive/vehicle/aidl/generated_lib/java/EnumForVehicleProperty.java
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+
+/**
+ * DO NOT EDIT MANUALLY!!!
+ *
+ * Generated by tools/generate_annotation_enums.py.
+ */
+
+// clang-format off
+
+package android.hardware.automotive.vehicle;
+
+import java.util.List;
+import java.util.Map;
+
+public final class EnumForVehicleProperty {
+
+ public static final Map<Integer, List<Class<?>>> values = Map.ofEntries(
+ Map.entry(VehicleProperty.INFO_FUEL_TYPE, List.of(FuelType.class)),
+ Map.entry(VehicleProperty.INFO_EV_CONNECTOR_TYPE, List.of(EvConnectorType.class)),
+ Map.entry(VehicleProperty.INFO_FUEL_DOOR_LOCATION, List.of(PortLocationType.class)),
+ Map.entry(VehicleProperty.INFO_EV_PORT_LOCATION, List.of(PortLocationType.class)),
+ Map.entry(VehicleProperty.INFO_DRIVER_SEAT, List.of(VehicleAreaSeat.class)),
+ Map.entry(VehicleProperty.INFO_MULTI_EV_PORT_LOCATIONS, List.of(PortLocationType.class)),
+ Map.entry(VehicleProperty.ENGINE_OIL_LEVEL, List.of(VehicleOilLevel.class)),
+ Map.entry(VehicleProperty.GEAR_SELECTION, List.of(VehicleGear.class)),
+ Map.entry(VehicleProperty.CURRENT_GEAR, List.of(VehicleGear.class)),
+ Map.entry(VehicleProperty.TURN_SIGNAL_STATE, List.of(VehicleTurnSignal.class)),
+ Map.entry(VehicleProperty.IGNITION_STATE, List.of(VehicleIgnitionState.class)),
+ Map.entry(VehicleProperty.EV_STOPPING_MODE, List.of(EvStoppingMode.class)),
+ Map.entry(VehicleProperty.HVAC_FAN_DIRECTION, List.of(VehicleHvacFanDirection.class)),
+ Map.entry(VehicleProperty.HVAC_TEMPERATURE_DISPLAY_UNITS, List.of(VehicleUnit.class)),
+ Map.entry(VehicleProperty.HVAC_FAN_DIRECTION_AVAILABLE, List.of(VehicleHvacFanDirection.class)),
+ Map.entry(VehicleProperty.DISTANCE_DISPLAY_UNITS, List.of(VehicleUnit.class)),
+ Map.entry(VehicleProperty.FUEL_VOLUME_DISPLAY_UNITS, List.of(VehicleUnit.class)),
+ Map.entry(VehicleProperty.TIRE_PRESSURE_DISPLAY_UNITS, List.of(VehicleUnit.class)),
+ Map.entry(VehicleProperty.EV_BATTERY_DISPLAY_UNITS, List.of(VehicleUnit.class)),
+ Map.entry(VehicleProperty.HW_ROTARY_INPUT, List.of(RotaryInputType.class)),
+ Map.entry(VehicleProperty.HW_CUSTOM_INPUT, List.of(CustomInputType.class)),
+ Map.entry(VehicleProperty.SEAT_FOOTWELL_LIGHTS_STATE, List.of(VehicleLightState.class)),
+ Map.entry(VehicleProperty.SEAT_FOOTWELL_LIGHTS_SWITCH, List.of(VehicleLightSwitch.class)),
+ Map.entry(VehicleProperty.SEAT_OCCUPANCY, List.of(VehicleSeatOccupancyState.class)),
+ Map.entry(VehicleProperty.WINDSHIELD_WIPERS_STATE, List.of(WindshieldWipersState.class)),
+ Map.entry(VehicleProperty.WINDSHIELD_WIPERS_SWITCH, List.of(WindshieldWipersSwitch.class)),
+ Map.entry(VehicleProperty.HEADLIGHTS_STATE, List.of(VehicleLightState.class)),
+ Map.entry(VehicleProperty.HIGH_BEAM_LIGHTS_STATE, List.of(VehicleLightState.class)),
+ Map.entry(VehicleProperty.FOG_LIGHTS_STATE, List.of(VehicleLightState.class)),
+ Map.entry(VehicleProperty.HAZARD_LIGHTS_STATE, List.of(VehicleLightState.class)),
+ Map.entry(VehicleProperty.HEADLIGHTS_SWITCH, List.of(VehicleLightSwitch.class)),
+ Map.entry(VehicleProperty.HIGH_BEAM_LIGHTS_SWITCH, List.of(VehicleLightSwitch.class)),
+ Map.entry(VehicleProperty.FOG_LIGHTS_SWITCH, List.of(VehicleLightSwitch.class)),
+ Map.entry(VehicleProperty.HAZARD_LIGHTS_SWITCH, List.of(VehicleLightSwitch.class)),
+ Map.entry(VehicleProperty.CABIN_LIGHTS_STATE, List.of(VehicleLightState.class)),
+ Map.entry(VehicleProperty.CABIN_LIGHTS_SWITCH, List.of(VehicleLightSwitch.class)),
+ Map.entry(VehicleProperty.READING_LIGHTS_STATE, List.of(VehicleLightState.class)),
+ Map.entry(VehicleProperty.READING_LIGHTS_SWITCH, List.of(VehicleLightSwitch.class)),
+ Map.entry(VehicleProperty.STEERING_WHEEL_LIGHTS_STATE, List.of(VehicleLightState.class)),
+ Map.entry(VehicleProperty.STEERING_WHEEL_LIGHTS_SWITCH, List.of(VehicleLightSwitch.class)),
+ Map.entry(VehicleProperty.ELECTRONIC_TOLL_COLLECTION_CARD_TYPE, List.of(ElectronicTollCollectionCardType.class)),
+ Map.entry(VehicleProperty.ELECTRONIC_TOLL_COLLECTION_CARD_STATUS, List.of(ElectronicTollCollectionCardStatus.class)),
+ Map.entry(VehicleProperty.FRONT_FOG_LIGHTS_STATE, List.of(VehicleLightState.class)),
+ Map.entry(VehicleProperty.FRONT_FOG_LIGHTS_SWITCH, List.of(VehicleLightSwitch.class)),
+ Map.entry(VehicleProperty.REAR_FOG_LIGHTS_STATE, List.of(VehicleLightState.class)),
+ Map.entry(VehicleProperty.REAR_FOG_LIGHTS_SWITCH, List.of(VehicleLightSwitch.class)),
+ Map.entry(VehicleProperty.EV_CHARGE_STATE, List.of(EvChargeState.class)),
+ Map.entry(VehicleProperty.EV_REGENERATIVE_BRAKING_STATE, List.of(EvRegenerativeBrakingState.class)),
+ Map.entry(VehicleProperty.TRAILER_PRESENT, List.of(TrailerState.class)),
+ Map.entry(VehicleProperty.GENERAL_SAFETY_REGULATION_COMPLIANCE_REQUIREMENT, List.of(GsrComplianceRequirementType.class)),
+ Map.entry(VehicleProperty.SHUTDOWN_REQUEST, List.of(VehicleApPowerStateShutdownParam.class)),
+ Map.entry(VehicleProperty.AUTOMATIC_EMERGENCY_BRAKING_STATE, List.of(AutomaticEmergencyBrakingState.class, ErrorState.class)),
+ Map.entry(VehicleProperty.FORWARD_COLLISION_WARNING_STATE, List.of(ForwardCollisionWarningState.class, ErrorState.class)),
+ Map.entry(VehicleProperty.BLIND_SPOT_WARNING_STATE, List.of(BlindSpotWarningState.class, ErrorState.class)),
+ Map.entry(VehicleProperty.LANE_DEPARTURE_WARNING_STATE, List.of(LaneDepartureWarningState.class, ErrorState.class)),
+ Map.entry(VehicleProperty.LANE_KEEP_ASSIST_STATE, List.of(LaneKeepAssistState.class, ErrorState.class)),
+ Map.entry(VehicleProperty.LANE_CENTERING_ASSIST_COMMAND, List.of(LaneCenteringAssistCommand.class)),
+ Map.entry(VehicleProperty.LANE_CENTERING_ASSIST_STATE, List.of(LaneCenteringAssistState.class, ErrorState.class)),
+ Map.entry(VehicleProperty.EMERGENCY_LANE_KEEP_ASSIST_STATE, List.of(EmergencyLaneKeepAssistState.class, ErrorState.class)),
+ Map.entry(VehicleProperty.CRUISE_CONTROL_TYPE, List.of(CruiseControlType.class, ErrorState.class)),
+ Map.entry(VehicleProperty.CRUISE_CONTROL_STATE, List.of(CruiseControlState.class, ErrorState.class)),
+ Map.entry(VehicleProperty.CRUISE_CONTROL_COMMAND, List.of(CruiseControlCommand.class)),
+ Map.entry(VehicleProperty.HANDS_ON_DETECTION_DRIVER_STATE, List.of(HandsOnDetectionDriverState.class, ErrorState.class)),
+ Map.entry(VehicleProperty.HANDS_ON_DETECTION_WARNING, List.of(HandsOnDetectionWarning.class, ErrorState.class))
+ );
+
+}
diff --git a/automotive/vehicle/tools/generate_annotation_enums.py b/automotive/vehicle/tools/generate_annotation_enums.py
index fddc55b..05fc99a 100755
--- a/automotive/vehicle/tools/generate_annotation_enums.py
+++ b/automotive/vehicle/tools/generate_annotation_enums.py
@@ -18,7 +18,7 @@
Need ANDROID_BUILD_TOP environmental variable to be set. This script will update
ChangeModeForVehicleProperty.h and AccessForVehicleProperty.h under generated_lib/cpp and
- ChangeModeForVehicleProperty.java and AccessForVehicleProperty.java under generated_lib/java.
+ ChangeModeForVehicleProperty.java, AccessForVehicleProperty.java, EnumForVehicleProperty.java under generated_lib/java.
Usage:
$ python generate_annotation_enums.py
@@ -40,6 +40,8 @@
'ChangeModeForVehicleProperty.java')
ACCESS_JAVA_FILE_PATH = ('hardware/interfaces/automotive/vehicle/aidl/generated_lib/java/' +
'AccessForVehicleProperty.java')
+ENUM_JAVA_FILE_PATH = ('hardware/interfaces/automotive/vehicle/aidl/generated_lib/java/' +
+ 'EnumForVehicleProperty.java')
SCRIPT_PATH = 'hardware/interfaces/automotive/vehicle/tools/generate_annotation_enums.py'
TAB = ' '
@@ -54,7 +56,7 @@
RE_VALUE = re.compile('\s*(\w+)\s*=(.*)')
LICENSE = """/*
- * Copyright (C) 2022 The Android Open Source Project
+ * 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.
@@ -167,6 +169,22 @@
}
"""
+ENUM_JAVA_HEADER = """package android.hardware.automotive.vehicle;
+
+import java.util.List;
+import java.util.Map;
+
+public final class EnumForVehicleProperty {
+
+ public static final Map<Integer, List<Class<?>>> values = Map.ofEntries(
+"""
+
+ENUM_JAVA_FOOTER = """
+ );
+
+}
+"""
+
class PropertyConfig:
"""Represents one VHAL property definition in VehicleProperty.aidl."""
@@ -272,6 +290,11 @@
annotation = "VehiclePropertyAccess::" + config.access_modes[0]
else:
annotation = "VehiclePropertyAccess." + config.access_modes[0]
+ elif field == 'enum_types':
+ if len(config.enum_types) < 1:
+ continue;
+ if not cpp:
+ annotation = "List.of(" + ', '.join([class_name + ".class" for class_name in config.enum_types]) + ")"
else:
raise Exception('Unknown field: ' + field)
if counter != 0:
@@ -348,7 +371,7 @@
else:
android_top = os.environ['ANDROID_BUILD_TOP']
if not android_top:
- print('ANDROID_BUILD_TOP is not in envorinmental variable, please run source and lunch ' +
+ print('ANDROID_BUILD_TOP is not in environmental variable, please run source and lunch ' +
'at the android root')
aidl_file = os.path.join(android_top, PROP_AIDL_FILE_PATH)
@@ -363,6 +386,7 @@
access_cpp_file = os.path.join(android_top, ACCESS_CPP_FILE_PATH);
change_mode_java_file = os.path.join(android_top, CHANGE_MODE_JAVA_FILE_PATH);
access_java_file = os.path.join(android_top, ACCESS_JAVA_FILE_PATH);
+ enum_java_file = os.path.join(android_top, ENUM_JAVA_FILE_PATH);
temp_files = []
if not args.check_only:
@@ -370,6 +394,7 @@
access_cpp_output = access_cpp_file
change_mode_java_output = change_mode_java_file
access_java_output = access_java_file
+ enum_java_output = enum_java_file
else:
change_mode_cpp_output = createTempFile()
temp_files.append(change_mode_cpp_output)
@@ -379,6 +404,8 @@
temp_files.append(change_mode_java_output)
access_java_output = createTempFile()
temp_files.append(access_java_output)
+ enum_java_output = createTempFile()
+ temp_files.append(enum_java_output)
try:
f.convert(change_mode_cpp_output, CHANGE_MODE_CPP_HEADER, CHANGE_MODE_CPP_FOOTER,
@@ -387,6 +414,7 @@
CHANGE_MODE_JAVA_FOOTER, False, 'change_mode')
f.convert(access_cpp_output, ACCESS_CPP_HEADER, ACCESS_CPP_FOOTER, True, 'access_mode')
f.convert(access_java_output, ACCESS_JAVA_HEADER, ACCESS_JAVA_FOOTER, False, 'access_mode')
+ f.convert(enum_java_output, ENUM_JAVA_HEADER, ENUM_JAVA_FOOTER, False, 'enum_types')
if not args.check_only:
return
@@ -394,7 +422,8 @@
if ((not filecmp.cmp(change_mode_cpp_output, change_mode_cpp_file)) or
(not filecmp.cmp(change_mode_java_output, change_mode_java_file)) or
(not filecmp.cmp(access_cpp_output, access_cpp_file)) or
- (not filecmp.cmp(access_java_output, access_java_file))):
+ (not filecmp.cmp(access_java_output, access_java_file)) or
+ (not filecmp.cmp(enum_java_output, enum_java_file))):
print('The generated enum files for VehicleProperty.aidl requires update, ')
print('Run \npython ' + android_top + '/' + SCRIPT_PATH)
sys.exit(1)
diff --git a/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp b/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp
index bc9a527..3dca0ae 100644
--- a/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp
+++ b/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp
@@ -116,7 +116,7 @@
class VtsHalAutomotiveVehicleTargetTest : public testing::TestWithParam<ServiceDescriptor> {
protected:
- void checkIsSupported(int32_t propertyId);
+ bool checkIsSupported(int32_t propertyId);
public:
void verifyProperty(VehicleProperty propId, VehiclePropertyAccess access,
@@ -207,7 +207,9 @@
ALOGD("VtsHalAutomotiveVehicleTargetTest::get");
int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
- checkIsSupported(propId);
+ if (!checkIsSupported(propId)) {
+ GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
+ }
auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
@@ -293,7 +295,9 @@
ALOGD("VtsHalAutomotiveVehicleTargetTest::setNotWritableProp");
int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
- checkIsSupported(propId);
+ if (!checkIsSupported(propId)) {
+ GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
+ }
auto getValueResult = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
ASSERT_TRUE(getValueResult.ok())
@@ -335,7 +339,9 @@
ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeAndUnsubscribe");
int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
- checkIsSupported(propId);
+ if (!checkIsSupported(propId)) {
+ GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
+ }
auto propConfigsResult = mVhalClient->getPropConfigs({propId});
@@ -425,7 +431,9 @@
}
int32_t propId = toInt(VehicleProperty::PARKING_BRAKE_ON);
- checkIsSupported(propId);
+ if (!checkIsSupported(propId)) {
+ GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
+ }
auto prop = mVhalClient->createHalPropValue(propId);
auto result = mVhalClient->getValueSync(*prop);
@@ -883,13 +891,9 @@
VehicleArea::GLOBAL, VehiclePropertyType::MIXED);
}
-void VtsHalAutomotiveVehicleTargetTest::checkIsSupported(int32_t propertyId) {
+bool VtsHalAutomotiveVehicleTargetTest::checkIsSupported(int32_t propertyId) {
auto result = mVhalClient->getPropConfigs({propertyId});
- ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: "
- << result.error().message();
- if (result.value().size() == 0) {
- GTEST_SKIP() << "Property: " << propertyId << " is not supported, skip the test";
- }
+ return result.ok();
}
std::vector<ServiceDescriptor> getDescriptors() {
diff --git a/media/OWNERS b/media/OWNERS
index 71a53ef..01b440a 100644
--- a/media/OWNERS
+++ b/media/OWNERS
@@ -1,7 +1,6 @@
# Bug component: 25690
# Media team
-jgus@google.com
lajos@google.com
taklee@google.com
wonsik@google.com
diff --git a/tv/OWNERS b/tv/OWNERS
index ee7f272..e051b28 100644
--- a/tv/OWNERS
+++ b/tv/OWNERS
@@ -9,4 +9,5 @@
quxiangfang@google.com
shubang@google.com
yixiaoluo@google.com
+qingxun@google.com
diff --git a/tv/input/OWNERS b/tv/input/OWNERS
index e69de29..1252e4e 100644
--- a/tv/input/OWNERS
+++ b/tv/input/OWNERS
@@ -0,0 +1 @@
+# Bug component: 826094
diff --git a/vibrator/OWNERS b/vibrator/OWNERS
index 62a567e..c4de58a 100644
--- a/vibrator/OWNERS
+++ b/vibrator/OWNERS
@@ -1,8 +1,2 @@
# Bug component: 345036
-
include platform/frameworks/base:/services/core/java/com/android/server/vibrator/OWNERS
-
-chrispaulo@google.com
-michaelwr@google.com
-nathankulczak@google.com
-taikuo@google.com