Fix crash in DisplayResolveInfo writeToParcel impl

This fixes an incorrect use of List.toArray() leading to a crash

When passed no arguments, toArray returns an Object[] and not T[],
hence the unchecked cast will throw ClassCastException when this is run.

This change cleans up the parcelable implementation by replacing
writeParcelableArray with writeTypedList, which is more efficient and
avoids the conversion to/from an array entirely.

Bug: 200347466
Test: Take screenshot, tap share, long press an app, short press power
Change-Id: I225664c8709502c7e45ac06c2858c0c5ac0b7506
diff --git a/core/java/com/android/internal/app/chooser/DisplayResolveInfo.java b/core/java/com/android/internal/app/chooser/DisplayResolveInfo.java
index 5ebc915..96cc5e1b 100644
--- a/core/java/com/android/internal/app/chooser/DisplayResolveInfo.java
+++ b/core/java/com/android/internal/app/chooser/DisplayResolveInfo.java
@@ -35,7 +35,6 @@
 import com.android.internal.app.ResolverListAdapter.ResolveInfoPresentationGetter;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -206,7 +205,7 @@
         dest.writeCharSequence(mDisplayLabel);
         dest.writeCharSequence(mExtendedInfo);
         dest.writeParcelable(mResolvedIntent, 0);
-        dest.writeParcelableArray((Intent[]) mSourceIntents.toArray(), 0);
+        dest.writeTypedList(mSourceIntents);
         dest.writeBoolean(mIsSuspended);
         dest.writeBoolean(mPinned);
         dest.writeParcelable(mResolveInfo, 0);
@@ -227,9 +226,7 @@
         mDisplayLabel = in.readCharSequence();
         mExtendedInfo = in.readCharSequence();
         mResolvedIntent = in.readParcelable(null /* ClassLoader */, android.content.Intent.class);
-        mSourceIntents.addAll(
-                Arrays.asList((Intent[]) in.readParcelableArray(null /* ClassLoader */,
-                        Intent.class)));
+        in.readTypedList(mSourceIntents, Intent.CREATOR);
         mIsSuspended = in.readBoolean();
         mPinned = in.readBoolean();
         mResolveInfo = in.readParcelable(null /* ClassLoader */, android.content.pm.ResolveInfo.class);