From 69aa938dc15e9910ff9aa18037cc7df6146920f4 Mon Sep 17 00:00:00 2001 From: Terry Wang Date: Tue, 23 Nov 2021 15:25:17 -0800 Subject: [PATCH] Add @SystemApi annotation to parcel.writeBlob and readBlob. AppSearch will put text-based document via binder to server side. Parcel.writeBlob could take care of decide where to put in Android Shared Memory if data is too large. Remove {@SystemApi} to make it available for AppSearch. Bug: 185441119 Test: presubmit Change-Id: I95218fdca2baa5b4a287f05c9d79273b4a6e622c --- core/api/current.txt | 3 +++ core/java/android/os/Parcel.java | 23 +++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 32865ad929e96..c22306c47198e 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -31728,6 +31728,7 @@ package android.os { method @Nullable public java.util.ArrayList readArrayList(@Nullable ClassLoader, @NonNull Class); method public void readBinderArray(@NonNull android.os.IBinder[]); method public void readBinderList(@NonNull java.util.List); + method @Nullable public byte[] readBlob(); method public boolean readBoolean(); method public void readBooleanArray(@NonNull boolean[]); method @Nullable public android.os.Bundle readBundle(); @@ -31786,6 +31787,8 @@ package android.os { method public void writeArray(@Nullable Object[]); method public void writeBinderArray(@Nullable android.os.IBinder[]); method public void writeBinderList(@Nullable java.util.List); + method public void writeBlob(@Nullable byte[]); + method public void writeBlob(@Nullable byte[], int, int); method public void writeBoolean(boolean); method public void writeBooleanArray(@Nullable boolean[]); method public void writeBundle(@Nullable android.os.Bundle); diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java index 7bdb6b90c07b8..d0842d660396a 100644 --- a/core/java/android/os/Parcel.java +++ b/core/java/android/os/Parcel.java @@ -902,11 +902,15 @@ public final class Parcel { /** * Write a blob of data into the parcel at the current {@link #dataPosition}, * growing {@link #dataCapacity} if needed. + * + *

If the blob is small, then it is stored in-place, otherwise it is transferred by way of + * an anonymous shared memory region. If you prefer send in-place, please use + * {@link #writeByteArray(byte[])}. + * * @param b Bytes to place into the parcel. - * {@hide} - * {@SystemApi} + * + * @see #readBlob() */ - @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public final void writeBlob(@Nullable byte[] b) { writeBlob(b, 0, (b != null) ? b.length : 0); } @@ -914,11 +918,16 @@ public final class Parcel { /** * Write a blob of data into the parcel at the current {@link #dataPosition}, * growing {@link #dataCapacity} if needed. + * + *

If the blob is small, then it is stored in-place, otherwise it is transferred by way of + * an anonymous shared memory region. If you prefer send in-place, please use + * {@link #writeByteArray(byte[], int, int)}. + * * @param b Bytes to place into the parcel. * @param offset Index of first byte to be written. * @param len Number of bytes to write. - * {@hide} - * {@SystemApi} + * + * @see #readBlob() */ public final void writeBlob(@Nullable byte[] b, int offset, int len) { if (b == null) { @@ -3197,10 +3206,8 @@ public final class Parcel { /** * Read a blob of data from the parcel and return it as a byte array. - * {@hide} - * {@SystemApi} + * @see #writeBlob(byte[], int, int) */ - @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @Nullable public final byte[] readBlob() { return nativeReadBlob(mNativePtr);