Merge "Add host support to DefauleVehicleHal lib" into main
diff --git a/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp b/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp
index 1e6f186..70790c4 100644
--- a/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp
+++ b/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp
@@ -1254,6 +1254,7 @@
SKIP_TEST_IF_DATA_UNSUPPORTED(mDescriptor.common.flags);
ASSERT_NO_FATAL_FAILURE(generateSineWave(mTestFrequencies, mInput, 1.0, kSamplingFrequency,
mChannelLayout));
+ mInputDb = calculateDb(mInput);
}
void TearDown() override { TearDownDynamicsProcessingEffect(); }
@@ -1276,11 +1277,11 @@
void fillMbcBandConfig(std::vector<DynamicsProcessing::MbcBandConfig>& cfgs, int channelIndex,
float threshold, float ratio, float noiseGate, float expanderRatio,
- int bandIndex, int cutoffFreqHz) {
- cfgs.push_back(createMbcBandConfig(
- channelIndex, bandIndex, static_cast<float>(cutoffFreqHz), kDefaultAttackTime,
- kDefaultReleaseTime, ratio, threshold, kDefaultKneeWidth, noiseGate, expanderRatio,
- kDefaultPreGainDb, kDefaultPostGainDb));
+ int bandIndex, int cutoffFreqHz, float preGain, float postGain) {
+ cfgs.push_back(createMbcBandConfig(channelIndex, bandIndex,
+ static_cast<float>(cutoffFreqHz), kDefaultAttackTime,
+ kDefaultReleaseTime, ratio, threshold, kDefaultKneeWidth,
+ noiseGate, expanderRatio, preGain, postGain));
}
void getMagnitudeValue(const std::vector<float>& output, std::vector<float>& bufferMag) {
@@ -1291,10 +1292,9 @@
void validateOutput(const std::vector<float>& output, float threshold, float ratio,
size_t bandIndex) {
- float inputDb = calculateDb(mInput);
std::vector<float> outputMag(mBinOffsets.size());
EXPECT_NO_FATAL_FAILURE(getMagnitudeValue(output, outputMag));
- if (threshold >= inputDb || ratio == 1) {
+ if (threshold >= mInputDb || ratio == 1) {
std::vector<float> inputMag(mBinOffsets.size());
EXPECT_NO_FATAL_FAILURE(getMagnitudeValue(mInput, inputMag));
for (size_t i = 0; i < inputMag.size(); i++) {
@@ -1315,10 +1315,11 @@
for (size_t i = 0; i < cutoffFreqHz.size(); i++) {
for (int channelIndex = 0; channelIndex < mChannelCount; channelIndex++) {
fillMbcBandConfig(mCfgs, channelIndex, threshold, ratio, kDefaultNoiseGateDb,
- kDefaultExpanderRatio, i, cutoffFreqHz[i]);
+ kDefaultExpanderRatio, i, cutoffFreqHz[i], kDefaultPreGainDb,
+ kDefaultPostGainDb);
fillMbcBandConfig(mCfgs, channelIndex, kDefaultThresholdDb, kDefaultRatio,
kDefaultNoiseGateDb, kDefaultExpanderRatio, i ^ 1,
- cutoffFreqHz[i ^ 1]);
+ cutoffFreqHz[i ^ 1], kDefaultPreGainDb, kDefaultPostGainDb);
}
ASSERT_NO_FATAL_FAILURE(setMbcParamsAndProcess(output));
@@ -1347,6 +1348,8 @@
static constexpr float kDefaultExpanderRatio = 1;
static constexpr float kDefaultRatio = 1;
static constexpr float kBinWidth = (float)kSamplingFrequency / kNPointFFT;
+ // Full scale sine wave with 100 Hz and 1000 Hz frequency is -6 dB
+ static constexpr float kFullScaleDb = -6;
std::vector<int> mTestFrequencies = {100, 1000};
// Calculating normalizing factor by dividing the number of FFT points by half and the number of
// test frequencies. The normalization accounts for the FFT splitting the signal into positive
@@ -1357,6 +1360,7 @@
std::vector<DynamicsProcessing::ChannelConfig> mChannelConfig;
std::vector<int> mBinOffsets;
std::vector<float> mInput;
+ float mInputDb;
};
TEST_P(DynamicsProcessingMbcBandConfigDataTest, IncreasingThreshold) {
@@ -1379,6 +1383,31 @@
}
}
+TEST_P(DynamicsProcessingMbcBandConfigDataTest, IncreasingPostGain) {
+ std::vector<float> postGainDbValues = {-55, -30, 0, 30, 55};
+ std::vector<float> output(mInput.size());
+ for (float postGainDb : postGainDbValues) {
+ float amplitude = 1.0 / (pow(10, postGainDb / 20));
+ ASSERT_NO_FATAL_FAILURE(generateSineWave(mTestFrequencies, mInput, amplitude,
+ kSamplingFrequency, mChannelLayout));
+ mInputDb = calculateDb(mInput);
+ EXPECT_NEAR(mInputDb, kFullScaleDb - postGainDb, kToleranceDb);
+ cleanUpMbcConfig();
+ for (int i = 0; i < mChannelCount; i++) {
+ fillMbcBandConfig(mCfgs, i, kDefaultThresholdDb, kDefaultRatio, kDefaultNoiseGateDb,
+ kDefaultExpanderRatio, 0 /*band index*/, 2000 /*cutoffFrequency*/,
+ kDefaultPreGainDb, postGainDb);
+ }
+ EXPECT_NO_FATAL_FAILURE(setMbcParamsAndProcess(output));
+ if (!isAllParamsValid()) {
+ continue;
+ }
+ float outputDb = calculateDb(output, kStartIndex);
+ EXPECT_NEAR(outputDb, mInputDb + postGainDb, kToleranceDb)
+ << "PostGain: " << postGainDb << ", OutputDb: " << outputDb;
+ }
+}
+
INSTANTIATE_TEST_SUITE_P(DynamicsProcessingTest, DynamicsProcessingMbcBandConfigDataTest,
testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, getEffectTypeUuidDynamicsProcessing())),
diff --git a/security/rkp/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp b/security/rkp/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp
index 9d90440..65e93c6 100644
--- a/security/rkp/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp
+++ b/security/rkp/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp
@@ -60,6 +60,10 @@
const string KEYMINT_STRONGBOX_INSTANCE_NAME =
"android.hardware.security.keymint.IKeyMintDevice/strongbox";
+constexpr std::string_view kVerifiedBootState = "ro.boot.verifiedbootstate";
+constexpr std::string_view kDeviceState = "ro.boot.vbmeta.device_state";
+constexpr std::string_view kDefaultValue = "";
+
#define INSTANTIATE_REM_PROV_AIDL_TEST(name) \
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(name); \
INSTANTIATE_TEST_SUITE_P( \
@@ -171,6 +175,37 @@
return nullptr;
}
+void unlockedBootloaderStatesImpliesNonNormalDiceChain(
+ const string& rpcInstanceName, std::shared_ptr<IRemotelyProvisionedComponent> rpc) {
+ auto challenge = randomBytes(MAX_CHALLENGE_SIZE);
+ bytevec csr;
+ auto status = rpc->generateCertificateRequestV2({} /* keysToSign */, challenge, &csr);
+ ASSERT_TRUE(status.isOk()) << status.getDescription();
+
+ auto isProper = isCsrWithProperDiceChain(csr, rpcInstanceName);
+ ASSERT_TRUE(isProper) << isProper.message();
+ if (!*isProper) {
+ GTEST_SKIP() << "Skipping test: Only a proper DICE chain has a mode set.";
+ }
+
+ auto nonNormalMode = hasNonNormalModeInDiceChain(csr, rpcInstanceName);
+ ASSERT_TRUE(nonNormalMode) << nonNormalMode.message();
+
+ auto deviceState = ::android::base::GetProperty(string(kDeviceState), string(kDefaultValue));
+ auto verifiedBootState =
+ ::android::base::GetProperty(string(kVerifiedBootState), string(kDefaultValue));
+
+ ASSERT_TRUE(!deviceState.empty());
+ ASSERT_TRUE(!verifiedBootState.empty());
+
+ ASSERT_EQ(deviceState != "locked" || verifiedBootState != "green", *nonNormalMode)
+ << kDeviceState << " = '" << deviceState << "' and " << kVerifiedBootState << " = '"
+ << verifiedBootState << "', but the DICE "
+ << " chain has a " << (*nonNormalMode ? "non-normal" : "normal") << " DICE mode."
+ << " Locked devices must report normal, and unlocked devices must report "
+ << " non-normal.";
+}
+
} // namespace
class VtsRemotelyProvisionedComponentTests : public testing::TestWithParam<std::string> {
@@ -345,7 +380,7 @@
* is not "green" if and only if the mode on at least one certificate in the DICE chain
* is non-normal.
*/
-TEST(NonParameterizedTests, unlockedBootloaderStatesImpliesNonnormalRkpVmDiceChain) {
+TEST(NonParameterizedTests, unlockedBootloaderStatesImpliesNonNormalRkpVmDiceChain) {
if (!AServiceManager_isDeclared(RKPVM_INSTANCE_NAME.c_str())) {
GTEST_SKIP() << "The RKP VM (" << RKPVM_INSTANCE_NAME << ") is not present on this device.";
}
@@ -359,32 +394,31 @@
GTEST_SKIP() << "The RKP VM is not supported on this system.";
}
- auto challenge = randomBytes(MAX_CHALLENGE_SIZE);
- bytevec csr;
- auto rkpVmStatus = rpc->generateCertificateRequestV2({} /* keysToSign */, challenge, &csr);
- ASSERT_TRUE(rkpVmStatus.isOk()) << status.getDescription();
+ unlockedBootloaderStatesImpliesNonNormalDiceChain(RKPVM_INSTANCE_NAME, rpc);
+}
- auto isProper = isCsrWithProperDiceChain(csr, RKPVM_INSTANCE_NAME);
- ASSERT_TRUE(isProper) << isProper.message();
- if (!*isProper) {
- GTEST_SKIP() << "Skipping test: Only a proper DICE chain has a mode set.";
+/**
+ * If trusty.security_vm.keymint.enabled is set to "true", then do the following.
+ *
+ * Check that ro.boot.vbmeta.device_state is not "locked" or ro.boot.verifiedbootstate
+ * is not "green" if and only if the mode on at least one certificate in the DICE chain
+ * is non-normal.
+ */
+TEST(NonParameterizedTests, unlockedBootloaderStatesImpliesNonNormalKeyMintInAVmDiceChain) {
+ if (::android::base::GetBoolProperty("trusty.security_vm.keymint.enabled", false)) {
+ GTEST_SKIP() << "The KeyMint (" << DEFAULT_INSTANCE_NAME
+ << ") instance is not inside a VM.";
}
- auto nonNormalMode = hasNonNormalModeInDiceChain(csr, RKPVM_INSTANCE_NAME);
- ASSERT_TRUE(nonNormalMode) << nonNormalMode.message();
+ auto rpc = getHandle<IRemotelyProvisionedComponent>(DEFAULT_INSTANCE_NAME);
+ ASSERT_NE(rpc, nullptr) << "The KeyMint (" << DEFAULT_INSTANCE_NAME
+ << ") instance RPC is unavailable.";
- auto deviceState = ::android::base::GetProperty("ro.boot.vbmeta.device_state", "");
- auto verifiedBootState = ::android::base::GetProperty("ro.boot.verifiedbootstate", "");
+ RpcHardwareInfo hardwareInfo;
+ auto status = rpc->getHardwareInfo(&hardwareInfo);
+ ASSERT_TRUE(status.isOk()) << status.getDescription();
- ASSERT_TRUE(!deviceState.empty());
- ASSERT_TRUE(!verifiedBootState.empty());
-
- ASSERT_EQ(deviceState != "locked" || verifiedBootState != "green", *nonNormalMode)
- << "ro.boot.vbmeta.device_state = '" << deviceState
- << "' and ro.boot.verifiedbootstate = '" << verifiedBootState << "', but the DICE "
- << " chain has a " << (*nonNormalMode ? "non-normal" : "normal") << " DICE mode."
- << " Locked devices must report normal, and unlocked devices must report "
- << " non-normal.";
+ unlockedBootloaderStatesImpliesNonNormalDiceChain(DEFAULT_INSTANCE_NAME, rpc);
}
using GetHardwareInfoTests = VtsRemotelyProvisionedComponentTests;