Merge "[fastboot+init] avoid std::allocator<const T>" into main
This commit is contained in:
commit
2deb758b9b
2 changed files with 11 additions and 12 deletions
|
|
@ -90,7 +90,7 @@ std::string TransportSniffer::CreateTrace() {
|
||||||
// and be printed as a string, or just a raw byte-buffer
|
// and be printed as a string, or just a raw byte-buffer
|
||||||
const auto msg = [&ret, no_print](const std::vector<char>& buf) {
|
const auto msg = [&ret, no_print](const std::vector<char>& buf) {
|
||||||
ret += android::base::StringPrintf("(%lu bytes): ", buf.size());
|
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;
|
const unsigned max_chars = 50;
|
||||||
if (buf.size() > max_chars) {
|
if (buf.size() > max_chars) {
|
||||||
iter = buf.begin() + max_chars;
|
iter = buf.begin() + max_chars;
|
||||||
|
|
|
||||||
|
|
@ -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> triple1_chord = {KEY_BACKSPACE, KEY_VOLUMEDOWN, KEY_VOLUMEUP};
|
||||||
const std::vector<int> triple2_chord = {KEY_VOLUMEDOWN, KEY_VOLUMEUP, KEY_BACK};
|
const std::vector<int> triple2_chord = {KEY_VOLUMEDOWN, KEY_VOLUMEUP, KEY_BACK};
|
||||||
|
|
||||||
const std::vector<const std::vector<int>> empty_chords;
|
const std::vector<std::vector<int>> empty_chords;
|
||||||
const std::vector<const std::vector<int>> chords = {
|
const std::vector<std::vector<int>> chords = {
|
||||||
escape_chord,
|
escape_chord,
|
||||||
triple1_chord,
|
triple1_chord,
|
||||||
triple2_chord,
|
triple2_chord,
|
||||||
};
|
};
|
||||||
|
|
||||||
class TestFrame {
|
class TestFrame {
|
||||||
public:
|
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);
|
void RelaxForMs(std::chrono::milliseconds wait = 1ms);
|
||||||
|
|
||||||
|
|
@ -194,16 +194,15 @@ class TestFrame {
|
||||||
std::string Format() const;
|
std::string Format() const;
|
||||||
|
|
||||||
private:
|
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_;
|
Epoll epoll_;
|
||||||
Keychords keychords_;
|
Keychords keychords_;
|
||||||
std::vector<const std::vector<int>> keycodes_;
|
std::vector<std::vector<int>> keycodes_;
|
||||||
EventHandler* ev_;
|
EventHandler* ev_;
|
||||||
};
|
};
|
||||||
|
|
||||||
TestFrame::TestFrame(const std::vector<const std::vector<int>>& chords, EventHandler* ev)
|
TestFrame::TestFrame(const std::vector<std::vector<int>>& chords, EventHandler* ev) : ev_(ev) {
|
||||||
: ev_(ev) {
|
|
||||||
if (!epoll_.Open().ok()) return;
|
if (!epoll_.Open().ok()) return;
|
||||||
for (const auto& keycodes : chords) keychords_.Register(keycodes);
|
for (const auto& keycodes : chords) keychords_.Register(keycodes);
|
||||||
keychords_.Start(&epoll_, [this](const std::vector<int>& 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();
|
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("{");
|
std::string ret("{");
|
||||||
if (!chords.empty()) {
|
if (!chords.empty()) {
|
||||||
ret += android::base::Join(chords.front(), ' ');
|
ret += android::base::Join(chords.front(), ' ');
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue