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

Commit 62e480bc authored by Elliott Hughes's avatar Elliott Hughes Committed by android-build-merger
Browse files

Merge "Sort devices list before output." am: 18cdd350

am: e93f4e82

Change-Id: I0a55bc85c506c8f4d10e4a730e2547f13ebfef14
parents 4b8ff4e6 e93f4e82
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -952,10 +952,18 @@ static void append_transport(const atransport* t, std::string* result, bool long
}

std::string list_transports(bool long_listing) {
    std::string result;

    std::lock_guard<std::recursive_mutex> lock(transport_lock);
    for (const auto& t : transport_list) {

    auto sorted_transport_list = transport_list;
    sorted_transport_list.sort([](atransport*& x, atransport*& y) {
        if (x->type != y->type) {
            return x->type < y->type;
        }
        return strcmp(x->serial, y->serial) < 0;
    });

    std::string result;
    for (const auto& t : sorted_transport_list) {
        append_transport(t, &result, long_listing);
    }
    return result;