Merge "Merge TQ1A.230205.002"
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl
index d825eac..ea63de5 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl
@@ -37,6 +37,7 @@
android.hardware.audio.effect.VendorExtension vendorExtension;
android.hardware.audio.effect.Equalizer.BandLevel[] bandLevels;
int preset;
+ int[] centerFreqMh;
@VintfStability
union Id {
int vendorExtensionTag;
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/HapticGenerator.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/HapticGenerator.aidl
index 20f7e02..35186c3 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/HapticGenerator.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/HapticGenerator.aidl
@@ -48,9 +48,9 @@
}
@Backing(type="int") @VintfStability
enum VibratorScale {
- MUTE = (-100),
- VERY_LOW = (-2),
- LOW = (-1),
+ MUTE = (-100) /* -100 */,
+ VERY_LOW = (-2) /* -2 */,
+ LOW = (-1) /* -1 */,
NONE = 0,
HIGH = 1,
VERY_HIGH = 2,
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/NoiseSuppression.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/NoiseSuppression.aidl
index 1cf92ef..153e021 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/NoiseSuppression.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/NoiseSuppression.aidl
@@ -36,6 +36,7 @@
union NoiseSuppression {
android.hardware.audio.effect.VendorExtension vendor;
android.hardware.audio.effect.NoiseSuppression.Level level;
+ android.hardware.audio.effect.NoiseSuppression.Type type;
@VintfStability
union Id {
int vendorExtensionTag;
@@ -52,4 +53,9 @@
HIGH,
VERY_HIGH,
}
+ @Backing(type="int") @VintfStability
+ enum Type {
+ SINGLE_CHANNEL,
+ MULTI_CHANNEL,
+ }
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Virtualizer.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Virtualizer.aidl
index 9fdd692..2f367d9 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Virtualizer.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Virtualizer.aidl
@@ -36,10 +36,18 @@
union Virtualizer {
android.hardware.audio.effect.VendorExtension vendor;
int strengthPm;
+ android.hardware.audio.effect.Virtualizer.ChannelAngle[] speakerAngles;
+ android.media.audio.common.AudioDeviceDescription device;
@VintfStability
union Id {
int vendorExtensionTag;
android.hardware.audio.effect.Virtualizer.Tag commonTag;
+ android.hardware.audio.effect.Virtualizer.SpeakerAnglesPayload speakerAnglesPayload;
+ }
+ @VintfStability
+ parcelable SpeakerAnglesPayload {
+ android.media.audio.common.AudioChannelLayout layout;
+ android.media.audio.common.AudioDeviceDescription device;
}
@VintfStability
parcelable Capability {
@@ -47,4 +55,10 @@
int maxStrengthPm;
boolean strengthSupported;
}
+ @VintfStability
+ parcelable ChannelAngle {
+ int channel;
+ int azimuthDegree;
+ int elevationDegree;
+ }
}
diff --git a/audio/aidl/android/hardware/audio/effect/Equalizer.aidl b/audio/aidl/android/hardware/audio/effect/Equalizer.aidl
index 79a1c4f..7903fde 100644
--- a/audio/aidl/android/hardware/audio/effect/Equalizer.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Equalizer.aidl
@@ -72,7 +72,7 @@
}
/**
- * Supported minimal and maximal frequency for each band in millihertz.
+ * Supported minimal and maximal frequency for each band in milliHertz.
*/
@VintfStability
parcelable BandFrequency {
@@ -97,8 +97,14 @@
* Level for each band.
*/
BandLevel[] bandLevels;
+
/**
* Index of current preset.
*/
int preset;
+
+ /**
+ * Get only parameter, get the center frequency for all bands in milliHertz.
+ */
+ int[] centerFreqMh;
}
diff --git a/audio/aidl/android/hardware/audio/effect/NoiseSuppression.aidl b/audio/aidl/android/hardware/audio/effect/NoiseSuppression.aidl
index 9969a0b..c4baff8 100644
--- a/audio/aidl/android/hardware/audio/effect/NoiseSuppression.aidl
+++ b/audio/aidl/android/hardware/audio/effect/NoiseSuppression.aidl
@@ -68,4 +68,11 @@
* The NS level.
*/
Level level;
+
+ /**
+ * Noise suppression type.
+ */
+ @VintfStability @Backing(type="int") enum Type { SINGLE_CHANNEL, MULTI_CHANNEL }
+
+ Type type;
}
diff --git a/audio/aidl/android/hardware/audio/effect/Virtualizer.aidl b/audio/aidl/android/hardware/audio/effect/Virtualizer.aidl
index 5f385a6..fc453ad 100644
--- a/audio/aidl/android/hardware/audio/effect/Virtualizer.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Virtualizer.aidl
@@ -17,6 +17,8 @@
package android.hardware.audio.effect;
import android.hardware.audio.effect.VendorExtension;
+import android.media.audio.common.AudioChannelLayout;
+import android.media.audio.common.AudioDeviceDescription;
/**
* Virtualizer specific definitions. An audio virtualizer is a general name for an effect to
@@ -35,6 +37,7 @@
union Id {
int vendorExtensionTag;
Virtualizer.Tag commonTag;
+ SpeakerAnglesPayload speakerAnglesPayload;
}
/**
@@ -43,6 +46,25 @@
VendorExtension vendor;
/**
+ * Payload to query speaker angles for the given channel position mask and device.
+ * The Virtualizer implementation must return EX_ILLEGAL_ARGUMENT if the given payload not
+ * supported.
+ */
+ @VintfStability
+ parcelable SpeakerAnglesPayload {
+ /**
+ * Audio channel position definition. See
+ * android.media.audio.common.AudioChannelLayout.aidl. Only the channel position "CHANNEL_*"
+ * in AudioChannelLayout be used.
+ */
+ AudioChannelLayout layout;
+ /**
+ * Audio device type. See android.media.audio.common.AudioDeviceDescription.aidl.
+ */
+ AudioDeviceDescription device;
+ }
+
+ /**
* Capability supported by Virtualizer implementation.
*/
@VintfStability
@@ -74,4 +96,39 @@
* the 'maxStrengthPm' capability.
*/
int strengthPm;
+
+ /**
+ * All angles are expressed in degrees and are relative to the listener.
+ */
+ @VintfStability
+ parcelable ChannelAngle {
+ /**
+ * Audio channel layout, CHANNEL_* constants defined in
+ * android.media.audio.common.AudioChannelLayout.
+ */
+ int channel;
+
+ /**
+ * 0 is the direction the listener faces, 180 is behind the listener, and -90 is left of
+ * the listener.
+ */
+ int azimuthDegree;
+
+ /**
+ * 0 is the horizontal plane, +90 is above the listener, -90 is below.
+ */
+ int elevationDegree;
+ }
+
+ /**
+ * Get only parameter.
+ * A vector of angles per channel represented by azimuth and elevation (in degrees), client must
+ * set Parameter.Id to SpeakerAnglesPayload to get speakerAngles.
+ */
+ ChannelAngle[] speakerAngles;
+
+ /**
+ * The audio device on which virtualzation mode is forced.
+ */
+ AudioDeviceDescription device;
}
diff --git a/audio/aidl/default/equalizer/EqualizerSw.cpp b/audio/aidl/default/equalizer/EqualizerSw.cpp
index 984b943..0a6ac34 100644
--- a/audio/aidl/default/equalizer/EqualizerSw.cpp
+++ b/audio/aidl/default/equalizer/EqualizerSw.cpp
@@ -150,6 +150,10 @@
eqParam.set<Equalizer::preset>(mContext->getEqPreset());
break;
}
+ case Equalizer::centerFreqMh: {
+ eqParam.set<Equalizer::centerFreqMh>(mContext->getCenterFreqs());
+ break;
+ }
default: {
LOG(ERROR) << __func__ << " not handled tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
diff --git a/audio/aidl/default/equalizer/EqualizerSw.h b/audio/aidl/default/equalizer/EqualizerSw.h
index 65a8002..fabcfeb 100644
--- a/audio/aidl/default/equalizer/EqualizerSw.h
+++ b/audio/aidl/default/equalizer/EqualizerSw.h
@@ -68,10 +68,16 @@
return bandLevels;
}
+ std::vector<int> getCenterFreqs() {
+ return {std::begin(kPresetsFrequencies), std::end(kPresetsFrequencies)};
+ }
+
private:
static const int NUM_OF_BANDS = 5;
static const int NUM_OF_PRESETS = 10;
static const int PRESET_CUSTOM = -1;
+ static constexpr std::array<uint16_t, NUM_OF_BANDS> kPresetsFrequencies = {60, 230, 910, 3600,
+ 14000};
// preset band level
int mPreset = PRESET_CUSTOM;
int32_t mBandLevels[NUM_OF_BANDS] = {3, 0, 0, 0, 3};
diff --git a/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.cpp b/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.cpp
index a36cfe0..51fe4ea 100644
--- a/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.cpp
+++ b/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.cpp
@@ -90,10 +90,15 @@
switch (tag) {
case NoiseSuppression::level: {
RETURN_IF(mContext->setLevel(param.get<NoiseSuppression::level>()) != RetCode::SUCCESS,
- EX_ILLEGAL_ARGUMENT, "levelSupported");
+ EX_ILLEGAL_ARGUMENT, "levelNotSupported");
return ndk::ScopedAStatus::ok();
}
- default: {
+ case NoiseSuppression::type: {
+ RETURN_IF(mContext->setType(param.get<NoiseSuppression::type>()) != RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "typeNotSupported");
+ return ndk::ScopedAStatus::ok();
+ }
+ case NoiseSuppression::vendor: {
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
EX_ILLEGAL_ARGUMENT, "NoiseSuppressionTagNotSupported");
@@ -111,10 +116,11 @@
case NoiseSuppression::Id::commonTag:
return getParameterNoiseSuppression(specificId.get<NoiseSuppression::Id::commonTag>(),
specific);
- default:
+ case NoiseSuppression::Id::vendorExtensionTag: {
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
EX_ILLEGAL_ARGUMENT, "NoiseSuppressionTagNotSupported");
+ }
}
}
@@ -127,7 +133,11 @@
param.set<NoiseSuppression::level>(mContext->getLevel());
break;
}
- default: {
+ case NoiseSuppression::type: {
+ param.set<NoiseSuppression::type>(mContext->getType());
+ break;
+ }
+ case NoiseSuppression::vendor: {
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
EX_ILLEGAL_ARGUMENT, "NoiseSuppressionTagNotSupported");
@@ -177,4 +187,9 @@
return mLevel;
}
+RetCode NoiseSuppressionSwContext::setType(NoiseSuppression::Type type) {
+ mType = type;
+ return RetCode::SUCCESS;
+}
+
} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.h b/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.h
index f39d8e5..a851e38 100644
--- a/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.h
+++ b/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.h
@@ -35,9 +35,12 @@
RetCode setLevel(NoiseSuppression::Level level);
NoiseSuppression::Level getLevel();
+ RetCode setType(NoiseSuppression::Type type);
+ NoiseSuppression::Type getType() { return mType; }
private:
NoiseSuppression::Level mLevel = NoiseSuppression::Level::LOW;
+ NoiseSuppression::Type mType = NoiseSuppression::Type::SINGLE_CHANNEL;
};
class NoiseSuppressionSw final : public EffectImpl {
diff --git a/audio/aidl/default/virtualizer/VirtualizerSw.cpp b/audio/aidl/default/virtualizer/VirtualizerSw.cpp
index cc51937..08535bd 100644
--- a/audio/aidl/default/virtualizer/VirtualizerSw.cpp
+++ b/audio/aidl/default/virtualizer/VirtualizerSw.cpp
@@ -30,6 +30,8 @@
using aidl::android::hardware::audio::effect::kVirtualizerSwImplUUID;
using aidl::android::hardware::audio::effect::State;
using aidl::android::hardware::audio::effect::VirtualizerSw;
+using aidl::android::media::audio::common::AudioChannelLayout;
+using aidl::android::media::audio::common::AudioDeviceDescription;
using aidl::android::media::audio::common::AudioUuid;
extern "C" binder_exception_t createEffect(const AudioUuid* in_impl_uuid,
@@ -93,10 +95,18 @@
RETURN_IF(mContext->setVrStrength(vrParam.get<Virtualizer::strengthPm>()) !=
RetCode::SUCCESS,
- EX_ILLEGAL_ARGUMENT, "strengthPmNotSupported");
+ EX_ILLEGAL_ARGUMENT, "setStrengthPmFailed");
return ndk::ScopedAStatus::ok();
}
- default: {
+ case Virtualizer::device: {
+ RETURN_IF(mContext->setForcedDevice(vrParam.get<Virtualizer::device>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "setDeviceFailed");
+ return ndk::ScopedAStatus::ok();
+ }
+ case Virtualizer::speakerAngles:
+ FALLTHROUGH_INTENDED;
+ case Virtualizer::vendor: {
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
"VirtualizerTagNotSupported");
@@ -113,10 +123,13 @@
switch (vrIdTag) {
case Virtualizer::Id::commonTag:
return getParameterVirtualizer(vrId.get<Virtualizer::Id::commonTag>(), specific);
- default:
+ case Virtualizer::Id::speakerAnglesPayload:
+ return getSpeakerAngles(vrId.get<Virtualizer::Id::speakerAnglesPayload>(), specific);
+ case Virtualizer::Id::vendorExtensionTag: {
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
"VirtualizerTagNotSupported");
+ }
}
}
@@ -130,7 +143,13 @@
vrParam.set<Virtualizer::strengthPm>(mContext->getVrStrength());
break;
}
- default: {
+ case Virtualizer::device: {
+ vrParam.set<Virtualizer::device>(mContext->getForcedDevice());
+ break;
+ }
+ case Virtualizer::speakerAngles:
+ FALLTHROUGH_INTENDED;
+ case Virtualizer::vendor: {
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
"VirtualizerTagNotSupported");
@@ -141,6 +160,27 @@
return ndk::ScopedAStatus::ok();
}
+ndk::ScopedAStatus VirtualizerSw::getSpeakerAngles(const Virtualizer::SpeakerAnglesPayload payload,
+ Parameter::Specific* specific) {
+ std::vector<Virtualizer::ChannelAngle> angles;
+ if (::android::hardware::audio::common::getChannelCount(payload.layout) == 1) {
+ angles = {{.channel = (int32_t)AudioChannelLayout::CHANNEL_FRONT_LEFT,
+ .azimuthDegree = 0,
+ .elevationDegree = 0}};
+ } else {
+ angles = {{.channel = (int32_t)AudioChannelLayout::CHANNEL_FRONT_LEFT,
+ .azimuthDegree = -90,
+ .elevationDegree = 0},
+ {.channel = (int32_t)AudioChannelLayout::CHANNEL_FRONT_RIGHT,
+ .azimuthDegree = 90,
+ .elevationDegree = 0}};
+ }
+
+ Virtualizer param = Virtualizer::make<Virtualizer::speakerAngles>(angles);
+ specific->set<Parameter::Specific::virtualizer>(param);
+ return ndk::ScopedAStatus::ok();
+}
+
std::shared_ptr<EffectContext> VirtualizerSw::createContext(const Parameter::Common& common) {
if (mContext) {
LOG(DEBUG) << __func__ << " context already exist";
diff --git a/audio/aidl/default/virtualizer/VirtualizerSw.h b/audio/aidl/default/virtualizer/VirtualizerSw.h
index 0f294cd..1016ffc 100644
--- a/audio/aidl/default/virtualizer/VirtualizerSw.h
+++ b/audio/aidl/default/virtualizer/VirtualizerSw.h
@@ -34,9 +34,18 @@
}
RetCode setVrStrength(int strength);
int getVrStrength() const { return mStrength; }
+ RetCode setForcedDevice(
+ const ::aidl::android::media::audio::common::AudioDeviceDescription& device) {
+ mForceDevice = device;
+ return RetCode::SUCCESS;
+ }
+ aidl::android::media::audio::common::AudioDeviceDescription getForcedDevice() const {
+ return mForceDevice;
+ }
private:
int mStrength = 0;
+ ::aidl::android::media::audio::common::AudioDeviceDescription mForceDevice;
};
class VirtualizerSw final : public EffectImpl {
@@ -68,5 +77,7 @@
ndk::ScopedAStatus getParameterVirtualizer(const Virtualizer::Tag& tag,
Parameter::Specific* specific);
+ ndk::ScopedAStatus getSpeakerAngles(const Virtualizer::SpeakerAnglesPayload payload,
+ Parameter::Specific* specific);
};
} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/vts/VtsHalNSTargetTest.cpp b/audio/aidl/vts/VtsHalNSTargetTest.cpp
index 93ad86d..0b92290 100644
--- a/audio/aidl/vts/VtsHalNSTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalNSTargetTest.cpp
@@ -34,13 +34,14 @@
using aidl::android::hardware::audio::effect::NoiseSuppression;
using aidl::android::hardware::audio::effect::Parameter;
-enum ParamName { PARAM_INSTANCE_NAME, PARAM_LEVEL };
-using NSParamTestParam =
- std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, NoiseSuppression::Level>;
+enum ParamName { PARAM_INSTANCE_NAME, PARAM_LEVEL, PARAM_TYPE };
+using NSParamTestParam = std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>,
+ NoiseSuppression::Level, NoiseSuppression::Type>;
class NSParamTest : public ::testing::TestWithParam<NSParamTestParam>, public EffectHelper {
public:
- NSParamTest() : mLevel(std::get<PARAM_LEVEL>(GetParam())) {
+ NSParamTest()
+ : mLevel(std::get<PARAM_LEVEL>(GetParam())), mType(std::get<PARAM_TYPE>(GetParam())) {
std::tie(mFactory, mDescriptor) = std::get<PARAM_INSTANCE_NAME>(GetParam());
}
@@ -75,6 +76,7 @@
std::shared_ptr<IEffect> mEffect;
Descriptor mDescriptor;
NoiseSuppression::Level mLevel;
+ NoiseSuppression::Type mType;
void SetAndGetParameters() {
for (auto& it : mTags) {
@@ -113,10 +115,19 @@
ns.set<NoiseSuppression::level>(level);
mTags.push_back({NoiseSuppression::level, ns});
}
+ void addTypeParam(NoiseSuppression::Type type) {
+ NoiseSuppression ns;
+ ns.set<NoiseSuppression::type>(type);
+ mTags.push_back({NoiseSuppression::type, ns});
+ }
static std::unordered_set<NoiseSuppression::Level> getLevelValues() {
return {ndk::enum_range<NoiseSuppression::Level>().begin(),
ndk::enum_range<NoiseSuppression::Level>().end()};
}
+ static std::unordered_set<NoiseSuppression::Type> getTypeValues() {
+ return {ndk::enum_range<NoiseSuppression::Type>().begin(),
+ ndk::enum_range<NoiseSuppression::Type>().end()};
+ }
private:
std::vector<std::pair<NoiseSuppression::Tag, NoiseSuppression>> mTags;
@@ -128,18 +139,27 @@
SetAndGetParameters();
}
+TEST_P(NSParamTest, SetAndGetType) {
+ EXPECT_NO_FATAL_FAILURE(addLevelParam(mLevel));
+ SetAndGetParameters();
+}
+
INSTANTIATE_TEST_SUITE_P(
NSParamTest, NSParamTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, kNoiseSuppressionTypeUUID)),
- testing::ValuesIn(NSParamTest::getLevelValues())),
+ testing::ValuesIn(NSParamTest::getLevelValues()),
+ testing::ValuesIn(NSParamTest::getTypeValues())),
[](const testing::TestParamInfo<NSParamTest::ParamType>& info) {
auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
std::string level = aidl::android::hardware::audio::effect::toString(
std::get<PARAM_LEVEL>(info.param));
+ std::string type = aidl::android::hardware::audio::effect::toString(
+ std::get<PARAM_TYPE>(info.param));
std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
descriptor.common.name + "_UUID_" +
- descriptor.common.id.uuid.toString() + "_level_" + level;
+ descriptor.common.id.uuid.toString() + "_level_" + level + "_type_" +
+ type;
std::replace_if(
name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
return name;
diff --git a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
index e9b74b7..128ef61 100644
--- a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
+++ b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
@@ -1566,6 +1566,7 @@
};
for (auto& lc3_config : lc3_codec_configs) {
+ le_audio_broadcast_config.streamMap.resize(1);
le_audio_broadcast_config.streamMap[0]
.leAudioCodecConfig.set<LeAudioCodecConfiguration::lc3Config>(
lc3_config);
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp
index 1dec900..0a804bb 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp
@@ -200,13 +200,21 @@
GetUnicastCapability(scenario.getEncode());
UnicastCapability unicast_decode_capability =
GetUnicastCapability(scenario.getDecode());
- // encode and decode cannot be unknown at the same time
- if (unicast_encode_capability.codecType == CodecType::UNKNOWN &&
- unicast_decode_capability.codecType == CodecType::UNKNOWN) {
- continue;
- }
BroadcastCapability broadcast_capability = {.codecType =
CodecType::UNKNOWN};
+
+ if (scenario.hasBroadcast()) {
+ broadcast_capability = GetBroadcastCapability(scenario.getBroadcast());
+ }
+
+ // At least one capability should be valid
+ if (unicast_encode_capability.codecType == CodecType::UNKNOWN &&
+ unicast_decode_capability.codecType == CodecType::UNKNOWN &&
+ broadcast_capability.codecType == CodecType::UNKNOWN) {
+ LOG(ERROR) << __func__ << ": None of the capability is valid.";
+ continue;
+ }
+
le_audio_codec_capabilities.push_back(
{.unicastEncodeCapability = unicast_encode_capability,
.unicastDecodeCapability = unicast_decode_capability,
@@ -252,6 +260,54 @@
return {.codecType = CodecType::UNKNOWN};
}
+BroadcastCapability BluetoothLeAudioCodecsProvider::GetBroadcastCapability(
+ const std::string& coding_direction) {
+ if (coding_direction == "invalid") {
+ return {.codecType = CodecType::UNKNOWN};
+ }
+
+ auto configuration_iter = configuration_map_.find(coding_direction);
+ if (configuration_iter == configuration_map_.end()) {
+ return {.codecType = CodecType::UNKNOWN};
+ }
+
+ auto codec_configuration_iter = codec_configuration_map_.find(
+ configuration_iter->second.getCodecConfiguration());
+ if (codec_configuration_iter == codec_configuration_map_.end()) {
+ return {.codecType = CodecType::UNKNOWN};
+ }
+
+ auto strategy_configuration_iter = strategy_configuration_map_.find(
+ configuration_iter->second.getStrategyConfiguration());
+ if (strategy_configuration_iter == strategy_configuration_map_.end()) {
+ return {.codecType = CodecType::UNKNOWN};
+ }
+
+ CodecType codec_type =
+ GetCodecType(codec_configuration_iter->second.getCodec());
+ std::vector<std::optional<Lc3Capabilities>> bcastLc3Cap(
+ 1, std::optional(ComposeLc3Capability(codec_configuration_iter->second)));
+
+ if (codec_type == CodecType::LC3) {
+ return ComposeBroadcastCapability(
+ codec_type,
+ GetAudioLocation(
+ strategy_configuration_iter->second.getAudioLocation()),
+ strategy_configuration_iter->second.getChannelCount(), bcastLc3Cap);
+ }
+ return {.codecType = CodecType::UNKNOWN};
+}
+
+template <class T>
+BroadcastCapability BluetoothLeAudioCodecsProvider::ComposeBroadcastCapability(
+ const CodecType& codec_type, const AudioLocation& audio_location,
+ const uint8_t& channel_count, const std::vector<T>& capability) {
+ return {.codecType = codec_type,
+ .supportedChannel = audio_location,
+ .channelCountPerStream = channel_count,
+ .leAudioCodecCapabilities = std::optional(capability)};
+}
+
template <class T>
UnicastCapability BluetoothLeAudioCodecsProvider::ComposeUnicastCapability(
const CodecType& codec_type, const AudioLocation& audio_location,
@@ -322,6 +378,10 @@
// 1. two connected device, one for L one for R
// 2. one connected device for both L and R
return true;
+ } else if (strategy_configuration.getConnectedDevice() == 0 &&
+ strategy_configuration.getChannelCount() == 2) {
+ // Broadcast
+ return true;
}
} else if (strategy_configuration.getAudioLocation() ==
setting::AudioLocation::MONO) {
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h
index e879984..06e4595 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h
+++ b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h
@@ -20,6 +20,7 @@
#include <android-base/logging.h>
#include <unordered_map>
+#include <vector>
#include "aidl_android_hardware_bluetooth_audio_setting.h"
@@ -66,12 +67,20 @@
static UnicastCapability GetUnicastCapability(
const std::string& coding_direction);
+ static BroadcastCapability GetBroadcastCapability(
+ const std::string& coding_direction);
+
template <class T>
static inline UnicastCapability ComposeUnicastCapability(
const CodecType& codec_type, const AudioLocation& audio_location,
const uint8_t& device_cnt, const uint8_t& channel_count,
const T& capability);
+ template <class T>
+ static inline BroadcastCapability ComposeBroadcastCapability(
+ const CodecType& codec_type, const AudioLocation& audio_location,
+ const uint8_t& channel_count, const std::vector<T>& capability);
+
static inline Lc3Capabilities ComposeLc3Capability(
const setting::CodecConfiguration& codec_configuration);
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProviderTest.cpp b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProviderTest.cpp
index 5393cd7..dba2749 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProviderTest.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProviderTest.cpp
@@ -46,7 +46,11 @@
// Define valid components for each list
// Scenario
static const Scenario kValidScenario(std::make_optional("OneChanStereo_16_1"),
- std::make_optional("OneChanStereo_16_1"));
+ std::make_optional("OneChanStereo_16_1"),
+ std::nullopt);
+static const Scenario kValidBroadcastScenario(
+ std::nullopt, std::nullopt, std::make_optional("BcastStereo_16_2"));
+
// Configuration
static const Configuration kValidConfigOneChanStereo_16_1(
std::make_optional("OneChanStereo_16_1"), std::make_optional("LC3_16k_1"),
@@ -69,11 +73,15 @@
std::make_optional("MONO_ONE_CIS_PER_DEVICE"),
std::make_optional(AudioLocation::MONO), std::make_optional(1),
std::make_optional(1));
+static const StrategyConfiguration kValidStrategyBroadcastStereo(
+ std::make_optional("BROADCAST_STEREO"),
+ std::make_optional(AudioLocation::STEREO), std::make_optional(0),
+ std::make_optional(2));
// Define valid test list built from above valid components
// Scenario, Configuration, CodecConfiguration, StrategyConfiguration
-static const std::vector<ScenarioList> kValidScenarioList = {
- ScenarioList(std::vector<Scenario>{kValidScenario})};
+static const std::vector<ScenarioList> kValidScenarioList = {ScenarioList(
+ std::vector<Scenario>{kValidScenario, kValidBroadcastScenario})};
static const std::vector<ConfigurationList> kValidConfigurationList = {
ConfigurationList(
std::vector<Configuration>{kValidConfigOneChanStereo_16_1})};
@@ -84,7 +92,7 @@
kValidStrategyConfigurationList = {
StrategyConfigurationList(std::vector<StrategyConfiguration>{
kValidStrategyStereoOneCis, kValidStrategyStereoTwoCis,
- kValidStrategyMonoOneCis})};
+ kValidStrategyMonoOneCis, kValidStrategyBroadcastStereo})};
class BluetoothLeAudioCodecsProviderTest
: public ::testing::TestWithParam<OffloadSetting> {
@@ -151,13 +159,15 @@
static std::vector<ScenarioList> CreateInvalidScenarios() {
std::vector<ScenarioList> invalid_scenario_test_cases;
invalid_scenario_test_cases.push_back(ScenarioList(std::vector<Scenario>{
- Scenario(std::nullopt, std::make_optional("OneChanStereo_16_1"))}));
-
- invalid_scenario_test_cases.push_back(ScenarioList(std::vector<Scenario>{
- Scenario(std::make_optional("OneChanStereo_16_1"), std::nullopt)}));
+ Scenario(std::nullopt, std::make_optional("OneChanStereo_16_1"),
+ std::nullopt)}));
invalid_scenario_test_cases.push_back(ScenarioList(
- std::vector<Scenario>{Scenario(std::nullopt, std::nullopt)}));
+ std::vector<Scenario>{Scenario(std::make_optional("OneChanStereo_16_1"),
+ std::nullopt, std::nullopt)}));
+
+ invalid_scenario_test_cases.push_back(ScenarioList(std::vector<Scenario>{
+ Scenario(std::nullopt, std::nullopt, std::nullopt)}));
invalid_scenario_test_cases.push_back(
ScenarioList(std::vector<Scenario>{}));
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 c7904b3..c8d1af0 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
@@ -40,6 +40,8 @@
<scenario encode="OneChanStereo_16_2" decode="OneChanMono_16_2"/>
<scenario encode="TwoChanStereo_16_2" decode="OneChanMono_16_2"/>
<scenario encode="OneChanMono_16_2" decode="OneChanMono_16_2"/>
+ <!-- broadcast -->
+ <scenario encode="invalid" decode="invalid" broadcast="BcastStereo_16_2"/>
</scenarioList>
<configurationList>
<configuration name="OneChanMono_16_1" codecConfiguration="LC3_16k_1" strategyConfiguration="MONO_ONE_CIS_PER_DEVICE"/>
@@ -48,6 +50,7 @@
<configuration name="OneChanMono_16_2" codecConfiguration="LC3_16k_2" strategyConfiguration="MONO_ONE_CIS_PER_DEVICE"/>
<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"/>
</configurationList>
<codecConfigurationList>
<codecConfiguration name="LC3_16k_1" codec="LC3" samplingFrequency="16000" frameDurationUs="7500" octetsPerCodecFrame="30"/>
@@ -57,5 +60,6 @@
<strategyConfiguration name="STEREO_ONE_CIS_PER_DEVICE" audioLocation="STEREO" connectedDevice="2" channelCount="1"/>
<strategyConfiguration name="STEREO_TWO_CISES_PER_DEVICE" audioLocation="STEREO" connectedDevice="1" channelCount="2"/>
<strategyConfiguration name="MONO_ONE_CIS_PER_DEVICE" audioLocation="MONO" connectedDevice="1" channelCount="1"/>
+ <strategyConfiguration name="BROADCAST_STEREO" audioLocation="STEREO" connectedDevice="0" channelCount="2"/>
</strategyConfigurationList>
</leAudioOffloadSetting>
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 213e597..8c2d6a1 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
@@ -32,6 +32,7 @@
<xs:complexType>
<xs:attribute name="encode" type="xs:string"/>
<xs:attribute name="decode" type="xs:string"/>
+ <xs:attribute name="broadcast" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="configuration">
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 06aa21a..886350e 100644
--- a/bluetooth/audio/utils/le_audio_codec_capabilities/schema/current.txt
+++ b/bluetooth/audio/utils/le_audio_codec_capabilities/schema/current.txt
@@ -64,8 +64,10 @@
public class Scenario {
ctor public Scenario();
+ method public String getBroadcast();
method public String getDecode();
method public String getEncode();
+ method public void setBroadcast(String);
method public void setDecode(String);
method public void setEncode(String);
}
diff --git a/cas/aidl/default/OWNERS b/cas/aidl/OWNERS
similarity index 100%
rename from cas/aidl/default/OWNERS
rename to cas/aidl/OWNERS
diff --git a/secure_element/1.0/vts/OWNERS b/secure_element/1.0/vts/OWNERS
deleted file mode 100644
index c7963e7..0000000
--- a/secure_element/1.0/vts/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-alisher@google.com
-jackcwyu@google.com
-georgekgchang@google.com
-zachoverflow@google.com
diff --git a/secure_element/1.0/vts/functional/OWNERS b/secure_element/1.0/vts/functional/OWNERS
deleted file mode 100644
index a7ee7e9..0000000
--- a/secure_element/1.0/vts/functional/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-# Bug component: 456592
-jackcwyu@google.com
diff --git a/secure_element/1.1/vts/OWNERS b/secure_element/1.1/vts/OWNERS
deleted file mode 100644
index c7963e7..0000000
--- a/secure_element/1.1/vts/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-alisher@google.com
-jackcwyu@google.com
-georgekgchang@google.com
-zachoverflow@google.com
diff --git a/secure_element/1.1/vts/functional/OWNERS b/secure_element/1.1/vts/functional/OWNERS
deleted file mode 100644
index a7ee7e9..0000000
--- a/secure_element/1.1/vts/functional/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-# Bug component: 456592
-jackcwyu@google.com
diff --git a/secure_element/1.2/vts/OWNERS b/secure_element/1.2/vts/OWNERS
deleted file mode 100644
index c7963e7..0000000
--- a/secure_element/1.2/vts/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-alisher@google.com
-jackcwyu@google.com
-georgekgchang@google.com
-zachoverflow@google.com
diff --git a/secure_element/1.2/vts/functional/OWNERS b/secure_element/1.2/vts/functional/OWNERS
deleted file mode 100644
index a7ee7e9..0000000
--- a/secure_element/1.2/vts/functional/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-# Bug component: 456592
-jackcwyu@google.com
diff --git a/secure_element/OWNERS b/secure_element/OWNERS
new file mode 100644
index 0000000..492696b
--- /dev/null
+++ b/secure_element/OWNERS
@@ -0,0 +1,5 @@
+# Bug component: 456592
+alisher@google.com
+jackcwyu@google.com
+georgekgchang@google.com
+henrichataing@google.com
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
index e9cbe10..588a1d4 100644
--- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
@@ -2052,9 +2052,10 @@
// Check whether the given named feature is available.
bool check_feature(const std::string& name) {
::android::sp<::android::IServiceManager> sm(::android::defaultServiceManager());
- ::android::sp<::android::IBinder> binder(sm->getService(::android::String16("package_native")));
+ ::android::sp<::android::IBinder> binder(
+ sm->waitForService(::android::String16("package_native")));
if (binder == nullptr) {
- GTEST_LOG_(ERROR) << "getService package_native failed";
+ GTEST_LOG_(ERROR) << "waitForService package_native failed";
return false;
}
::android::sp<::android::content::pm::IPackageManagerNative> packageMgr =
diff --git a/thermal/aidl/android/hardware/thermal/IThermal.aidl b/thermal/aidl/android/hardware/thermal/IThermal.aidl
index 7c23c17..c94edcd 100644
--- a/thermal/aidl/android/hardware/thermal/IThermal.aidl
+++ b/thermal/aidl/android/hardware/thermal/IThermal.aidl
@@ -36,9 +36,8 @@
* exist on boot. The method always returns and never removes from
* the list such cooling devices.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, getMessage() must be populated with the human-readable
- * error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
CoolingDevice[] getCoolingDevices();
@@ -54,9 +53,8 @@
* exist on boot. The method always returns and never removes from
* the list such cooling devices.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
CoolingDevice[] getCoolingDevicesWithType(in CoolingType type);
@@ -70,9 +68,8 @@
* they go offline, if these devices exist on boot. The method
* always returns and never removes such temperatures.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
Temperature[] getTemperatures();
@@ -88,9 +85,8 @@
* they go offline, if these devices exist on boot. The method
* always returns and never removes such temperatures.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
Temperature[] getTemperaturesWithType(in TemperatureType type);
@@ -110,9 +106,8 @@
* throttling status, use getTemperatures or registerThermalChangedCallback
* and listen to the callback.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
TemperatureThreshold[] getTemperatureThresholds();
@@ -135,9 +130,8 @@
* throttling status, use getTemperatures or registerThermalChangedCallback
* and listen to the callback.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
TemperatureThreshold[] getTemperatureThresholdsWithType(in TemperatureType type);
@@ -152,12 +146,10 @@
* thermal events. if nullptr callback is given, the status code will be
* STATUS_BAD_VALUE and the operation will fail.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message. If callback is given nullptr, the returned status code
- * will be STATUS_BAD_VALUE and the exception will be EX_ILLEGAL_ARGUMENT.
- * if callback is already registered, the returned status code will be
- * STATUS_INVALID_OPERATION, the exception will be EX_ILLEGAL_ARGUMENT.
+ * @throws EX_ILLEGAL_ARGUMENT If the callback is given nullptr or already registered. And the
+ * getMessage() must be populated with human-readable error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
void registerThermalChangedCallback(in IThermalChangedCallback callback);
@@ -174,12 +166,10 @@
* STATUS_BAD_VALUE and the operation will fail.
* @param type the type to be filtered.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message. If callback is given nullptr, the returned status code
- * will be STATUS_BAD_VALUE and the exception will be EX_ILLEGAL_ARGUMENT.
- * if callback is already registered, the returned status code will be
- * STATUS_INVALID_OPERATION, the exception will be EX_ILLEGAL_ARGUMENT.
+ * @throws EX_ILLEGAL_ARGUMENT If the callback is given nullptr or already registered. And the
+ * getMessage() must be populated with human-readable error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
void registerThermalChangedCallbackWithType(
in IThermalChangedCallback callback, in TemperatureType type);
@@ -192,12 +182,10 @@
* thermal events. if nullptr callback is given, the status code will be
* STATUS_BAD_VALUE and the operation will fail.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message. If callback is given nullptr, the returned status code
- * will be STATUS_BAD_VALUE and the exception will be EX_ILLEGAL_ARGUMENT.
- * if callback is not registered, the returned status code will be
- * STATUS_INVALID_OPERATION, the exception will be EX_ILLEGAL_ARGUMENT.
+ * @throws EX_ILLEGAL_ARGUMENT If the callback is given nullptr or not previously registered.
+ * And the getMessage() must be populated with human-readable error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
void unregisterThermalChangedCallback(in IThermalChangedCallback callback);
}
diff --git a/thermal/aidl/default/Thermal.cpp b/thermal/aidl/default/Thermal.cpp
index 5771e0e..f643d22 100644
--- a/thermal/aidl/default/Thermal.cpp
+++ b/thermal/aidl/default/Thermal.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#define LOG_TAG "thermal_service_example"
+
#include "Thermal.h"
#include <android-base/logging.h>
@@ -22,6 +24,18 @@
using ndk::ScopedAStatus;
+namespace {
+
+bool interfacesEqual(const std::shared_ptr<::ndk::ICInterface>& left,
+ const std::shared_ptr<::ndk::ICInterface>& right) {
+ if (left == nullptr || right == nullptr || !left->isRemote() || !right->isRemote()) {
+ return left == right;
+ }
+ return left->asBinder() == right->asBinder();
+}
+
+} // namespace
+
ScopedAStatus Thermal::getCoolingDevices(std::vector<CoolingDevice>* /* out_devices */) {
LOG(VERBOSE) << __func__;
return ScopedAStatus::ok();
@@ -61,12 +75,20 @@
const std::shared_ptr<IThermalChangedCallback>& in_callback) {
LOG(VERBOSE) << __func__ << " IThermalChangedCallback: " << in_callback;
if (in_callback == nullptr) {
- return ScopedAStatus::fromStatus(STATUS_BAD_VALUE);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Invalid nullptr callback");
}
- if (mCallbacks.find(in_callback) != mCallbacks.end()) {
- return ScopedAStatus::fromStatus(STATUS_INVALID_OPERATION);
+ {
+ std::lock_guard<std::mutex> _lock(thermal_callback_mutex_);
+ if (std::any_of(thermal_callbacks_.begin(), thermal_callbacks_.end(),
+ [&](const std::shared_ptr<IThermalChangedCallback>& c) {
+ return interfacesEqual(c, in_callback);
+ })) {
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Callback already registered");
+ }
+ thermal_callbacks_.push_back(in_callback);
}
- mCallbacks.insert(in_callback);
return ScopedAStatus::ok();
}
@@ -75,26 +97,48 @@
LOG(VERBOSE) << __func__ << " IThermalChangedCallback: " << in_callback
<< ", TemperatureType: " << static_cast<int32_t>(in_type);
if (in_callback == nullptr) {
- return ScopedAStatus::fromStatus(STATUS_BAD_VALUE);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Invalid nullptr callback");
}
- if (mCallbacks.find(in_callback) != mCallbacks.end()) {
- return ScopedAStatus::fromStatus(STATUS_INVALID_OPERATION);
+ {
+ std::lock_guard<std::mutex> _lock(thermal_callback_mutex_);
+ if (std::any_of(thermal_callbacks_.begin(), thermal_callbacks_.end(),
+ [&](const std::shared_ptr<IThermalChangedCallback>& c) {
+ return interfacesEqual(c, in_callback);
+ })) {
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Callback already registered");
+ }
+ thermal_callbacks_.push_back(in_callback);
}
- mCallbacks.insert(in_callback);
return ScopedAStatus::ok();
}
ScopedAStatus Thermal::unregisterThermalChangedCallback(
const std::shared_ptr<IThermalChangedCallback>& in_callback) {
LOG(VERBOSE) << __func__ << " IThermalChangedCallback: " << in_callback;
- bool found = false;
if (in_callback == nullptr) {
- return ScopedAStatus::fromStatus(STATUS_BAD_VALUE);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Invalid nullptr callback");
}
- if (mCallbacks.find(in_callback) == mCallbacks.end()) {
- return ScopedAStatus::fromStatus(STATUS_INVALID_OPERATION);
+ {
+ std::lock_guard<std::mutex> _lock(thermal_callback_mutex_);
+ bool removed = false;
+ thermal_callbacks_.erase(
+ std::remove_if(thermal_callbacks_.begin(), thermal_callbacks_.end(),
+ [&](const std::shared_ptr<IThermalChangedCallback>& c) {
+ if (interfacesEqual(c, in_callback)) {
+ removed = true;
+ return true;
+ }
+ return false;
+ }),
+ thermal_callbacks_.end());
+ if (!removed) {
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Callback wasn't registered");
+ }
}
- mCallbacks.erase(in_callback);
return ScopedAStatus::ok();
}
diff --git a/thermal/aidl/default/Thermal.h b/thermal/aidl/default/Thermal.h
index 788af4a..8885e63 100644
--- a/thermal/aidl/default/Thermal.h
+++ b/thermal/aidl/default/Thermal.h
@@ -54,7 +54,8 @@
const std::shared_ptr<IThermalChangedCallback>& in_callback) override;
private:
- std::set<std::shared_ptr<IThermalChangedCallback>> mCallbacks;
+ std::mutex thermal_callback_mutex_;
+ std::vector<std::shared_ptr<IThermalChangedCallback>> thermal_callbacks_;
};
} // namespace example
diff --git a/thermal/aidl/default/main.cpp b/thermal/aidl/default/main.cpp
index 61d8ad0..9f4ddb8 100644
--- a/thermal/aidl/default/main.cpp
+++ b/thermal/aidl/default/main.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#define LOG_TAG "thermal_service_example"
+
#include "Thermal.h"
#include <android-base/logging.h>
diff --git a/thermal/aidl/vts/VtsHalThermalTargetTest.cpp b/thermal/aidl/vts/VtsHalThermalTargetTest.cpp
index b93250e..73c5dd2 100644
--- a/thermal/aidl/vts/VtsHalThermalTargetTest.cpp
+++ b/thermal/aidl/vts/VtsHalThermalTargetTest.cpp
@@ -95,21 +95,21 @@
mThermalCallback = ndk::SharedRefBase::make<ThermalCallback>();
ASSERT_NE(mThermalCallback, nullptr);
- auto ret = mThermal->registerThermalChangedCallback(mThermalCallback);
- ASSERT_TRUE(ret.isOk());
+ auto status = mThermal->registerThermalChangedCallback(mThermalCallback);
+ ASSERT_TRUE(status.isOk());
// Expect to fail if register again
- ret = mThermal->registerThermalChangedCallback(mThermalCallback);
- ASSERT_FALSE(ret.isOk());
- ASSERT_TRUE(ret.getStatus() == STATUS_INVALID_OPERATION);
+ status = mThermal->registerThermalChangedCallback(mThermalCallback);
+ ASSERT_FALSE(status.isOk());
+ ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
}
void TearDown() override {
- auto ret = mThermal->unregisterThermalChangedCallback(mThermalCallback);
- ASSERT_TRUE(ret.isOk());
+ auto status = mThermal->unregisterThermalChangedCallback(mThermalCallback);
+ ASSERT_TRUE(status.isOk());
// Expect to fail if unregister again
- ret = mThermal->unregisterThermalChangedCallback(mThermalCallback);
- ASSERT_FALSE(ret.isOk());
- ASSERT_TRUE(ret.getStatus() == STATUS_INVALID_OPERATION);
+ status = mThermal->unregisterThermalChangedCallback(mThermalCallback);
+ ASSERT_FALSE(status.isOk());
+ ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
}
protected: