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

Commit 2547f740 authored by Dan Albert's avatar Dan Albert
Browse files

Revert "adb: turn CHECKs into an error + transport restart."

This reverts commit b41d7ae1.

Bug: http://b/135753060
Test: treehugger
Change-Id: Ib7cd7b7eaffa55ec2884a096a1c11739b12af6d1
parent 782036b7
Loading
Loading
Loading
Loading
+7 −20
Original line number Diff line number Diff line
@@ -509,16 +509,14 @@ struct UsbFfsConnection : public Connection {
            }

            if (id.direction == TransferDirection::READ) {
                if (!HandleRead(id, event.res)) {
                    return;
                }
                HandleRead(id, event.res);
            } else {
                HandleWrite(id);
            }
        }
    }

    bool HandleRead(TransferId id, int64_t size) {
    void HandleRead(TransferId id, int64_t size) {
        uint64_t read_idx = id.id % kUsbReadQueueDepth;
        IoBlock* block = &read_requests_[read_idx];
        block->pending = false;
@@ -528,7 +526,7 @@ struct UsbFfsConnection : public Connection {
        if (block->id().id != needed_read_id_) {
            LOG(VERBOSE) << "read " << block->id().id << " completed while waiting for "
                         << needed_read_id_;
            return true;
            return;
        }

        for (uint64_t id = needed_read_id_;; ++id) {
@@ -537,22 +535,15 @@ struct UsbFfsConnection : public Connection {
            if (current_block->pending) {
                break;
            }
            if (!ProcessRead(current_block)) {
                return false;
            }
            ProcessRead(current_block);
            ++needed_read_id_;
        }

        return true;
    }

    bool ProcessRead(IoBlock* block) {
    void ProcessRead(IoBlock* block) {
        if (!block->payload->empty()) {
            if (!incoming_header_.has_value()) {
                if (block->payload->size() != sizeof(amessage)) {
                    HandleError("received packet of unexpected length while reading header");
                    return false;
                }
                CHECK_EQ(sizeof(amessage), block->payload->size());
                amessage msg;
                memcpy(&msg, block->payload->data(), sizeof(amessage));
                LOG(DEBUG) << "USB read:" << dump_header(&msg);
@@ -560,10 +551,7 @@ struct UsbFfsConnection : public Connection {
            } else {
                size_t bytes_left = incoming_header_->data_length - incoming_payload_.size();
                Block payload = std::move(*block->payload);
                if (block->payload->size() > bytes_left) {
                    HandleError("received too many bytes while waiting for payload");
                    return false;
                }
                CHECK_LE(payload.size(), bytes_left);
                incoming_payload_.append(std::make_unique<Block>(std::move(payload)));
            }

@@ -582,7 +570,6 @@ struct UsbFfsConnection : public Connection {

        PrepareReadBlock(block, block->id().id + kUsbReadQueueDepth);
        SubmitRead(block);
        return true;
    }

    bool SubmitRead(IoBlock* block) {