Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base/cvd/cuttlefish/common/libs/utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ cf_cc_library(
"@abseil-cpp//absl/log:log_sink",
"@abseil-cpp//absl/log:log_sink_registry",
"@abseil-cpp//absl/strings",
"@abseil-cpp//absl/strings:str_format",
],
)

Expand Down
10 changes: 4 additions & 6 deletions base/cvd/cuttlefish/common/libs/utils/flag_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <utility>
#include <vector>

#include <android-base/strings.h>
#include "absl/strings/str_replace.h"
#include "absl/strings/str_join.h"
#include <fmt/format.h>
#include <fmt/ranges.h> // NOLINT(misc-include-cleaner): version difference
Expand Down Expand Up @@ -171,13 +171,12 @@ Result<int> ParseInt(const std::string& value, std::string_view name) {

Result<Flag::FlagProcessResult> Flag::Process(
const std::string& arg, const std::optional<std::string>& next_arg) const {
using android::base::StringReplace;
auto normalized_arg = StringReplace(arg, "-", "_", true);
auto normalized_arg = absl::StrReplaceAll(arg, {{"-", "_"}});
if (!setter_ && !aliases_.empty()) {
return CF_ERRF("No setter for flag with alias {}", aliases_[0].name);
}
for (auto& alias : aliases_) {
auto normalized_alias = StringReplace(alias.name, "-", "_", true);
auto normalized_alias = absl::StrReplaceAll(alias.name, {{"-", "_"}});
switch (alias.mode) {
case FlagAliasMode::kFlagConsumesArbitrary:
if (normalized_arg != normalized_alias) {
Expand Down Expand Up @@ -258,8 +257,7 @@ bool Flag::HasAlias(const FlagAlias& test) const {
}

static std::string XmlEscape(const std::string& s) {
using android::base::StringReplace;
return StringReplace(StringReplace(s, "<", "&lt;", true), ">", "&gt;", true);
return absl::StrReplaceAll(s, {{"<", "&lt;"}, {">", "&gt;"}});
}

bool Flag::WriteGflagsCompatXml(std::ostream& out) const {
Expand Down
10 changes: 4 additions & 6 deletions base/cvd/cuttlefish/common/libs/utils/tee_logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@

#include <android-base/file.h>
#include <android-base/macros.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <android-base/threads.h>
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
Expand All @@ -44,15 +42,15 @@
#include "absl/log/log_sink.h"
#include "absl/log/log_sink_registry.h"
#include "absl/strings/numbers.h"
#include "absl/strings/str_format.h"

#include "cuttlefish/common/libs/fs/shared_buf.h"
#include "cuttlefish/common/libs/utils/contains.h"
#include "cuttlefish/common/libs/utils/environment.h"
#include "cuttlefish/common/libs/utils/proc_file_utils.h"
#include "cuttlefish/result/result.h"

using android::base::GetThreadId;
using android::base::StringPrintf;
using absl::StrFormat;

namespace cuttlefish {
namespace {
Expand Down Expand Up @@ -142,11 +140,11 @@ std::string StderrOutputGenerator(const struct tm& now, int pid, uint64_t tid,
std::string line_prefix;
if (file != nullptr) {
line_prefix =
StringPrintf("%s %c %s %5d %5" PRIu64 " %s:%u] ", tag ? tag : "nullptr",
StrFormat("%s %c %s %5d %5" PRIu64 " %s:%u] ", tag ? tag : "nullptr",
severity_char, timestamp, pid, tid, file, line);
} else {
line_prefix =
StringPrintf("%s %c %s %5d %5" PRIu64 " ", tag ? tag : "nullptr",
StrFormat("%s %c %s %5d %5" PRIu64 " ", tag ? tag : "nullptr",
severity_char, timestamp, pid, tid);
}

Expand Down
2 changes: 2 additions & 0 deletions base/cvd/cuttlefish/host/commands/assemble_cvd/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ cf_cc_library(
"//libbase",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/strings",
],
)

Expand Down Expand Up @@ -289,6 +290,7 @@ cf_cc_library(
"//cuttlefish/host/libs/config:config_flag",
"//cuttlefish/host/libs/feature",
"//libbase",
"@abseil-cpp//absl/strings",
"@fruit",
"@gflags",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "absl/log/check.h"
#include "absl/log/log.h"
#include "android-base/strings.h"
#include "absl/strings/str_replace.h"

#include "cuttlefish/common/libs/fs/shared_fd.h"
#include "cuttlefish/common/libs/utils/files.h"
Expand Down Expand Up @@ -315,14 +315,13 @@ Result<void> RepackVendorBootImage(
unpack.KernelCommandLine() +
(bootconfig_supported
? ""
: " " + android::base::StringReplace(bootconfig, "\n", " ", true));
: " " + absl::StrReplaceAll(bootconfig, {{"\n", " "}}));
if (!bootconfig_supported) {
// TODO(b/182417593): Until we pass the module parameters through
// modules.options, we pass them through bootconfig using
// 'kernel.<key>=<value>' But if we don't support bootconfig, we need to
// rename them back to the old cmdline version
kernel_cmdline = android::base::StringReplace(
kernel_cmdline, " kernel.", " ", true);
absl::StrReplaceAll({{" kernel.", " "}}, &kernel_cmdline);
}
VLOG(0) << "Cmdline from vendor boot image is " << kernel_cmdline;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <unordered_set>
#include <vector>

#include <android-base/strings.h>
#include "absl/strings/str_replace.h"
#include <fruit/fruit.h>
#include <gflags/gflags.h>

Expand All @@ -28,8 +28,7 @@
namespace cuttlefish {

static std::string XmlEscape(const std::string& s) {
using android::base::StringReplace;
return StringReplace(StringReplace(s, "<", "&lt;", true), ">", "&gt;", true);
return absl::StrReplaceAll(s, {{"<", "&lt;"}, {">", "&gt;"}});
}

class ParseGflagsImpl : public ParseGflags {
Expand Down
5 changes: 2 additions & 3 deletions base/cvd/cuttlefish/host/commands/assemble_cvd/flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
#include "android-base/file.h"
#include "android-base/strings.h"
#include "fmt/format.h"
#include "fruit/fruit.h"
#include "gflags/gflags.h"
Expand Down Expand Up @@ -170,8 +169,8 @@ Result<std::unordered_map<int, std::string>> CreateNumToWebrtcDeviceIdMap(
auto itr = device_ids.begin();
for (const auto num : instance_nums) {
std::string_view device_id_view(itr->data(), itr->size());
output_map[num] = android::base::StringReplace(device_id_view, "{num}",
std::to_string(num), true);
output_map[num] =
absl::StrReplaceAll(device_id_view, {{"{num}", std::to_string(num)}});
++itr;
}
return output_map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ cf_cc_binary(
"//cuttlefish/result",
"//libbase",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/strings",
"@gflags",
"@grpc",
"@grpc//:grpc++",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
#include <string>
#include <vector>

#include <android-base/hex.h>
#include <gflags/gflags.h>
#include <google/protobuf/empty.pb.h>
#include <grpcpp/ext/proto_server_reflection_plugin.h>
#include <grpcpp/grpcpp.h>
#include <grpcpp/health_check_service_interface.h>
#include "absl/log/log.h"
#include "absl/strings/escaping.h"

#include "cuttlefish/host/commands/casimir_control_server/casimir_control.grpc.pb.h"
#include "cuttlefish/host/commands/casimir_control_server/casimir_controller.h"
Expand Down Expand Up @@ -207,8 +207,8 @@ class CasimirControlServiceImpl final : public CasimirControlService::Service {
std::vector<uint8_t> bytes =
CF_EXPECT(device_->SendApdu(id, std::move(apdu_bytes[i])),
"Failed to send APDU bytes");
std::string resp = android::base::HexString(
reinterpret_cast<void*>(bytes.data()), bytes.size());
std::string resp = absl::BytesToHexString(
std::string_view(reinterpret_cast<const char*>(bytes.data()), bytes.size()));
response->add_response_hex_strings(std::move(resp));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <unordered_set>
#include <vector>

#include <android-base/strings.h>
#include "absl/strings/str_replace.h"

#include "cuttlefish/common/libs/utils/environment.h"
#include "cuttlefish/host/commands/cvd/cli/command_request.h"
Expand All @@ -48,8 +48,7 @@ std::string BashEscape(const std::string& input) {
}
safe = false;
}
using android::base::StringReplace;
return safe ? input : "'" + StringReplace(input, "'", "\\'", true) + "'";
return safe ? input : "'" + absl::StrReplaceAll(input, {{"'", "\\'"}}) + "'";
}

std::string FormattedCommand(const CommandRequest& command) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <utility>
#include <vector>

#include <android-base/strings.h>
#include <google/protobuf/util/json_util.h>

#include "cuttlefish/common/libs/utils/flags_validator.h"
Expand All @@ -35,7 +34,6 @@

namespace cuttlefish {

using android::base::StringReplace;
using cvd::config::EnvironmentSpecification;
using cvd::config::Instance;
using cvd::config::Vm;
Expand Down
2 changes: 2 additions & 0 deletions base/cvd/cuttlefish/host/commands/modem_simulator/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cf_cc_library(
"//cuttlefish/host/commands/modem_simulator:virtual_modem_simulator",
"//libbase",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/strings",
],
)

Expand Down Expand Up @@ -236,6 +237,7 @@ cf_cc_test(
"//cuttlefish/host/libs/config:cuttlefish_config",
"//libbase",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/strings",
"@gflags",
"@googletest//:gtest",
"@googletest//:gtest_main",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <algorithm>

#include <android-base/strings.h>
#include "absl/strings/str_replace.h"
#include "absl/log/log.h"

#include "cuttlefish/common/libs/fs/shared_select.h"
Expand Down Expand Up @@ -114,7 +114,7 @@ void ChannelMonitor::ReadCommand(Client& client) {
incomplete_command.clear();

// Replacing '\n' with '\r'
commands = android::base::StringReplace(commands, "\n", "\r", true);
absl::StrReplaceAll({{"\n", "\r"}}, &commands);

// Split into commands and dispatch
size_t pos = 0, r_pos = 0; // '\r' or '\n'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <android-base/strings.h>
#include "absl/strings/strip.h"

#include <algorithm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <gtest/gtest.h>
#include <stdlib.h>
#include "absl/log/log.h"
#include "absl/strings/str_replace.h"

#include <filesystem>
#include <fstream>
Expand Down Expand Up @@ -125,7 +126,7 @@ class ModemServiceTest : public ::testing::Test {
incomplete_command.resize(0);

// replacing '\n' with '\r'
commands = android::base::StringReplace(commands, "\n", "\r", true);
absl::StrReplaceAll({{"\n", "\r"}}, &commands);

// split into commands and dispatch
size_t pos = 0, r_pos = 0; // '\r' or '\n'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ cf_cc_library(
"//cuttlefish/host/libs/vm_manager",
"//cuttlefish/result",
"//libbase",
"@abseil-cpp//absl/strings",
"@fruit",
"@jsoncpp",
],
Expand Down
11 changes: 5 additions & 6 deletions base/cvd/cuttlefish/host/commands/run_cvd/launch/mcu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <utility>
#include <vector>

#include <android-base/strings.h>
#include "absl/strings/str_replace.h"
#include <fruit/component.h>
#include <fruit/fruit_forward_decls.h>
#include <fruit/macro.h>
Expand Down Expand Up @@ -69,14 +69,13 @@ class Mcu : public vm_manager::VmmDependencyCommand {
CF_EXPECT(start.type() == Json::arrayValue,
"mcu: config: start-cmd: array expected");
CF_EXPECT(!start.empty(), "mcu: config: empty start-cmd");
Command command(android::base::StringReplace(start[0].asString(), "${bin}",
HostBinaryPath(""), true));
Command command(absl::StrReplaceAll(start[0].asString(),
{{"${bin}", HostBinaryPath("")}}));

for (unsigned int i = 1; i < start.size(); i++) {
auto param = start[i].asString();
param = android::base::StringReplace(param, "${wdir}", mcu_dir_, true);
param = android::base::StringReplace(param, "${bin}", HostBinaryPath(""),
true);
absl::StrReplaceAll({{"${wdir}", mcu_dir_}, {"${bin}", HostBinaryPath("")}},
&param);
command.AddParameter(param);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ extern "C" {
#include <crypto_scrypt.h>
}

#include <android-base/memory.h>
#include <gatekeeper/gatekeeper.h>

#include <iostream>
Expand Down Expand Up @@ -149,7 +148,8 @@ class SoftGateKeeper : public GateKeeper {
}

bool DoVerify(const password_handle_t* expected_handle, const SizedBuffer& password) {
uint64_t user_id = android::base::get_unaligned<secure_id_t>(&expected_handle->user_id);
uint64_t user_id;
memcpy(&user_id, &expected_handle->user_id, sizeof(user_id));
FastHashMap::const_iterator it = fast_hash_map_.find(user_id);
if (it != fast_hash_map_.end() && VerifyFast(it->second, password)) {
return true;
Expand Down
4 changes: 2 additions & 2 deletions base/cvd/cuttlefish/host/libs/web/credential_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <vector>

#include <android-base/strings.h>
#include "absl/strings/str_replace.h"
#include "absl/strings/strip.h"
#include "absl/strings/str_split.h"
#include <json/value.h>
Expand Down Expand Up @@ -65,8 +66,7 @@ std::string CollectSslErrors() {

Result<std::string> Base64Url(const char* data, size_t size) {
std::string base64 = CF_EXPECT(EncodeBase64(data, size));
base64 = android::base::StringReplace(base64, "+", "-", /* all */ true);
base64 = android::base::StringReplace(base64, "/", "_", /* all */ true);
absl::StrReplaceAll({{"+", "-"}, {"/", "_"}}, &base64);
return base64;
}

Expand Down
9 changes: 9 additions & 0 deletions gigabyte-ampere-cuttlefish-installer/preseed/preseed.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ d-i keyboard-configuration/xkb-keymap select us
# skip displaying a list if there is more than one interface.
d-i netcfg/choose_interface select auto

# To set a different link detection timeout (default is 3 seconds).
# Values are interpreted as seconds.
d-i netcfg/link_wait_timeout string 30

# If you have a slow dhcp server and the installer times out waiting for
# it, this might be useful.
d-i netcfg/dhcp_timeout string 90
d-i netcfg/dhcpv6_timeout string 90

# Any hostname and domain names assigned from dhcp take precedence over
# values set here. However, setting the values still prevents the questions
# from being shown, even if values come from dhcp.
Expand Down
Loading