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

Commit 535f063b authored by Steven Moreland's avatar Steven Moreland Committed by android-build-merger
Browse files

Merge "libbinder_ndk: AParcel_(get|set)DataPosition" am: 31ca88da am: ebe8cb4a

am: 8c0b5a33

Change-Id: I3d18361b3d09968fc658d2c369bd35a91ae3c32f
parents f7bf8356 8c0b5a33
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -53,6 +53,31 @@ typedef struct AParcel AParcel;
 */
void AParcel_delete(AParcel* parcel) __INTRODUCED_IN(29);

/**
 * Sets the position within the parcel.
 *
 * \param parcel The parcel of which to set the position.
 * \param position Position of the parcel to set. This must be a value returned by
 * AParcel_getDataPosition. Positions are constant for a given parcel between processes.
 *
 * \return STATUS_OK on success. If position is negative, then STATUS_BAD_VALUE will be returned.
 */
binder_status_t AParcel_setDataPosition(const AParcel* parcel, int32_t position)
        __INTRODUCED_IN(29);

/**
 * Gets the current position within the parcel.
 *
 * \param parcel The parcel of which to get the position.
 *
 * \return The size of the parcel. This will always be greater than 0. The values returned by this
 * function before and after calling various reads and writes are not defined. Only the delta
 * between two positions between a specific sequence of calls is defined. For instance, if position
 * is X, writeBool is called, and then position is Y, readBool can be called from position X will
 * return the same value, and then position will be Y.
 */
int32_t AParcel_getDataPosition(const AParcel* parcel) __INTRODUCED_IN(29);

/**
 * This is called to allocate a buffer for a C-style string (null-terminated). The returned buffer
 * should be at least length bytes. This includes space for a null terminator. For a string, length
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ LIBBINDER_NDK { # introduced=29
    AIBinder_Weak_new;
    AIBinder_Weak_promote;
    AParcel_delete;
    AParcel_getDataPosition;
    AParcel_readBool;
    AParcel_readBoolArray;
    AParcel_readByte;
@@ -48,6 +49,7 @@ LIBBINDER_NDK { # introduced=29
    AParcel_readUint32Array;
    AParcel_readUint64;
    AParcel_readUint64Array;
    AParcel_setDataPosition;
    AParcel_writeBool;
    AParcel_writeBoolArray;
    AParcel_writeByte;
+13 −0
Original line number Diff line number Diff line
@@ -212,6 +212,19 @@ void AParcel_delete(AParcel* parcel) {
    delete parcel;
}

binder_status_t AParcel_setDataPosition(const AParcel* parcel, int32_t position) {
    if (position < 0) {
        return STATUS_BAD_VALUE;
    }

    parcel->get()->setDataPosition(position);
    return STATUS_OK;
}

int32_t AParcel_getDataPosition(const AParcel* parcel) {
    return parcel->get()->dataPosition();
}

binder_status_t AParcel_writeStrongBinder(AParcel* parcel, AIBinder* binder) {
    sp<IBinder> writeBinder = binder != nullptr ? binder->getBinder() : nullptr;
    return parcel->get()->writeStrongBinder(writeBinder);