Merge "Change the way rkp tool obtains serial number" into main am: 40f1230a1d
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2861829 Change-Id: I7c0d85c0ff1ae7f834cf8baca7147aa494ad46d5 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
2edabacc98
3 changed files with 6 additions and 5 deletions
|
@ -130,7 +130,7 @@ struct JsonOutput {
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
JsonOutput jsonEncodeCsrWithBuild(const std::string instance_name,
|
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
|
* Parses a DeviceInfo structure from the given CBOR data. The parsed data is then validated to
|
||||||
|
|
|
@ -337,9 +337,9 @@ ErrMsgOr<std::vector<BccEntryData>> validateBcc(const cppbor::Array* bcc,
|
||||||
return result;
|
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 kFingerprintProp = "ro.build.fingerprint";
|
||||||
const std::string kSerialNoProp = "ro.serialno";
|
|
||||||
|
|
||||||
if (!::android::base::WaitForPropertyCreation(kFingerprintProp)) {
|
if (!::android::base::WaitForPropertyCreation(kFingerprintProp)) {
|
||||||
return JsonOutput::Error("Unable to read build fingerprint");
|
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::Value json(Json::objectValue);
|
||||||
json["name"] = instance_name;
|
json["name"] = instance_name;
|
||||||
json["build_fingerprint"] = ::android::base::GetProperty(kFingerprintProp, /*default=*/"");
|
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["csr"] = base64.data(); // Boring writes a NUL-terminated c-string
|
||||||
|
|
||||||
Json::StreamWriterBuilder factory;
|
Json::StreamWriterBuilder factory;
|
||||||
|
|
|
@ -182,10 +182,11 @@ TEST(RemoteProvUtilsTest, GetProdEekChain) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(RemoteProvUtilsTest, JsonEncodeCsr) {
|
TEST(RemoteProvUtilsTest, JsonEncodeCsr) {
|
||||||
|
const std::string kSerialNoProp = "ro.serialno";
|
||||||
cppbor::Array array;
|
cppbor::Array array;
|
||||||
array.add(1);
|
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;
|
ASSERT_TRUE(error.empty()) << error;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue