Merge "[fastboot+init] avoid std::allocator<const T>" into main

This commit is contained in:
Ryan Prichard 2024-09-05 18:34:28 +00:00 committed by Gerrit Code Review
commit 2deb758b9b
2 changed files with 11 additions and 12 deletions

View file

@ -90,7 +90,7 @@ std::string TransportSniffer::CreateTrace() {
// and be printed as a string, or just a raw byte-buffer
const auto msg = [&ret, no_print](const std::vector<char>& buf) {
ret += android::base::StringPrintf("(%lu bytes): ", buf.size());
std::vector<const char>::iterator iter = buf.end();
std::vector<char>::const_iterator iter = buf.end();
const unsigned max_chars = 50;
if (buf.size() > max_chars) {
iter = buf.begin() + max_chars;

View file

@ -168,16 +168,16 @@ const std::vector<int> escape_chord = {KEY_ESC};
const std::vector<int> triple1_chord = {KEY_BACKSPACE, KEY_VOLUMEDOWN, KEY_VOLUMEUP};
const std::vector<int> triple2_chord = {KEY_VOLUMEDOWN, KEY_VOLUMEUP, KEY_BACK};
const std::vector<const std::vector<int>> empty_chords;
const std::vector<const std::vector<int>> chords = {
escape_chord,
triple1_chord,
triple2_chord,
const std::vector<std::vector<int>> empty_chords;
const std::vector<std::vector<int>> chords = {
escape_chord,
triple1_chord,
triple2_chord,
};
class TestFrame {
public:
TestFrame(const std::vector<const std::vector<int>>& chords, EventHandler* ev = nullptr);
TestFrame(const std::vector<std::vector<int>>& chords, EventHandler* ev = nullptr);
void RelaxForMs(std::chrono::milliseconds wait = 1ms);
@ -194,16 +194,15 @@ class TestFrame {
std::string Format() const;
private:
static std::string Format(const std::vector<const std::vector<int>>& chords);
static std::string Format(const std::vector<std::vector<int>>& chords);
Epoll epoll_;
Keychords keychords_;
std::vector<const std::vector<int>> keycodes_;
std::vector<std::vector<int>> keycodes_;
EventHandler* ev_;
};
TestFrame::TestFrame(const std::vector<const std::vector<int>>& chords, EventHandler* ev)
: ev_(ev) {
TestFrame::TestFrame(const std::vector<std::vector<int>>& chords, EventHandler* ev) : ev_(ev) {
if (!epoll_.Open().ok()) return;
for (const auto& keycodes : chords) keychords_.Register(keycodes);
keychords_.Start(&epoll_, [this](const std::vector<int>& keycodes) {
@ -262,7 +261,7 @@ void TestFrame::WaitForChord(const std::vector<int>& chord) {
for (int retry = 1000; retry && !IsChord(chord); --retry) RelaxForMs();
}
std::string TestFrame::Format(const std::vector<const std::vector<int>>& chords) {
std::string TestFrame::Format(const std::vector<std::vector<int>>& chords) {
std::string ret("{");
if (!chords.empty()) {
ret += android::base::Join(chords.front(), ' ');