Merge "secure_element/aidl: add state checking in TearDown()"
diff --git a/audio/aidl/default/EffectFactory.cpp b/audio/aidl/default/EffectFactory.cpp
index c1ac3f2..f0687cc 100644
--- a/audio/aidl/default/EffectFactory.cpp
+++ b/audio/aidl/default/EffectFactory.cpp
@@ -75,6 +75,8 @@
RETURN_IF(!libInterface || !libInterface->queryEffectFunc, EX_NULL_POINTER,
"dlNullQueryEffectFunc");
RETURN_IF_BINDER_EXCEPTION(libInterface->queryEffectFunc(&id.uuid, &desc));
+ // update proxy UUID with information from config xml
+ desc.common.id.proxy = id.proxy;
_aidl_return->emplace_back(std::move(desc));
}
}
diff --git a/audio/aidl/default/include/core-impl/StreamUsb.h b/audio/aidl/default/include/core-impl/StreamUsb.h
index f1815dd..36e64cb 100644
--- a/audio/aidl/default/include/core-impl/StreamUsb.h
+++ b/audio/aidl/default/include/core-impl/StreamUsb.h
@@ -56,7 +56,7 @@
std::vector<::aidl::android::media::audio::common::AudioDeviceAddress> mConnectedDevices
GUARDED_BY(mLock);
std::vector<std::shared_ptr<alsa_device_proxy>> mAlsaDeviceProxies GUARDED_BY(mLock);
- bool mIsStandby = false;
+ bool mIsStandby = true;
};
class StreamInUsb final : public StreamIn {
diff --git a/audio/aidl/default/usb/ModuleUsb.cpp b/audio/aidl/default/usb/ModuleUsb.cpp
index 80b0a5b..89895bf 100644
--- a/audio/aidl/default/usb/ModuleUsb.cpp
+++ b/audio/aidl/default/usb/ModuleUsb.cpp
@@ -120,7 +120,11 @@
const bool isInput = isUsbInputDeviceType(devicePort.device.type.type);
alsa_device_profile profile;
profile_init(&profile, isInput ? PCM_IN : PCM_OUT);
+ profile.card = alsaAddress[0];
+ profile.device = alsaAddress[1];
if (!profile_read_device_info(&profile)) {
+ LOG(ERROR) << __func__ << ": failed to read device info, card=" << profile.card
+ << ", device=" << profile.device;
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
diff --git a/audio/aidl/default/usb/StreamUsb.cpp b/audio/aidl/default/usb/StreamUsb.cpp
index fbfe0f1..5d1d7fe 100644
--- a/audio/aidl/default/usb/StreamUsb.cpp
+++ b/audio/aidl/default/usb/StreamUsb.cpp
@@ -107,10 +107,13 @@
::android::status_t DriverUsb::transfer(void* buffer, size_t frameCount, size_t* actualFrameCount,
int32_t* latencyMs) {
if (!mConfig.has_value() || mConnectedDevices.empty()) {
+ LOG(ERROR) << __func__ << ": failed, has config: " << mConfig.has_value()
+ << ", has connected devices: " << mConnectedDevices.empty();
return ::android::NO_INIT;
}
if (mIsStandby) {
if (::android::status_t status = exitStandby(); status != ::android::OK) {
+ LOG(ERROR) << __func__ << ": failed to exit standby, status=" << status;
return status;
}
}
@@ -151,6 +154,7 @@
std::vector<std::shared_ptr<alsa_device_proxy>> alsaDeviceProxies;
for (const auto& device : connectedDevices) {
alsa_device_profile profile;
+ profile_init(&profile, mIsInput ? PCM_IN : PCM_OUT);
profile.card = device.get<AudioDeviceAddress::alsa>()[0];
profile.device = device.get<AudioDeviceAddress::alsa>()[1];
if (!profile_read_device_info(&profile)) {
@@ -174,6 +178,11 @@
<< " error=" << err;
return ::android::UNKNOWN_ERROR;
}
+ if (int err = proxy_open(proxy.get()); err != 0) {
+ LOG(ERROR) << __func__ << ": failed to open device, address=" << device.toString()
+ << " error=" << err;
+ return ::android::UNKNOWN_ERROR;
+ }
alsaDeviceProxies.push_back(std::move(proxy));
}
{
diff --git a/audio/aidl/default/usb/UsbAlsaUtils.cpp b/audio/aidl/default/usb/UsbAlsaUtils.cpp
index 3a74c2a..74d9c28 100644
--- a/audio/aidl/default/usb/UsbAlsaUtils.cpp
+++ b/audio/aidl/default/usb/UsbAlsaUtils.cpp
@@ -114,8 +114,8 @@
static const AudioFormatDescToPcmFormatMap formatDescToPcmFormatMap = {
{make_AudioFormatDescription(PcmType::UINT_8_BIT), PCM_FORMAT_S8},
{make_AudioFormatDescription(PcmType::INT_16_BIT), PCM_FORMAT_S16_LE},
- {make_AudioFormatDescription(PcmType::INT_24_BIT), PCM_FORMAT_S24_LE},
- {make_AudioFormatDescription(PcmType::FIXED_Q_8_24), PCM_FORMAT_S24_3LE},
+ {make_AudioFormatDescription(PcmType::FIXED_Q_8_24), PCM_FORMAT_S24_LE},
+ {make_AudioFormatDescription(PcmType::INT_24_BIT), PCM_FORMAT_S24_3LE},
{make_AudioFormatDescription(PcmType::INT_32_BIT), PCM_FORMAT_S32_LE},
{make_AudioFormatDescription(PcmType::FLOAT_32_BIT), PCM_FORMAT_FLOAT_LE},
};
diff --git a/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp b/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
index df66bd3..d8ad6c9 100644
--- a/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
@@ -139,7 +139,10 @@
Descriptor desc;
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(getDescriptor(mEffect, desc));
- EXPECT_EQ(mDescriptor.common, desc.common);
+ EXPECT_EQ(mDescriptor.common.id.type, desc.common.id.type);
+ EXPECT_EQ(mDescriptor.common.id.uuid, desc.common.id.uuid);
+ EXPECT_EQ(mDescriptor.common.name, desc.common.name);
+ EXPECT_EQ(mDescriptor.common.implementor, desc.common.implementor);
// Effect implementation Must fill in implementor and name
EXPECT_NE("", desc.common.name);
EXPECT_NE("", desc.common.implementor);
@@ -176,7 +179,11 @@
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(getDescriptor(mEffect, desc));
- EXPECT_EQ(1ul, idSet.count(desc.common.id));
+ int uuidCount = std::count_if(idSet.begin(), idSet.end(), [&](const auto& id) {
+ return id.uuid == desc.common.id.uuid && id.type == desc.common.id.type;
+ });
+
+ EXPECT_EQ(1, uuidCount);
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
diff --git a/health/aidl/vts/functional/VtsHalHealthTargetTest.cpp b/health/aidl/vts/functional/VtsHalHealthTargetTest.cpp
index 69d4789..783ce11 100644
--- a/health/aidl/vts/functional/VtsHalHealthTargetTest.cpp
+++ b/health/aidl/vts/functional/VtsHalHealthTargetTest.cpp
@@ -257,7 +257,7 @@
BatteryChargingPolicy value;
/* set ChargingPolicy*/
- status = health->setChargingPolicy(static_cast<BatteryChargingPolicy>(2)); // LONG_LIFE
+ status = health->setChargingPolicy(BatteryChargingPolicy::LONG_LIFE);
ASSERT_THAT(status, AnyOf(IsOk(), ExceptionIs(EX_UNSUPPORTED_OPERATION)));
if (!status.isOk()) return;
@@ -265,7 +265,9 @@
status = health->getChargingPolicy(&value);
ASSERT_THAT(status, AnyOf(IsOk(), ExceptionIs(EX_UNSUPPORTED_OPERATION)));
if (!status.isOk()) return;
- ASSERT_THAT(static_cast<int>(value), Eq(2));
+ // the result of getChargingPolicy will be one of default(1), ADAPTIVE_AON(2)
+ // ADAPTIVE_AC(3) or LONG_LIFE(4). default(1) means NOT_SUPPORT
+ ASSERT_THAT(static_cast<int>(value), AnyOf(Eq(1), Eq(4)));
}
MATCHER(IsValidHealthData, "") {
diff --git a/neuralnetworks/aidl/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/aidl/vts/functional/GeneratedTestHarness.cpp
index dcf8451..e344458 100644
--- a/neuralnetworks/aidl/vts/functional/GeneratedTestHarness.cpp
+++ b/neuralnetworks/aidl/vts/functional/GeneratedTestHarness.cpp
@@ -736,8 +736,8 @@
// If a sync fence is returned, try start another run waiting for the sync
// fence.
if (testConfig.reusable) {
- ret = execution->executeFenced(waitFor, kNoDeadline, kNoDuration,
- &executionResult);
+ // Nothing to do because at most one execution may occur on a reusable
+ // execution object at any given time.
} else if (testConfig.useConfig) {
ret = preparedModel->executeFencedWithConfig(
request, waitFor,
diff --git a/radio/1.5/vts/functional/radio_hidl_hal_api.cpp b/radio/1.5/vts/functional/radio_hidl_hal_api.cpp
index 5539b9c..316c308 100644
--- a/radio/1.5/vts/functional/radio_hidl_hal_api.cpp
+++ b/radio/1.5/vts/functional/radio_hidl_hal_api.cpp
@@ -565,9 +565,9 @@
serial = GetRandomSerialNumber();
::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band17;
- band17.eutranBands() = {::android::hardware::radio::V1_5::EutranBands::BAND_17};
+ band17.eutranBands({::android::hardware::radio::V1_5::EutranBands::BAND_17});
::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band20;
- band20.eutranBands() = {::android::hardware::radio::V1_5::EutranBands::BAND_20};
+ band20.eutranBands({::android::hardware::radio::V1_5::EutranBands::BAND_20});
::android::hardware::radio::V1_5::RadioAccessSpecifier specifier17 = {
.radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::EUTRAN,
.bands = band17,
diff --git a/secure_element/aidl/android/hardware/secure_element/ISecureElement.aidl b/secure_element/aidl/android/hardware/secure_element/ISecureElement.aidl
index 8c0dd6d..800494a 100644
--- a/secure_element/aidl/android/hardware/secure_element/ISecureElement.aidl
+++ b/secure_element/aidl/android/hardware/secure_element/ISecureElement.aidl
@@ -117,6 +117,9 @@
* closed by this operation.
* HAL service must send onStateChange() with connected equal to true
* after resetting and all the re-initialization has been successfully completed.
+ *
+ * @throws ServiceSpecificException on error with the following code:
+ * - FAILED if the service was unable to reset the secure element.
*/
void reset();
diff --git a/security/keymint/aidl/vts/functional/KeyMintTest.cpp b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
index c6b8906..c45dd3f 100644
--- a/security/keymint/aidl/vts/functional/KeyMintTest.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
@@ -590,8 +590,7 @@
return name.substr(pos + 1);
}
-bool matching_rp_instance(const string& km_name,
- std::shared_ptr<IRemotelyProvisionedComponent>* rp) {
+std::shared_ptr<IRemotelyProvisionedComponent> matching_rp_instance(const std::string& km_name) {
string km_suffix = device_suffix(km_name);
vector<string> rp_names =
@@ -601,11 +600,10 @@
// KeyMint instance, assume they match.
if (device_suffix(rp_name) == km_suffix && AServiceManager_isDeclared(rp_name.c_str())) {
::ndk::SpAIBinder binder(AServiceManager_waitForService(rp_name.c_str()));
- *rp = IRemotelyProvisionedComponent::fromBinder(binder);
- return true;
+ return IRemotelyProvisionedComponent::fromBinder(binder);
}
}
- return false;
+ return nullptr;
}
} // namespace
@@ -1140,11 +1138,14 @@
GTEST_SKIP() << "RKP support is not required on this platform";
}
- // There should be an IRemotelyProvisionedComponent instance associated with the KeyMint
- // instance.
- std::shared_ptr<IRemotelyProvisionedComponent> rp;
- ASSERT_TRUE(matching_rp_instance(GetParam(), &rp))
- << "No IRemotelyProvisionedComponent found that matches KeyMint device " << GetParam();
+ // Check for an IRemotelyProvisionedComponent instance associated with the
+ // KeyMint instance.
+ std::shared_ptr<IRemotelyProvisionedComponent> rp = matching_rp_instance(GetParam());
+ if (rp == nullptr && SecLevel() == SecurityLevel::STRONGBOX) {
+ GTEST_SKIP() << "Encountered StrongBox implementation that does not support RKP";
+ }
+ ASSERT_NE(rp, nullptr) << "No IRemotelyProvisionedComponent found that matches KeyMint device "
+ << GetParam();
// Generate a P-256 keypair to use as an attestation key.
MacedPublicKey macedPubKey;
@@ -1218,11 +1219,14 @@
GTEST_SKIP() << "RKP support is not required on this platform";
}
- // There should be an IRemotelyProvisionedComponent instance associated with the KeyMint
- // instance.
- std::shared_ptr<IRemotelyProvisionedComponent> rp;
- ASSERT_TRUE(matching_rp_instance(GetParam(), &rp))
- << "No IRemotelyProvisionedComponent found that matches KeyMint device " << GetParam();
+ // Check for an IRemotelyProvisionedComponent instance associated with the
+ // KeyMint instance.
+ std::shared_ptr<IRemotelyProvisionedComponent> rp = matching_rp_instance(GetParam());
+ if (rp == nullptr && SecLevel() == SecurityLevel::STRONGBOX) {
+ GTEST_SKIP() << "Encountered StrongBox implementation that does not support RKP";
+ }
+ ASSERT_NE(rp, nullptr) << "No IRemotelyProvisionedComponent found that matches KeyMint device "
+ << GetParam();
// Generate a P-256 keypair to use as an attestation key.
MacedPublicKey macedPubKey;
diff --git a/security/keymint/support/remote_prov_utils.cpp b/security/keymint/support/remote_prov_utils.cpp
index 086ee79..7214234 100644
--- a/security/keymint/support/remote_prov_utils.cpp
+++ b/security/keymint/support/remote_prov_utils.cpp
@@ -22,6 +22,7 @@
#include "aidl/android/hardware/security/keymint/IRemotelyProvisionedComponent.h"
#include <aidl/android/hardware/security/keymint/RpcHardwareInfo.h>
+#include <android-base/macros.h>
#include <android-base/properties.h>
#include <cppbor.h>
#include <hwtrust/hwtrust.h>
@@ -43,6 +44,7 @@
constexpr int32_t kBccPayloadSubjPubKey = -4670552;
constexpr int32_t kBccPayloadKeyUsage = -4670553;
constexpr int kP256AffinePointSize = 32;
+constexpr uint32_t kNumTeeDeviceInfoEntries = 14;
using EC_KEY_Ptr = bssl::UniquePtr<EC_KEY>;
using EVP_PKEY_Ptr = bssl::UniquePtr<EVP_PKEY>;
@@ -388,6 +390,11 @@
return entryName + " has an invalid value.\n";
}
+bool isTeeDeviceInfo(const cppbor::Map& devInfo) {
+ return devInfo.get("security_level") && devInfo.get("security_level")->asTstr() &&
+ devInfo.get("security_level")->asTstr()->value() == "tee";
+}
+
ErrMsgOr<std::unique_ptr<cppbor::Map>> parseAndValidateDeviceInfo(
const std::vector<uint8_t>& deviceInfoBytes, IRemotelyProvisionedComponent* provisionable,
bool isFactory) {
@@ -396,6 +403,21 @@
const cppbor::Array kValidSecurityLevels = {"tee", "strongbox"};
const cppbor::Array kValidAttIdStates = {"locked", "open"};
const cppbor::Array kValidFused = {0, 1};
+ constexpr std::array<std::string_view, kNumTeeDeviceInfoEntries> kDeviceInfoKeys = {
+ "brand",
+ "manufacturer",
+ "product",
+ "model",
+ "device",
+ "vb_state",
+ "bootloader_state",
+ "vbmeta_digest",
+ "os_version",
+ "system_patch_level",
+ "boot_patch_level",
+ "vendor_patch_level",
+ "security_level",
+ "fused"};
struct AttestationIdEntry {
const char* id;
@@ -439,20 +461,48 @@
}
std::string error;
+ std::string tmp;
+ std::set<std::string_view> previousKeys;
switch (info.versionNumber) {
case 3:
+ if (isTeeDeviceInfo(*parsed) && parsed->size() != kNumTeeDeviceInfoEntries) {
+ error += fmt::format(
+ "Err: Incorrect number of device info entries. Expected {} but got"
+ "{}\n",
+ kNumTeeDeviceInfoEntries, parsed->size());
+ }
+ // TEE IRPC instances require all entries to be present in DeviceInfo. Non-TEE instances
+ // may omit `os_version`
+ if (!isTeeDeviceInfo(*parsed) && (parsed->size() != kNumTeeDeviceInfoEntries ||
+ parsed->size() != kNumTeeDeviceInfoEntries - 1)) {
+ error += fmt::format(
+ "Err: Incorrect number of device info entries. Expected {} or {} but got"
+ "{}\n",
+ kNumTeeDeviceInfoEntries - 1, kNumTeeDeviceInfoEntries, parsed->size());
+ }
+ for (auto& [key, _] : *parsed) {
+ const std::string& keyValue = key->asTstr()->value();
+ if (!previousKeys.insert(keyValue).second) {
+ error += "Err: Duplicate device info entry: <" + keyValue + ">,\n";
+ }
+ if (std::find(kDeviceInfoKeys.begin(), kDeviceInfoKeys.end(), keyValue) ==
+ kDeviceInfoKeys.end()) {
+ error += "Err: Unrecognized key entry: <" + key->asTstr()->value() + ">,\n";
+ }
+ }
+ FALLTHROUGH_INTENDED;
case 2:
for (const auto& entry : kAttestationIdEntrySet) {
- error += checkMapEntry(isFactory && !entry.alwaysValidate, *parsed, cppbor::TSTR,
- entry.id);
+ tmp = checkMapEntry(isFactory && !entry.alwaysValidate, *parsed, cppbor::TSTR,
+ entry.id);
}
- if (!error.empty()) {
- return error +
- "Attestation IDs are missing or malprovisioned. If this test is being\n"
- "run against an early proto or EVT build, this error is probably WAI\n"
- "and indicates that Device IDs were not provisioned in the factory. If\n"
- "this error is returned on a DVT or later build revision, then\n"
- "something is likely wrong with the factory provisioning process.";
+ if (!tmp.empty()) {
+ error += tmp +
+ "Attestation IDs are missing or malprovisioned. If this test is being\n"
+ "run against an early proto or EVT build, this error is probably WAI\n"
+ "and indicates that Device IDs were not provisioned in the factory. If\n"
+ "this error is returned on a DVT or later build revision, then\n"
+ "something is likely wrong with the factory provisioning process.";
}
// TODO: Refactor the KeyMint code that validates these fields and include it here.
error += checkMapEntry(isFactory, *parsed, cppbor::TSTR, "vb_state", kValidVbStates);
@@ -465,8 +515,7 @@
error += checkMapEntry(isFactory, *parsed, cppbor::UINT, "fused", kValidFused);
error += checkMapEntry(isFactory, *parsed, cppbor::TSTR, "security_level",
kValidSecurityLevels);
- if (parsed->get("security_level") && parsed->get("security_level")->asTstr() &&
- parsed->get("security_level")->asTstr()->value() == "tee") {
+ if (isTeeDeviceInfo(*parsed)) {
error += checkMapEntry(isFactory, *parsed, cppbor::TSTR, "os_version");
}
break;
diff --git a/tests/extension/vibrator/aidl/Android.bp b/tests/extension/vibrator/aidl/Android.bp
index 20df5bb..0306dca 100644
--- a/tests/extension/vibrator/aidl/Android.bp
+++ b/tests/extension/vibrator/aidl/Android.bp
@@ -38,5 +38,11 @@
enabled: false,
},
},
- versions: ["1"],
+ frozen: true,
+ versions_with_info: [
+ {
+ version: "1",
+ imports: ["android.hardware.vibrator-V2"],
+ },
+ ],
}
diff --git a/tests/extension/vibrator/aidl/default/Android.bp b/tests/extension/vibrator/aidl/default/Android.bp
index 0f3895f..5e156af 100644
--- a/tests/extension/vibrator/aidl/default/Android.bp
+++ b/tests/extension/vibrator/aidl/default/Android.bp
@@ -29,6 +29,6 @@
"libbase",
"libbinder_ndk",
"android.hardware.vibrator-V2-ndk",
- "android.hardware.tests.extension.vibrator-V2-ndk",
+ "android.hardware.tests.extension.vibrator-V1-ndk",
],
}