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

Commit 7d3c86cc authored by Hao Ke's avatar Hao Ke Committed by Automerger Merge Worker
Browse files

Merge "Set default ClassLoader for Parcel readSerializable API." am:...

Merge "Set default ClassLoader for Parcel readSerializable API." am: 3760188d am: d0ba4745 am: 99c9242a am: 9af122c2

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1899432

Change-Id: Ic8c06a10c75fa7a733fae2d43d31e7259fe7872e
parents 57cae553 9af122c2
Loading
Loading
Loading
Loading
+10 −4
Original line number Original line Diff line number Diff line
@@ -4430,6 +4430,9 @@ public final class Parcel {
     * @return the Serializable object, or null if the Serializable name
     * @return the Serializable object, or null if the Serializable name
     * wasn't found in the parcel.
     * wasn't found in the parcel.
     *
     *
     * Unlike {@link #readSerializable(ClassLoader, Class)}, it uses the nearest valid class loader
     * up the execution stack to instantiate the Serializable object.
     *
     * @deprecated Use the type-safer version {@link #readSerializable(ClassLoader, Class)} starting
     * @deprecated Use the type-safer version {@link #readSerializable(ClassLoader, Class)} starting
     *       from Android {@link Build.VERSION_CODES#TIRAMISU}.
     *       from Android {@link Build.VERSION_CODES#TIRAMISU}.
     */
     */
@@ -4440,9 +4443,11 @@ public final class Parcel {
    }
    }


    /**
    /**
     * Same as {@link #readSerializable()} but accepts {@code loader} parameter
     * Same as {@link #readSerializable()} but accepts {@code loader} and {@code clazz} parameters.
     * as the primary classLoader for resolving the Serializable class; and {@code clazz} parameter
     *
     * as the required type.
     * @param loader A ClassLoader from which to instantiate the Serializable object,
     * or null for the default class loader.
     * @param clazz The type of the object expected.
     *
     *
     * @throws BadParcelableException Throws BadParcelableException if the item to be deserialized
     * @throws BadParcelableException Throws BadParcelableException if the item to be deserialized
     * is not an instance of that class or any of its children class or there there was an error
     * is not an instance of that class or any of its children class or there there was an error
@@ -4452,7 +4457,8 @@ public final class Parcel {
    public <T extends Serializable> T readSerializable(@Nullable ClassLoader loader,
    public <T extends Serializable> T readSerializable(@Nullable ClassLoader loader,
            @NonNull Class<T> clazz) {
            @NonNull Class<T> clazz) {
        Objects.requireNonNull(clazz);
        Objects.requireNonNull(clazz);
        return readSerializableInternal(loader, clazz);
        return readSerializableInternal(
                loader == null ? getClass().getClassLoader() : loader, clazz);
    }
    }


    /**
    /**