Merge "Added End-of-Parcel check API." am: 93b3eb84ec am: 479f10d9b7 am: 258395cc81 am: 4e657826b5

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1876569

Change-Id: Ifc7f5b520cd39702ecb24bc419bee2caa3273412
This commit is contained in:
Hao Ke
2021-12-04 01:01:03 +00:00
committed by Automerger Merge Worker
2 changed files with 14 additions and 0 deletions

View File

@@ -31815,6 +31815,7 @@ package android.os {
method public int dataPosition();
method public int dataSize();
method public void enforceInterface(@NonNull String);
method public void enforceNoDataAvail();
method public boolean hasFileDescriptors();
method public boolean hasFileDescriptors(int, int);
method public byte[] marshall();

View File

@@ -845,6 +845,19 @@ public final class Parcel {
nativeEnforceInterface(mNativePtr, interfaceName);
}
/**
* Verify there are no bytes left to be read on the Parcel.
*
* @throws BadParcelableException If the current position hasn't reached the end of the Parcel.
* When used over binder, this exception should propagate to the caller.
*/
public void enforceNoDataAvail() {
final int n = dataAvail();
if (n > 0) {
throw new BadParcelableException("Parcel data not fully consumed, unread size: " + n);
}
}
/**
* Writes the work source uid to the request headers.
*