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

Commit 1a5cb387 authored by Bernardo Rufino's avatar Bernardo Rufino
Browse files

Revert "Revert "Migrate unsafe parcel APIs in framework-minus-apex""

This reverts commit 331be9a6.

Reintroducing ag/16366278 since it seems unrelated to b/214053959 (more details on b/214053959#comment55).

Original commit message:

Migrate unsafe parcel APIs in framework-minus-apex

Migrate the following unsafe parcel APIs in framework-minus-apex:
* Parcel.readSerializable()
* Parcel.readArrayList()
* Parcel.readList()
* Parcel.readParcelable()
* Parcel.readParcelableList()
* Parcel.readSparseArray()

This CL was generated by applying lint fixes that infer the expected
type from the caller code and provide that as the type parameter
(ag/16365240).

A few observations:
* In some classes we couldn't migrate because the class also belonged to
another build module whose min SDK wasn't current (as is the case for
framework-minus-apex), hence I suppressed the lint check
(since I'll eventually submit the lint check to the tree).
* In some cases, I needed to do the cast in
https://stackoverflow.com/a/1080525/5765705 to make the compiler happy
since there isn't another way of providing a class of type
Class<MyClassWithGenerics<T>>.
* In the readSerializable() case, the new API also requires the class
loader, that was inferred to by InferredClass.class.getClassLoader().
* Note that automatic formatting and import rely on running hooked up
to the IDE, which wasn't the case here.

Bug: 195622897
Change-Id: I272432e6e082a973f7a50492ec35d79c2b577c93
Test: TH passes
parent d6b531e6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public final class BlobInfo implements Parcelable {
        mLeaseInfos = leaseInfos;
    }

    @SuppressWarnings("UnsafeParcelApi")
    private BlobInfo(Parcel in) {
        mId = in.readLong();
        mExpiryTimeMs = in.readLong();
+1 −0
Original line number Diff line number Diff line
@@ -1408,6 +1408,7 @@ public class AlarmManager {
         * Use the {@link #CREATOR}
         * @hide
         */
        @SuppressWarnings("UnsafeParcelApi")
        AlarmClockInfo(Parcel in) {
            mTriggerTime = in.readLong();
            mShowIntent = in.readParcelable(PendingIntent.class.getClassLoader());
+1 −0
Original line number Diff line number Diff line
@@ -881,6 +881,7 @@ public class JobInfo implements Parcelable {
        return hashCode;
    }

    @SuppressWarnings("UnsafeParcelApi")
    private JobInfo(Parcel in) {
        jobId = in.readInt();
        extras = in.readPersistableBundle();
+1 −1
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ public final class AccessibilityGestureEvent implements Parcelable {
    private AccessibilityGestureEvent(@NonNull Parcel parcel) {
        mGestureId = parcel.readInt();
        mDisplayId = parcel.readInt();
        ParceledListSlice<MotionEvent> slice = parcel.readParcelable(getClass().getClassLoader());
        ParceledListSlice<MotionEvent> slice = parcel.readParcelable(getClass().getClassLoader(), android.content.pm.ParceledListSlice.class);
        mMotionEvents = slice.getList();
    }

+2 −2
Original line number Diff line number Diff line
@@ -1094,8 +1094,8 @@ public class AccessibilityServiceInfo implements Parcelable {
        mInteractiveUiTimeout = parcel.readInt();
        flags = parcel.readInt();
        crashed = parcel.readInt() != 0;
        mComponentName = parcel.readParcelable(this.getClass().getClassLoader());
        mResolveInfo = parcel.readParcelable(null);
        mComponentName = parcel.readParcelable(this.getClass().getClassLoader(), android.content.ComponentName.class);
        mResolveInfo = parcel.readParcelable(null, android.content.pm.ResolveInfo.class);
        mSettingsActivityName = parcel.readString();
        mCapabilities = parcel.readInt();
        mSummaryResId = parcel.readInt();
Loading