diff options
| -rw-r--r-- | core/api/current.txt | 18 | ||||
| -rw-r--r-- | core/java/android/os/Parcel.java | 55 |
2 files changed, 62 insertions, 11 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index f15d457f3c24..087b54ee86f2 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -31446,9 +31446,9 @@ package android.os { method public byte[] marshall(); method @NonNull public static android.os.Parcel obtain(); method @NonNull public static android.os.Parcel obtain(@NonNull android.os.IBinder); - method @Nullable public Object[] readArray(@Nullable ClassLoader); + method @Deprecated @Nullable public Object[] readArray(@Nullable ClassLoader); method @Nullable public <T> T[] readArray(@Nullable ClassLoader, @NonNull Class<T>); - method @Nullable public java.util.ArrayList readArrayList(@Nullable ClassLoader); + method @Deprecated @Nullable public java.util.ArrayList readArrayList(@Nullable ClassLoader); method @Nullable public <T> java.util.ArrayList<T> readArrayList(@Nullable ClassLoader, @NonNull Class<? extends T>); method public void readBinderArray(@NonNull android.os.IBinder[]); method public void readBinderList(@NonNull java.util.List<android.os.IBinder>); @@ -31466,32 +31466,32 @@ package android.os { method public android.os.ParcelFileDescriptor readFileDescriptor(); method public float readFloat(); method public void readFloatArray(@NonNull float[]); - method @Nullable public java.util.HashMap readHashMap(@Nullable ClassLoader); + method @Deprecated @Nullable public java.util.HashMap readHashMap(@Nullable ClassLoader); method @Nullable public <K, V> java.util.HashMap<K,V> readHashMap(@Nullable ClassLoader, @NonNull Class<? extends K>, @NonNull Class<? extends V>); method public int readInt(); method public void readIntArray(@NonNull int[]); method public <T extends android.os.IInterface> void readInterfaceArray(@NonNull T[], @NonNull java.util.function.Function<android.os.IBinder,T>); method public <T extends android.os.IInterface> void readInterfaceList(@NonNull java.util.List<T>, @NonNull java.util.function.Function<android.os.IBinder,T>); - method public void readList(@NonNull java.util.List, @Nullable ClassLoader); + method @Deprecated public void readList(@NonNull java.util.List, @Nullable ClassLoader); method public <T> void readList(@NonNull java.util.List<? super T>, @Nullable ClassLoader, @NonNull Class<T>); method public long readLong(); method public void readLongArray(@NonNull long[]); - method public void readMap(@NonNull java.util.Map, @Nullable ClassLoader); + method @Deprecated public void readMap(@NonNull java.util.Map, @Nullable ClassLoader); method public <K, V> void readMap(@NonNull java.util.Map<? super K,? super V>, @Nullable ClassLoader, @NonNull Class<K>, @NonNull Class<V>); - method @Nullable public <T extends android.os.Parcelable> T readParcelable(@Nullable ClassLoader); + method @Deprecated @Nullable public <T extends android.os.Parcelable> T readParcelable(@Nullable ClassLoader); method @Nullable public <T extends android.os.Parcelable> T readParcelable(@Nullable ClassLoader, @NonNull Class<T>); method @Nullable public android.os.Parcelable[] readParcelableArray(@Nullable ClassLoader); method @Nullable public <T> T[] readParcelableArray(@Nullable ClassLoader, @NonNull Class<T>); - method @Nullable public android.os.Parcelable.Creator<?> readParcelableCreator(@Nullable ClassLoader); + method @Deprecated @Nullable public android.os.Parcelable.Creator<?> readParcelableCreator(@Nullable ClassLoader); method @Nullable public <T> android.os.Parcelable.Creator<T> readParcelableCreator(@Nullable ClassLoader, @NonNull Class<T>); method @NonNull public <T extends android.os.Parcelable> java.util.List<T> readParcelableList(@NonNull java.util.List<T>, @Nullable ClassLoader); method @Nullable public android.os.PersistableBundle readPersistableBundle(); method @Nullable public android.os.PersistableBundle readPersistableBundle(@Nullable ClassLoader); - method @Nullable public java.io.Serializable readSerializable(); + method @Deprecated @Nullable public java.io.Serializable readSerializable(); method @Nullable public <T extends java.io.Serializable> T readSerializable(@Nullable ClassLoader, @NonNull Class<T>); method @NonNull public android.util.Size readSize(); method @NonNull public android.util.SizeF readSizeF(); - method @Nullable public <T> android.util.SparseArray<T> readSparseArray(@Nullable ClassLoader); + method @Deprecated @Nullable public <T> android.util.SparseArray<T> readSparseArray(@Nullable ClassLoader); method @Nullable public <T> android.util.SparseArray<T> readSparseArray(@Nullable ClassLoader, @NonNull Class<? extends T>); method @Nullable public android.util.SparseBooleanArray readSparseBooleanArray(); method @Nullable public String readString(); diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java index 09e5a8f7382c..7bdb6b90c07b 100644 --- a/core/java/android/os/Parcel.java +++ b/core/java/android/os/Parcel.java @@ -2990,7 +2990,12 @@ public final class Parcel { * Please use {@link #readBundle(ClassLoader)} instead (whose data must have * been written with {@link #writeBundle}. Read into an existing Map object * from the parcel at the current dataPosition(). + * + * @deprecated Consider using {@link #readBundle(ClassLoader)} as stated above, in case this + * method is still preferred use the type-safer version {@link #readMap(Map, ClassLoader, + * Class, Class)} starting from Android {@link Build.VERSION_CODES#TIRAMISU}. */ + @Deprecated public final void readMap(@NonNull Map outVal, @Nullable ClassLoader loader) { int n = readInt(); readMapInternal(outVal, n, loader, /* clazzKey */ null, /* clazzValue */ null); @@ -3016,7 +3021,14 @@ public final class Parcel { * Read into an existing List object from the parcel at the current * dataPosition(), using the given class loader to load any enclosed * Parcelables. If it is null, the default class loader is used. + * + * @deprecated Use the type-safer version {@link #readList(List, ClassLoader, Class)} starting + * from Android {@link Build.VERSION_CODES#TIRAMISU}. Also consider changing the format to + * use {@link #readTypedList(List, Parcelable.Creator)} if possible (eg. if the items' + * class is final) since this is also more performant. Note that changing to the latter + * also requires changing the writes. */ + @Deprecated public final void readList(@NonNull List outVal, @Nullable ClassLoader loader) { int N = readInt(); readListInternal(outVal, N, loader, /* clazz */ null); @@ -3043,10 +3055,14 @@ public final class Parcel { * object from the parcel at the current dataPosition(), using the given * class loader to load any enclosed Parcelables. Returns null if * the previously written map object was null. + * + * @deprecated Consider using {@link #readBundle(ClassLoader)} as stated above, in case this + * method is still preferred use the type-safer version {@link #readHashMap(ClassLoader, + * Class, Class)} starting from Android {@link Build.VERSION_CODES#TIRAMISU}. */ + @Deprecated @Nullable - public final HashMap readHashMap(@Nullable ClassLoader loader) - { + public HashMap readHashMap(@Nullable ClassLoader loader) { int n = readInt(); if (n < 0) { return null; @@ -3247,7 +3263,14 @@ public final class Parcel { * dataPosition(). Returns null if the previously written list object was * null. The given class loader will be used to load any enclosed * Parcelables. + * + * @deprecated Use the type-safer version {@link #readArrayList(ClassLoader, Class)} starting + * from Android {@link Build.VERSION_CODES#TIRAMISU}. Also consider changing the format to + * use {@link #createTypedArrayList(Parcelable.Creator)} if possible (eg. if the items' + * class is final) since this is also more performant. Note that changing to the latter + * also requires changing the writes. */ + @Deprecated @Nullable public ArrayList readArrayList(@Nullable ClassLoader loader) { return readArrayListInternal(loader, /* clazz */ null); @@ -3274,7 +3297,14 @@ public final class Parcel { * dataPosition(). Returns null if the previously written array was * null. The given class loader will be used to load any enclosed * Parcelables. + * + * @deprecated Use the type-safer version {@link #readArray(ClassLoader, Class)} starting from + * Android {@link Build.VERSION_CODES#TIRAMISU}. Also consider changing the format to use + * {@link #createTypedArray(Parcelable.Creator)} if possible (eg. if the items' class is + * final) since this is also more performant. Note that changing to the latter also + * requires changing the writes. */ + @Deprecated @Nullable public Object[] readArray(@Nullable ClassLoader loader) { return readArrayInternal(loader, /* clazz */ null); @@ -3300,7 +3330,14 @@ public final class Parcel { * dataPosition(). Returns null if the previously written list object was * null. The given class loader will be used to load any enclosed * Parcelables. + * + * @deprecated Use the type-safer version {@link #readSparseArray(ClassLoader, Class)} starting + * from Android {@link Build.VERSION_CODES#TIRAMISU}. Also consider changing the format to + * use {@link #createTypedSparseArray(Parcelable.Creator)} if possible (eg. if the items' + * class is final) since this is also more performant. Note that changing to the latter + * also requires changing the writes. */ + @Deprecated @Nullable public <T> SparseArray<T> readSparseArray(@Nullable ClassLoader loader) { return readSparseArrayInternal(loader, /* clazz */ null); @@ -4107,7 +4144,13 @@ public final class Parcel { * object has been written. * @throws BadParcelableException Throws BadParcelableException if there * was an error trying to instantiate the Parcelable. + * + * @deprecated Use the type-safer version {@link #readParcelable(ClassLoader, Class)} starting + * from Android {@link Build.VERSION_CODES#TIRAMISU}. Also consider changing the format to + * use {@link Parcelable.Creator#createFromParcel(Parcel)} if possible since this is also + * more performant. Note that changing to the latter also requires changing the writes. */ + @Deprecated @Nullable public final <T extends Parcelable> T readParcelable(@Nullable ClassLoader loader) { return readParcelableInternal(loader, /* clazz */ null); @@ -4176,7 +4219,11 @@ public final class Parcel { * read the {@link Parcelable.Creator}. * * @see #writeParcelableCreator + * + * @deprecated Use the type-safer version {@link #readParcelableCreator(ClassLoader, Class)} + * starting from Android {@link Build.VERSION_CODES#TIRAMISU}. */ + @Deprecated @Nullable public final Parcelable.Creator<?> readParcelableCreator(@Nullable ClassLoader loader) { return readParcelableCreatorInternal(loader, /* clazz */ null); @@ -4337,7 +4384,11 @@ public final class Parcel { * Read and return a new Serializable object from the parcel. * @return the Serializable object, or null if the Serializable name * wasn't found in the parcel. + * + * @deprecated Use the type-safer version {@link #readSerializable(ClassLoader, Class)} starting + * from Android {@link Build.VERSION_CODES#TIRAMISU}. */ + @Deprecated @Nullable public Serializable readSerializable() { return readSerializableInternal(/* loader */ null, /* clazz */ null); |