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

Commit 124e39bd authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Rewrite battery history storage."

parents af491da9 97e2bcd7
Loading
Loading
Loading
Loading
+11 −7
Original line number Original line Diff line number Diff line
@@ -338,7 +338,7 @@ void Parcel::setDataPosition(size_t pos) const


status_t Parcel::setDataCapacity(size_t size)
status_t Parcel::setDataCapacity(size_t size)
{
{
    if (size > mDataSize) return continueWrite(size);
    if (size > mDataCapacity) return continueWrite(size);
    return NO_ERROR;
    return NO_ERROR;
}
}


@@ -386,11 +386,13 @@ status_t Parcel::appendFrom(Parcel *parcel, size_t offset, size_t len)
    }
    }
    int numObjects = lastIndex - firstIndex + 1;
    int numObjects = lastIndex - firstIndex + 1;


    if ((mDataSize+len) > mDataCapacity) {
        // grow data
        // grow data
        err = growData(len);
        err = growData(len);
        if (err != NO_ERROR) {
        if (err != NO_ERROR) {
            return err;
            return err;
        }
        }
    }


    // append data
    // append data
    memcpy(mData + mDataPos, data + offset, len);
    memcpy(mData + mDataPos, data + offset, len);
@@ -1384,8 +1386,10 @@ status_t Parcel::continueWrite(size_t desired)
                return NO_MEMORY;
                return NO_MEMORY;
            }
            }
        } else {
        } else {
            if (mDataSize > desired) {
                mDataSize = desired;
                mDataSize = desired;
                LOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
                LOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
            }
            if (mDataPos > desired) {
            if (mDataPos > desired) {
                mDataPos = desired;
                mDataPos = desired;
                LOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos);
                LOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos);