diff options
| -rw-r--r-- | libs/binder/ndk/include_ndk/android/binder_parcel.h | 25 | ||||
| -rw-r--r-- | libs/binder/ndk/libbinder_ndk.map.txt | 2 | ||||
| -rw-r--r-- | libs/binder/ndk/parcel.cpp | 13 |
3 files changed, 40 insertions, 0 deletions
diff --git a/libs/binder/ndk/include_ndk/android/binder_parcel.h b/libs/binder/ndk/include_ndk/android/binder_parcel.h index 3594349021..866af70157 100644 --- a/libs/binder/ndk/include_ndk/android/binder_parcel.h +++ b/libs/binder/ndk/include_ndk/android/binder_parcel.h @@ -54,6 +54,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 * will always be strictly less than or equal to the maximum size that can be held in a size_t and diff --git a/libs/binder/ndk/libbinder_ndk.map.txt b/libs/binder/ndk/libbinder_ndk.map.txt index 41df90bd64..4328b6ea6d 100644 --- a/libs/binder/ndk/libbinder_ndk.map.txt +++ b/libs/binder/ndk/libbinder_ndk.map.txt @@ -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; diff --git a/libs/binder/ndk/parcel.cpp b/libs/binder/ndk/parcel.cpp index 3c321009f8..2d68559395 100644 --- a/libs/binder/ndk/parcel.cpp +++ b/libs/binder/ndk/parcel.cpp @@ -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); |