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

Commit 4600be86 authored by Josh Gao's avatar Josh Gao Committed by android-build-merger
Browse files

Merge "adb: fix authentication when reconnecting." am: 46d19d34

am: 10e7241e

Change-Id: I0f6aff80994404d6c6c579c13853a04596f3e737
parents d2918a11 10e7241e
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -764,6 +764,10 @@ static void transport_unref(atransport* t) {
#if ADB_HOST
        if (t->IsTcpDevice() && !t->kicked()) {
            D("transport: %s unref (attempting reconnection)", t->serial.c_str());

            // We need to clear the transport's keys, so that on the next connection, it tries
            // again from the beginning.
            t->ResetKeys();
            reconnect_handler.TrackTransport(t);
        } else {
            D("transport: %s unref (kicking and closing)", t->serial.c_str());
@@ -1328,10 +1332,20 @@ bool check_header(apacket* p, atransport* t) {

#if ADB_HOST
std::shared_ptr<RSA> atransport::NextKey() {
    if (keys_.empty()) keys_ = adb_auth_get_private_keys();
    if (keys_.empty()) {
        LOG(INFO) << "fetching keys for transport " << this->serial_name();
        keys_ = adb_auth_get_private_keys();

        // We should have gotten at least one key: the one that's automatically generated.
        CHECK(!keys_.empty());
    }

    std::shared_ptr<RSA> result = keys_[0];
    keys_.pop_front();
    return result;
}

void atransport::ResetKeys() {
    keys_.clear();
}
#endif
+1 −0
Original line number Diff line number Diff line
@@ -258,6 +258,7 @@ class atransport {

#if ADB_HOST
    std::shared_ptr<RSA> NextKey();
    void ResetKeys();
#endif

    char token[TOKEN_SIZE] = {};