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

Commit ab0fca88 authored by Pinyao Ting's avatar Pinyao Ting
Browse files

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
parent 02637322
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -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);
            }
        }