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

Commit b5d9d909 authored by Shengsong Tan's avatar Shengsong Tan
Browse files

Remove usage of base/string/* in libfs_avb

As part of the effort to uprev libchrome in Android, we are
removing Android dependencies to libchrome utility functions
that are not strictly required.

This CL remove the usage of base/string/* and replace by
android-base/string*

Bug: 360917504
Change-Id: I89e7bdd66bdf8f565f6b2084a70335616a644069
Test: atest libfs_avb_internal_test
parent e322d543
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -16,10 +16,10 @@

#include <endian.h>

#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <base/files/file_util.h>
#include <base/rand_util.h>
#include <base/strings/string_util.h>
#include <libavb/libavb.h>

#include "avb_util.h"
@@ -70,7 +70,7 @@ void AvbUtilTest::SetVBMetaFlags(const base::FilePath& image_path, uint32_t flag

    std::string image_file_name = image_path.RemoveExtension().BaseName().value();
    bool is_vbmeta_partition =
        base::StartsWith(image_file_name, "vbmeta", base::CompareCase::INSENSITIVE_ASCII);
        android::base::StartsWithIgnoreCase(image_file_name, "vbmeta");

    android::base::unique_fd fd(open(image_path.value().c_str(), O_RDWR | O_CLOEXEC));
    EXPECT_TRUE(fd > 0);
@@ -603,7 +603,7 @@ bool AvbUtilTest::CompareVBMeta(const base::FilePath& avb_image_path,
    std::string image_file_name = avb_image_path.RemoveExtension().BaseName().value();

    base::FilePath extracted_vbmeta_path;
    if (base::StartsWith(image_file_name, "vbmeta", base::CompareCase::INSENSITIVE_ASCII)) {
    if (android::base::StartsWithIgnoreCase(image_file_name, "vbmeta")) {
        extracted_vbmeta_path = avb_image_path;  // no need to extract if it's a vbmeta image.
    } else {
        extracted_vbmeta_path = ExtractVBMetaImage(avb_image_path, image_file_name + "-vbmeta.img");
+0 −1
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@

#include <android-base/file.h>
#include <base/files/file_util.h>
#include <base/strings/string_util.h>

namespace fs_avb_host_test {

+2 −2
Original line number Diff line number Diff line
@@ -18,8 +18,8 @@
#include <stdlib.h>

#include <android-base/file.h>
#include <android-base/strings.h>
#include <base/files/file_util.h>
#include <base/strings/string_util.h>
#include <fs_avb/fs_avb.h>
#include <libavb/libavb.h>

@@ -49,7 +49,7 @@ void PublicFsAvbTest::ModifyVBMetaHeaderFlags(const base::FilePath& vbmeta_image

    // Only support modifying the flags in vbmeta*.img.
    std::string image_file_name = vbmeta_image_path.RemoveExtension().BaseName().value();
    ASSERT_TRUE(base::StartsWith(image_file_name, "vbmeta", base::CompareCase::INSENSITIVE_ASCII));
    ASSERT_TRUE(android::base::StartsWithIgnoreCase(image_file_name, "vbmeta"));

    android::base::unique_fd fd(open(vbmeta_image_path.value().c_str(), O_RDWR | O_CLOEXEC));
    EXPECT_TRUE(fd > 0);
+4 −5
Original line number Diff line number Diff line
@@ -19,8 +19,9 @@
#include <stdlib.h>

#include <android-base/file.h>
#include <android-base/strings.h>
#include <android-base/stringprintf.h>
#include <base/files/file_util.h>
#include <base/strings/string_util.h>

namespace fs_avb_host_test {

@@ -64,9 +65,7 @@ std::string BaseFsAvbTest::CalcVBMetaDigest(const std::string& file_name,
    std::string vbmeta_digest_data;
    EXPECT_TRUE(base::ReadFileToString(vbmeta_digest_path, &vbmeta_digest_data));
    // Returns the trimmed digest.
    std::string trimmed_digest_data;
    base::TrimString(vbmeta_digest_data, " \t\n", &trimmed_digest_data);
    return trimmed_digest_data;
    return android::base::Trim(vbmeta_digest_data);
}

base::FilePath BaseFsAvbTest::GenerateVBMetaImage(
@@ -91,7 +90,7 @@ base::FilePath BaseFsAvbTest::GenerateVBMetaImage(
    // --chain_partitions
    std::string chain_partition_options;
    for (const auto& partition : chain_partitions) {
        chain_partition_options += base::StringPrintf(
        chain_partition_options += android::base::StringPrintf(
                " --chain_partition %s:%u:%s", partition.partition_name.c_str(),
                partition.rollback_index_location, partition.key_blob_path.value().c_str());
    }
+2 −2
Original line number Diff line number Diff line
@@ -26,9 +26,9 @@
#include <string>
#include <vector>

#include <android-base/stringprintf.h>
#include <android-base/unique_fd.h>
#include <base/files/file_path.h>
#include <base/strings/stringprintf.h>
#include <fs_avb/types.h>
#include <gtest/gtest.h>

@@ -37,7 +37,7 @@
// the command exits normally with exit status |expected_exit_status|.
#define EXPECT_COMMAND(expected_exit_status, command_format, ...)                   \
    do {                                                                            \
        int rc = system(base::StringPrintf(command_format, ##__VA_ARGS__).c_str()); \
        int rc = system(android::base::StringPrintf(command_format, ##__VA_ARGS__).c_str()); \
        EXPECT_TRUE(WIFEXITED(rc));                                                 \
        EXPECT_EQ(WEXITSTATUS(rc), expected_exit_status);                           \
    } while (0);