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

Commit b2cacbb9 authored by Tao Bao's avatar Tao Bao Committed by android-build-merger
Browse files

Merge changes from topic "libsparse-callback"

am: 49b7f296

Change-Id: I106758e1ba319e0b2f1a912fe383f5ab5752ee2f
parents 315efbeb 49b7f296
Loading
Loading
Loading
Loading
+11 −15
Original line number Diff line number Diff line
@@ -278,19 +278,14 @@ int64_t fb_upload_data(Transport* transport, const char* outfile) {
    return _command_end(transport);
}

#define TRANSPORT_BUF_SIZE 1024
static constexpr size_t TRANSPORT_BUF_SIZE = 1024;
static char transport_buf[TRANSPORT_BUF_SIZE];
static int transport_buf_len;

static int fb_download_data_sparse_write(void *priv, const void *data, int len)
{
    int r;
    Transport* transport = reinterpret_cast<Transport*>(priv);
    int to_write;
    const char* ptr = reinterpret_cast<const char*>(data);
static size_t transport_buf_len;

static int fb_download_data_sparse_write(void* priv, const void* data, size_t len) {
    const char* ptr = static_cast<const char*>(data);
    if (transport_buf_len) {
        to_write = std::min(TRANSPORT_BUF_SIZE - transport_buf_len, len);
        size_t to_write = std::min(TRANSPORT_BUF_SIZE - transport_buf_len, len);

        memcpy(transport_buf + transport_buf_len, ptr, to_write);
        transport_buf_len += to_write;
@@ -298,9 +293,10 @@ static int fb_download_data_sparse_write(void *priv, const void *data, int len)
        len -= to_write;
    }

    Transport* transport = static_cast<Transport*>(priv);
    if (transport_buf_len == TRANSPORT_BUF_SIZE) {
        r = _command_write_data(transport, transport_buf, TRANSPORT_BUF_SIZE);
        if (r != TRANSPORT_BUF_SIZE) {
        int64_t r = _command_write_data(transport, transport_buf, TRANSPORT_BUF_SIZE);
        if (r != static_cast<int64_t>(TRANSPORT_BUF_SIZE)) {
            return -1;
        }
        transport_buf_len = 0;
@@ -311,9 +307,9 @@ static int fb_download_data_sparse_write(void *priv, const void *data, int len)
            g_error = "internal error: transport_buf not empty";
            return -1;
        }
        to_write = round_down(len, TRANSPORT_BUF_SIZE);
        r = _command_write_data(transport, ptr, to_write);
        if (r != to_write) {
        size_t to_write = round_down(len, TRANSPORT_BUF_SIZE);
        int64_t r = _command_write_data(transport, ptr, to_write);
        if (r != static_cast<int64_t>(to_write)) {
            return -1;
        }
        ptr += to_write;