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

Commit 8cf510ff authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Minor fixes to fastboot_driver"

parents acc0a908 c771ae0f
Loading
Loading
Loading
Loading
+11 −6
Original line number Original line Diff line number Diff line
@@ -134,7 +134,7 @@ RetCode FastBootDriver::Partitions(std::vector<std::tuple<std::string, uint32_t>
        return ret;
        return ret;
    }
    }


    std::regex reg("partition-size[[:s:]]*:[[:s:]]*([[:w:]]+)[[:s:]]*:[[:s:]]*0x([[:d:]]+)");
    std::regex reg("partition-size[[:s:]]*:[[:s:]]*([[:w:]]+)[[:s:]]*:[[:s:]]*0x([[:xdigit:]]+)");
    std::smatch sm;
    std::smatch sm;


    for (auto& s : all) {
    for (auto& s : all) {
@@ -264,11 +264,16 @@ RetCode FastBootDriver::Upload(const std::string& outfile, std::string* response
                               std::vector<std::string>* info) {
                               std::vector<std::string>* info) {
    RetCode ret;
    RetCode ret;
    int dsize;
    int dsize;
    if ((ret = RawCommand(Commands::UPLOAD, response, info, &dsize)) || dsize == 0) {
    if ((ret = RawCommand(Commands::UPLOAD, response, info, &dsize))) {
        error_ = "Upload request failed";
        error_ = "Upload request failed: " + error_;
        return ret;
        return ret;
    }
    }


    if (!dsize) {
        error_ = "Upload request failed, device reports 0 bytes available";
        return BAD_DEV_RESP;
    }

    std::vector<char> data;
    std::vector<char> data;
    data.resize(dsize);
    data.resize(dsize);


@@ -462,10 +467,10 @@ RetCode FastBootDriver::SendBuffer(const std::vector<char>& buf) {
}
}


RetCode FastBootDriver::SendBuffer(const void* buf, size_t size) {
RetCode FastBootDriver::SendBuffer(const void* buf, size_t size) {
    // ioctl on 0-length buffer causes freezing
    if (!size) {
    if (!size) {
        return SUCCESS;
        return BAD_ARG;
    }
    }

    // Write the buffer
    // Write the buffer
    ssize_t tmp = transport->Write(buf, size);
    ssize_t tmp = transport->Write(buf, size);


@@ -521,7 +526,7 @@ int FastBootDriver::SparseWriteCallback(std::vector<char>& tpbuf, const char* da
    // Now we need to send a multiple of chunk size
    // Now we need to send a multiple of chunk size
    size_t nchunks = (len - total) / TRANSPORT_CHUNK_SIZE;
    size_t nchunks = (len - total) / TRANSPORT_CHUNK_SIZE;
    size_t nbytes = TRANSPORT_CHUNK_SIZE * nchunks;
    size_t nbytes = TRANSPORT_CHUNK_SIZE * nchunks;
    if (SendBuffer(data + total, nbytes)) {
    if (nbytes && SendBuffer(data + total, nbytes)) {  // Don't send a ZLP
        error_ = ErrnoStr("Send failed in SparseWriteCallback()");
        error_ = ErrnoStr("Send failed in SparseWriteCallback()");
        return -1;
        return -1;
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -103,7 +103,7 @@ class FastBootDriver {


    /* HELPERS */
    /* HELPERS */
    void SetInfoCallback(std::function<void(std::string&)> info);
    void SetInfoCallback(std::function<void(std::string&)> info);
    const std::string RCString(RetCode rc);
    static const std::string RCString(RetCode rc);
    std::string Error();
    std::string Error();
    RetCode WaitForDisconnect();
    RetCode WaitForDisconnect();