Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18a9fa99 authored by chuanchuan.gao's avatar chuanchuan.gao Committed by Eddy-SH Chen
Browse files

Change the way rkp tool obtains serial number

[Description]
1.Add patch to modify rkp_factory_extraction_tool, so
 that it can meet TV customer's factory product line.
2.Change the method for
rkp_factory_extraction_tool to get the serial number.
3.Introduce a new input parameter, serialno_prop,
to the function jsonEncodeCsrWithBuild.
4.Use the new property of serialno_prop if it is set,
otherwise defaults to "ro.serialno".

Test:
1.build pass
2.AC on/off pass
3.run "rkp_factory_extraction_tool
--output_format build+csr
--serialno_prop $(customer_prop) > csr.json" pass
4.run "rkp_factory_extraction_tool
--output_format build+csr > csr.json" pass
5.VtsHalRemotelyProvisionedComponentTargetTest pass
6.libkeymint_remote_prov_support_test pass
7.VtsAidlKeyMintTargetTest pass

Bug: 313811996
Change-Id: I8aa83bacab22f0a28bc54aea9e816f75a382ffde
parent 577cc0ac
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+3 −3
Original line number Diff line number Diff line
@@ -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;
+2 −1
Original line number Diff line number Diff line
@@ -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;