[fastboot+init] avoid std::allocator<const T>

std::vector<const T> uses std::allocator<const T>, which is an
undocumented libc++ extension to the C++ standard library. The extension
was removed in llvm.org/PR96319. Use an ordinary non-const T instead.

Bug: http://b/349681543
Test: m fuzzy_fastboot CtsInitTestCases
Test: m MODULES-IN-system-core
Flag: EXEMPT, refactor to fix build failure
Change-Id: Ia98a2f090e87541fd35a89bd75bf9638bc7dc711
This commit is contained in:
Ryan Prichard 2024-09-04 17:34:25 -07:00
parent 942e372dd8
commit 4f13b13aac
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(), ' ');