diff options
| author | 2024-03-05 22:40:59 +0000 | |
|---|---|---|
| committer | 2024-03-06 02:45:32 +0000 | |
| commit | ab0fca883340dc83235dbf783ccb16f36f3a11a0 (patch) | |
| tree | a026769c0c6bf14e4725957f6046684f226dbd35 | |
| parent | 02637322207d444d89e6e94a9d653046938dd40a (diff) | |
Various Fixes in RemoteViews.DrawInstructions
1. NPE in RemoteViews when instantiated from DrawInstructions
RemoteViews instantiated from DrawInstruction currently doesn't require
application info, this CL adds a null check before parcel/unparcel the
applicaiton field in the RemoteViews to prevent NPE.
2. TTL Exception when passing DrawInstructions between processes
DrawInstructions may contain bytearray that exceeds the size limit in
Binder transaction which leads to transaction too large exception. This
CL instead read/write the bytearray to/from parcel as blobs.
Bug: 286130467
Test: atest RemoteViewsTest
Change-Id: I679f985dbedb8d1ad770bb04e080a7ab49d89531
| -rw-r--r-- | core/java/android/widget/RemoteViews.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index fe4ac4e2f0f1..a2d8d80096c5 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -4299,7 +4299,7 @@ public class RemoteViews implements Parcelable, Filter { } if (mode == MODE_NORMAL) { - mApplication = ApplicationInfo.CREATOR.createFromParcel(parcel); + mApplication = parcel.readTypedObject(ApplicationInfo.CREATOR); mIdealSize = parcel.readInt() == 0 ? null : SizeF.CREATOR.createFromParcel(parcel); mLayoutId = parcel.readInt(); mViewId = parcel.readInt(); @@ -6805,7 +6805,7 @@ public class RemoteViews implements Parcelable, Filter { mBitmapCache.writeBitmapsToParcel(dest, flags); mCollectionCache.writeToParcel(dest, flags, intentsToIgnore); } - mApplication.writeToParcel(dest, flags); + dest.writeTypedObject(mApplication, flags); if (mIsRoot || mIdealSize == null) { dest.writeInt(0); } else { @@ -6893,7 +6893,8 @@ public class RemoteViews implements Parcelable, Filter { * @hide */ public boolean hasSameAppInfo(ApplicationInfo info) { - return mApplication.packageName.equals(info.packageName) && mApplication.uid == info.uid; + return mApplication == null || mApplication.packageName.equals(info.packageName) + && mApplication.uid == info.uid; } /** @@ -7672,8 +7673,7 @@ public class RemoteViews implements Parcelable, Filter { byte[] instruction; final List<byte[]> instructions = new ArrayList<>(size); for (int i = 0; i < size; i++) { - instruction = new byte[in.readInt()]; - in.readByteArray(instruction); + instruction = in.readBlob(); instructions.add(instruction); } return new DrawInstructions(instructions); @@ -7688,8 +7688,7 @@ public class RemoteViews implements Parcelable, Filter { final List<byte[]> instructions = drawInstructions.mInstructions; dest.writeInt(instructions.size()); for (byte[] instruction : instructions) { - dest.writeInt(instruction.length); - dest.writeByteArray(instruction); + dest.writeBlob(instruction); } } |