Merge changes Ic8eaee53,Ide961d91,Ie97f3ce9
* changes:
audio: Allow going to 'IDLE' for synchronous drain
audio: Improve test coverage
audio VTS: Refactor support for non-deterministic SM behavior
diff --git a/audio/aidl/TEST_MAPPING b/audio/aidl/TEST_MAPPING
index a166e61..486c13d 100644
--- a/audio/aidl/TEST_MAPPING
+++ b/audio/aidl/TEST_MAPPING
@@ -13,6 +13,9 @@
"name": "VtsHalDownmixTargetTest"
},
{
+ "name": "VtsHalDynamicProcessingTargetTest"
+ },
+ {
"name": "VtsHalEnvironmentalReverbTargetTest"
},
{
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/CommandId.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/CommandId.aidl
index 79299ee..86b69fa 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/CommandId.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/CommandId.aidl
@@ -37,14 +37,14 @@
START = 0,
STOP = 1,
RESET = 2,
- VENDOR_COMMAND_0 = 256,
- VENDOR_COMMAND_1 = 257,
- VENDOR_COMMAND_2 = 258,
- VENDOR_COMMAND_3 = 259,
- VENDOR_COMMAND_4 = 260,
- VENDOR_COMMAND_5 = 261,
- VENDOR_COMMAND_6 = 262,
- VENDOR_COMMAND_7 = 263,
- VENDOR_COMMAND_8 = 264,
- VENDOR_COMMAND_9 = 265,
+ VENDOR_COMMAND_0 = 0x100,
+ VENDOR_COMMAND_1,
+ VENDOR_COMMAND_2,
+ VENDOR_COMMAND_3,
+ VENDOR_COMMAND_4,
+ VENDOR_COMMAND_5,
+ VENDOR_COMMAND_6,
+ VENDOR_COMMAND_7,
+ VENDOR_COMMAND_8,
+ VENDOR_COMMAND_9,
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Downmix.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Downmix.aidl
index 76f8ce5..402441d 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Downmix.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Downmix.aidl
@@ -47,7 +47,7 @@
}
@VintfStability
enum Type {
- STRIP = 0,
- FOLD = 1,
+ STRIP,
+ FOLD,
}
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/DynamicsProcessing.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/DynamicsProcessing.aidl
index ed4dc80..8e5b719 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/DynamicsProcessing.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/DynamicsProcessing.aidl
@@ -36,14 +36,14 @@
union DynamicsProcessing {
android.hardware.audio.effect.VendorExtension vendorExtension;
android.hardware.audio.effect.DynamicsProcessing.EngineArchitecture engineArchitecture;
- android.hardware.audio.effect.DynamicsProcessing.BandChannelConfig preEq;
- android.hardware.audio.effect.DynamicsProcessing.BandChannelConfig postEq;
- android.hardware.audio.effect.DynamicsProcessing.EqBandConfig preEqBand;
- android.hardware.audio.effect.DynamicsProcessing.EqBandConfig postEqBand;
- android.hardware.audio.effect.DynamicsProcessing.BandChannelConfig mbc;
- android.hardware.audio.effect.DynamicsProcessing.MbcBandConfig mbcBand;
- android.hardware.audio.effect.DynamicsProcessing.LimiterConfig limiter;
- float inputGainDb;
+ android.hardware.audio.effect.DynamicsProcessing.ChannelConfig[] preEq;
+ android.hardware.audio.effect.DynamicsProcessing.ChannelConfig[] postEq;
+ android.hardware.audio.effect.DynamicsProcessing.EqBandConfig[] preEqBand;
+ android.hardware.audio.effect.DynamicsProcessing.EqBandConfig[] postEqBand;
+ android.hardware.audio.effect.DynamicsProcessing.ChannelConfig[] mbc;
+ android.hardware.audio.effect.DynamicsProcessing.MbcBandConfig[] mbcBand;
+ android.hardware.audio.effect.DynamicsProcessing.LimiterConfig[] limiter;
+ android.hardware.audio.effect.DynamicsProcessing.InputGain[] inputGain;
@VintfStability
union Id {
int vendorExtensionTag;
@@ -52,37 +52,39 @@
@VintfStability
parcelable Capability {
ParcelableHolder extension;
+ float minCutOffFreq;
+ float maxCutOffFreq;
}
enum ResolutionPreference {
- FAVOR_FREQUENCY_RESOLUTION = 0,
- FAVOR_TIME_RESOLUTION = 1,
+ FAVOR_FREQUENCY_RESOLUTION,
+ FAVOR_TIME_RESOLUTION,
}
@VintfStability
- parcelable BandEnablement {
+ parcelable StageEnablement {
boolean inUse;
int bandCount;
}
@VintfStability
parcelable EngineArchitecture {
android.hardware.audio.effect.DynamicsProcessing.ResolutionPreference resolutionPreference = android.hardware.audio.effect.DynamicsProcessing.ResolutionPreference.FAVOR_FREQUENCY_RESOLUTION;
- float preferredFrameDurationMs;
- android.hardware.audio.effect.DynamicsProcessing.BandEnablement preEqBand;
- android.hardware.audio.effect.DynamicsProcessing.BandEnablement postEqBand;
- android.hardware.audio.effect.DynamicsProcessing.BandEnablement mbcBand;
+ float preferredProcessingDurationMs;
+ android.hardware.audio.effect.DynamicsProcessing.StageEnablement preEqStage;
+ android.hardware.audio.effect.DynamicsProcessing.StageEnablement postEqStage;
+ android.hardware.audio.effect.DynamicsProcessing.StageEnablement mbcStage;
boolean limiterInUse;
}
@VintfStability
- parcelable BandChannelConfig {
+ parcelable ChannelConfig {
int channel;
- android.hardware.audio.effect.DynamicsProcessing.BandEnablement enablement;
+ boolean enable;
}
@VintfStability
parcelable EqBandConfig {
int channel;
int band;
boolean enable;
- float cutoffFrequency;
- float gain;
+ float cutoffFrequencyHz;
+ float gainDb;
}
@VintfStability
parcelable MbcBandConfig {
@@ -90,7 +92,6 @@
int band;
boolean enable;
float cutoffFrequencyHz;
- float gainDb;
float attackTimeMs;
float releaseTimeMs;
float ratio;
@@ -105,7 +106,6 @@
parcelable LimiterConfig {
int channel;
boolean enable;
- boolean inUse;
int linkGroup;
float attackTimeMs;
float releaseTimeMs;
@@ -113,4 +113,9 @@
float thresholdDb;
float postGainDb;
}
+ @VintfStability
+ parcelable InputGain {
+ int channel;
+ float gainDb;
+ }
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl
index 0e61932..7f34f33 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl
@@ -44,15 +44,15 @@
int diffusionPm;
int densityPm;
boolean bypass;
- const int MIN_ROOM_LEVEL_MB = -6000;
+ const int MIN_ROOM_LEVEL_MB = (-6000);
const int MAX_ROOM_LEVEL_MB = 0;
- const int MIN_ROOM_HF_LEVEL_MB = -4000;
+ const int MIN_ROOM_HF_LEVEL_MB = (-4000);
const int MAX_ROOM_HF_LEVEL_MB = 0;
const int MIN_DECAY_TIME_MS = 100;
const int MAX_DECAY_TIME_MS = 20000;
const int MIN_DECAY_HF_RATIO_PM = 100;
const int MAX_DECAY_HF_RATIO_PM = 1000;
- const int MIN_LEVEL_MB = -6000;
+ const int MIN_LEVEL_MB = (-6000);
const int MAX_LEVEL_MB = 0;
const int MIN_DELAY_MS = 0;
const int MAX_DELAY_MS = 65;
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 959594b..20f7e02 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),
+ VERY_LOW = (-2),
+ LOW = (-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 223d95a..397f897 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
@@ -47,8 +47,8 @@
}
@Backing(type="int") @VintfStability
enum Level {
- LOW = 0,
- MEDIUM = 1,
- HIGH = 2,
+ LOW,
+ MEDIUM,
+ HIGH,
}
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/PresetReverb.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/PresetReverb.aidl
index 24a9ce1..4651742 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/PresetReverb.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/PresetReverb.aidl
@@ -38,13 +38,13 @@
android.hardware.audio.effect.PresetReverb.Presets preset;
@Backing(type="int") @VintfStability
enum Presets {
- NONE = 0,
- SMALLROOM = 1,
- MEDIUMROOM = 2,
- LARGEROOM = 3,
- MEDIUMHALL = 4,
- LARGEHALL = 5,
- PLATE = 6,
+ NONE,
+ SMALLROOM,
+ MEDIUMROOM,
+ LARGEROOM,
+ MEDIUMHALL,
+ LARGEHALL,
+ PLATE,
}
@VintfStability
union Id {
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/State.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/State.aidl
index 3176b01..17f9814 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/State.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/State.aidl
@@ -34,7 +34,7 @@
package android.hardware.audio.effect;
@Backing(type="byte") @VintfStability
enum State {
- INIT = 0,
- IDLE = 1,
- PROCESSING = 2,
+ INIT,
+ IDLE,
+ PROCESSING,
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Visualizer.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Visualizer.aidl
index 25f0b73..c8cb551 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Visualizer.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Visualizer.aidl
@@ -62,12 +62,12 @@
@VintfStability
enum ScalingMode {
NORMALIZED = 0,
- AS_PLAYED = 1,
+ AS_PLAYED,
}
@VintfStability
enum MeasurementMode {
NONE = 0,
- PEAK_RMS = 1,
+ PEAK_RMS,
}
@VintfStability
union GetOnlyParameters {
diff --git a/audio/aidl/android/hardware/audio/effect/DynamicsProcessing.aidl b/audio/aidl/android/hardware/audio/effect/DynamicsProcessing.aidl
index ee5dcad..6db3338 100644
--- a/audio/aidl/android/hardware/audio/effect/DynamicsProcessing.aidl
+++ b/audio/aidl/android/hardware/audio/effect/DynamicsProcessing.aidl
@@ -51,6 +51,14 @@
* capability definition not enough.
*/
ParcelableHolder extension;
+ /**
+ * Min Cut off frequency (in Hz) for all Bands.
+ */
+ float minCutOffFreq;
+ /**
+ * Max Cut off frequency (in Hz) for all Bands.
+ */
+ float maxCutOffFreq;
}
/**
@@ -68,16 +76,16 @@
}
/**
- * Band enablement configuration.
+ * Stage enablement configuration.
*/
@VintfStability
- parcelable BandEnablement {
+ parcelable StageEnablement {
/**
- * True if multi-band stage is in use.
+ * True if stage is in use.
*/
boolean inUse;
/**
- * Number of bands configured for this stage.
+ * Number of bands configured for this stage. Must be positive when inUse is true.
*/
int bandCount;
}
@@ -92,21 +100,22 @@
*/
ResolutionPreference resolutionPreference = ResolutionPreference.FAVOR_FREQUENCY_RESOLUTION;
/**
- * Preferred frame duration in milliseconds (ms).
+ * Preferred processing duration in milliseconds (ms). Must not be negative, 0 means no
+ * preference.
*/
- float preferredFrameDurationMs;
+ float preferredProcessingDurationMs;
/**
* PreEq stage (Multi-band Equalizer) configuration.
*/
- BandEnablement preEqBand;
+ StageEnablement preEqStage;
/**
* PostEq stage (Multi-band Equalizer) configuration.
*/
- BandEnablement postEqBand;
+ StageEnablement postEqStage;
/**
* MBC stage (Multi-band Compressor) configuration.
*/
- BandEnablement mbcBand;
+ StageEnablement mbcStage;
/**
* True if Limiter stage is in use.
*/
@@ -114,18 +123,19 @@
}
/**
- * Band enablement configuration for a specific channel.
+ * Enablement configuration for a specific channel.
*/
@VintfStability
- parcelable BandChannelConfig {
+ parcelable ChannelConfig {
/**
- * Channel index.
+ * Channel index. Must not be negative, and not exceed the channel count calculated from
+ * Parameter.common.input.base.channelMask.
*/
int channel;
/**
- * Channel index.
+ * Channel enablement configuration. Can not be true if corresponding stage is not in use.
*/
- BandEnablement enablement;
+ boolean enable;
}
/**
@@ -134,7 +144,8 @@
@VintfStability
parcelable EqBandConfig {
/**
- * Channel index.
+ * Channel index. Must not be negative, and not exceed the channel count calculated from
+ * Parameter.common.input.base.channelMask.
*/
int channel;
/**
@@ -142,17 +153,20 @@
*/
int band;
/**
- * True if EQ stage is enabled.
+ * True if EQ band is enabled.
+ * If EngineArchitecture EQ stage inUse was set to false, then enable can not be set to
+ * true.
*/
boolean enable;
/**
- * Topmost frequency number (in Hz) this band will process.
+ * Topmost frequency number (in Hz) this band will process. Must be in the range of
+ * [minCutOffFreq, maxCutOffFreq] defined in Capability.
*/
- float cutoffFrequency;
+ float cutoffFrequencyHz;
/**
* Gain factor in decibels (dB).
*/
- float gain;
+ float gainDb;
}
/**
@@ -161,51 +175,53 @@
@VintfStability
parcelable MbcBandConfig {
/**
- * Channel index.
+ * Channel index. Must not be negative, and not exceed the channel count calculated from
+ * Parameter.common.input.base.channelMask.
*/
int channel;
/**
- * Band index, must in the range of [0, bandCount-1].
+ * Band index. Must be in the range of [0, bandCount-1].
*/
int band;
/**
- * True if MBC stage is enabled.
+ * True if MBC band is enabled.
+ * If EngineArchitecture MBC inUse was set to false, then enable here can not be set to
+ * true.
*/
boolean enable;
/**
- * Topmost frequency number (in Hz) this band will process.
+ * Topmost frequency number (in Hz) this band will process. Must be in the range of
+ * [minCutOffFreq, maxCutOffFreq] defined in Capability.
*/
float cutoffFrequencyHz;
/**
- * Gain factor in decibels (dB).
- */
- float gainDb;
- /**
- * Attack Time for compressor in milliseconds (ms).
+ * Attack Time for compressor in milliseconds (ms). Must not be negative.
*/
float attackTimeMs;
/**
- * Release Time for compressor in milliseconds (ms).
+ * Release Time for compressor in milliseconds (ms). Must not be negative.
*/
float releaseTimeMs;
/**
- * Compressor ratio (N:1) (input:output).
+ * Compressor ratio (N:1) (input:output). Must not be negative.
*/
float ratio;
/**
- * Compressor threshold measured in decibels (dB) from 0 dB Full Scale (dBFS).
+ * Compressor threshold measured in decibels (dB) from 0 dB Full Scale (dBFS). Must not be
+ * positive.
*/
float thresholdDb;
/**
- * Width in decibels (dB) around compressor threshold point.
+ * Width in decibels (dB) around compressor threshold point. Must not be negative.
*/
float kneeWidthDb;
/**
- * Noise gate threshold in decibels (dB) from 0 dB Full Scale (dBFS).
+ * Noise gate threshold in decibels (dB) from 0 dB Full Scale (dBFS). Must not be positive.
*/
float noiseGateThresholdDb;
/**
- * Expander ratio (1:N) (input:output) for signals below the Noise Gate Threshold.
+ * Expander ratio (1:N) (input:output) for signals below the Noise Gate Threshold. Must not
+ * be negative.
*/
float expanderRatio;
/**
@@ -224,36 +240,35 @@
@VintfStability
parcelable LimiterConfig {
/**
- * Channel index.
+ * Channel index. Must not be negative, and not exceed the channel count calculated from
+ * Parameter.common.input.base.channelMask.
*/
int channel;
/**
- * True if Limiter stage is enabled.
+ * True if Limiter band is enabled.
+ * If EngineArchitecture limiterInUse was set to false, then enable can not be set to true.
*/
boolean enable;
/**
- * True if Limiter stage is in use.
- */
- boolean inUse;
- /**
* Index of group assigned to this Limiter. Only limiters that share the same linkGroup
* index will react together.
*/
int linkGroup;
/**
- * Attack Time for compressor in milliseconds (ms).
+ * Attack Time for compressor in milliseconds (ms). Must not be negative.
*/
float attackTimeMs;
/**
- * Release Time for compressor in milliseconds (ms).
+ * Release Time for compressor in milliseconds (ms). Must not be negative.
*/
float releaseTimeMs;
/**
- * Compressor ratio (N:1) (input:output).
+ * Compressor ratio (N:1) (input:output). Must not be negative.
*/
float ratio;
/**
- * Compressor threshold measured in decibels (dB) from 0 dB Full Scale (dBFS).
+ * Compressor threshold measured in decibels (dB) from 0 dB Full Scale (dBFS). Must not be
+ * positive.
*/
float thresholdDb;
/**
@@ -263,39 +278,55 @@
}
/**
+ * Input gain for a channel (specified by the channel index).
+ */
+ @VintfStability
+ parcelable InputGain {
+ /**
+ * Channel index. Must not be negative, and not exceed the channel count calculated from
+ * Parameter.common.input.base.channelMask.
+ */
+ int channel;
+ /**
+ * Gain applied to the input signal in decibels (dB). 0 dB means no change in level.
+ */
+ float gainDb;
+ }
+
+ /**
* Effect engine architecture.
*/
EngineArchitecture engineArchitecture;
/**
- * PreEq stage per channel configuration.
+ * PreEq stage per channel configuration. Only valid when pre EQ stage inUse is true.
*/
- BandChannelConfig preEq;
+ ChannelConfig[] preEq;
/**
- * PostEq stage per channel configuration.
+ * PostEq stage per channel configuration. Only valid when post EQ stage inUse is true.
*/
- BandChannelConfig postEq;
+ ChannelConfig[] postEq;
/**
- * PreEq stage per band configuration.
+ * PreEq stage per band configuration. Only valid when pre EQ stage inUse is true.
*/
- EqBandConfig preEqBand;
+ EqBandConfig[] preEqBand;
/**
- * PostEq stage per band configuration.
+ * PostEq stage per band configuration. Only valid when post EQ stage inUse is true.
*/
- EqBandConfig postEqBand;
+ EqBandConfig[] postEqBand;
/**
- * MBC stage per channel configuration.
+ * MBC stage per channel configuration. Only valid when MBC stage inUse is true.
*/
- BandChannelConfig mbc;
+ ChannelConfig[] mbc;
/**
- * PostEq stage per band configuration.
+ * PostEq stage per band configuration. Only valid when MBC stage inUse is true.
*/
- MbcBandConfig mbcBand;
+ MbcBandConfig[] mbcBand;
/**
- * Limiter stage configuration.
+ * Limiter stage configuration. Only valid when limiter stage inUse is true.
*/
- LimiterConfig limiter;
+ LimiterConfig[] limiter;
/**
- * Input gain factor in decibels (dB). 0 dB means no change in level.
+ * Input gain factor.
*/
- float inputGainDb;
+ InputGain[] inputGain;
}
diff --git a/audio/aidl/default/Android.bp b/audio/aidl/default/Android.bp
index 6f23636..1e6785f 100644
--- a/audio/aidl/default/Android.bp
+++ b/audio/aidl/default/Android.bp
@@ -156,7 +156,7 @@
"libbassboostsw",
"libbundleaidl",
"libdownmixaidl",
- "libdynamicsprocessingsw",
+ "libdynamicsprocessingaidl",
"libenvreverbsw",
"libequalizersw",
"libhapticgeneratoraidl",
diff --git a/audio/aidl/default/acousticEchoCanceler/AcousticEchoCancelerSw.cpp b/audio/aidl/default/acousticEchoCanceler/AcousticEchoCancelerSw.cpp
index 7f06013..40b46e0 100644
--- a/audio/aidl/default/acousticEchoCanceler/AcousticEchoCancelerSw.cpp
+++ b/audio/aidl/default/acousticEchoCanceler/AcousticEchoCancelerSw.cpp
@@ -54,7 +54,6 @@
return EX_ILLEGAL_ARGUMENT;
}
*_aidl_return = AcousticEchoCancelerSw::kDescriptor;
- LOG(ERROR) << __func__ << "xxx " << _aidl_return->toString();
return EX_NONE;
}
diff --git a/audio/aidl/default/audio_effects_config.xml b/audio/aidl/default/audio_effects_config.xml
index 9670e9c..e460f89 100644
--- a/audio/aidl/default/audio_effects_config.xml
+++ b/audio/aidl/default/audio_effects_config.xml
@@ -33,7 +33,7 @@
<library name="bassboostsw" path="libbassboostsw.so"/>
<library name="bundle" path="libbundleaidl.so"/>
<library name="downmix" path="libdownmixaidl.so"/>
- <library name="dynamics_processingsw" path="libdynamicsprocessingsw.so"/>
+ <library name="dynamics_processing" path="libdynamicsprocessingaidl.so"/>
<library name="equalizersw" path="libequalizersw.so"/>
<library name="haptic_generator" path="libhapticgeneratoraidl.so"/>
<library name="loudness_enhancer" path="libloudnessenhanceraidl.so"/>
@@ -72,7 +72,7 @@
<libsw library="bundle" uuid="8631f300-72e2-11df-b57e-0002a5d5c51b"/>
</effectProxy>
<effect name="downmix" library="downmix" uuid="93f04452-e4fe-41cc-91f9-e475b6d1d69f"/>
- <effect name="dynamics_processing" library="dynamics_processingsw" uuid="fa818d78-588b-11ed-9b6a-0242ac120002"/>
+ <effect name="dynamics_processing" library="dynamics_processing" uuid="e0e6539b-1781-7261-676f-6d7573696340"/>
<effect name="haptic_generator" library="haptic_generator" uuid="97c4acd1-8b82-4f2f-832e-c2fe5d7a9931"/>
<effect name="loudness_enhancer" library="loudness_enhancer" uuid="fa415329-2034-4bea-b5dc-5b381c8d1e2c"/>
<effect name="env_reverb" library="env_reverbsw" uuid="fa819886-588b-11ed-9b6a-0242ac120002"/>
diff --git a/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.cpp b/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.cpp
index 39345a9..0ffbaa1 100644
--- a/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.cpp
+++ b/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.cpp
@@ -18,6 +18,7 @@
#define LOG_TAG "AHAL_DynamicsProcessingSw"
#include <Utils.h>
#include <algorithm>
+#include <set>
#include <unordered_set>
#include <android-base/logging.h>
@@ -60,7 +61,8 @@
namespace aidl::android::hardware::audio::effect {
const std::string DynamicsProcessingSw::kEffectName = "DynamicsProcessingSw";
-const DynamicsProcessing::Capability DynamicsProcessingSw::kCapability;
+const DynamicsProcessing::Capability DynamicsProcessingSw::kCapability = {.minCutOffFreq = 220,
+ .maxCutOffFreq = 20000};
const Descriptor DynamicsProcessingSw::kDescriptor = {
.common = {.id = {.type = kDynamicsProcessingTypeUUID,
.uuid = kDynamicsProcessingSwImplUUID,
@@ -83,16 +85,143 @@
RETURN_IF(Parameter::Specific::dynamicsProcessing != specific.getTag(), EX_ILLEGAL_ARGUMENT,
"EffectNotSupported");
- mSpecificParam = specific.get<Parameter::Specific::dynamicsProcessing>();
- LOG(DEBUG) << __func__ << " success with: " << specific.toString();
- return ndk::ScopedAStatus::ok();
+ RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
+
+ LOG(INFO) << __func__ << specific.toString();
+ auto& dpParam = specific.get<Parameter::Specific::dynamicsProcessing>();
+ auto tag = dpParam.getTag();
+ switch (tag) {
+ case DynamicsProcessing::engineArchitecture: {
+ RETURN_IF(mContext->setEngineArchitecture(
+ dpParam.get<DynamicsProcessing::engineArchitecture>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "setEngineArchitectureFailed");
+ return ndk::ScopedAStatus::ok();
+ }
+ case DynamicsProcessing::preEq: {
+ RETURN_IF(mContext->setPreEqChannelCfgs(dpParam.get<DynamicsProcessing::preEq>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "setPreEqChannelCfgsFailed");
+ return ndk::ScopedAStatus::ok();
+ }
+ case DynamicsProcessing::postEq: {
+ RETURN_IF(mContext->setPostEqChannelCfgs(dpParam.get<DynamicsProcessing::postEq>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "setPostEqChannelCfgsFailed");
+ return ndk::ScopedAStatus::ok();
+ }
+ case DynamicsProcessing::mbc: {
+ RETURN_IF(mContext->setMbcChannelCfgs(dpParam.get<DynamicsProcessing::mbc>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "setMbcChannelCfgsFailed");
+ return ndk::ScopedAStatus::ok();
+ }
+ case DynamicsProcessing::preEqBand: {
+ RETURN_IF(mContext->setPreEqBandCfgs(dpParam.get<DynamicsProcessing::preEqBand>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "setPreEqBandCfgsFailed");
+ return ndk::ScopedAStatus::ok();
+ }
+ case DynamicsProcessing::postEqBand: {
+ RETURN_IF(mContext->setPostEqBandCfgs(dpParam.get<DynamicsProcessing::postEqBand>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "setPostEqBandCfgsFailed");
+ return ndk::ScopedAStatus::ok();
+ }
+ case DynamicsProcessing::mbcBand: {
+ RETURN_IF(mContext->setMbcBandCfgs(dpParam.get<DynamicsProcessing::mbcBand>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "setMbcBandCfgsFailed");
+ return ndk::ScopedAStatus::ok();
+ }
+ case DynamicsProcessing::limiter: {
+ RETURN_IF(mContext->setLimiterCfgs(dpParam.get<DynamicsProcessing::limiter>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "limiterCfgsFailed");
+ return ndk::ScopedAStatus::ok();
+ }
+ case DynamicsProcessing::inputGain: {
+ RETURN_IF(mContext->setInputGainCfgs(dpParam.get<DynamicsProcessing::inputGain>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "inputGainCfgFailed");
+ return ndk::ScopedAStatus::ok();
+ }
+ case DynamicsProcessing::vendorExtension: {
+ LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
+ EX_ILLEGAL_ARGUMENT, "DynamicsProcessingTagNotSupported");
+ }
+ }
}
ndk::ScopedAStatus DynamicsProcessingSw::getParameterSpecific(const Parameter::Id& id,
Parameter::Specific* specific) {
auto tag = id.getTag();
RETURN_IF(Parameter::Id::dynamicsProcessingTag != tag, EX_ILLEGAL_ARGUMENT, "wrongIdTag");
- specific->set<Parameter::Specific::dynamicsProcessing>(mSpecificParam);
+ auto dpId = id.get<Parameter::Id::dynamicsProcessingTag>();
+ auto dpIdTag = dpId.getTag();
+ switch (dpIdTag) {
+ case DynamicsProcessing::Id::commonTag:
+ return getParameterDynamicsProcessing(dpId.get<DynamicsProcessing::Id::commonTag>(),
+ specific);
+ case DynamicsProcessing::Id::vendorExtensionTag:
+ LOG(ERROR) << __func__ << " unsupported tag: " << toString(dpIdTag);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
+ EX_ILLEGAL_ARGUMENT, "DynamicsProcessingTagNotSupported");
+ }
+}
+
+ndk::ScopedAStatus DynamicsProcessingSw::getParameterDynamicsProcessing(
+ const DynamicsProcessing::Tag& tag, Parameter::Specific* specific) {
+ RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
+
+ DynamicsProcessing dpParam;
+ switch (tag) {
+ case DynamicsProcessing::Tag::engineArchitecture: {
+ dpParam.set<DynamicsProcessing::engineArchitecture>(mContext->getEngineArchitecture());
+ break;
+ }
+ case DynamicsProcessing::Tag::preEq: {
+ dpParam.set<DynamicsProcessing::preEq>(mContext->getPreEqChannelCfgs());
+ break;
+ }
+ case DynamicsProcessing::Tag::postEq: {
+ dpParam.set<DynamicsProcessing::postEq>(mContext->getPostEqChannelCfgs());
+ break;
+ }
+ case DynamicsProcessing::Tag::mbc: {
+ dpParam.set<DynamicsProcessing::mbc>(mContext->getMbcChannelCfgs());
+ break;
+ }
+ case DynamicsProcessing::Tag::preEqBand: {
+ dpParam.set<DynamicsProcessing::preEqBand>(mContext->getPreEqBandCfgs());
+ break;
+ }
+ case DynamicsProcessing::Tag::postEqBand: {
+ dpParam.set<DynamicsProcessing::postEqBand>(mContext->getPostEqBandCfgs());
+ break;
+ }
+ case DynamicsProcessing::Tag::mbcBand: {
+ dpParam.set<DynamicsProcessing::mbcBand>(mContext->getMbcBandCfgs());
+ break;
+ }
+ case DynamicsProcessing::Tag::limiter: {
+ dpParam.set<DynamicsProcessing::limiter>(mContext->getLimiterCfgs());
+ break;
+ }
+ case DynamicsProcessing::Tag::inputGain: {
+ dpParam.set<DynamicsProcessing::inputGain>(mContext->getInputGainCfgs());
+ break;
+ }
+ case DynamicsProcessing::vendorExtension: {
+ LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
+ EX_ILLEGAL_ARGUMENT, "DynamicsProcessingTagNotSupported");
+ }
+ }
+
+ specific->set<Parameter::Specific::dynamicsProcessing>(dpParam);
+ LOG(INFO) << __func__ << specific->toString();
return ndk::ScopedAStatus::ok();
}
@@ -127,4 +256,252 @@
return {STATUS_OK, samples, samples};
}
+RetCode DynamicsProcessingSwContext::setCommon(const Parameter::Common& common) {
+ mCommon = common;
+ mChannelCount =
+ ::android::hardware::audio::common::getChannelCount(common.input.base.channelMask);
+ resizeChannels();
+ resizeBands();
+ LOG(INFO) << __func__ << mCommon.toString();
+ return RetCode::SUCCESS;
+}
+
+RetCode DynamicsProcessingSwContext::setEngineArchitecture(
+ const DynamicsProcessing::EngineArchitecture& cfg) {
+ RETURN_VALUE_IF(!validateEngineConfig(cfg), RetCode::ERROR_ILLEGAL_PARAMETER,
+ "illegalEngineConfig");
+
+ if (mEngineSettings == cfg) {
+ LOG(INFO) << __func__ << " not change in engine, do nothing";
+ return RetCode::SUCCESS;
+ }
+ mEngineSettings = cfg;
+ resizeBands();
+ return RetCode::SUCCESS;
+}
+
+RetCode DynamicsProcessingSwContext::setChannelCfgs(
+ const std::vector<DynamicsProcessing::ChannelConfig>& cfgs,
+ std::vector<DynamicsProcessing::ChannelConfig>& targetCfgs,
+ const DynamicsProcessing::StageEnablement& stage) {
+ RETURN_VALUE_IF(!stage.inUse, RetCode::ERROR_ILLEGAL_PARAMETER, "stageNotInUse");
+
+ RetCode ret = RetCode::SUCCESS;
+ std::unordered_set<int> channelSet;
+ for (auto& cfg : cfgs) {
+ if (cfg.channel < 0 || (size_t)cfg.channel >= mChannelCount) {
+ LOG(ERROR) << __func__ << " skip illegal channel config " << cfg.toString();
+ ret = RetCode::ERROR_ILLEGAL_PARAMETER;
+ continue;
+ }
+ if (0 != channelSet.count(cfg.channel)) {
+ LOG(WARNING) << __func__ << " duplicated channel " << cfg.channel;
+ ret = RetCode::ERROR_ILLEGAL_PARAMETER;
+ } else {
+ channelSet.insert(cfg.channel);
+ }
+ targetCfgs[cfg.channel] = cfg;
+ }
+ return ret;
+}
+
+RetCode DynamicsProcessingSwContext::setPreEqChannelCfgs(
+ const std::vector<DynamicsProcessing::ChannelConfig>& cfgs) {
+ return setChannelCfgs(cfgs, mPreEqChCfgs, mEngineSettings.preEqStage);
+}
+
+RetCode DynamicsProcessingSwContext::setPostEqChannelCfgs(
+ const std::vector<DynamicsProcessing::ChannelConfig>& cfgs) {
+ return setChannelCfgs(cfgs, mPostEqChCfgs, mEngineSettings.postEqStage);
+}
+
+RetCode DynamicsProcessingSwContext::setMbcChannelCfgs(
+ const std::vector<DynamicsProcessing::ChannelConfig>& cfgs) {
+ return setChannelCfgs(cfgs, mMbcChCfgs, mEngineSettings.mbcStage);
+}
+
+RetCode DynamicsProcessingSwContext::setEqBandCfgs(
+ const std::vector<DynamicsProcessing::EqBandConfig>& cfgs,
+ std::vector<DynamicsProcessing::EqBandConfig>& targetCfgs,
+ const DynamicsProcessing::StageEnablement& stage,
+ const std::vector<DynamicsProcessing::ChannelConfig>& channelConfig) {
+ RETURN_VALUE_IF(!stage.inUse, RetCode::ERROR_ILLEGAL_PARAMETER, "eqStageNotInUse");
+
+ RetCode ret = RetCode::SUCCESS;
+ std::set<std::pair<int /* channel */, int /* band */>> bandSet;
+
+ for (auto& cfg : cfgs) {
+ if (0 != bandSet.count({cfg.channel, cfg.band})) {
+ LOG(WARNING) << __func__ << " duplicated band " << cfg.toString();
+ ret = RetCode::ERROR_ILLEGAL_PARAMETER;
+ } else {
+ bandSet.insert({cfg.channel, cfg.band});
+ }
+ if (!validateEqBandConfig(cfg, mChannelCount, stage.bandCount, channelConfig)) {
+ LOG(WARNING) << __func__ << " skip invalid band " << cfg.toString();
+ ret = RetCode::ERROR_ILLEGAL_PARAMETER;
+ continue;
+ ;
+ }
+ targetCfgs[cfg.channel * stage.bandCount + cfg.band] = cfg;
+ }
+ return ret;
+}
+
+RetCode DynamicsProcessingSwContext::setPreEqBandCfgs(
+ const std::vector<DynamicsProcessing::EqBandConfig>& cfgs) {
+ return setEqBandCfgs(cfgs, mPreEqChBands, mEngineSettings.preEqStage, mPreEqChCfgs);
+}
+
+RetCode DynamicsProcessingSwContext::setPostEqBandCfgs(
+ const std::vector<DynamicsProcessing::EqBandConfig>& cfgs) {
+ return setEqBandCfgs(cfgs, mPostEqChBands, mEngineSettings.postEqStage, mPostEqChCfgs);
+}
+
+RetCode DynamicsProcessingSwContext::setMbcBandCfgs(
+ const std::vector<DynamicsProcessing::MbcBandConfig>& cfgs) {
+ RETURN_VALUE_IF(!mEngineSettings.mbcStage.inUse, RetCode::ERROR_ILLEGAL_PARAMETER,
+ "mbcNotInUse");
+
+ RetCode ret = RetCode::SUCCESS;
+ std::set<std::pair<int /* channel */, int /* band */>> bandSet;
+
+ int bandCount = mEngineSettings.mbcStage.bandCount;
+ std::vector<bool> filled(mChannelCount * bandCount, false);
+ for (auto& it : cfgs) {
+ if (0 != bandSet.count({it.channel, it.band})) {
+ LOG(WARNING) << __func__ << " duplicated band " << it.toString();
+ ret = RetCode::ERROR_ILLEGAL_PARAMETER;
+ } else {
+ bandSet.insert({it.channel, it.band});
+ }
+ if (!validateMbcBandConfig(it, mChannelCount, mEngineSettings.mbcStage.bandCount,
+ mMbcChCfgs)) {
+ LOG(WARNING) << __func__ << " skip invalid band " << it.toString();
+ ret = RetCode::ERROR_ILLEGAL_PARAMETER;
+ continue;
+ ;
+ }
+ mMbcChBands[it.channel * bandCount + it.band] = it;
+ }
+ return ret;
+}
+
+RetCode DynamicsProcessingSwContext::setLimiterCfgs(
+ const std::vector<DynamicsProcessing::LimiterConfig>& cfgs) {
+ RETURN_VALUE_IF(!mEngineSettings.limiterInUse, RetCode::ERROR_ILLEGAL_PARAMETER,
+ "limiterNotInUse");
+
+ RetCode ret = RetCode::SUCCESS;
+ std::unordered_set<int> channelSet;
+
+ for (auto& it : cfgs) {
+ if (0 != channelSet.count(it.channel)) {
+ LOG(WARNING) << __func__ << " duplicated channel " << it.channel;
+ ret = RetCode::ERROR_ILLEGAL_PARAMETER;
+ } else {
+ channelSet.insert(it.channel);
+ }
+ if (!validateLimiterConfig(it, mChannelCount)) {
+ LOG(WARNING) << __func__ << " skip invalid limiter " << it.toString();
+ ret = RetCode::ERROR_ILLEGAL_PARAMETER;
+ continue;
+ }
+ mLimiterCfgs[it.channel] = it;
+ }
+ return ret;
+}
+
+void DynamicsProcessingSwContext::resizeChannels() {
+ if (mPreEqChCfgs.size() != mChannelCount) {
+ mPreEqChCfgs.resize(mChannelCount, {.channel = kInvalidChannelId});
+ }
+ if (mPostEqChCfgs.size() != mChannelCount) {
+ mPostEqChCfgs.resize(mChannelCount, {.channel = kInvalidChannelId});
+ }
+ if (mMbcChCfgs.size() != mChannelCount) {
+ mMbcChCfgs.resize(mChannelCount, {.channel = kInvalidChannelId});
+ }
+ if (mLimiterCfgs.size() != mChannelCount) {
+ mLimiterCfgs.resize(mChannelCount, {.channel = kInvalidChannelId});
+ }
+ if (mInputGainCfgs.size() != mChannelCount) {
+ mInputGainCfgs.resize(mChannelCount, {.channel = kInvalidChannelId});
+ }
+}
+
+void DynamicsProcessingSwContext::resizeBands() {
+ if (mPreEqChBands.size() != (size_t)(mChannelCount * mEngineSettings.preEqStage.bandCount)) {
+ mPreEqChBands.resize(mChannelCount * mEngineSettings.preEqStage.bandCount,
+ {.channel = kInvalidChannelId});
+ }
+ if (mPostEqChBands.size() != (size_t)(mChannelCount * mEngineSettings.postEqStage.bandCount)) {
+ mPostEqChBands.resize(mChannelCount * mEngineSettings.postEqStage.bandCount,
+ {.channel = kInvalidChannelId});
+ }
+ if (mMbcChBands.size() != (size_t)(mChannelCount * mEngineSettings.mbcStage.bandCount)) {
+ mMbcChBands.resize(mChannelCount * mEngineSettings.mbcStage.bandCount,
+ {.channel = kInvalidChannelId});
+ }
+}
+
+RetCode DynamicsProcessingSwContext::setInputGainCfgs(
+ const std::vector<DynamicsProcessing::InputGain>& cfgs) {
+ for (const auto& cfg : cfgs) {
+ RETURN_VALUE_IF(cfg.channel < 0 || (size_t)cfg.channel >= mChannelCount,
+ RetCode::ERROR_ILLEGAL_PARAMETER, "invalidChannel");
+ mInputGainCfgs[cfg.channel] = cfg;
+ }
+ return RetCode::SUCCESS;
+}
+
+std::vector<DynamicsProcessing::InputGain> DynamicsProcessingSwContext::getInputGainCfgs() {
+ std::vector<DynamicsProcessing::InputGain> ret;
+ std::copy_if(mInputGainCfgs.begin(), mInputGainCfgs.end(), std::back_inserter(ret),
+ [&](const auto& gain) { return gain.channel != kInvalidChannelId; });
+ return ret;
+}
+
+bool DynamicsProcessingSwContext::validateCutoffFrequency(float freq) {
+ return freq >= DynamicsProcessingSw::kCapability.minCutOffFreq &&
+ freq <= DynamicsProcessingSw::kCapability.maxCutOffFreq;
+}
+
+bool DynamicsProcessingSwContext::validateStageEnablement(
+ const DynamicsProcessing::StageEnablement& enablement) {
+ return !enablement.inUse || (enablement.inUse && enablement.bandCount > 0);
+}
+
+bool DynamicsProcessingSwContext::validateEngineConfig(
+ const DynamicsProcessing::EngineArchitecture& engine) {
+ return engine.preferredProcessingDurationMs >= 0 &&
+ validateStageEnablement(engine.preEqStage) &&
+ validateStageEnablement(engine.postEqStage) && validateStageEnablement(engine.mbcStage);
+}
+
+bool DynamicsProcessingSwContext::validateEqBandConfig(
+ const DynamicsProcessing::EqBandConfig& band, int maxChannel, int maxBand,
+ const std::vector<DynamicsProcessing::ChannelConfig>& channelConfig) {
+ return band.channel >= 0 && band.channel < maxChannel &&
+ (size_t)band.channel < channelConfig.size() && channelConfig[band.channel].enable &&
+ band.band >= 0 && band.band < maxBand && validateCutoffFrequency(band.cutoffFrequencyHz);
+}
+
+bool DynamicsProcessingSwContext::validateMbcBandConfig(
+ const DynamicsProcessing::MbcBandConfig& band, int maxChannel, int maxBand,
+ const std::vector<DynamicsProcessing::ChannelConfig>& channelConfig) {
+ return band.channel >= 0 && band.channel < maxChannel &&
+ (size_t)band.channel < channelConfig.size() && channelConfig[band.channel].enable &&
+ band.band >= 0 && band.band < maxBand &&
+ validateCutoffFrequency(band.cutoffFrequencyHz) && band.attackTimeMs >= 0 &&
+ band.releaseTimeMs >= 0 && band.ratio >= 0 && band.thresholdDb <= 0 &&
+ band.kneeWidthDb <= 0 && band.noiseGateThresholdDb <= 0 && band.expanderRatio >= 0;
+}
+
+bool DynamicsProcessingSwContext::validateLimiterConfig(
+ const DynamicsProcessing::LimiterConfig& limiter, int maxChannel) {
+ return limiter.channel >= 0 && limiter.channel < maxChannel && limiter.attackTimeMs >= 0 &&
+ limiter.releaseTimeMs >= 0 && limiter.ratio >= 0 && limiter.thresholdDb <= 0;
+}
+
} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.h b/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.h
index 2ae46c5..e336df7 100644
--- a/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.h
+++ b/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.h
@@ -29,11 +29,77 @@
class DynamicsProcessingSwContext final : public EffectContext {
public:
DynamicsProcessingSwContext(int statusDepth, const Parameter::Common& common)
- : EffectContext(statusDepth, common) {
+ : EffectContext(statusDepth, common),
+ mChannelCount(::android::hardware::audio::common::getChannelCount(
+ common.input.base.channelMask)),
+ mPreEqChCfgs(mChannelCount, {.channel = kInvalidChannelId}),
+ mPostEqChCfgs(mChannelCount, {.channel = kInvalidChannelId}),
+ mMbcChCfgs(mChannelCount, {.channel = kInvalidChannelId}),
+ mLimiterCfgs(mChannelCount, {.channel = kInvalidChannelId}) {
LOG(DEBUG) << __func__;
}
- // TODO: add specific context here
-};
+
+ // utils
+ RetCode setChannelCfgs(const std::vector<DynamicsProcessing::ChannelConfig>& cfgs,
+ std::vector<DynamicsProcessing::ChannelConfig>& targetCfgs,
+ const DynamicsProcessing::StageEnablement& engineSetting);
+
+ RetCode setEqBandCfgs(const std::vector<DynamicsProcessing::EqBandConfig>& cfgs,
+ std::vector<DynamicsProcessing::EqBandConfig>& targetCfgs,
+ const DynamicsProcessing::StageEnablement& stage,
+ const std::vector<DynamicsProcessing::ChannelConfig>& channelConfig);
+
+ // set params
+ RetCode setCommon(const Parameter::Common& common) override;
+ RetCode setEngineArchitecture(const DynamicsProcessing::EngineArchitecture& cfg);
+ RetCode setPreEqChannelCfgs(const std::vector<DynamicsProcessing::ChannelConfig>& cfgs);
+ RetCode setPostEqChannelCfgs(const std::vector<DynamicsProcessing::ChannelConfig>& cfgs);
+ RetCode setMbcChannelCfgs(const std::vector<DynamicsProcessing::ChannelConfig>& cfgs);
+ RetCode setPreEqBandCfgs(const std::vector<DynamicsProcessing::EqBandConfig>& cfgs);
+ RetCode setPostEqBandCfgs(const std::vector<DynamicsProcessing::EqBandConfig>& cfgs);
+ RetCode setMbcBandCfgs(const std::vector<DynamicsProcessing::MbcBandConfig>& cfgs);
+ RetCode setLimiterCfgs(const std::vector<DynamicsProcessing::LimiterConfig>& cfgs);
+ RetCode setInputGainCfgs(const std::vector<DynamicsProcessing::InputGain>& cfgs);
+
+ // get params
+ DynamicsProcessing::EngineArchitecture getEngineArchitecture() { return mEngineSettings; }
+ std::vector<DynamicsProcessing::ChannelConfig> getPreEqChannelCfgs() { return mPreEqChCfgs; }
+ std::vector<DynamicsProcessing::ChannelConfig> getPostEqChannelCfgs() { return mPostEqChCfgs; }
+ std::vector<DynamicsProcessing::ChannelConfig> getMbcChannelCfgs() { return mMbcChCfgs; }
+ std::vector<DynamicsProcessing::EqBandConfig> getPreEqBandCfgs() { return mPreEqChBands; }
+ std::vector<DynamicsProcessing::EqBandConfig> getPostEqBandCfgs() { return mPostEqChBands; }
+ std::vector<DynamicsProcessing::MbcBandConfig> getMbcBandCfgs() { return mMbcChBands; }
+ std::vector<DynamicsProcessing::LimiterConfig> getLimiterCfgs() { return mLimiterCfgs; }
+ std::vector<DynamicsProcessing::InputGain> getInputGainCfgs();
+
+ private:
+ static constexpr int32_t kInvalidChannelId = -1;
+ size_t mChannelCount = 0;
+ DynamicsProcessing::EngineArchitecture mEngineSettings;
+ // Channel config vector with size of mChannelCount
+ std::vector<DynamicsProcessing::ChannelConfig> mPreEqChCfgs;
+ std::vector<DynamicsProcessing::ChannelConfig> mPostEqChCfgs;
+ std::vector<DynamicsProcessing::ChannelConfig> mMbcChCfgs;
+ std::vector<DynamicsProcessing::LimiterConfig> mLimiterCfgs;
+ std::vector<DynamicsProcessing::InputGain> mInputGainCfgs;
+ // Band config vector with size of mChannelCount * bandCount
+ std::vector<DynamicsProcessing::EqBandConfig> mPreEqChBands;
+ std::vector<DynamicsProcessing::EqBandConfig> mPostEqChBands;
+ std::vector<DynamicsProcessing::MbcBandConfig> mMbcChBands;
+
+ bool validateCutoffFrequency(float freq);
+ bool validateStageEnablement(const DynamicsProcessing::StageEnablement& enablement);
+ bool validateEngineConfig(const DynamicsProcessing::EngineArchitecture& engine);
+ bool validateEqBandConfig(const DynamicsProcessing::EqBandConfig& band, int maxChannel,
+ int maxBand,
+ const std::vector<DynamicsProcessing::ChannelConfig>& channelConfig);
+ bool validateMbcBandConfig(const DynamicsProcessing::MbcBandConfig& band, int maxChannel,
+ int maxBand,
+ const std::vector<DynamicsProcessing::ChannelConfig>& channelConfig);
+ bool validateLimiterConfig(const DynamicsProcessing::LimiterConfig& limiter, int maxChannel);
+ void resizeChannels();
+ void resizeBands();
+}; // DynamicsProcessingSwContext
class DynamicsProcessingSw final : public EffectImpl {
public:
@@ -60,7 +126,9 @@
private:
std::shared_ptr<DynamicsProcessingSwContext> mContext;
- /* parameters */
- DynamicsProcessing mSpecificParam;
-};
+ ndk::ScopedAStatus getParameterDynamicsProcessing(const DynamicsProcessing::Tag& tag,
+ Parameter::Specific* specific);
+
+}; // DynamicsProcessingSw
+
} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/include/effect-impl/EffectContext.h b/audio/aidl/default/include/effect-impl/EffectContext.h
index 1f39db0..a3e7ff2 100644
--- a/audio/aidl/default/include/effect-impl/EffectContext.h
+++ b/audio/aidl/default/include/effect-impl/EffectContext.h
@@ -119,11 +119,11 @@
virtual RetCode setCommon(const Parameter::Common& common) {
mCommon = common;
- LOG(ERROR) << __func__ << mCommon.toString();
+ LOG(INFO) << __func__ << mCommon.toString();
return RetCode::SUCCESS;
}
virtual Parameter::Common getCommon() {
- LOG(ERROR) << __func__ << mCommon.toString();
+ LOG(INFO) << __func__ << mCommon.toString();
return mCommon;
}
diff --git a/audio/aidl/default/include/effect-impl/EffectTypes.h b/audio/aidl/default/include/effect-impl/EffectTypes.h
index 58c8672..b100a2e 100644
--- a/audio/aidl/default/include/effect-impl/EffectTypes.h
+++ b/audio/aidl/default/include/effect-impl/EffectTypes.h
@@ -98,12 +98,13 @@
} \
} while (0)
-#define RETURN_VALUE_IF(expr, ret, log) \
- do { \
- if (expr) { \
- LOG(ERROR) << __func__ << ":" << __LINE__ << " return with expr " << #expr << (log); \
- return ret; \
- } \
+#define RETURN_VALUE_IF(expr, ret, log) \
+ do { \
+ if (expr) { \
+ LOG(ERROR) << __func__ << ":" << __LINE__ << " return with expr \"" << #expr \
+ << "\":" << (log); \
+ return ret; \
+ } \
} while (0)
#define RETURN_IF_BINDER_EXCEPTION(functor) \
diff --git a/audio/aidl/default/include/effect-impl/EffectUUID.h b/audio/aidl/default/include/effect-impl/EffectUUID.h
index 6eec29e..1a60829 100644
--- a/audio/aidl/default/include/effect-impl/EffectUUID.h
+++ b/audio/aidl/default/include/effect-impl/EffectUUID.h
@@ -135,6 +135,12 @@
0x11ed,
0x9b6a,
{0x02, 0x42, 0xac, 0x12, 0x00, 0x02}};
+// e0e6539b-1781-7261-676f-6d7573696340
+static const AudioUuid kDynamicsProcessingImplUUID = {static_cast<int32_t>(0xe0e6539b),
+ 0x1781,
+ 0x7261,
+ 0x676f,
+ {0x6d, 0x75, 0x73, 0x69, 0x63, 0x40}};
// 1411e6d6-aecd-4021-a1cf-a6aceb0d71e5
static const AudioUuid kHapticGeneratorTypeUUID = {static_cast<int32_t>(0x1411e6d6),
0xaecd,
diff --git a/audio/aidl/vts/Android.bp b/audio/aidl/vts/Android.bp
index becdf1b..f9d12dd 100644
--- a/audio/aidl/vts/Android.bp
+++ b/audio/aidl/vts/Android.bp
@@ -81,6 +81,12 @@
}
cc_test {
+ name: "VtsHalDynamicsProcessingTargetTest",
+ defaults: ["VtsHalAudioTargetTestDefaults"],
+ srcs: ["VtsHalDynamicsProcessingTest.cpp"],
+}
+
+cc_test {
name: "VtsHalEnvironmentalReverbTargetTest",
defaults: ["VtsHalAudioTargetTestDefaults"],
srcs: ["VtsHalEnvironmentalReverbTargetTest.cpp"],
diff --git a/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp b/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp
new file mode 100644
index 0000000..9feff91
--- /dev/null
+++ b/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp
@@ -0,0 +1,1115 @@
+/*
+ * 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.
+ */
+
+#include <aidl/Vintf.h>
+
+#define LOG_TAG "VtsHalDynamicsProcessingTest"
+
+#include <set>
+#include <string>
+#include <unordered_map>
+#include <unordered_set>
+
+#include <Utils.h>
+#include "EffectHelper.h"
+
+using namespace android;
+
+using aidl::android::hardware::audio::effect::Capability;
+using aidl::android::hardware::audio::effect::Descriptor;
+using aidl::android::hardware::audio::effect::DynamicsProcessing;
+using aidl::android::hardware::audio::effect::IEffect;
+using aidl::android::hardware::audio::effect::IFactory;
+using aidl::android::hardware::audio::effect::kDynamicsProcessingTypeUUID;
+using aidl::android::hardware::audio::effect::Parameter;
+
+/**
+ * Here we focus on specific parameter checking, general IEffect interfaces testing performed in
+ * VtsAudioEffectTargetTest.
+ */
+class DynamicsProcessingTestHelper : public EffectHelper {
+ public:
+ DynamicsProcessingTestHelper(std::pair<std::shared_ptr<IFactory>, Descriptor> pair,
+ int32_t channelLayOut = AudioChannelLayout::LAYOUT_STEREO) {
+ std::tie(mFactory, mDescriptor) = pair;
+ mChannelLayout = channelLayOut;
+ mChannelCount = ::android::hardware::audio::common::getChannelCount(
+ AudioChannelLayout::make<AudioChannelLayout::layoutMask>(mChannelLayout));
+ }
+
+ // setup
+ void SetUpDynamicsProcessingEffect() {
+ ASSERT_NE(nullptr, mFactory);
+ ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
+
+ Parameter::Specific specific = getDefaultParamSpecific();
+ Parameter::Common common = EffectHelper::createParamCommon(
+ 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
+ 0x100 /* iFrameCount */, 0x100 /* oFrameCount */,
+ AudioChannelLayout::make<AudioChannelLayout::layoutMask>(mChannelLayout),
+ AudioChannelLayout::make<AudioChannelLayout::layoutMask>(mChannelLayout));
+ IEffect::OpenEffectReturn ret;
+ ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &ret, EX_NONE));
+ ASSERT_NE(nullptr, mEffect);
+ mEngineConfigApplied = mEngineConfigPreset;
+ }
+
+ Parameter::Specific getDefaultParamSpecific() {
+ DynamicsProcessing dp = DynamicsProcessing::make<DynamicsProcessing::engineArchitecture>(
+ mEngineConfigPreset);
+ Parameter::Specific specific =
+ Parameter::Specific::make<Parameter::Specific::dynamicsProcessing>(dp);
+ return specific;
+ }
+
+ // teardown
+ void TearDownDynamicsProcessingEffect() {
+ ASSERT_NO_FATAL_FAILURE(close(mEffect));
+ ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
+ }
+
+ // utils functions for parameter checking
+ bool isParamValid(const DynamicsProcessing::Tag& tag, const DynamicsProcessing& dp,
+ const Descriptor& desc);
+ bool isParamEqual(const DynamicsProcessing::Tag& tag, const DynamicsProcessing& dpRef,
+ const DynamicsProcessing& dpTest);
+
+ bool isEnablementValid(const DynamicsProcessing::StageEnablement& enablement);
+ bool isEngineConfigValid(const DynamicsProcessing::EngineArchitecture& cfg);
+
+ bool isCutoffFrequencyValid(float freq, const DynamicsProcessing::Capability& cap);
+ bool isChannelConfigValid(const std::vector<DynamicsProcessing::ChannelConfig>& cfgs,
+ bool stageInUse);
+
+ bool isPreEqBandConfigValid(const DynamicsProcessing::Capability& cap,
+ const std::vector<DynamicsProcessing::EqBandConfig>& cfgs,
+ bool stageInUse, int bandCount);
+ bool isPostEqBandConfigValid(const DynamicsProcessing::Capability& cap,
+ const std::vector<DynamicsProcessing::EqBandConfig>& cfgs,
+ bool stageInUse, int bandCount);
+ bool isMbcBandConfigValid(const DynamicsProcessing::Capability& cap,
+ const std::vector<DynamicsProcessing::MbcBandConfig>& cfgs,
+ bool stageInUse, int bandCount);
+ bool isLimiterConfigValid(const std::vector<DynamicsProcessing::LimiterConfig>& cfgs,
+ bool stageInUse);
+ bool isInputGainValid(const std::vector<DynamicsProcessing::InputGain>& cfgs);
+
+ bool isEngineConfigEqual(const DynamicsProcessing::EngineArchitecture& refCfg,
+ const DynamicsProcessing::EngineArchitecture& testCfg);
+
+ template <typename T>
+ std::vector<T> filterEnabledVector(const std::vector<T>& vec);
+
+ template <typename T>
+ bool isAidlVectorEqualAfterFilter(const std::vector<T>& source, const std::vector<T>& target);
+
+ template <typename T>
+ bool isAidlVectorEqual(const std::vector<T>& source, const std::vector<T>& target);
+
+ // get set params and validate
+ void SetAndGetDynamicsProcessingParameters();
+
+ // enqueue test parameters
+ void addEngineConfig(const DynamicsProcessing::EngineArchitecture& cfg);
+ void addPreEqChannelConfig(const std::vector<DynamicsProcessing::ChannelConfig>& cfg);
+ void addPostEqChannelConfig(const std::vector<DynamicsProcessing::ChannelConfig>& cfg);
+ void addMbcChannelConfig(const std::vector<DynamicsProcessing::ChannelConfig>& cfg);
+ void addPreEqBandConfigs(const std::vector<DynamicsProcessing::EqBandConfig>& cfgs);
+ void addPostEqBandConfigs(const std::vector<DynamicsProcessing::EqBandConfig>& cfgs);
+ void addMbcBandConfigs(const std::vector<DynamicsProcessing::MbcBandConfig>& cfgs);
+ void addLimiterConfig(const std::vector<DynamicsProcessing::LimiterConfig>& cfg);
+ void addInputGain(const std::vector<DynamicsProcessing::InputGain>& inputGain);
+
+ static constexpr float kPreferredProcessingDurationMs = 10.0f;
+ static constexpr int kBandCount = 5;
+ std::shared_ptr<IFactory> mFactory;
+ std::shared_ptr<IEffect> mEffect;
+ Descriptor mDescriptor;
+ DynamicsProcessing::EngineArchitecture mEngineConfigApplied;
+ DynamicsProcessing::EngineArchitecture mEngineConfigPreset{
+ .resolutionPreference =
+ DynamicsProcessing::ResolutionPreference::FAVOR_FREQUENCY_RESOLUTION,
+ .preferredProcessingDurationMs = kPreferredProcessingDurationMs,
+ .preEqStage = {.inUse = true, .bandCount = kBandCount},
+ .postEqStage = {.inUse = true, .bandCount = kBandCount},
+ .mbcStage = {.inUse = true, .bandCount = kBandCount},
+ .limiterInUse = true,
+ };
+
+ std::unordered_set<int /* channelId */> mPreEqChannelEnable;
+ std::unordered_set<int /* channelId */> mPostEqChannelEnable;
+ std::unordered_set<int /* channelId */> mMbcChannelEnable;
+ std::unordered_set<int /* channelId */> mLimiterChannelEnable;
+ static const std::set<std::vector<DynamicsProcessing::ChannelConfig>> kChannelConfigTestSet;
+ static const std::set<DynamicsProcessing::StageEnablement> kStageEnablementTestSet;
+ static const std::set<std::vector<DynamicsProcessing::InputGain>> kInputGainTestSet;
+
+ private:
+ int32_t mChannelLayout;
+ int mChannelCount;
+ std::vector<std::pair<DynamicsProcessing::Tag, DynamicsProcessing>> mTags;
+ void CleanUp() {
+ mTags.clear();
+ mPreEqChannelEnable.clear();
+ mPostEqChannelEnable.clear();
+ mMbcChannelEnable.clear();
+ mLimiterChannelEnable.clear();
+ }
+};
+
+// test value set for DynamicsProcessing::StageEnablement
+const std::set<DynamicsProcessing::StageEnablement>
+ DynamicsProcessingTestHelper::kStageEnablementTestSet = {
+ {.inUse = true, .bandCount = DynamicsProcessingTestHelper::kBandCount},
+ {.inUse = true, .bandCount = 0},
+ {.inUse = true, .bandCount = -1},
+ {.inUse = false, .bandCount = DynamicsProcessingTestHelper::kBandCount}};
+
+// test value set for DynamicsProcessing::ChannelConfig
+const std::set<std::vector<DynamicsProcessing::ChannelConfig>>
+ DynamicsProcessingTestHelper::kChannelConfigTestSet = {
+ {{.channel = -1, .enable = false},
+ {.channel = 0, .enable = true},
+ {.channel = 1, .enable = false},
+ {.channel = 2, .enable = true}},
+
+ {{.channel = -1, .enable = false}, {.channel = 2, .enable = true}},
+
+ {{.channel = 0, .enable = true}, {.channel = 1, .enable = true}}};
+
+// test value set for DynamicsProcessing::InputGain
+const std::set<std::vector<DynamicsProcessing::InputGain>>
+ DynamicsProcessingTestHelper::kInputGainTestSet = {
+ {{.channel = 0, .gainDb = 10.f},
+ {.channel = 1, .gainDb = 0.f},
+ {.channel = 2, .gainDb = -10.f}},
+
+ {{.channel = -1, .gainDb = -10.f}, {.channel = -2, .gainDb = 10.f}},
+
+ {{.channel = -1, .gainDb = 10.f}, {.channel = 0, .gainDb = -10.f}}};
+
+bool DynamicsProcessingTestHelper::isParamValid(const DynamicsProcessing::Tag& tag,
+ const DynamicsProcessing& dp,
+ const Descriptor& desc) {
+ const DynamicsProcessing::Capability& dpCap =
+ desc.capability.get<Capability::dynamicsProcessing>();
+ switch (tag) {
+ case DynamicsProcessing::engineArchitecture: {
+ return isEngineConfigValid(dp.get<DynamicsProcessing::engineArchitecture>());
+ }
+ case DynamicsProcessing::preEq: {
+ return isChannelConfigValid(dp.get<DynamicsProcessing::preEq>(),
+ mEngineConfigApplied.preEqStage.inUse);
+ }
+ case DynamicsProcessing::postEq: {
+ return isChannelConfigValid(dp.get<DynamicsProcessing::postEq>(),
+ mEngineConfigApplied.postEqStage.inUse);
+ }
+ case DynamicsProcessing::mbc: {
+ return isChannelConfigValid(dp.get<DynamicsProcessing::mbc>(),
+ mEngineConfigApplied.mbcStage.inUse);
+ }
+ case DynamicsProcessing::preEqBand: {
+ return isPreEqBandConfigValid(dpCap, dp.get<DynamicsProcessing::preEqBand>(),
+ mEngineConfigApplied.preEqStage.inUse,
+ mEngineConfigApplied.preEqStage.bandCount);
+ }
+ case DynamicsProcessing::postEqBand: {
+ return isPostEqBandConfigValid(dpCap, dp.get<DynamicsProcessing::postEqBand>(),
+ mEngineConfigApplied.postEqStage.inUse,
+ mEngineConfigApplied.postEqStage.bandCount);
+ }
+ case DynamicsProcessing::mbcBand: {
+ return isMbcBandConfigValid(dpCap, dp.get<DynamicsProcessing::mbcBand>(),
+ mEngineConfigApplied.mbcStage.inUse,
+ mEngineConfigApplied.mbcStage.bandCount);
+ }
+ case DynamicsProcessing::limiter: {
+ return isLimiterConfigValid(dp.get<DynamicsProcessing::limiter>(),
+ mEngineConfigApplied.limiterInUse);
+ }
+ case DynamicsProcessing::inputGain: {
+ return isInputGainValid(dp.get<DynamicsProcessing::inputGain>());
+ }
+ case DynamicsProcessing::vendorExtension: {
+ return true;
+ }
+ }
+ return true;
+}
+
+bool DynamicsProcessingTestHelper::isParamEqual(const DynamicsProcessing::Tag& tag,
+ const DynamicsProcessing& dpRef,
+ const DynamicsProcessing& dpTest) {
+ switch (tag) {
+ case DynamicsProcessing::engineArchitecture: {
+ return isEngineConfigEqual(dpRef.get<DynamicsProcessing::engineArchitecture>(),
+ dpTest.get<DynamicsProcessing::engineArchitecture>());
+ }
+ case DynamicsProcessing::preEq: {
+ const auto& source = dpRef.get<DynamicsProcessing::preEq>();
+ const auto& target = dpTest.get<DynamicsProcessing::preEq>();
+ return isAidlVectorEqualAfterFilter<DynamicsProcessing::ChannelConfig>(source, target);
+ }
+ case DynamicsProcessing::postEq: {
+ return isAidlVectorEqualAfterFilter<DynamicsProcessing::ChannelConfig>(
+ dpRef.get<DynamicsProcessing::postEq>(),
+ dpTest.get<DynamicsProcessing::postEq>());
+ }
+ case DynamicsProcessing::mbc: {
+ return isAidlVectorEqualAfterFilter<DynamicsProcessing::ChannelConfig>(
+ dpRef.get<DynamicsProcessing::mbc>(), dpTest.get<DynamicsProcessing::mbc>());
+ }
+ case DynamicsProcessing::preEqBand: {
+ return isAidlVectorEqualAfterFilter<DynamicsProcessing::EqBandConfig>(
+ dpRef.get<DynamicsProcessing::preEqBand>(),
+ dpTest.get<DynamicsProcessing::preEqBand>());
+ }
+ case DynamicsProcessing::postEqBand: {
+ return isAidlVectorEqualAfterFilter<DynamicsProcessing::EqBandConfig>(
+ dpRef.get<DynamicsProcessing::postEqBand>(),
+ dpTest.get<DynamicsProcessing::postEqBand>());
+ }
+ case DynamicsProcessing::mbcBand: {
+ return isAidlVectorEqualAfterFilter<DynamicsProcessing::MbcBandConfig>(
+ dpRef.get<DynamicsProcessing::mbcBand>(),
+ dpTest.get<DynamicsProcessing::mbcBand>());
+ }
+ case DynamicsProcessing::limiter: {
+ return isAidlVectorEqualAfterFilter<DynamicsProcessing::LimiterConfig>(
+ dpRef.get<DynamicsProcessing::limiter>(),
+ dpTest.get<DynamicsProcessing::limiter>());
+ }
+ case DynamicsProcessing::inputGain: {
+ return isAidlVectorEqual<DynamicsProcessing::InputGain>(
+ dpRef.get<DynamicsProcessing::inputGain>(),
+ dpTest.get<DynamicsProcessing::inputGain>());
+ }
+ case DynamicsProcessing::vendorExtension: {
+ return false;
+ }
+ }
+}
+
+bool DynamicsProcessingTestHelper::isEnablementValid(
+ const DynamicsProcessing::StageEnablement& enablement) {
+ return !enablement.inUse || (enablement.inUse && enablement.bandCount > 0);
+}
+
+bool DynamicsProcessingTestHelper::isEngineConfigValid(
+ const DynamicsProcessing::EngineArchitecture& cfg) {
+ return cfg.preferredProcessingDurationMs >= 0 && isEnablementValid(cfg.preEqStage) &&
+ isEnablementValid(cfg.postEqStage) && isEnablementValid(cfg.mbcStage);
+}
+
+bool DynamicsProcessingTestHelper::isChannelConfigValid(
+ const std::vector<DynamicsProcessing::ChannelConfig>& cfgs, bool stageInUse) {
+ std::unordered_set<int> channelSet;
+ if (!stageInUse) return false;
+ for (auto cfg : cfgs) {
+ if (cfg.channel < 0 || cfg.channel >= mChannelCount || 0 != channelSet.count(cfg.channel)) {
+ return false;
+ }
+ channelSet.insert(cfg.channel);
+ }
+ return true;
+}
+
+bool DynamicsProcessingTestHelper::isCutoffFrequencyValid(
+ float freq, const DynamicsProcessing::Capability& cap) {
+ return freq >= cap.minCutOffFreq && freq <= cap.maxCutOffFreq;
+}
+
+bool DynamicsProcessingTestHelper::isPreEqBandConfigValid(
+ const DynamicsProcessing::Capability& cap,
+ const std::vector<DynamicsProcessing::EqBandConfig>& cfgs, bool stageInUse, int bandCount) {
+ std::set<std::pair<int /* channelID */, int /* bandID */>> bandSet;
+ if (!stageInUse) return false;
+ for (auto cfg : cfgs) {
+ if (0 == mPreEqChannelEnable.count(cfg.channel) || cfg.channel < 0 ||
+ cfg.channel >= mChannelCount || cfg.band < 0 || cfg.band >= bandCount ||
+ !isCutoffFrequencyValid(cfg.cutoffFrequencyHz, cap) ||
+ 0 != bandSet.count({cfg.channel, cfg.band})) {
+ return false;
+ }
+ bandSet.insert({cfg.channel, cfg.band});
+ }
+ return true;
+}
+
+bool DynamicsProcessingTestHelper::isPostEqBandConfigValid(
+ const DynamicsProcessing::Capability& cap,
+ const std::vector<DynamicsProcessing::EqBandConfig>& cfgs, bool stageInUse, int bandCount) {
+ std::set<std::pair<int /* channelID */, int /* bandID */>> bandSet;
+ // not able to set/get parameter when stage not in use.
+ if (!stageInUse) return false;
+ for (auto cfg : cfgs) {
+ if (0 == mPostEqChannelEnable.count(cfg.channel) || cfg.channel < 0 ||
+ cfg.channel >= mChannelCount || cfg.band < 0 || cfg.band >= bandCount ||
+ !isCutoffFrequencyValid(cfg.cutoffFrequencyHz, cap) ||
+ 0 != bandSet.count({cfg.channel, cfg.band})) {
+ return false;
+ }
+ bandSet.insert({cfg.channel, cfg.band});
+ }
+ return true;
+}
+
+bool DynamicsProcessingTestHelper::isMbcBandConfigValid(
+ const DynamicsProcessing::Capability& cap,
+ const std::vector<DynamicsProcessing::MbcBandConfig>& cfgs, bool stageInUse,
+ int bandCount) {
+ std::set<std::pair<int /* channelID */, int /* bandID */>> bandSet;
+ if (!stageInUse) return false;
+ for (auto cfg : cfgs) {
+ if (0 == mMbcChannelEnable.count(cfg.channel) || cfg.channel < 0 ||
+ cfg.channel >= mChannelCount || cfg.band < 0 || cfg.band >= bandCount ||
+ (cfg.attackTimeMs < 0) || cfg.releaseTimeMs < 0 || cfg.ratio < 0 ||
+ cfg.thresholdDb > 0 || cfg.kneeWidthDb < 0 || cfg.noiseGateThresholdDb > 0 ||
+ cfg.expanderRatio < 0 || !isCutoffFrequencyValid(cfg.cutoffFrequencyHz, cap) ||
+ 0 != bandSet.count({cfg.channel, cfg.band})) {
+ return false;
+ }
+ bandSet.insert({cfg.channel, cfg.band});
+ }
+ return true;
+}
+
+bool DynamicsProcessingTestHelper::isLimiterConfigValid(
+ const std::vector<DynamicsProcessing::LimiterConfig>& cfgs, bool stageInUse) {
+ std::set<int> channelSet;
+ if (!stageInUse) return false;
+ for (auto cfg : cfgs) {
+ if (0 == mLimiterChannelEnable.count(cfg.channel) || cfg.channel < 0 ||
+ cfg.channel >= mChannelCount || cfg.attackTimeMs < 0 || cfg.releaseTimeMs < 0 ||
+ cfg.ratio < 0 || cfg.thresholdDb > 0 || 0 != channelSet.count(cfg.channel)) {
+ return false;
+ }
+ channelSet.insert(cfg.channel);
+ }
+ return true;
+}
+
+bool DynamicsProcessingTestHelper::isInputGainValid(
+ const std::vector<DynamicsProcessing::InputGain>& cfgs) {
+ std::set<int> channelSet;
+ for (auto cfg : cfgs) {
+ if (cfg.channel < 0 || cfg.channel >= mChannelCount || 0 != channelSet.count(cfg.channel)) {
+ return false;
+ }
+ channelSet.insert(cfg.channel);
+ }
+ return true;
+}
+
+bool DynamicsProcessingTestHelper::isEngineConfigEqual(
+ const DynamicsProcessing::EngineArchitecture& ref,
+ const DynamicsProcessing::EngineArchitecture& test) {
+ return ref == test;
+}
+
+template <typename T>
+std::vector<T> DynamicsProcessingTestHelper::filterEnabledVector(const std::vector<T>& vec) {
+ std::vector<T> ret;
+ std::copy_if(vec.begin(), vec.end(), std::back_inserter(ret),
+ [](const auto& v) { return v.enable; });
+ return ret;
+}
+
+template <typename T>
+bool DynamicsProcessingTestHelper::isAidlVectorEqual(const std::vector<T>& source,
+ const std::vector<T>& target) {
+ if (source.size() != target.size()) return false;
+
+ auto tempS = source;
+ auto tempT = target;
+ std::sort(tempS.begin(), tempS.end());
+ std::sort(tempT.begin(), tempT.end());
+ return tempS == tempT;
+}
+
+template <typename T>
+bool DynamicsProcessingTestHelper::isAidlVectorEqualAfterFilter(const std::vector<T>& source,
+ const std::vector<T>& target) {
+ return isAidlVectorEqual<T>(filterEnabledVector<T>(source), filterEnabledVector<T>(target));
+}
+
+void DynamicsProcessingTestHelper::SetAndGetDynamicsProcessingParameters() {
+ for (auto& it : mTags) {
+ auto& tag = it.first;
+ auto& dp = it.second;
+
+ // validate parameter
+ Descriptor desc;
+ ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
+ const bool valid = isParamValid(tag, dp, desc);
+ const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
+
+ // set parameter
+ Parameter expectParam;
+ Parameter::Specific specific;
+ specific.set<Parameter::Specific::dynamicsProcessing>(dp);
+ expectParam.set<Parameter::specific>(specific);
+ ASSERT_STATUS(expected, mEffect->setParameter(expectParam)) << expectParam.toString();
+
+ // only get if parameter in range and set success
+ if (expected == EX_NONE) {
+ Parameter getParam;
+ Parameter::Id id;
+ DynamicsProcessing::Id dpId;
+ dpId.set<DynamicsProcessing::Id::commonTag>(tag);
+ id.set<Parameter::Id::dynamicsProcessingTag>(dpId);
+ // if set success, then get should match
+ EXPECT_STATUS(expected, mEffect->getParameter(id, &getParam));
+ Parameter::Specific specificTest = getParam.get<Parameter::specific>();
+ const auto& target = specificTest.get<Parameter::Specific::dynamicsProcessing>();
+ EXPECT_TRUE(isParamEqual(tag, dp, target)) << dp.toString() << "\n"
+ << target.toString();
+ // update mEngineConfigApplied after setting successfully
+ if (tag == DynamicsProcessing::engineArchitecture) {
+ mEngineConfigApplied = target.get<DynamicsProcessing::engineArchitecture>();
+ }
+ }
+ }
+}
+
+void DynamicsProcessingTestHelper::addEngineConfig(
+ const DynamicsProcessing::EngineArchitecture& cfg) {
+ DynamicsProcessing dp;
+ dp.set<DynamicsProcessing::engineArchitecture>(cfg);
+ mTags.push_back({DynamicsProcessing::engineArchitecture, dp});
+}
+
+void DynamicsProcessingTestHelper::addPreEqChannelConfig(
+ const std::vector<DynamicsProcessing::ChannelConfig>& cfgs) {
+ DynamicsProcessing dp;
+ dp.set<DynamicsProcessing::preEq>(cfgs);
+ mTags.push_back({DynamicsProcessing::preEq, dp});
+ for (auto& cfg : cfgs) {
+ if (cfg.enable) mPreEqChannelEnable.insert(cfg.channel);
+ }
+}
+
+void DynamicsProcessingTestHelper::addPostEqChannelConfig(
+ const std::vector<DynamicsProcessing::ChannelConfig>& cfgs) {
+ DynamicsProcessing dp;
+ dp.set<DynamicsProcessing::postEq>(cfgs);
+ mTags.push_back({DynamicsProcessing::postEq, dp});
+ for (auto& cfg : cfgs) {
+ if (cfg.enable) mPostEqChannelEnable.insert(cfg.channel);
+ }
+}
+
+void DynamicsProcessingTestHelper::addMbcChannelConfig(
+ const std::vector<DynamicsProcessing::ChannelConfig>& cfgs) {
+ DynamicsProcessing dp;
+ dp.set<DynamicsProcessing::mbc>(cfgs);
+ mTags.push_back({DynamicsProcessing::mbc, dp});
+ for (auto& cfg : cfgs) {
+ if (cfg.enable) mMbcChannelEnable.insert(cfg.channel);
+ }
+}
+
+void DynamicsProcessingTestHelper::addPreEqBandConfigs(
+ const std::vector<DynamicsProcessing::EqBandConfig>& cfgs) {
+ DynamicsProcessing dp;
+ dp.set<DynamicsProcessing::preEqBand>(cfgs);
+ mTags.push_back({DynamicsProcessing::preEqBand, dp});
+}
+
+void DynamicsProcessingTestHelper::addPostEqBandConfigs(
+ const std::vector<DynamicsProcessing::EqBandConfig>& cfgs) {
+ DynamicsProcessing dp;
+ dp.set<DynamicsProcessing::postEqBand>(cfgs);
+ mTags.push_back({DynamicsProcessing::postEqBand, dp});
+}
+
+void DynamicsProcessingTestHelper::addMbcBandConfigs(
+ const std::vector<DynamicsProcessing::MbcBandConfig>& cfgs) {
+ DynamicsProcessing dp;
+ dp.set<DynamicsProcessing::mbcBand>(cfgs);
+ mTags.push_back({DynamicsProcessing::mbcBand, dp});
+}
+
+void DynamicsProcessingTestHelper::addLimiterConfig(
+ const std::vector<DynamicsProcessing::LimiterConfig>& cfgs) {
+ DynamicsProcessing dp;
+ dp.set<DynamicsProcessing::limiter>(cfgs);
+ mTags.push_back({DynamicsProcessing::limiter, dp});
+ for (auto& cfg : cfgs) {
+ if (cfg.enable) mLimiterChannelEnable.insert(cfg.channel);
+ }
+}
+
+void DynamicsProcessingTestHelper::addInputGain(
+ const std::vector<DynamicsProcessing::InputGain>& inputGains) {
+ DynamicsProcessing dp;
+ dp.set<DynamicsProcessing::inputGain>(inputGains);
+ mTags.push_back({DynamicsProcessing::inputGain, dp});
+}
+
+/**
+ * Test DynamicsProcessing Engine Configuration
+ */
+enum EngineArchitectureTestParamName {
+ ENGINE_TEST_INSTANCE_NAME,
+ ENGINE_TEST_RESOLUTION_PREFERENCE,
+ ENGINE_TEST_PREFERRED_DURATION,
+ ENGINE_TEST_STAGE_ENABLEMENT,
+ ENGINE_TEST_LIMITER_IN_USE
+};
+using EngineArchitectureTestParams = std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>,
+ DynamicsProcessing::ResolutionPreference, float,
+ DynamicsProcessing::StageEnablement, bool>;
+
+void fillEngineArchConfig(DynamicsProcessing::EngineArchitecture& cfg,
+ const EngineArchitectureTestParams& params) {
+ cfg.resolutionPreference = std::get<ENGINE_TEST_RESOLUTION_PREFERENCE>(params);
+ cfg.preferredProcessingDurationMs = std::get<ENGINE_TEST_PREFERRED_DURATION>(params);
+ cfg.preEqStage = cfg.postEqStage = cfg.mbcStage =
+ std::get<ENGINE_TEST_STAGE_ENABLEMENT>(params);
+ cfg.limiterInUse = std::get<ENGINE_TEST_LIMITER_IN_USE>(params);
+}
+
+class DynamicsProcessingTestEngineArchitecture
+ : public ::testing::TestWithParam<EngineArchitectureTestParams>,
+ public DynamicsProcessingTestHelper {
+ public:
+ DynamicsProcessingTestEngineArchitecture()
+ : DynamicsProcessingTestHelper(std::get<ENGINE_TEST_INSTANCE_NAME>(GetParam())) {
+ fillEngineArchConfig(mCfg, GetParam());
+ };
+
+ void SetUp() override { SetUpDynamicsProcessingEffect(); }
+
+ void TearDown() override { TearDownDynamicsProcessingEffect(); }
+
+ DynamicsProcessing::EngineArchitecture mCfg;
+};
+
+TEST_P(DynamicsProcessingTestEngineArchitecture, SetAndGetEngineArch) {
+ EXPECT_NO_FATAL_FAILURE(addEngineConfig(mCfg));
+ SetAndGetDynamicsProcessingParameters();
+}
+
+INSTANTIATE_TEST_SUITE_P(
+ DynamicsProcessingTest, DynamicsProcessingTestEngineArchitecture,
+ ::testing::Combine(
+ testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kDynamicsProcessingTypeUUID)),
+ testing::Values(DynamicsProcessing::ResolutionPreference::FAVOR_TIME_RESOLUTION,
+ DynamicsProcessing::ResolutionPreference::
+ FAVOR_FREQUENCY_RESOLUTION), // variant
+ testing::Values(-10.f, 0.f, 10.f), // processing duration
+ testing::ValuesIn(
+ DynamicsProcessingTestHelper::kStageEnablementTestSet), // preEQ/postEQ/mbc
+ testing::Bool()), // limiter enable
+ [](const auto& info) {
+ auto descriptor = std::get<ENGINE_TEST_INSTANCE_NAME>(info.param).second;
+ DynamicsProcessing::EngineArchitecture cfg;
+ fillEngineArchConfig(cfg, info.param);
+ std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
+ descriptor.common.name + "_UUID_" +
+ descriptor.common.id.uuid.toString() + "_Cfg_" + cfg.toString();
+ std::replace_if(
+ name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
+ return name;
+ });
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DynamicsProcessingTestEngineArchitecture);
+
+/**
+ * Test DynamicsProcessing Input Gain
+ */
+enum InputGainTestParamName {
+ INPUT_GAIN_INSTANCE_NAME,
+ INPUT_GAIN_PARAM,
+};
+class DynamicsProcessingTestInputGain
+ : public ::testing::TestWithParam<std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>,
+ std::vector<DynamicsProcessing::InputGain>>>,
+ public DynamicsProcessingTestHelper {
+ public:
+ DynamicsProcessingTestInputGain()
+ : DynamicsProcessingTestHelper(std::get<INPUT_GAIN_INSTANCE_NAME>(GetParam())),
+ mInputGain(std::get<INPUT_GAIN_PARAM>(GetParam())){};
+
+ void SetUp() override { SetUpDynamicsProcessingEffect(); }
+
+ void TearDown() override { TearDownDynamicsProcessingEffect(); }
+
+ const std::vector<DynamicsProcessing::InputGain> mInputGain;
+};
+
+TEST_P(DynamicsProcessingTestInputGain, SetAndGetInputGain) {
+ EXPECT_NO_FATAL_FAILURE(addInputGain(mInputGain));
+ SetAndGetDynamicsProcessingParameters();
+}
+
+INSTANTIATE_TEST_SUITE_P(
+ DynamicsProcessingTest, DynamicsProcessingTestInputGain,
+ ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kDynamicsProcessingTypeUUID)),
+ testing::ValuesIn(DynamicsProcessingTestInputGain::kInputGainTestSet)),
+ [](const auto& info) {
+ auto descriptor = std::get<INPUT_GAIN_INSTANCE_NAME>(info.param).second;
+ std::string gains =
+ ::android::internal::ToString(std::get<INPUT_GAIN_PARAM>(info.param));
+ std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
+ descriptor.common.name + "_UUID_" +
+ descriptor.common.id.uuid.toString() + "_inputGains_" + gains;
+ std::replace_if(
+ name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
+ return name;
+ });
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DynamicsProcessingTestInputGain);
+
+/**
+ * Test DynamicsProcessing Limiter Config
+ */
+enum LimiterConfigTestParamName {
+ LIMITER_INSTANCE_NAME,
+ LIMITER_CHANNEL,
+ LIMITER_ENABLE,
+ LIMITER_LINK_GROUP,
+ LIMITER_ENGINE_IN_USE,
+ LIMITER_ADDITIONAL,
+};
+enum LimiterConfigTestAdditionalParam {
+ LIMITER_ATTACK_TIME,
+ LIMITER_RELEASE_TIME,
+ LIMITER_RATIO,
+ LIMITER_THRESHOLD,
+ LIMITER_POST_GAIN,
+ LIMITER_MAX_NUM,
+};
+using LimiterConfigTestAdditional = std::array<float, LIMITER_MAX_NUM>;
+// attachTime, releaseTime, ratio, thresh, postGain
+static constexpr std::array<LimiterConfigTestAdditional, 4> kLimiterConfigTestAdditionalParam = {
+ {{-1, -60, -2.5, -2, -3.14},
+ {-1, 60, -2.5, 2, -3.14},
+ {1, -60, 2.5, -2, 3.14},
+ {1, 60, 2.5, 2, 3.14}}};
+
+using LimiterConfigTestParams =
+ std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int32_t, bool, int32_t, bool,
+ LimiterConfigTestAdditional>;
+
+void fillLimiterConfig(DynamicsProcessing::LimiterConfig& cfg,
+ const LimiterConfigTestParams& params) {
+ const std::array<float, LIMITER_MAX_NUM> additional = std::get<LIMITER_ADDITIONAL>(params);
+ cfg.channel = std::get<LIMITER_CHANNEL>(params);
+ cfg.enable = std::get<LIMITER_ENABLE>(params);
+ cfg.linkGroup = std::get<LIMITER_LINK_GROUP>(params);
+ cfg.attackTimeMs = additional[LIMITER_ATTACK_TIME];
+ cfg.releaseTimeMs = additional[LIMITER_RELEASE_TIME];
+ cfg.ratio = additional[LIMITER_RATIO];
+ cfg.thresholdDb = additional[LIMITER_THRESHOLD];
+ cfg.postGainDb = additional[LIMITER_POST_GAIN];
+}
+
+class DynamicsProcessingTestLimiterConfig
+ : public ::testing::TestWithParam<LimiterConfigTestParams>,
+ public DynamicsProcessingTestHelper {
+ public:
+ DynamicsProcessingTestLimiterConfig()
+ : DynamicsProcessingTestHelper(std::get<LIMITER_INSTANCE_NAME>(GetParam())),
+ mLimiterInUseEngine(std::get<LIMITER_ENGINE_IN_USE>(GetParam())) {
+ fillLimiterConfig(mCfg, GetParam());
+ }
+
+ void SetUp() override { SetUpDynamicsProcessingEffect(); }
+
+ void TearDown() override { TearDownDynamicsProcessingEffect(); }
+
+ DynamicsProcessing::LimiterConfig mCfg;
+ bool mLimiterInUseEngine;
+};
+
+TEST_P(DynamicsProcessingTestLimiterConfig, SetAndGetLimiterConfig) {
+ mEngineConfigPreset.limiterInUse = mLimiterInUseEngine;
+ EXPECT_NO_FATAL_FAILURE(addEngineConfig(mEngineConfigPreset));
+ EXPECT_NO_FATAL_FAILURE(addLimiterConfig({mCfg}));
+ SetAndGetDynamicsProcessingParameters();
+}
+
+INSTANTIATE_TEST_SUITE_P(
+ DynamicsProcessingTest, DynamicsProcessingTestLimiterConfig,
+ ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kDynamicsProcessingTypeUUID)),
+ testing::Values(-1, 0, 1, 2), // channel count
+ testing::Bool(), // enable
+ testing::Values(3), // link group
+ testing::Bool(), // engine limiter enable
+ testing::ValuesIn(kLimiterConfigTestAdditionalParam)), // Additional
+ [](const auto& info) {
+ auto descriptor = std::get<LIMITER_INSTANCE_NAME>(info.param).second;
+ DynamicsProcessing::LimiterConfig cfg;
+ fillLimiterConfig(cfg, info.param);
+ std::string engineLimiterInUse =
+ std::to_string(std::get<LIMITER_ENGINE_IN_USE>(info.param));
+ std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
+ descriptor.common.name + "_UUID_" +
+ descriptor.common.id.uuid.toString() + "_limiterConfig_" +
+ cfg.toString() + "_engineSetting_" + engineLimiterInUse;
+ std::replace_if(
+ name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
+ return name;
+ });
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DynamicsProcessingTestLimiterConfig);
+
+/**
+ * Test DynamicsProcessing ChannelConfig
+ */
+enum ChannelConfigTestParamName {
+ BAND_CHANNEL_TEST_INSTANCE_NAME,
+ BAND_CHANNEL_TEST_CHANNEL_CONFIG,
+ BAND_CHANNEL_TEST_ENGINE_IN_USE
+};
+using ChannelConfigTestParams = std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>,
+ std::vector<DynamicsProcessing::ChannelConfig>, bool>;
+
+class DynamicsProcessingTestChannelConfig
+ : public ::testing::TestWithParam<ChannelConfigTestParams>,
+ public DynamicsProcessingTestHelper {
+ public:
+ DynamicsProcessingTestChannelConfig()
+ : DynamicsProcessingTestHelper(std::get<BAND_CHANNEL_TEST_INSTANCE_NAME>(GetParam())),
+ mCfg(std::get<BAND_CHANNEL_TEST_CHANNEL_CONFIG>(GetParam())),
+ mInUseEngine(std::get<BAND_CHANNEL_TEST_ENGINE_IN_USE>(GetParam())) {}
+
+ void SetUp() override { SetUpDynamicsProcessingEffect(); }
+
+ void TearDown() override { TearDownDynamicsProcessingEffect(); }
+
+ std::vector<DynamicsProcessing::ChannelConfig> mCfg;
+ const bool mInUseEngine;
+};
+
+TEST_P(DynamicsProcessingTestChannelConfig, SetAndGetPreEqChannelConfig) {
+ mEngineConfigPreset.preEqStage.inUse = mInUseEngine;
+ EXPECT_NO_FATAL_FAILURE(addEngineConfig(mEngineConfigPreset));
+ EXPECT_NO_FATAL_FAILURE(addPreEqChannelConfig(mCfg));
+ SetAndGetDynamicsProcessingParameters();
+}
+
+TEST_P(DynamicsProcessingTestChannelConfig, SetAndGetPostEqChannelConfig) {
+ mEngineConfigPreset.postEqStage.inUse = mInUseEngine;
+ EXPECT_NO_FATAL_FAILURE(addEngineConfig(mEngineConfigPreset));
+ EXPECT_NO_FATAL_FAILURE(addPostEqChannelConfig(mCfg));
+ SetAndGetDynamicsProcessingParameters();
+}
+
+TEST_P(DynamicsProcessingTestChannelConfig, SetAndGetMbcChannelConfig) {
+ mEngineConfigPreset.mbcStage.inUse = mInUseEngine;
+ EXPECT_NO_FATAL_FAILURE(addEngineConfig(mEngineConfigPreset));
+ EXPECT_NO_FATAL_FAILURE(addMbcChannelConfig(mCfg));
+ SetAndGetDynamicsProcessingParameters();
+}
+
+INSTANTIATE_TEST_SUITE_P(
+ DynamicsProcessingTest, DynamicsProcessingTestChannelConfig,
+ ::testing::Combine(
+ testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kDynamicsProcessingTypeUUID)),
+ testing::ValuesIn(
+ DynamicsProcessingTestHelper::kChannelConfigTestSet), // channel config
+ testing::Bool()), // Engine inUse
+ [](const auto& info) {
+ auto descriptor = std::get<BAND_CHANNEL_TEST_INSTANCE_NAME>(info.param).second;
+ std::string engineInUse =
+ std::to_string(std::get<BAND_CHANNEL_TEST_ENGINE_IN_USE>(info.param));
+ std::string channelConfig = ::android::internal::ToString(
+ std::get<BAND_CHANNEL_TEST_CHANNEL_CONFIG>(info.param));
+
+ std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
+ descriptor.common.name + "_UUID_" +
+ descriptor.common.id.uuid.toString() + "_" + channelConfig +
+ "_engineInUse_" + engineInUse;
+ std::replace_if(
+ name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
+ return name;
+ });
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DynamicsProcessingTestChannelConfig);
+
+/**
+ * Test DynamicsProcessing EqBandConfig
+ */
+enum EqBandConfigTestParamName {
+ EQ_BAND_INSTANCE_NAME,
+ EQ_BAND_CHANNEL,
+ EQ_BAND_CHANNEL_ENABLE,
+ EQ_BAND_ENABLE,
+ EQ_BAND_CUT_OFF_FREQ,
+ EQ_BAND_GAIN,
+ EQ_BAND_STAGE_IN_USE
+};
+using EqBandConfigTestParams = std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int32_t,
+ std::vector<DynamicsProcessing::ChannelConfig>, bool,
+ std::vector<std::pair<int, float>>, float, bool>;
+
+void fillEqBandConfig(std::vector<DynamicsProcessing::EqBandConfig>& cfgs,
+ const EqBandConfigTestParams& params) {
+ const std::vector<std::pair<int, float>> cutOffFreqs = std::get<EQ_BAND_CUT_OFF_FREQ>(params);
+ int bandCount = cutOffFreqs.size();
+ cfgs.resize(bandCount);
+ for (int i = 0; i < bandCount; i++) {
+ cfgs[i].channel = std::get<EQ_BAND_CHANNEL>(params);
+ cfgs[i].band = cutOffFreqs[i].first;
+ cfgs[i].enable = std::get<EQ_BAND_ENABLE>(params);
+ cfgs[i].cutoffFrequencyHz = cutOffFreqs[i].second;
+ cfgs[i].gainDb = std::get<EQ_BAND_GAIN>(params);
+ }
+}
+
+class DynamicsProcessingTestEqBandConfig : public ::testing::TestWithParam<EqBandConfigTestParams>,
+ public DynamicsProcessingTestHelper {
+ public:
+ DynamicsProcessingTestEqBandConfig()
+ : DynamicsProcessingTestHelper(std::get<EQ_BAND_INSTANCE_NAME>(GetParam())),
+ mStageInUse(std::get<EQ_BAND_STAGE_IN_USE>(GetParam())),
+ mChannelConfig(std::get<EQ_BAND_CHANNEL_ENABLE>(GetParam())) {
+ fillEqBandConfig(mCfgs, GetParam());
+ }
+
+ void SetUp() override { SetUpDynamicsProcessingEffect(); }
+
+ void TearDown() override { TearDownDynamicsProcessingEffect(); }
+
+ std::vector<DynamicsProcessing::EqBandConfig> mCfgs;
+ const bool mStageInUse;
+ const std::vector<DynamicsProcessing::ChannelConfig> mChannelConfig;
+};
+
+TEST_P(DynamicsProcessingTestEqBandConfig, SetAndGetPreEqBandConfig) {
+ mEngineConfigPreset.preEqStage.inUse = mStageInUse;
+ mEngineConfigPreset.preEqStage.bandCount = mCfgs.size();
+ EXPECT_NO_FATAL_FAILURE(addEngineConfig(mEngineConfigPreset));
+ EXPECT_NO_FATAL_FAILURE(addPreEqChannelConfig(mChannelConfig));
+ EXPECT_NO_FATAL_FAILURE(addPreEqBandConfigs(mCfgs));
+ SetAndGetDynamicsProcessingParameters();
+}
+
+TEST_P(DynamicsProcessingTestEqBandConfig, SetAndGetPostEqBandConfig) {
+ mEngineConfigPreset.postEqStage.inUse = mStageInUse;
+ mEngineConfigPreset.postEqStage.bandCount = mCfgs.size();
+ EXPECT_NO_FATAL_FAILURE(addEngineConfig(mEngineConfigPreset));
+ EXPECT_NO_FATAL_FAILURE(addPostEqChannelConfig(mChannelConfig));
+ EXPECT_NO_FATAL_FAILURE(addPostEqBandConfigs(mCfgs));
+ SetAndGetDynamicsProcessingParameters();
+}
+
+std::vector<std::vector<std::pair<int, float>>> kBands{
+ {
+ {0, 600},
+ {1, 2000},
+ {2, 6000},
+ {3, 10000},
+ {4, 16000},
+ }, // 5 bands
+ {
+ {0, 800},
+ {3, 15000},
+ {2, 6000},
+ {1, 2000},
+ }, // 4 bands, unsorted
+ {
+ {0, 650},
+ {1, 2000},
+ {2, 6000},
+ {3, 10000},
+ {3, 16000},
+ }, // 5 bands, missing band
+ {
+ {0, 900},
+ {1, 8000},
+ {2, 4000},
+ {3, 12000},
+ }, // 4 bands, cutoff freq not increasing
+ {
+ {0, 450},
+ {1, 2000},
+ {7, 6000},
+ {3, 10000},
+ {4, 16000},
+ }, // bad band index
+ {
+ {0, 1},
+ {1, 8000},
+ }, // too low cutoff freq
+ {
+ {0, 1200},
+ {1, 80000},
+ }, // too high cutoff freq
+};
+
+INSTANTIATE_TEST_SUITE_P(
+ DynamicsProcessingTest, DynamicsProcessingTestEqBandConfig,
+ ::testing::Combine(
+ testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kDynamicsProcessingTypeUUID)),
+ testing::Values(-1, 0, 10), // channel ID
+ testing::ValuesIn(
+ DynamicsProcessingTestHelper::kChannelConfigTestSet), // channel enable
+ testing::Bool(), // band enable
+ testing::ValuesIn(kBands), // cut off frequencies
+ testing::Values(-3.14f, 3.14f), // gain
+ testing::Bool()), // stage in use
+ [](const auto& info) {
+ auto descriptor = std::get<EQ_BAND_INSTANCE_NAME>(info.param).second;
+ std::vector<DynamicsProcessing::EqBandConfig> cfgs;
+ fillEqBandConfig(cfgs, info.param);
+ std::string enable =
+ ::android::internal::ToString(std::get<EQ_BAND_CHANNEL_ENABLE>(info.param));
+ std::string bands = ::android::internal::ToString(cfgs);
+ std::string stageInUse = std::to_string(std::get<EQ_BAND_STAGE_IN_USE>(info.param));
+ std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
+ descriptor.common.name + "_UUID_" +
+ descriptor.common.id.uuid.toString() + "_" + enable + "_bands_" +
+ bands + "_stageInUse_" + stageInUse;
+ std::replace_if(
+ name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
+ return name;
+ });
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DynamicsProcessingTestEqBandConfig);
+
+/**
+ * Test DynamicsProcessing MbcBandConfig
+ */
+
+enum MbcBandConfigParamName {
+ MBC_BAND_INSTANCE_NAME,
+ MBC_BAND_CHANNEL,
+ MBC_BAND_CHANNEL_CONFIG,
+ MBC_BAND_ENABLE,
+ MBC_BAND_CUTOFF_FREQ,
+ MBC_BAND_STAGE_IN_USE,
+ MBC_BAND_ADDITIONAL
+};
+enum MbcBandConfigAdditional {
+ MBC_ADD_ATTACK_TIME,
+ MBC_ADD_RELEASE_TIME,
+ MBC_ADD_RATIO,
+ MBC_ADD_THRESHOLD,
+ MBC_ADD_KNEE_WIDTH,
+ MBC_ADD_NOISE_GATE_THRESHOLD,
+ MBC_ADD_EXPENDER_RATIO,
+ MBC_ADD_PRE_GAIN,
+ MBC_ADD_POST_GAIN,
+ MBC_ADD_MAX_NUM
+};
+using TestParamsMbcBandConfigAdditional = std::array<float, MBC_ADD_MAX_NUM>;
+
+// attachTime, releaseTime, ratio, thresh, kneeWidth, noise, expander, preGain, postGain
+static constexpr std::array<TestParamsMbcBandConfigAdditional, 4> kMbcBandConfigAdditionalParam = {
+ {{-3, -10, -2, -2, -5, -90, -2.5, -2, -2},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {-3, 10, -2, 2, -5, 90, -2.5, 2, -2},
+ {3, 10, 2, 2, 5, 90, 2.5, 2, 2}}};
+
+using TestParamsMbcBandConfig =
+ std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int32_t,
+ std::vector<DynamicsProcessing::ChannelConfig>, bool,
+ std::vector<std::pair<int, float>>, bool, TestParamsMbcBandConfigAdditional>;
+
+void fillMbcBandConfig(std::vector<DynamicsProcessing::MbcBandConfig>& cfgs,
+ const TestParamsMbcBandConfig& params) {
+ const std::vector<std::pair<int, float>> cutOffFreqs = std::get<MBC_BAND_CUTOFF_FREQ>(params);
+ const std::array<float, MBC_ADD_MAX_NUM> additional = std::get<MBC_BAND_ADDITIONAL>(params);
+ int bandCount = cutOffFreqs.size();
+ cfgs.resize(bandCount);
+ for (int i = 0; i < bandCount; i++) {
+ cfgs[i] = DynamicsProcessing::MbcBandConfig{
+ .channel = std::get<MBC_BAND_CHANNEL>(params),
+ .band = cutOffFreqs[i].first,
+ .enable = std::get<MBC_BAND_ENABLE>(params),
+ .cutoffFrequencyHz = cutOffFreqs[i].second,
+ .attackTimeMs = additional[MBC_ADD_ATTACK_TIME],
+ .releaseTimeMs = additional[MBC_ADD_RELEASE_TIME],
+ .ratio = additional[MBC_ADD_RATIO],
+ .thresholdDb = additional[MBC_ADD_THRESHOLD],
+ .kneeWidthDb = additional[MBC_ADD_KNEE_WIDTH],
+ .noiseGateThresholdDb = additional[MBC_ADD_NOISE_GATE_THRESHOLD],
+ .expanderRatio = additional[MBC_ADD_EXPENDER_RATIO],
+ .preGainDb = additional[MBC_ADD_PRE_GAIN],
+ .postGainDb = additional[MBC_ADD_POST_GAIN]};
+ }
+}
+
+class DynamicsProcessingTestMbcBandConfig
+ : public ::testing::TestWithParam<TestParamsMbcBandConfig>,
+ public DynamicsProcessingTestHelper {
+ public:
+ DynamicsProcessingTestMbcBandConfig()
+ : DynamicsProcessingTestHelper(std::get<MBC_BAND_INSTANCE_NAME>(GetParam())),
+ mStageInUse(std::get<MBC_BAND_STAGE_IN_USE>(GetParam())),
+ mChannelConfig(std::get<MBC_BAND_CHANNEL_CONFIG>(GetParam())) {
+ fillMbcBandConfig(mCfgs, GetParam());
+ }
+
+ void SetUp() override { SetUpDynamicsProcessingEffect(); }
+
+ void TearDown() override { TearDownDynamicsProcessingEffect(); }
+
+ std::vector<DynamicsProcessing::MbcBandConfig> mCfgs;
+ const bool mStageInUse;
+ const std::vector<DynamicsProcessing::ChannelConfig> mChannelConfig;
+};
+
+TEST_P(DynamicsProcessingTestMbcBandConfig, SetAndGetMbcBandConfig) {
+ mEngineConfigPreset.mbcStage.inUse = mStageInUse;
+ mEngineConfigPreset.mbcStage.bandCount = mCfgs.size();
+ EXPECT_NO_FATAL_FAILURE(addEngineConfig(mEngineConfigPreset));
+ EXPECT_NO_FATAL_FAILURE(addMbcChannelConfig(mChannelConfig));
+ EXPECT_NO_FATAL_FAILURE(addMbcBandConfigs(mCfgs));
+ SetAndGetDynamicsProcessingParameters();
+}
+
+INSTANTIATE_TEST_SUITE_P(
+ DynamicsProcessingTest, DynamicsProcessingTestMbcBandConfig,
+ ::testing::Combine(
+ testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kDynamicsProcessingTypeUUID)),
+ testing::Values(-1, 0, 10), // channel count
+ testing::ValuesIn(
+ DynamicsProcessingTestHelper::kChannelConfigTestSet), // channel config
+ testing::Bool(), // enable
+ testing::ValuesIn(kBands), // cut off frequencies
+ testing::Bool(), // stage in use
+ testing::ValuesIn(kMbcBandConfigAdditionalParam)), // Additional
+ [](const auto& info) {
+ auto descriptor = std::get<MBC_BAND_INSTANCE_NAME>(info.param).second;
+ std::vector<DynamicsProcessing::MbcBandConfig> cfgs;
+ fillMbcBandConfig(cfgs, info.param);
+ std::string enable =
+ ::android::internal::ToString(std::get<MBC_BAND_CHANNEL_CONFIG>(info.param));
+ std::string mbcBands = ::android::internal::ToString(cfgs);
+ std::string stageInUse = std::to_string(std::get<MBC_BAND_STAGE_IN_USE>(info.param));
+ std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
+ descriptor.common.name + "_UUID_" +
+ descriptor.common.id.uuid.toString() + "_enable_" + enable +
+ "_bands_" + mbcBands + "_stageInUse_" + stageInUse;
+ std::replace_if(
+ name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
+ return name;
+ });
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DynamicsProcessingTestMbcBandConfig);
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ABinderProcess_setThreadPoolMaxThreadCount(1);
+ ABinderProcess_startThreadPool();
+ return RUN_ALL_TESTS();
+}
diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml
index 568d94c..71afee3 100644
--- a/compatibility_matrices/compatibility_matrix.current.xml
+++ b/compatibility_matrices/compatibility_matrix.current.xml
@@ -590,6 +590,16 @@
</interface>
</hal>
<hal format="aidl" optional="true">
+ <name>android.hardware.radio.sap</name>
+ <version>1</version>
+ <interface>
+ <name>ISap</name>
+ <instance>slot1</instance>
+ <instance>slot2</instance>
+ <instance>slot3</instance>
+ </interface>
+ </hal>
+ <hal format="aidl" optional="true">
<name>android.hardware.radio.voice</name>
<version>1</version>
<interface>
diff --git a/graphics/Android.bp b/graphics/Android.bp
index 4c51454..4ae7ec7 100644
--- a/graphics/Android.bp
+++ b/graphics/Android.bp
@@ -21,6 +21,9 @@
static_libs: [
"android.hardware.graphics.allocator-V2-ndk",
],
+ defaults: [
+ "android.hardware.graphics.common-ndk_static",
+ ],
}
cc_defaults {
@@ -28,6 +31,9 @@
shared_libs: [
"android.hardware.graphics.allocator-V2-ndk",
],
+ defaults: [
+ "android.hardware.graphics.common-ndk_shared",
+ ],
}
cc_defaults {
diff --git a/graphics/allocator/aidl/aidl_api/android.hardware.graphics.allocator/current/android/hardware/graphics/allocator/BufferDescriptorInfo.aidl b/graphics/allocator/aidl/aidl_api/android.hardware.graphics.allocator/current/android/hardware/graphics/allocator/BufferDescriptorInfo.aidl
index 980e246..49c2497 100644
--- a/graphics/allocator/aidl/aidl_api/android.hardware.graphics.allocator/current/android/hardware/graphics/allocator/BufferDescriptorInfo.aidl
+++ b/graphics/allocator/aidl/aidl_api/android.hardware.graphics.allocator/current/android/hardware/graphics/allocator/BufferDescriptorInfo.aidl
@@ -41,4 +41,5 @@
android.hardware.graphics.common.PixelFormat format = android.hardware.graphics.common.PixelFormat.UNSPECIFIED;
android.hardware.graphics.common.BufferUsage usage = android.hardware.graphics.common.BufferUsage.CPU_READ_NEVER;
long reservedSize;
+ android.hardware.graphics.common.ExtendableType[] additionalOptions;
}
diff --git a/graphics/allocator/aidl/android/hardware/graphics/allocator/AllocationResult.aidl b/graphics/allocator/aidl/android/hardware/graphics/allocator/AllocationResult.aidl
index 0774e25..76f1c95 100644
--- a/graphics/allocator/aidl/android/hardware/graphics/allocator/AllocationResult.aidl
+++ b/graphics/allocator/aidl/android/hardware/graphics/allocator/AllocationResult.aidl
@@ -18,13 +18,17 @@
import android.hardware.common.NativeHandle;
- /**
+/**
* Result of an IAllocator::allocate call.
*
* @sa +ndk libnativewindow#AHardwareBuffer_Desc
*/
@VintfStability
parcelable AllocationResult {
+ /**
+ * The number of pixels between two consecutive rows of an allocated buffer, when the concept
+ * of consecutive rows is defined. Otherwise, it has no meaning.
+ */
int stride;
NativeHandle[] buffers;
-}
\ No newline at end of file
+}
diff --git a/graphics/allocator/aidl/android/hardware/graphics/allocator/BufferDescriptorInfo.aidl b/graphics/allocator/aidl/android/hardware/graphics/allocator/BufferDescriptorInfo.aidl
index ffc50b8..50aa2b7 100644
--- a/graphics/allocator/aidl/android/hardware/graphics/allocator/BufferDescriptorInfo.aidl
+++ b/graphics/allocator/aidl/android/hardware/graphics/allocator/BufferDescriptorInfo.aidl
@@ -17,6 +17,7 @@
package android.hardware.graphics.allocator;
import android.hardware.graphics.common.BufferUsage;
+import android.hardware.graphics.common.ExtendableType;
import android.hardware.graphics.common.PixelFormat;
@VintfStability
@@ -54,6 +55,9 @@
/**
* Buffer usage mask; valid flags can be found in the definition of
* BufferUsage.aidl in graphics/common
+ *
+ * The allocator must report isSupported() == false and reject any allocations
+ * with unrecognized buffer usages.
*/
BufferUsage usage = BufferUsage.CPU_READ_NEVER;
@@ -62,4 +66,16 @@
* See getReservedRegion for more information.
*/
long reservedSize;
+
+ /**
+ * Extensible additional options that can be set.
+ *
+ * This is intended for options that do not change the overall usage, but which do impact
+ * how a buffer is allocated. An example of this is compression level, such as for
+ * the EGL_EXT_surface_compression extension.
+ *
+ * The allocator must report isSupported() == false and reject any allocations
+ * with unrecognized options.
+ */
+ ExtendableType[] additionalOptions;
}
diff --git a/graphics/allocator/aidl/vts/VtsHalGraphicsAllocatorAidl_TargetTest.cpp b/graphics/allocator/aidl/vts/VtsHalGraphicsAllocatorAidl_TargetTest.cpp
index 09f1c15..4778020 100644
--- a/graphics/allocator/aidl/vts/VtsHalGraphicsAllocatorAidl_TargetTest.cpp
+++ b/graphics/allocator/aidl/vts/VtsHalGraphicsAllocatorAidl_TargetTest.cpp
@@ -217,6 +217,8 @@
}
return ret;
}
+
+ int32_t allocatorVersion() const { return mIAllocatorVersion; }
};
BufferHandle::~BufferHandle() {
@@ -309,6 +311,62 @@
EXPECT_GE(buffer->stride(), 64);
}
+TEST_P(GraphicsAllocatorAidlTests, RejectsUnknownUsages) {
+ if (allocatorVersion() < 2) {
+ GTEST_SKIP() << "Must be version 2+";
+ return;
+ }
+
+ constexpr auto FirstInvalidV2Usage = static_cast<BufferUsage>(1LL << 33);
+
+ BufferUsage invalidUsage;
+ if (allocatorVersion() == 2) {
+ invalidUsage = FirstInvalidV2Usage;
+ } else {
+ GTEST_FAIL() << "Unknown version " << allocatorVersion();
+ }
+
+ BufferDescriptorInfo info{
+ .name = {"CPU_8888"},
+ .width = 64,
+ .height = 64,
+ .layerCount = 1,
+ .format = PixelFormat::RGBA_8888,
+ .usage = BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN,
+ .reservedSize = 0,
+ };
+
+ // First make sure we can allocate a known usage buffer as expected
+ EXPECT_TRUE(isSupported(info));
+ EXPECT_TRUE(allocate(info));
+
+ // Now add the unknown bit and verify it's rejected
+ info.usage |= invalidUsage;
+ EXPECT_FALSE(isSupported(info)) << "isSupported() returned true for unknown-to-HAL usage";
+ EXPECT_FALSE(allocate(info)) << "allocate succeeded for unknown-to-HAL usage";
+}
+
+TEST_P(GraphicsAllocatorAidlTests, RejectsUnknownOptions) {
+ if (allocatorVersion() < 2) {
+ GTEST_SKIP() << "Must be version 2+";
+ return;
+ }
+
+ BufferDescriptorInfo info{
+ .name = {"CPU_8888"},
+ .width = 64,
+ .height = 64,
+ .layerCount = 1,
+ .format = PixelFormat::RGBA_8888,
+ .usage = BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN,
+ .reservedSize = 0,
+ };
+ info.additionalOptions.push_back({"android.hardware.graphics.common.NotARealOption", 1});
+
+ EXPECT_FALSE(isSupported(info)) << "isSupported() returned true for unknown-to-HAL option";
+ EXPECT_FALSE(allocate(info)) << "allocate succeeded for unknown-to-HAL option";
+}
+
TEST_P(GraphicsFrontBufferTests, FrontBufferGpuToCpu) {
BufferDescriptorInfo info{
.name = {"CPU_8888"},
diff --git a/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/StandardMetadataType.aidl b/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/StandardMetadataType.aidl
index 06b31a2..6e2e106 100644
--- a/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/StandardMetadataType.aidl
+++ b/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/StandardMetadataType.aidl
@@ -58,4 +58,5 @@
CTA861_3 = 20,
SMPTE2094_40 = 21,
SMPTE2094_10 = 22,
+ STRIDE = 23,
}
diff --git a/graphics/common/aidl/android/hardware/graphics/common/StandardMetadataType.aidl b/graphics/common/aidl/android/hardware/graphics/common/StandardMetadataType.aidl
index 4bca795..8cfdae6 100644
--- a/graphics/common/aidl/android/hardware/graphics/common/StandardMetadataType.aidl
+++ b/graphics/common/aidl/android/hardware/graphics/common/StandardMetadataType.aidl
@@ -368,4 +368,17 @@
* If this is unset when encoded into a byte stream, the byte stream is empty.
*/
SMPTE2094_10 = 22,
+
+ /**
+ * Can be used to get the stride in pixels of the buffer allocation. This is the number of
+ * pixels between two consecutive rows of an allocated buffer, when the concept of consecutive
+ * rows is defined. Otherwise, it has no meaning.
+ *
+ * Must match the value returned in android.hardware.graphics.allocator.AllocationResult#stride
+ *
+ * This is required metadata in mapper5 and should be read-only.
+ *
+ * The metadata type is a uint32_t.
+ */
+ STRIDE = 23,
}
diff --git a/graphics/composer/aidl/vts/VtsComposerClient.cpp b/graphics/composer/aidl/vts/VtsComposerClient.cpp
index 5bc7296..dd4161e 100644
--- a/graphics/composer/aidl/vts/VtsComposerClient.cpp
+++ b/graphics/composer/aidl/vts/VtsComposerClient.cpp
@@ -393,14 +393,31 @@
return {std::move(configs.first), vtsDisplays};
}
for (int config : configs.second) {
- auto status = updateDisplayProperties(&vtsDisplay, config);
+ auto status = addDisplayConfig(&vtsDisplay, config);
if (!status.isOk()) {
- ALOGE("Unable to get the displays for test, failed to update the properties "
+ ALOGE("Unable to get the displays for test, failed to add config "
"for display %" PRId64,
display);
return {std::move(status), vtsDisplays};
}
}
+
+ auto config = getActiveConfig(display);
+ if (!config.first.isOk()) {
+ ALOGE("Unable to get the displays for test, failed to get active config "
+ "for display %" PRId64, display);
+ return {std::move(config.first), vtsDisplays};
+ }
+
+ auto status = updateDisplayProperties(&vtsDisplay, config.second);
+ if (!status.isOk()) {
+ ALOGE("Unable to get the displays for test, "
+ "failed to update the properties "
+ "for display %" PRId64,
+ display);
+ return {std::move(status), vtsDisplays};
+ }
+
vtsDisplays.emplace_back(vtsDisplay);
addDisplayToDisplayResources(display, /*isVirtual*/ false);
}
@@ -409,7 +426,7 @@
}
}
-ScopedAStatus VtsComposerClient::updateDisplayProperties(VtsDisplay* vtsDisplay, int32_t config) {
+ScopedAStatus VtsComposerClient::addDisplayConfig(VtsDisplay* vtsDisplay, int32_t config) {
const auto width =
getDisplayAttribute(vtsDisplay->getDisplayId(), config, DisplayAttribute::WIDTH);
const auto height =
@@ -420,7 +437,6 @@
getDisplayAttribute(vtsDisplay->getDisplayId(), config, DisplayAttribute::CONFIG_GROUP);
if (width.first.isOk() && height.first.isOk() && vsyncPeriod.first.isOk() &&
configGroup.first.isOk()) {
- vtsDisplay->setDimensions(width.second, height.second);
vtsDisplay->addDisplayConfig(config, {vsyncPeriod.second, configGroup.second});
return ScopedAStatus::ok();
}
@@ -431,6 +447,21 @@
return ScopedAStatus::fromServiceSpecificError(IComposerClient::EX_BAD_CONFIG);
}
+ScopedAStatus VtsComposerClient::updateDisplayProperties(VtsDisplay* vtsDisplay, int32_t config) {
+ const auto width =
+ getDisplayAttribute(vtsDisplay->getDisplayId(), config, DisplayAttribute::WIDTH);
+ const auto height =
+ getDisplayAttribute(vtsDisplay->getDisplayId(), config, DisplayAttribute::HEIGHT);
+ if (width.first.isOk() && height.first.isOk()) {
+ vtsDisplay->setDimensions(width.second, height.second);
+ return ScopedAStatus::ok();
+ }
+
+ LOG(ERROR) << "Failed to update display property for width: " << width.first.isOk()
+ << ", height: " << height.first.isOk();
+ return ScopedAStatus::fromServiceSpecificError(IComposerClient::EX_BAD_CONFIG);
+}
+
ScopedAStatus VtsComposerClient::addDisplayToDisplayResources(int64_t display, bool isVirtual) {
if (mDisplayResources.insert({display, DisplayResource(isVirtual)}).second) {
return ScopedAStatus::ok();
diff --git a/graphics/composer/aidl/vts/VtsComposerClient.h b/graphics/composer/aidl/vts/VtsComposerClient.h
index 3625c8c..74c5da5 100644
--- a/graphics/composer/aidl/vts/VtsComposerClient.h
+++ b/graphics/composer/aidl/vts/VtsComposerClient.h
@@ -173,6 +173,7 @@
std::pair<ScopedAStatus, std::vector<VtsDisplay>> getDisplays();
private:
+ ScopedAStatus addDisplayConfig(VtsDisplay* vtsDisplay, int32_t config);
ScopedAStatus updateDisplayProperties(VtsDisplay* vtsDisplay, int32_t config);
ScopedAStatus addDisplayToDisplayResources(int64_t display, bool isVirtual);
diff --git a/graphics/mapper/stable-c/implutils/include/android/hardware/graphics/mapper/utils/IMapperMetadataTypes.h b/graphics/mapper/stable-c/implutils/include/android/hardware/graphics/mapper/utils/IMapperMetadataTypes.h
index 25af6d1..3dba86d 100644
--- a/graphics/mapper/stable-c/implutils/include/android/hardware/graphics/mapper/utils/IMapperMetadataTypes.h
+++ b/graphics/mapper/stable-c/implutils/include/android/hardware/graphics/mapper/utils/IMapperMetadataTypes.h
@@ -563,6 +563,7 @@
DEFINE_TYPE(CTA861_3, std::optional<Cta861_3>);
DEFINE_TYPE(SMPTE2094_10, std::optional<std::vector<uint8_t>>);
DEFINE_TYPE(SMPTE2094_40, std::optional<std::vector<uint8_t>>);
+DEFINE_TYPE(STRIDE, uint32_t);
#undef DEFINE_TYPE
diff --git a/graphics/mapper/stable-c/vts/VtsHalGraphicsMapperStableC_TargetTest.cpp b/graphics/mapper/stable-c/vts/VtsHalGraphicsMapperStableC_TargetTest.cpp
index 85246ee..e29d16e 100644
--- a/graphics/mapper/stable-c/vts/VtsHalGraphicsMapperStableC_TargetTest.cpp
+++ b/graphics/mapper/stable-c/vts/VtsHalGraphicsMapperStableC_TargetTest.cpp
@@ -1557,6 +1557,16 @@
}
}
+TEST_P(GraphicsMapperStableCTests, GetStride) {
+ auto buffer = allocateGeneric();
+ ASSERT_TRUE(buffer);
+ auto bufferHandle = buffer->import();
+ ASSERT_TRUE(bufferHandle);
+ auto value = getStandardMetadata<StandardMetadataType::STRIDE>(*bufferHandle);
+ ASSERT_TRUE(value.has_value());
+ EXPECT_EQ(buffer->stride(), *value);
+}
+
TEST_P(GraphicsMapperStableCTests, SupportsRequiredGettersSetters) {
auto buffer = allocateGeneric();
ASSERT_TRUE(buffer);
@@ -1587,6 +1597,7 @@
StandardMetadataType::BLEND_MODE,
StandardMetadataType::SMPTE2086,
StandardMetadataType::CTA861_3,
+ StandardMetadataType::STRIDE,
};
std::vector<StandardMetadataType> requiredSetters = {
diff --git a/radio/aidl/Android.bp b/radio/aidl/Android.bp
index 80ad14a..08bcc28 100644
--- a/radio/aidl/Android.bp
+++ b/radio/aidl/Android.bp
@@ -153,6 +153,28 @@
}
aidl_interface {
+ name: "android.hardware.radio.sap",
+ vendor_available: true,
+ host_supported: true,
+ srcs: ["android/hardware/radio/sap/*.aidl"],
+ stability: "vintf",
+ backend: {
+ cpp: {
+ enabled: true,
+ },
+ java: {
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.btservices",
+ ],
+ sdk_version: "module_current",
+ min_sdk_version: "Tiramisu",
+ },
+ },
+
+}
+
+aidl_interface {
name: "android.hardware.radio.sim",
vendor_available: true,
host_supported: true,
diff --git a/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/ISap.aidl b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/ISap.aidl
new file mode 100644
index 0000000..37391e9
--- /dev/null
+++ b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/ISap.aidl
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.radio.sap;
+@VintfStability
+interface ISap {
+ oneway void apduReq(in int serial, in android.hardware.radio.sap.SapApduType type, in byte[] command);
+ oneway void connectReq(in int serial, in int maxMsgSizeBytes);
+ oneway void disconnectReq(in int serial);
+ oneway void powerReq(in int serial, in boolean powerOn);
+ oneway void resetSimReq(in int serial);
+ oneway void setCallback(in android.hardware.radio.sap.ISapCallback sapCallback);
+ oneway void setTransferProtocolReq(in int serial, in android.hardware.radio.sap.SapTransferProtocol transferProtocol);
+ oneway void transferAtrReq(in int serial);
+ oneway void transferCardReaderStatusReq(in int serial);
+}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/ISapCallback.aidl b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/ISapCallback.aidl
new file mode 100644
index 0000000..d507709
--- /dev/null
+++ b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/ISapCallback.aidl
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.radio.sap;
+@VintfStability
+interface ISapCallback {
+ oneway void apduResponse(in int serial, in android.hardware.radio.sap.SapResultCode resultCode, in byte[] apduRsp);
+ oneway void connectResponse(in int serial, in android.hardware.radio.sap.SapConnectRsp sapConnectRsp, in int maxMsgSizeBytes);
+ oneway void disconnectIndication(in int serial, in android.hardware.radio.sap.SapDisconnectType disconnectType);
+ oneway void disconnectResponse(in int serial);
+ oneway void errorResponse(in int serial);
+ oneway void powerResponse(in int serial, in android.hardware.radio.sap.SapResultCode resultCode);
+ oneway void resetSimResponse(in int serial, in android.hardware.radio.sap.SapResultCode resultCode);
+ oneway void statusIndication(in int serial, in android.hardware.radio.sap.SapStatus status);
+ oneway void transferAtrResponse(in int serial, in android.hardware.radio.sap.SapResultCode resultCode, in byte[] atr);
+ oneway void transferCardReaderStatusResponse(in int serial, in android.hardware.radio.sap.SapResultCode resultCode, in int cardReaderStatus);
+ oneway void transferProtocolResponse(in int serial, in android.hardware.radio.sap.SapResultCode resultCode);
+}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapApduType.aidl b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapApduType.aidl
new file mode 100644
index 0000000..e0e2a03
--- /dev/null
+++ b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapApduType.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.radio.sap;
+@Backing(type="int") @VintfStability
+enum SapApduType {
+ APDU = 0,
+ APDU7816 = 1,
+}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapConnectRsp.aidl b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapConnectRsp.aidl
new file mode 100644
index 0000000..aceac37
--- /dev/null
+++ b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapConnectRsp.aidl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.radio.sap;
+@Backing(type="int") @VintfStability
+enum SapConnectRsp {
+ SUCCESS = 0,
+ CONNECT_FAILURE = 1,
+ MSG_SIZE_TOO_LARGE = 2,
+ MSG_SIZE_TOO_SMALL = 3,
+ CONNECT_OK_CALL_ONGOING = 4,
+}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapDisconnectType.aidl b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapDisconnectType.aidl
new file mode 100644
index 0000000..0447f9b
--- /dev/null
+++ b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapDisconnectType.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.radio.sap;
+@Backing(type="int") @VintfStability
+enum SapDisconnectType {
+ GRACEFUL = 0,
+ IMMEDIATE = 1,
+}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapResultCode.aidl b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapResultCode.aidl
new file mode 100644
index 0000000..1db226b
--- /dev/null
+++ b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapResultCode.aidl
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.radio.sap;
+@Backing(type="int") @VintfStability
+enum SapResultCode {
+ SUCCESS = 0,
+ GENERIC_FAILURE = 1,
+ CARD_NOT_ACCESSSIBLE = 2,
+ CARD_ALREADY_POWERED_OFF = 3,
+ CARD_REMOVED = 4,
+ CARD_ALREADY_POWERED_ON = 5,
+ DATA_NOT_AVAILABLE = 6,
+ NOT_SUPPORTED = 7,
+}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapStatus.aidl b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapStatus.aidl
new file mode 100644
index 0000000..32f71c2
--- /dev/null
+++ b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapStatus.aidl
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.radio.sap;
+@Backing(type="int") @VintfStability
+enum SapStatus {
+ UNKNOWN_ERROR = 0,
+ CARD_RESET = 1,
+ CARD_NOT_ACCESSIBLE = 2,
+ CARD_REMOVED = 3,
+ CARD_INSERTED = 4,
+ RECOVERED = 5,
+}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapTransferProtocol.aidl b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapTransferProtocol.aidl
new file mode 100644
index 0000000..e3ffdb0
--- /dev/null
+++ b/radio/aidl/aidl_api/android.hardware.radio.sap/current/android/hardware/radio/sap/SapTransferProtocol.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.radio.sap;
+@Backing(type="int") @VintfStability
+enum SapTransferProtocol {
+ T0 = 0,
+ T1 = 1,
+}
diff --git a/radio/aidl/android/hardware/radio/sap/ISap.aidl b/radio/aidl/android/hardware/radio/sap/ISap.aidl
new file mode 100644
index 0000000..552e602
--- /dev/null
+++ b/radio/aidl/android/hardware/radio/sap/ISap.aidl
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+package android.hardware.radio.sap;
+
+import android.hardware.radio.sap.ISapCallback;
+import android.hardware.radio.sap.SapApduType;
+import android.hardware.radio.sap.SapTransferProtocol;
+
+@VintfStability
+oneway interface ISap {
+ /**
+ * TRANSFER_APDU_REQ from SAP 1.1 spec 5.1.6
+ *
+ * @param serial Id to match req-resp. Resp must include same serial.
+ * @param type APDU command type
+ * @param command CommandAPDU/CommandAPDU7816 parameter depending on type
+ */
+ void apduReq(in int serial, in SapApduType type, in byte[] command);
+
+ /**
+ * CONNECT_REQ from SAP 1.1 spec 5.1.1
+ *
+ * @param serial Id to match req-resp. Resp must include same serial.
+ * @param maxMsgSizeBytes MaxMsgSize to be used for SIM Access Profile connection
+ */
+ void connectReq(in int serial, in int maxMsgSizeBytes);
+
+ /**
+ * DISCONNECT_REQ from SAP 1.1 spec 5.1.3
+ *
+ * @param serial Id to match req-resp. Resp must include same serial.
+ */
+ void disconnectReq(in int serial);
+
+ /**
+ * POWER_SIM_OFF_REQ and POWER_SIM_ON_REQ from SAP 1.1 spec 5.1.10 + 5.1.12
+ *
+ * @param serial Id to match req-resp. Resp must include same serial.
+ * @param powerOn true for on, false for off
+ */
+ void powerReq(in int serial, in boolean powerOn);
+
+ /**
+ * RESET_SIM_REQ from SAP 1.1 spec 5.1.14
+ *
+ * @param serial Id to match req-resp. Resp must include same serial.
+ */
+ void resetSimReq(in int serial);
+
+ /**
+ * Set callback that has response and unsolicited indication functions
+ *
+ * @param sapCallback Object containing response and unosolicited indication callbacks
+ */
+ void setCallback(in ISapCallback sapCallback);
+
+ /**
+ * SET_TRANSPORT_PROTOCOL_REQ from SAP 1.1 spec 5.1.20
+ *
+ * @param serial Id to match req-resp. Resp must include same serial.
+ * @param transferProtocol Transport Protocol
+ */
+ void setTransferProtocolReq(in int serial, in SapTransferProtocol transferProtocol);
+
+ /**
+ * TRANSFER_ATR_REQ from SAP 1.1 spec 5.1.8
+ *
+ * @param serial Id to match req-resp. Resp must include same serial.
+ */
+ void transferAtrReq(in int serial);
+
+ /**
+ * TRANSFER_CARD_READER_STATUS_REQ from SAP 1.1 spec 5.1.17
+ *
+ * @param serial Id to match req-resp. Resp must include same serial.
+ */
+ void transferCardReaderStatusReq(in int serial);
+}
diff --git a/radio/aidl/android/hardware/radio/sap/ISapCallback.aidl b/radio/aidl/android/hardware/radio/sap/ISapCallback.aidl
new file mode 100644
index 0000000..34111eb
--- /dev/null
+++ b/radio/aidl/android/hardware/radio/sap/ISapCallback.aidl
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+package android.hardware.radio.sap;
+
+import android.hardware.radio.sap.SapConnectRsp;
+import android.hardware.radio.sap.SapDisconnectType;
+import android.hardware.radio.sap.SapResultCode;
+import android.hardware.radio.sap.SapStatus;
+
+@VintfStability
+oneway interface ISapCallback {
+ /**
+ * TRANSFER_APDU_RESP from SAP 1.1 spec 5.1.7
+ *
+ * @param serial Id to match req-resp. Value must match the one in req.
+ * @param resultCode ResultCode to indicate if command was processed correctly
+ * Possible values:
+ * SapResultCode:SUCCESS,
+ * SapResultCode:GENERIC_FAILURE,
+ * SapResultCode:CARD_NOT_ACCESSSIBLE,
+ * SapResultCode:CARD_ALREADY_POWERED_OFF,
+ * SapResultCode:CARD_REMOVED
+ * @param apduRsp APDU Response. Valid only if command was processed correctly and no error
+ * occurred.
+ */
+ void apduResponse(in int serial, in SapResultCode resultCode, in byte[] apduRsp);
+
+ /**
+ * CONNECT_RESP from SAP 1.1 spec 5.1.2
+ *
+ * @param serial Id to match req-resp. Value must match the one in req.
+ * @param sapConnectRsp Connection Status
+ * @param maxMsgSizeBytes MaxMsgSize supported by server if request cannot be fulfilled.
+ * Valid only if connectResponse is SapConnectResponse:MSG_SIZE_TOO_LARGE.
+ */
+ void connectResponse(in int serial, in SapConnectRsp sapConnectRsp, in int maxMsgSizeBytes);
+
+ /**
+ * DISCONNECT_IND from SAP 1.1 spec 5.1.5
+ *
+ * @param serial Id to match req-resp. Value must match the one in req.
+ * @param disconnectType Disconnect Type to indicate if shutdown is graceful or immediate
+ */
+ void disconnectIndication(in int serial, in SapDisconnectType disconnectType);
+
+ /**
+ * DISCONNECT_RESP from SAP 1.1 spec 5.1.4
+ *
+ * @param serial Id to match req-resp. Value must match the one in req.
+ */
+ void disconnectResponse(in int serial);
+
+ /**
+ * ERROR_RESP from SAP 1.1 spec 5.1.19
+ *
+ * @param serial Id to match req-resp. Value must match the one in req.
+ */
+ void errorResponse(in int serial);
+
+ /**
+ * POWER_SIM_OFF_RESP and POWER_SIM_ON_RESP from SAP 1.1 spec 5.1.11 + 5.1.13
+ *
+ * @param serial Id to match req-resp. Value must match the one in req.
+ * @param resultCode ResultCode to indicate if command was processed correctly
+ * Possible values:
+ * SapResultCode:SUCCESS,
+ * SapResultCode:GENERIC_FAILURE,
+ * SapResultCode:CARD_NOT_ACCESSSIBLE, (possible only for power on req)
+ * SapResultCode:CARD_ALREADY_POWERED_OFF, (possible only for power off req)
+ * SapResultCode:CARD_REMOVED,
+ * SapResultCode:CARD_ALREADY_POWERED_ON (possible only for power on req)
+ */
+ void powerResponse(in int serial, in SapResultCode resultCode);
+
+ /**
+ * RESET_SIM_RESP from SAP 1.1 spec 5.1.15
+ *
+ * @param serial Id to match req-resp. Value must match the one in req.
+ * @param resultCode ResultCode to indicate if command was processed correctly
+ * Possible values:
+ * SapResultCode:SUCCESS,
+ * SapResultCode:GENERIC_FAILURE,
+ * SapResultCode:CARD_NOT_ACCESSSIBLE,
+ * SapResultCode:CARD_ALREADY_POWERED_OFF,
+ * SapResultCode:CARD_REMOVED
+ */
+ void resetSimResponse(in int serial, in SapResultCode resultCode);
+
+ /**
+ * STATUS_IND from SAP 1.1 spec 5.1.16
+ *
+ * @param serial Id to match req-resp. Value must match the one in req.
+ * @param status Parameter to indicate reason for the status change.
+ */
+ void statusIndication(in int serial, in SapStatus status);
+
+ /**
+ * TRANSFER_ATR_RESP from SAP 1.1 spec 5.1.9
+ *
+ * @param serial Id to match req-resp. Value must match the one in req.
+ * @param resultCode ResultCode to indicate if command was processed correctly
+ * Possible values:
+ * SapResultCode:SUCCESS,
+ * SapResultCode:GENERIC_FAILURE,
+ * SapResultCode:CARD_ALREADY_POWERED_OFF,
+ * SapResultCode:CARD_REMOVED,
+ * SapResultCode:DATA_NOT_AVAILABLE
+ * @param atr Answer to Reset from the subscription module. Included only if no error occurred,
+ * otherwise empty.
+ */
+ void transferAtrResponse(in int serial, in SapResultCode resultCode, in byte[] atr);
+
+ /**
+ * TRANSFER_CARD_READER_STATUS_REQ from SAP 1.1 spec 5.1.18
+ *
+ * @param serial Id to match req-resp. Value must match the one in req.
+ * @param resultCode ResultCode to indicate if command was processed correctly
+ * Possible values:
+ * SapResultCode:SUCCESS,
+ * SapResultCode:GENERIC_FAILURE
+ * SapResultCode:DATA_NOT_AVAILABLE
+ * @param cardReaderStatus Card Reader Status coded as described in 3GPP TS 11.14 Section 12.33
+ * and TS 31.111 Section 8.33
+ */
+ void transferCardReaderStatusResponse(
+ in int serial, in SapResultCode resultCode, in int cardReaderStatus);
+
+ /**
+ * SET_TRANSPORT_PROTOCOL_RESP from SAP 1.1 spec 5.1.21
+ *
+ * @param serial Id to match req-resp. Value must match the one in req.
+ * @param resultCode ResultCode to indicate if command was processed correctly
+ * Possible values:
+ * SapResultCode:SUCCESS
+ * SapResultCode:NOT_SUPPORTED
+ */
+ void transferProtocolResponse(in int serial, in SapResultCode resultCode);
+}
diff --git a/radio/aidl/android/hardware/radio/sap/SapApduType.aidl b/radio/aidl/android/hardware/radio/sap/SapApduType.aidl
new file mode 100644
index 0000000..ab8ffb9
--- /dev/null
+++ b/radio/aidl/android/hardware/radio/sap/SapApduType.aidl
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+package android.hardware.radio.sap;
+
+@VintfStability
+@Backing(type="int")
+enum SapApduType {
+ APDU,
+ APDU7816,
+}
diff --git a/radio/aidl/android/hardware/radio/sap/SapConnectRsp.aidl b/radio/aidl/android/hardware/radio/sap/SapConnectRsp.aidl
new file mode 100644
index 0000000..0e1d528
--- /dev/null
+++ b/radio/aidl/android/hardware/radio/sap/SapConnectRsp.aidl
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+package android.hardware.radio.sap;
+
+@VintfStability
+@Backing(type="int")
+enum SapConnectRsp {
+ SUCCESS,
+ CONNECT_FAILURE,
+ MSG_SIZE_TOO_LARGE,
+ MSG_SIZE_TOO_SMALL,
+ CONNECT_OK_CALL_ONGOING,
+}
diff --git a/radio/aidl/android/hardware/radio/sap/SapDisconnectType.aidl b/radio/aidl/android/hardware/radio/sap/SapDisconnectType.aidl
new file mode 100644
index 0000000..16d7cc6
--- /dev/null
+++ b/radio/aidl/android/hardware/radio/sap/SapDisconnectType.aidl
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+package android.hardware.radio.sap;
+
+@VintfStability
+@Backing(type="int")
+enum SapDisconnectType {
+ GRACEFUL,
+ IMMEDIATE,
+}
diff --git a/radio/aidl/android/hardware/radio/sap/SapResultCode.aidl b/radio/aidl/android/hardware/radio/sap/SapResultCode.aidl
new file mode 100644
index 0000000..4728ebe
--- /dev/null
+++ b/radio/aidl/android/hardware/radio/sap/SapResultCode.aidl
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+package android.hardware.radio.sap;
+
+@VintfStability
+@Backing(type="int")
+enum SapResultCode {
+ SUCCESS,
+ GENERIC_FAILURE,
+ CARD_NOT_ACCESSSIBLE,
+ CARD_ALREADY_POWERED_OFF,
+ CARD_REMOVED,
+ CARD_ALREADY_POWERED_ON,
+ DATA_NOT_AVAILABLE,
+ NOT_SUPPORTED,
+}
diff --git a/radio/aidl/android/hardware/radio/sap/SapStatus.aidl b/radio/aidl/android/hardware/radio/sap/SapStatus.aidl
new file mode 100644
index 0000000..309352d
--- /dev/null
+++ b/radio/aidl/android/hardware/radio/sap/SapStatus.aidl
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+package android.hardware.radio.sap;
+
+@VintfStability
+@Backing(type="int")
+enum SapStatus {
+ UNKNOWN_ERROR,
+ CARD_RESET,
+ CARD_NOT_ACCESSIBLE,
+ CARD_REMOVED,
+ CARD_INSERTED,
+ RECOVERED,
+}
diff --git a/radio/aidl/android/hardware/radio/sap/SapTransferProtocol.aidl b/radio/aidl/android/hardware/radio/sap/SapTransferProtocol.aidl
new file mode 100644
index 0000000..823c5f2
--- /dev/null
+++ b/radio/aidl/android/hardware/radio/sap/SapTransferProtocol.aidl
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+package android.hardware.radio.sap;
+
+@VintfStability
+@Backing(type="int")
+enum SapTransferProtocol {
+ T0,
+ T1,
+}
diff --git a/radio/aidl/compat/libradiocompat/Android.bp b/radio/aidl/compat/libradiocompat/Android.bp
index 487d91b..aa20fc3 100644
--- a/radio/aidl/compat/libradiocompat/Android.bp
+++ b/radio/aidl/compat/libradiocompat/Android.bp
@@ -40,6 +40,7 @@
"android.hardware.radio.messaging-V1-ndk",
"android.hardware.radio.modem-V1-ndk",
"android.hardware.radio.network-V1-ndk",
+ "android.hardware.radio.sap-V1-ndk",
"android.hardware.radio.sim-V1-ndk",
"android.hardware.radio.voice-V1-ndk",
"android.hardware.radio@1.0",
@@ -82,6 +83,9 @@
"network/RadioResponse-network.cpp",
"network/structs.cpp",
"network/utils.cpp",
+ "sap/Sap.cpp",
+ "sap/SapCallback.cpp",
+ "sap/structs.cpp",
"sim/RadioIndication-sim.cpp",
"sim/RadioResponse-sim.cpp",
"sim/RadioSim.cpp",
diff --git a/radio/aidl/compat/libradiocompat/commonStructs.cpp b/radio/aidl/compat/libradiocompat/commonStructs.cpp
index 6e4c873..d65ed1a 100644
--- a/radio/aidl/compat/libradiocompat/commonStructs.cpp
+++ b/radio/aidl/compat/libradiocompat/commonStructs.cpp
@@ -48,6 +48,10 @@
return v;
}
+uint8_t toHidl(int8_t v) {
+ return v;
+}
+
aidl::RadioIndicationType toAidl(V1_0::RadioIndicationType type) {
return aidl::RadioIndicationType(type);
}
diff --git a/radio/aidl/compat/libradiocompat/commonStructs.h b/radio/aidl/compat/libradiocompat/commonStructs.h
index a4a4869..f43a599 100644
--- a/radio/aidl/compat/libradiocompat/commonStructs.h
+++ b/radio/aidl/compat/libradiocompat/commonStructs.h
@@ -28,6 +28,7 @@
uint8_t toAidl(int8_t v);
int8_t toAidl(uint8_t v);
int32_t toAidl(uint32_t v);
+uint8_t toHidl(int8_t v);
aidl::android::hardware::radio::RadioIndicationType toAidl(V1_0::RadioIndicationType type);
aidl::android::hardware::radio::RadioResponseType toAidl(V1_0::RadioResponseType type);
diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/Sap.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/Sap.h
new file mode 100644
index 0000000..a293d11
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/Sap.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+#pragma once
+
+#include "RadioCompatBase.h"
+#include "SapCallback.h"
+
+#include <aidl/android/hardware/radio/sap/BnSap.h>
+#include <android/hardware/radio/1.0/ISap.h>
+#include <android/hardware/radio/1.0/ISapCallback.h>
+
+namespace android::hardware::radio::compat {
+
+/**
+ * HAL translator from HIDL ISap to AIDL ISap
+ *
+ * This class wraps existing HIDL implementation (either a binder stub or real
+ * class implementing the HAL) and implements AIDL HAL. It's up to the caller to
+ * fetch source implementation and publish resulting HAL instance.
+ */
+class Sap : public aidl::android::hardware::radio::sap::BnSap {
+ const sp<radio::V1_0::ISap> mHal;
+
+ const sp<SapCallback> mSapCallback;
+
+ ::ndk::ScopedAStatus apduReq(int32_t serial,
+ aidl::android::hardware::radio::sap::SapApduType type,
+ const std::vector<uint8_t>& command) override;
+ ::ndk::ScopedAStatus connectReq(int32_t serial, int32_t maxMsgSize) override;
+ ::ndk::ScopedAStatus disconnectReq(int32_t serial) override;
+ ::ndk::ScopedAStatus powerReq(int32_t serial, bool state) override;
+ ::ndk::ScopedAStatus resetSimReq(int32_t serial) override;
+ ::ndk::ScopedAStatus setCallback(
+ const std::shared_ptr<::aidl::android::hardware::radio::sap::ISapCallback>& sapCallback)
+ override;
+ ::ndk::ScopedAStatus setTransferProtocolReq(
+ int32_t serial,
+ aidl::android::hardware::radio::sap::SapTransferProtocol transferProtocol) override;
+ ::ndk::ScopedAStatus transferAtrReq(int32_t serial) override;
+ ::ndk::ScopedAStatus transferCardReaderStatusReq(int32_t serial) override;
+
+ public:
+ /**
+ * Constructs AIDL ISap instance wrapping existing HIDL ISap instance.
+ *
+ * \param hidlHal existing HIDL ISap HAL instance
+ */
+ Sap(sp<V1_0::ISap> hidlHal);
+};
+
+} // namespace android::hardware::radio::compat
diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/SapCallback.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/SapCallback.h
new file mode 100644
index 0000000..7e72106
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/SapCallback.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+#pragma once
+
+#include "GuaranteedCallback.h"
+
+#include <aidl/android/hardware/radio/sap/ISapCallback.h>
+#include <android/hardware/radio/1.0/ISapCallback.h>
+
+namespace android::hardware::radio::compat {
+
+class SapCallback : public V1_0::ISapCallback {
+ GuaranteedCallback<aidl::android::hardware::radio::sap::ISapCallback,
+ aidl::android::hardware::radio::sap::ISapCallbackDefault>
+ mCallback;
+
+ Return<void> apduResponse(int32_t serial, V1_0::SapResultCode resultCode,
+ const ::android::hardware::hidl_vec<uint8_t>& apduRsp) override;
+ Return<void> connectResponse(int32_t serial, V1_0::SapConnectRsp sapConnectRsp,
+ int32_t maxMsgSize) override;
+ Return<void> disconnectIndication(int32_t serial,
+ V1_0::SapDisconnectType disconnectType) override;
+ Return<void> disconnectResponse(int32_t serial) override;
+ Return<void> errorResponse(int32_t serial) override;
+ Return<void> powerResponse(int32_t serial, V1_0::SapResultCode resultCode) override;
+ Return<void> resetSimResponse(int32_t serial, V1_0::SapResultCode resultCode) override;
+ Return<void> statusIndication(int32_t serial, V1_0::SapStatus status) override;
+ Return<void> transferAtrResponse(int32_t serial, V1_0::SapResultCode resultCode,
+ const ::android::hardware::hidl_vec<uint8_t>& atr) override;
+ Return<void> transferCardReaderStatusResponse(int32_t serial, V1_0::SapResultCode resultCode,
+ int32_t cardReaderStatus) override;
+ Return<void> transferProtocolResponse(int32_t serial, V1_0::SapResultCode resultCode) override;
+
+ public:
+ void setResponseFunction(
+ const std::shared_ptr<aidl::android::hardware::radio::sap::ISapCallback>& callback);
+
+ std::shared_ptr<aidl::android::hardware::radio::sap::ISapCallback> respond();
+};
+
+} // namespace android::hardware::radio::compat
diff --git a/radio/aidl/compat/libradiocompat/sap/Sap.cpp b/radio/aidl/compat/libradiocompat/sap/Sap.cpp
new file mode 100644
index 0000000..1a77169
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/sap/Sap.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#include <libradiocompat/Sap.h>
+
+#include "commonStructs.h"
+#include "debug.h"
+#include "structs.h"
+
+#include "collections.h"
+
+#define RADIO_MODULE "Sap"
+
+namespace android::hardware::radio::compat {
+
+using ::ndk::ScopedAStatus;
+namespace aidl = ::aidl::android::hardware::radio::sap;
+constexpr auto ok = &ScopedAStatus::ok;
+
+Sap::Sap(sp<V1_0::ISap> hidlHal) : mHal(hidlHal), mSapCallback(sp<SapCallback>::make()) {}
+
+ScopedAStatus Sap::apduReq(int32_t serial, aidl::SapApduType type,
+ const std::vector<uint8_t>& command) {
+ LOG_CALL << serial;
+ mHal->apduReq(serial, toHidl(type), toHidl(command));
+ return ok();
+}
+
+ScopedAStatus Sap::connectReq(int32_t serial, int32_t maxMsgSize) {
+ LOG_CALL << serial;
+ mHal->connectReq(serial, maxMsgSize);
+ return ok();
+}
+
+ScopedAStatus Sap::disconnectReq(int32_t serial) {
+ LOG_CALL << serial;
+ mHal->disconnectReq(serial);
+ return ok();
+}
+
+ScopedAStatus Sap::powerReq(int32_t serial, bool state) {
+ LOG_CALL << serial;
+ mHal->powerReq(serial, state);
+ return ok();
+}
+
+ScopedAStatus Sap::resetSimReq(int32_t serial) {
+ LOG_CALL << serial;
+ mHal->resetSimReq(serial);
+ return ok();
+}
+
+ScopedAStatus Sap::setCallback(
+ const std::shared_ptr<::aidl::android::hardware::radio::sap::ISapCallback>& sapCallback) {
+ LOG_CALL << sapCallback;
+
+ CHECK(sapCallback);
+
+ mSapCallback->setResponseFunction(sapCallback);
+ mHal->setCallback(mSapCallback).assertOk();
+ return ok();
+}
+ScopedAStatus Sap::setTransferProtocolReq(int32_t serial,
+ aidl::SapTransferProtocol transferProtocol) {
+ LOG_CALL << serial;
+ mHal->setTransferProtocolReq(serial, toHidl(transferProtocol));
+ return ok();
+}
+
+ScopedAStatus Sap::transferAtrReq(int32_t serial) {
+ LOG_CALL << serial;
+ mHal->transferAtrReq(serial);
+ return ok();
+}
+ScopedAStatus Sap::transferCardReaderStatusReq(int32_t serial) {
+ LOG_CALL << serial;
+ mHal->transferCardReaderStatusReq(serial);
+ return ok();
+}
+
+} // namespace android::hardware::radio::compat
diff --git a/radio/aidl/compat/libradiocompat/sap/SapCallback.cpp b/radio/aidl/compat/libradiocompat/sap/SapCallback.cpp
new file mode 100644
index 0000000..a40dff8
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/sap/SapCallback.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#include <libradiocompat/SapCallback.h>
+
+#include "commonStructs.h"
+#include "debug.h"
+#include "structs.h"
+
+#include "collections.h"
+
+#define RADIO_MODULE "SapCallback"
+
+namespace android::hardware::radio::compat {
+
+namespace aidl = ::aidl::android::hardware::radio::sap;
+
+void SapCallback::setResponseFunction(const std::shared_ptr<aidl::ISapCallback>& callback) {
+ mCallback = callback;
+}
+
+std::shared_ptr<aidl::ISapCallback> SapCallback::respond() {
+ return mCallback.get();
+}
+
+Return<void> SapCallback::apduResponse(int32_t serial, V1_0::SapResultCode resultCode,
+ const hidl_vec<uint8_t>& apduRsp) {
+ LOG_CALL << serial;
+ respond()->apduResponse(serial, toAidl(resultCode), apduRsp);
+ return {};
+}
+
+Return<void> SapCallback::connectResponse(int32_t serial, V1_0::SapConnectRsp sapConnectRsp,
+ int32_t maxMsgSize) {
+ LOG_CALL << serial;
+ respond()->connectResponse(serial, toAidl(sapConnectRsp), maxMsgSize);
+ return {};
+}
+
+Return<void> SapCallback::disconnectIndication(int32_t serial,
+ V1_0::SapDisconnectType disconnectType) {
+ LOG_CALL << serial;
+ respond()->disconnectIndication(serial, toAidl(disconnectType));
+ return {};
+}
+
+Return<void> SapCallback::disconnectResponse(int32_t serial) {
+ LOG_CALL << serial;
+ respond()->disconnectResponse(serial);
+ return {};
+}
+
+Return<void> SapCallback::errorResponse(int32_t serial) {
+ LOG_CALL << serial;
+ respond()->errorResponse(serial);
+ return {};
+}
+
+Return<void> SapCallback::powerResponse(int32_t serial, V1_0::SapResultCode resultCode) {
+ LOG_CALL << serial;
+ respond()->powerResponse(serial, toAidl(resultCode));
+ return {};
+}
+
+Return<void> SapCallback::resetSimResponse(int32_t serial, V1_0::SapResultCode resultCode) {
+ LOG_CALL << serial;
+ respond()->resetSimResponse(serial, toAidl(resultCode));
+ return {};
+}
+
+Return<void> SapCallback::statusIndication(int32_t serial, V1_0::SapStatus status) {
+ LOG_CALL << serial;
+ respond()->statusIndication(serial, toAidl(status));
+ return {};
+}
+
+Return<void> SapCallback::transferAtrResponse(int32_t serial, V1_0::SapResultCode resultCode,
+ const hidl_vec<uint8_t>& atr) {
+ LOG_CALL << serial;
+ respond()->transferAtrResponse(serial, toAidl(resultCode), atr);
+ return {};
+}
+
+Return<void> SapCallback::transferCardReaderStatusResponse(int32_t serial,
+ V1_0::SapResultCode resultCode,
+ int32_t cardReaderStatus) {
+ LOG_CALL << serial;
+ respond()->transferCardReaderStatusResponse(serial, toAidl(resultCode), cardReaderStatus);
+ return {};
+}
+
+Return<void> SapCallback::transferProtocolResponse(int32_t serial, V1_0::SapResultCode resultCode) {
+ LOG_CALL << serial;
+ respond()->transferProtocolResponse(serial, toAidl(resultCode));
+ return {};
+}
+
+} // namespace android::hardware::radio::compat
diff --git a/radio/aidl/compat/libradiocompat/sap/structs.cpp b/radio/aidl/compat/libradiocompat/sap/structs.cpp
new file mode 100644
index 0000000..522056b
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/sap/structs.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#include "structs.h"
+
+namespace android::hardware::radio::compat {
+
+namespace aidl = ::aidl::android::hardware::radio::sap;
+
+V1_0::SapApduType toHidl(const aidl::SapApduType sapApduType) {
+ return V1_0::SapApduType(sapApduType);
+}
+
+V1_0::SapTransferProtocol toHidl(const aidl::SapTransferProtocol sapTransferProtocol) {
+ return V1_0::SapTransferProtocol(sapTransferProtocol);
+}
+
+aidl::SapResultCode toAidl(const V1_0::SapResultCode sapResultCode) {
+ return aidl::SapResultCode(sapResultCode);
+}
+
+aidl::SapConnectRsp toAidl(const V1_0::SapConnectRsp sapConnectRsp) {
+ return aidl::SapConnectRsp(sapConnectRsp);
+}
+
+aidl::SapDisconnectType toAidl(const V1_0::SapDisconnectType sapDisconnectType) {
+ return aidl::SapDisconnectType(sapDisconnectType);
+}
+
+aidl::SapStatus toAidl(const V1_0::SapStatus sapStatus) {
+ return aidl::SapStatus(sapStatus);
+}
+
+} // namespace android::hardware::radio::compat
diff --git a/radio/aidl/compat/libradiocompat/sap/structs.h b/radio/aidl/compat/libradiocompat/sap/structs.h
new file mode 100644
index 0000000..d88120d
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/sap/structs.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2022 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, eithe r express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <aidl/android/hardware/radio/sap/ISap.h>
+#include <android/hardware/radio/1.0/types.h>
+
+namespace android::hardware::radio::compat {
+
+V1_0::SapApduType toHidl(aidl::android::hardware::radio::sap::SapApduType sapAdpuType);
+V1_0::SapTransferProtocol toHidl(
+ aidl::android::hardware::radio::sap::SapTransferProtocol sapTransferProtocol);
+
+aidl::android::hardware::radio::sap::SapResultCode toAidl(V1_0::SapResultCode sapResultCode);
+aidl::android::hardware::radio::sap::SapConnectRsp toAidl(V1_0::SapConnectRsp sapConnectRsp);
+aidl::android::hardware::radio::sap::SapDisconnectType toAidl(
+ V1_0::SapDisconnectType sapDisconnectType);
+aidl::android::hardware::radio::sap::SapStatus toAidl(V1_0::SapStatus sapStatus);
+
+} // namespace android::hardware::radio::compat
diff --git a/radio/aidl/compat/service/Android.bp b/radio/aidl/compat/service/Android.bp
index 52eb71f..933e3e1 100644
--- a/radio/aidl/compat/service/Android.bp
+++ b/radio/aidl/compat/service/Android.bp
@@ -43,6 +43,7 @@
"android.hardware.radio.messaging-V1-ndk",
"android.hardware.radio.modem-V1-ndk",
"android.hardware.radio.network-V1-ndk",
+ "android.hardware.radio.sap-V1-ndk",
"android.hardware.radio.sim-V1-ndk",
"android.hardware.radio.voice-V1-ndk",
"android.hardware.radio@1.0",
diff --git a/radio/aidl/vts/Android.bp b/radio/aidl/vts/Android.bp
index 021ee89..97964b4 100644
--- a/radio/aidl/vts/Android.bp
+++ b/radio/aidl/vts/Android.bp
@@ -50,6 +50,8 @@
"radio_network_indication.cpp",
"radio_network_response.cpp",
"radio_network_test.cpp",
+ "radio_sap_callback.cpp",
+ "radio_sap_test.cpp",
"radio_sim_indication.cpp",
"radio_sim_response.cpp",
"radio_sim_test.cpp",
@@ -69,6 +71,7 @@
"android.hardware.radio.messaging-V1-ndk",
"android.hardware.radio.modem-V1-ndk",
"android.hardware.radio.network-V1-ndk",
+ "android.hardware.radio.sap-V1-ndk",
"android.hardware.radio.sim-V1-ndk",
"android.hardware.radio.voice-V1-ndk",
],
diff --git a/radio/aidl/vts/VtsHalRadioTargetTest.cpp b/radio/aidl/vts/VtsHalRadioTargetTest.cpp
index 1ebc6af..03d3c5a 100644
--- a/radio/aidl/vts/VtsHalRadioTargetTest.cpp
+++ b/radio/aidl/vts/VtsHalRadioTargetTest.cpp
@@ -21,6 +21,7 @@
#include "radio_messaging_utils.h"
#include "radio_modem_utils.h"
#include "radio_network_utils.h"
+#include "radio_sap_utils.h"
#include "radio_sim_utils.h"
#include "radio_voice_utils.h"
@@ -54,6 +55,11 @@
testing::ValuesIn(android::getAidlHalInstanceNames(IRadioNetwork::descriptor)),
android::PrintInstanceNameToString);
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(RadioSapTest);
+INSTANTIATE_TEST_SUITE_P(PerInstance, SapTest,
+ testing::ValuesIn(android::getAidlHalInstanceNames(ISap::descriptor)),
+ android::PrintInstanceNameToString);
+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(RadioSimTest);
INSTANTIATE_TEST_SUITE_P(PerInstance, RadioSimTest,
testing::ValuesIn(android::getAidlHalInstanceNames(IRadioSim::descriptor)),
diff --git a/radio/aidl/vts/radio_sap_callback.cpp b/radio/aidl/vts/radio_sap_callback.cpp
new file mode 100644
index 0000000..3b21ede
--- /dev/null
+++ b/radio/aidl/vts/radio_sap_callback.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+#include "radio_sap_utils.h"
+
+#include <android-base/logging.h>
+
+SapCallback::SapCallback(SapTest& parent) : parent_sap(parent) {}
+
+::ndk::ScopedAStatus SapCallback::apduResponse(int32_t serialNumber, SapResultCode resultCode,
+ const std::vector<uint8_t>& /*apduRsp*/) {
+ sapResponseSerial = serialNumber;
+ sapResultCode = resultCode;
+ parent_sap.notify(serialNumber);
+ return ndk::ScopedAStatus::ok();
+}
+::ndk::ScopedAStatus SapCallback::connectResponse(int32_t serialNumber,
+ SapConnectRsp /*sapConnectRsp*/,
+ int32_t /*maxMsgSize*/) {
+ sapResponseSerial = serialNumber;
+ parent_sap.notify(serialNumber);
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus SapCallback::disconnectIndication(int32_t /*serialNumber*/,
+ SapDisconnectType /*sapDisconnectType*/) {
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus SapCallback::disconnectResponse(int32_t serialNumber) {
+ sapResponseSerial = serialNumber;
+ parent_sap.notify(serialNumber);
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus SapCallback::errorResponse(int32_t /*serialNumber*/) {
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus SapCallback::powerResponse(int32_t serialNumber, SapResultCode resultCode) {
+ sapResponseSerial = serialNumber;
+ sapResultCode = resultCode;
+ parent_sap.notify(serialNumber);
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus SapCallback::resetSimResponse(int32_t serialNumber, SapResultCode resultCode) {
+ sapResponseSerial = serialNumber;
+ sapResultCode = resultCode;
+ parent_sap.notify(serialNumber);
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus SapCallback::statusIndication(int32_t /*serialNumber*/,
+ SapStatus /*sapStatus*/) {
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus SapCallback::transferAtrResponse(int32_t serialNumber,
+ SapResultCode resultCode,
+ const std::vector<uint8_t>& /*atr*/) {
+ sapResponseSerial = serialNumber;
+ sapResultCode = resultCode;
+ parent_sap.notify(serialNumber);
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus SapCallback::transferCardReaderStatusResponse(int32_t serialNumber,
+ SapResultCode resultCode,
+ int32_t /*cardReaderStatus*/) {
+ sapResponseSerial = serialNumber;
+ sapResultCode = resultCode;
+ parent_sap.notify(serialNumber);
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus SapCallback::transferProtocolResponse(int32_t serialNumber,
+ SapResultCode resultCode) {
+ sapResponseSerial = serialNumber;
+ sapResultCode = resultCode;
+ parent_sap.notify(serialNumber);
+ return ndk::ScopedAStatus::ok();
+}
diff --git a/radio/aidl/vts/radio_sap_test.cpp b/radio/aidl/vts/radio_sap_test.cpp
new file mode 100644
index 0000000..c94379c
--- /dev/null
+++ b/radio/aidl/vts/radio_sap_test.cpp
@@ -0,0 +1,233 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+
+#include "radio_sap_utils.h"
+
+#define ASSERT_OK(ret) ASSERT_TRUE((ret).isOk())
+#define TIMEOUT_PERIOD 40
+
+void SapTest::SetUp() {
+ std::string serviceName = GetParam();
+ if (!isServiceValidForDeviceConfiguration(serviceName)) {
+ LOG(DEBUG) << "Skipped the test due to device configuration.";
+ GTEST_SKIP();
+ }
+ sap = ISap::fromBinder(ndk::SpAIBinder(AServiceManager_waitForService(serviceName.c_str())));
+ ASSERT_NE(sap.get(), nullptr);
+
+ sapCb = ndk::SharedRefBase::make<SapCallback>(*this);
+ ASSERT_NE(sapCb.get(), nullptr);
+
+ count = 0;
+
+ ndk::ScopedAStatus res = sap->setCallback(sapCb);
+ ASSERT_OK(res) << res;
+}
+
+void SapTest::TearDown() {}
+
+::testing::AssertionResult SapTest::CheckAnyOfErrors(SapResultCode err,
+ std::vector<SapResultCode> errors) {
+ for (size_t i = 0; i < errors.size(); i++) {
+ if (err == errors[i]) {
+ return testing::AssertionSuccess();
+ }
+ }
+ return testing::AssertionFailure() << "SapError:" + toString(err) + " is returned";
+}
+
+void SapTest::notify(int receivedSerial) {
+ std::unique_lock<std::mutex> lock(mtx);
+ count++;
+ if (serial == receivedSerial) {
+ cv.notify_one();
+ }
+}
+
+std::cv_status SapTest::wait() {
+ std::unique_lock<std::mutex> lock(mtx);
+
+ std::cv_status status = std::cv_status::no_timeout;
+ auto now = std::chrono::system_clock::now();
+ while (count == 0) {
+ status = cv.wait_until(lock, now + std::chrono::seconds(TIMEOUT_PERIOD));
+ if (status == std::cv_status::timeout) {
+ return status;
+ }
+ }
+ count--;
+ return status;
+}
+
+/*
+ * Test ISap.connectReq() for the response returned.
+ */
+TEST_P(SapTest, connectReq) {
+ LOG(DEBUG) << "connectReq";
+ serial = GetRandomSerialNumber();
+ int32_t maxMsgSize = 100;
+
+ ndk::ScopedAStatus res = sap->connectReq(serial, maxMsgSize);
+ ASSERT_OK(res) << res;
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(sapCb->sapResponseSerial, serial);
+
+ // Modem side need time for connect to finish. Adding a waiting time to prevent
+ // disconnect being requested right after connect request.
+ sleep(1);
+}
+
+/*
+ * Test ISap.disconnectReq() for the response returned
+ */
+TEST_P(SapTest, disconnectReq) {
+ LOG(DEBUG) << "disconnectReq";
+ serial = GetRandomSerialNumber();
+
+ ndk::ScopedAStatus res = sap->disconnectReq(serial);
+ ASSERT_OK(res) << res;
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(sapCb->sapResponseSerial, serial);
+ LOG(DEBUG) << "disconnectReq finished";
+}
+
+/*
+ * Test ISap.apduReq() for the response returned.
+ */
+TEST_P(SapTest, apduReq) {
+ LOG(DEBUG) << "apduReq";
+ serial = GetRandomSerialNumber();
+ SapApduType sapApduType = SapApduType::APDU;
+ std::vector<uint8_t> command = {};
+
+ ndk::ScopedAStatus res = sap->apduReq(serial, sapApduType, command);
+ ASSERT_OK(res) << res;
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(sapCb->sapResponseSerial, serial);
+
+ ASSERT_TRUE(CheckAnyOfErrors(
+ sapCb->sapResultCode,
+ {SapResultCode::GENERIC_FAILURE, SapResultCode::CARD_ALREADY_POWERED_OFF,
+ SapResultCode::CARD_NOT_ACCESSSIBLE, SapResultCode::CARD_REMOVED,
+ SapResultCode::SUCCESS}));
+ LOG(DEBUG) << "apduReq finished";
+}
+
+/*
+ * Test ISap.transferAtrReq() for the response returned.
+ */
+TEST_P(SapTest, transferAtrReq) {
+ LOG(DEBUG) << "transferAtrReq";
+ serial = GetRandomSerialNumber();
+
+ ndk::ScopedAStatus res = sap->transferAtrReq(serial);
+ ASSERT_OK(res) << res;
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(sapCb->sapResponseSerial, serial);
+
+ ASSERT_TRUE(CheckAnyOfErrors(sapCb->sapResultCode,
+ {SapResultCode::GENERIC_FAILURE, SapResultCode::DATA_NOT_AVAILABLE,
+ SapResultCode::CARD_ALREADY_POWERED_OFF,
+ SapResultCode::CARD_REMOVED, SapResultCode::SUCCESS}));
+ LOG(DEBUG) << "transferAtrReq finished";
+}
+
+/*
+ * Test ISap.powerReq() for the response returned.
+ */
+TEST_P(SapTest, powerReq) {
+ LOG(DEBUG) << "powerReq";
+ serial = GetRandomSerialNumber();
+ bool state = true;
+
+ ndk::ScopedAStatus res = sap->powerReq(serial, state);
+ ASSERT_OK(res) << res;
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(sapCb->sapResponseSerial, serial);
+
+ ASSERT_TRUE(
+ CheckAnyOfErrors(sapCb->sapResultCode,
+ {SapResultCode::GENERIC_FAILURE, SapResultCode::CARD_NOT_ACCESSSIBLE,
+ SapResultCode::CARD_ALREADY_POWERED_OFF, SapResultCode::CARD_REMOVED,
+ SapResultCode::CARD_ALREADY_POWERED_ON, SapResultCode::SUCCESS}));
+ LOG(DEBUG) << "powerReq finished";
+}
+
+/*
+ * Test ISap.resetSimReq() for the response returned.
+ */
+TEST_P(SapTest, resetSimReq) {
+ LOG(DEBUG) << "resetSimReq";
+ serial = GetRandomSerialNumber();
+
+ ndk::ScopedAStatus res = sap->resetSimReq(serial);
+ ASSERT_OK(res) << res;
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(sapCb->sapResponseSerial, serial);
+
+ ASSERT_TRUE(
+ CheckAnyOfErrors(sapCb->sapResultCode,
+ {SapResultCode::GENERIC_FAILURE, SapResultCode::CARD_NOT_ACCESSSIBLE,
+ SapResultCode::CARD_ALREADY_POWERED_OFF, SapResultCode::CARD_REMOVED,
+ SapResultCode::SUCCESS}));
+ LOG(DEBUG) << "resetSimReq finished";
+}
+
+/*
+ * Test ISap.transferCardReaderStatusReq() for the response returned.
+ */
+TEST_P(SapTest, transferCardReaderStatusReq) {
+ LOG(DEBUG) << "transferCardReaderStatusReq";
+ serial = GetRandomSerialNumber();
+
+ ndk::ScopedAStatus res = sap->transferCardReaderStatusReq(serial);
+ ASSERT_OK(res) << res;
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(sapCb->sapResponseSerial, serial);
+
+ ASSERT_TRUE(CheckAnyOfErrors(sapCb->sapResultCode,
+ {SapResultCode::GENERIC_FAILURE, SapResultCode::DATA_NOT_AVAILABLE,
+ SapResultCode::SUCCESS}));
+ LOG(DEBUG) << "transferCardReaderStatusReq finished";
+}
+
+/*
+ * Test ISap.setTransferProtocolReq() for the response returned.
+ */
+TEST_P(SapTest, setTransferProtocolReq) {
+ LOG(DEBUG) << "setTransferProtocolReq";
+ serial = GetRandomSerialNumber();
+ SapTransferProtocol sapTransferProtocol = SapTransferProtocol::T0;
+
+ ndk::ScopedAStatus res = sap->setTransferProtocolReq(serial, sapTransferProtocol);
+ ASSERT_OK(res) << res;
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(sapCb->sapResponseSerial, serial);
+
+ ASSERT_TRUE(CheckAnyOfErrors(sapCb->sapResultCode,
+ {SapResultCode::NOT_SUPPORTED, SapResultCode::SUCCESS}));
+ LOG(DEBUG) << "setTransferProtocolReq finished";
+}
diff --git a/radio/aidl/vts/radio_sap_utils.h b/radio/aidl/vts/radio_sap_utils.h
new file mode 100644
index 0000000..bf17006
--- /dev/null
+++ b/radio/aidl/vts/radio_sap_utils.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+#pragma once
+
+#include <aidl/Gtest.h>
+#include <aidl/android/hardware/radio/sap/BnSapCallback.h>
+#include <aidl/android/hardware/radio/sap/ISap.h>
+
+#include "radio_aidl_hal_utils.h"
+
+using namespace aidl::android::hardware::radio::sap;
+
+class SapTest;
+
+/* Callback class for radio sap response */
+class SapCallback : public BnSapCallback {
+ protected:
+ SapTest& parent_sap;
+
+ public:
+ SapCallback(SapTest& parent_config);
+ virtual ~SapCallback() = default;
+
+ int32_t sapResponseSerial;
+ SapResultCode sapResultCode;
+
+ virtual ::ndk::ScopedAStatus apduResponse(int32_t serial, SapResultCode resultCode,
+ const std::vector<uint8_t>& adpuRsp) override;
+
+ virtual ::ndk::ScopedAStatus connectResponse(int32_t serial, SapConnectRsp sapConnectRsp,
+ int32_t maxMsgSize) override;
+
+ virtual ::ndk::ScopedAStatus disconnectIndication(int32_t serial,
+ SapDisconnectType sapDisconnectType) override;
+
+ virtual ::ndk::ScopedAStatus disconnectResponse(int32_t serial) override;
+
+ virtual ::ndk::ScopedAStatus errorResponse(int32_t serial) override;
+
+ virtual ::ndk::ScopedAStatus powerResponse(int32_t serial, SapResultCode resultCode) override;
+
+ virtual ::ndk::ScopedAStatus resetSimResponse(int32_t serial,
+ SapResultCode resultCode) override;
+
+ virtual ::ndk::ScopedAStatus statusIndication(int32_t serial, SapStatus sapStatus) override;
+
+ virtual ::ndk::ScopedAStatus transferAtrResponse(int32_t serial, SapResultCode resultCode,
+ const std::vector<uint8_t>& atr) override;
+
+ virtual ::ndk::ScopedAStatus transferCardReaderStatusResponse(
+ int32_t serial, SapResultCode resultCode, int32_t cardReaderStatus) override;
+
+ virtual ::ndk::ScopedAStatus transferProtocolResponse(int32_t serial,
+ SapResultCode resultCode) override;
+};
+
+// The main test class for AIDL SAP.
+class SapTest : public ::testing::TestWithParam<std::string> {
+ private:
+ std::mutex mtx;
+ std::condition_variable cv;
+ int count;
+
+ public:
+ virtual void SetUp() override;
+
+ virtual void TearDown() override;
+
+ ::testing::AssertionResult CheckAnyOfErrors(SapResultCode err,
+ std::vector<SapResultCode> errors);
+
+ /* Used as a mechanism to inform the test about data/event callback */
+ void notify(int receivedSerial);
+
+ /* Test code calls this function to wait for response */
+ std::cv_status wait();
+
+ /* Sap service */
+ std::shared_ptr<ISap> sap;
+
+ /* Sap Callback object */
+ std::shared_ptr<SapCallback> sapCb;
+
+ /* Serial for sap request */
+ int32_t serial;
+};
diff --git a/security/rkp/aidl/android/hardware/security/keymint/IRemotelyProvisionedComponent.aidl b/security/rkp/aidl/android/hardware/security/keymint/IRemotelyProvisionedComponent.aidl
index c506667..ff710f1 100644
--- a/security/rkp/aidl/android/hardware/security/keymint/IRemotelyProvisionedComponent.aidl
+++ b/security/rkp/aidl/android/hardware/security/keymint/IRemotelyProvisionedComponent.aidl
@@ -222,7 +222,7 @@
* 2 : bstr ; KID : EEK ID
* 3 : -25, ; Algorithm : ECDH-ES + HKDF-256
* -1 : 4, ; Curve : X25519
- * -2 : bstr ; X25519 public key
+ * -2 : bstr ; X25519 public key, little-endian
* }
*
* EekP256 = { ; COSE_Key
@@ -440,6 +440,9 @@
*
* ; The following section defines some types that are reused throughout the above
* ; data structures.
+ * ; NOTE: Integer encoding is different for Ed25519 and P256 keys:
+ * ; - Ed25519 is LE: https://www.rfc-editor.org/rfc/rfc8032#section-3.1
+ * ; - P256 is BE: https://www.secg.org/sec1-v2.pdf#page=19 (section 2.3.7)
* PubKeyEd25519 = { ; COSE_Key
* 1 : 1, ; Key type : octet key pair
* 3 : AlgorithmEdDSA, ; Algorithm : EdDSA
@@ -451,8 +454,8 @@
* 1 : 2, ; Key type : EC2
* 3 : AlgorithmES256, ; Algorithm : ECDSA w/ SHA-256
* -1 : 1, ; Curve: P256
- * -2 : bstr, ; X coordinate
- * -3 : bstr ; Y coordinate
+ * -2 : bstr, ; X coordinate, big-endian
+ * -3 : bstr ; Y coordinate, big-endian
* }
*
* AlgorithmES256 = -7
diff --git a/security/rkp/aidl/android/hardware/security/keymint/MacedPublicKey.aidl b/security/rkp/aidl/android/hardware/security/keymint/MacedPublicKey.aidl
index 275e322..1e41d1b 100644
--- a/security/rkp/aidl/android/hardware/security/keymint/MacedPublicKey.aidl
+++ b/security/rkp/aidl/android/hardware/security/keymint/MacedPublicKey.aidl
@@ -36,12 +36,15 @@
* ]
*
* ; NOTE: -70000 is deprecated for v3 HAL implementations.
+ * ; NOTE: Integer encoding is different for Ed25519 and P256 keys:
+ * ; - Ed25519 is LE: https://www.rfc-editor.org/rfc/rfc8032#section-3.1
+ * ; - P256 is BE: https://www.secg.org/sec1-v2.pdf#page=19 (section 2.3.7)
* PublicKey = { ; COSE_Key
* 1 : 2, ; Key type : EC2
* 3 : -7, ; Algorithm : ES256
* -1 : 1, ; Curve : P256
- * -2 : bstr, ; X coordinate, little-endian
- * -3 : bstr, ; Y coordinate, little-endian
+ * -2 : bstr, ; X coordinate, big-endian
+ * -3 : bstr, ; Y coordinate, big-endian
* -70000 : nil ; Presence indicates this is a test key. If set, K_mac is
* ; all zeros.
* },
diff --git a/security/rkp/aidl/android/hardware/security/keymint/ProtectedData.aidl b/security/rkp/aidl/android/hardware/security/keymint/ProtectedData.aidl
index d59508b..3f699bc 100644
--- a/security/rkp/aidl/android/hardware/security/keymint/ProtectedData.aidl
+++ b/security/rkp/aidl/android/hardware/security/keymint/ProtectedData.aidl
@@ -209,7 +209,7 @@
* PubKeyX25519 = { ; COSE_Key
* 1 : 1, ; Key type : Octet Key Pair
* -1 : 4, ; Curve : X25519
- * -2 : bstr ; Sender X25519 public key
+ * -2 : bstr ; Sender X25519 public key, little-endian
* }
*
* PubKeyEd25519 = { ; COSE_Key
@@ -222,16 +222,16 @@
* PubKeyEcdhP256 = { ; COSE_Key
* 1 : 2, ; Key type : EC2
* -1 : 1, ; Curve : P256
- * -2 : bstr ; Sender X coordinate
- * -3 : bstr ; Sender Y coordinate
+ * -2 : bstr ; Sender X coordinate, big-endian
+ * -3 : bstr ; Sender Y coordinate, big-endian
* }
*
* PubKeyECDSA256 = { ; COSE_Key
* 1 : 2, ; Key type : EC2
* 3 : AlgorithmES256, ; Algorithm : ECDSA w/ SHA-256
* -1 : 1, ; Curve: P256
- * -2 : bstr, ; X coordinate
- * -3 : bstr ; Y coordinate
+ * -2 : bstr, ; X coordinate, big-endian
+ * -3 : bstr ; Y coordinate, big-endian
* }
*
* AlgorithmES256 = -7
diff --git a/security/rkp/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp b/security/rkp/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp
index aebcf67..bbda56d 100644
--- a/security/rkp/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp
+++ b/security/rkp/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp
@@ -223,6 +223,20 @@
ASSERT_TRUE(provisionable_->getHardwareInfo(&hwInfo).isOk());
const std::set<int> validCurves = {RpcHardwareInfo::CURVE_P256, RpcHardwareInfo::CURVE_25519};
+ // First check for the implementations that supports only IRPC V3+.
+ if (rpcHardwareInfo.versionNumber >= VERSION_WITHOUT_TEST_MODE) {
+ bytevec keysToSignMac;
+ DeviceInfo deviceInfo;
+ ProtectedData protectedData;
+ auto status = provisionable_->generateCertificateRequest(false, {}, {}, {}, &deviceInfo,
+ &protectedData, &keysToSignMac);
+ if (!status.isOk() &&
+ (status.getServiceSpecificError() == BnRemotelyProvisionedComponent::STATUS_REMOVED)) {
+ ASSERT_EQ(hwInfo.supportedEekCurve, RpcHardwareInfo::CURVE_NONE)
+ << "Invalid curve: " << hwInfo.supportedEekCurve;
+ return;
+ }
+ }
ASSERT_EQ(validCurves.count(hwInfo.supportedEekCurve), 1)
<< "Invalid curve: " << hwInfo.supportedEekCurve;
}