Merge "Change the way rkp tool obtains serial number" into main am: 40f1230a1d am: c3e1e032a9

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2861829

Change-Id: Iacb293a784c4050842af26091749d9742aac926e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Seth Moore 2023-12-07 20:24:56 +00:00 committed by Automerger Merge Worker
commit c9674f6535
3 changed files with 6 additions and 5 deletions

View file

@ -130,7 +130,7 @@ struct JsonOutput {
* }
*/
JsonOutput jsonEncodeCsrWithBuild(const std::string instance_name,
const cppbor::Array& csr);
const cppbor::Array& csr, const std::string serialno_prop);
/**
* Parses a DeviceInfo structure from the given CBOR data. The parsed data is then validated to

View file

@ -337,9 +337,9 @@ ErrMsgOr<std::vector<BccEntryData>> validateBcc(const cppbor::Array* bcc,
return result;
}
JsonOutput jsonEncodeCsrWithBuild(const std::string instance_name, const cppbor::Array& csr) {
JsonOutput jsonEncodeCsrWithBuild(const std::string instance_name, const cppbor::Array& csr,
const std::string serialno_prop) {
const std::string kFingerprintProp = "ro.build.fingerprint";
const std::string kSerialNoProp = "ro.serialno";
if (!::android::base::WaitForPropertyCreation(kFingerprintProp)) {
return JsonOutput::Error("Unable to read build fingerprint");
@ -364,7 +364,7 @@ JsonOutput jsonEncodeCsrWithBuild(const std::string instance_name, const cppbor:
Json::Value json(Json::objectValue);
json["name"] = instance_name;
json["build_fingerprint"] = ::android::base::GetProperty(kFingerprintProp, /*default=*/"");
json["serialno"] = ::android::base::GetProperty(kSerialNoProp, /*default=*/"");
json["serialno"] = ::android::base::GetProperty(serialno_prop, /*default=*/"");
json["csr"] = base64.data(); // Boring writes a NUL-terminated c-string
Json::StreamWriterBuilder factory;

View file

@ -182,10 +182,11 @@ TEST(RemoteProvUtilsTest, GetProdEekChain) {
}
TEST(RemoteProvUtilsTest, JsonEncodeCsr) {
const std::string kSerialNoProp = "ro.serialno";
cppbor::Array array;
array.add(1);
auto [json, error] = jsonEncodeCsrWithBuild(std::string("test"), array);
auto [json, error] = jsonEncodeCsrWithBuild(std::string("test"), array, kSerialNoProp);
ASSERT_TRUE(error.empty()) << error;