| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.os; |
| 18 |
|
| 19 |
import android.compat.annotation.UnsupportedAppUsage; |
| 20 |
import android.util.MathUtils; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
public class ParcelableParcel implements Parcelable { |
| 27 |
final Parcel mParcel; |
| 28 |
final ClassLoader mClassLoader; |
| 29 |
|
| 30 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 31 |
public ParcelableParcel(ClassLoader loader) { |
| 32 |
mParcel = Parcel.obtain(); |
| 33 |
mClassLoader = loader; |
| 34 |
} |
| 35 |
|
| 36 |
public ParcelableParcel(Parcel src, ClassLoader loader) { |
| 37 |
mParcel = Parcel.obtain(); |
| 38 |
mClassLoader = loader; |
| 39 |
int size = src.readInt(); |
| 40 |
if (size < 0) { |
| 41 |
throw new IllegalArgumentException("Negative size read from parcel"); |
| 42 |
} |
| 43 |
|
| 44 |
int pos = src.dataPosition(); |
| 45 |
src.setDataPosition(MathUtils.addOrThrow(pos, size)); |
| 46 |
mParcel.appendFrom(src, pos, size); |
| 47 |
} |
| 48 |
|
| 49 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 50 |
public Parcel getParcel() { |
| 51 |
mParcel.setDataPosition(0); |
| 52 |
return mParcel; |
| 53 |
} |
| 54 |
|
| 55 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 56 |
public ClassLoader getClassLoader() { |
| 57 |
return mClassLoader; |
| 58 |
} |
| 59 |
|
| 60 |
@Override |
| 61 |
public int describeContents() { |
| 62 |
return 0; |
| 63 |
} |
| 64 |
|
| 65 |
@Override |
| 66 |
public void writeToParcel(Parcel dest, int flags) { |
| 67 |
dest.writeInt(mParcel.dataSize()); |
| 68 |
dest.appendFrom(mParcel, 0, mParcel.dataSize()); |
| 69 |
} |
| 70 |
|
| 71 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 72 |
public static final Parcelable.ClassLoaderCreator<ParcelableParcel> CREATOR |
| 73 |
= new Parcelable.ClassLoaderCreator<ParcelableParcel>() { |
| 74 |
public ParcelableParcel createFromParcel(Parcel in) { |
| 75 |
return new ParcelableParcel(in, null); |
| 76 |
} |
| 77 |
|
| 78 |
public ParcelableParcel createFromParcel(Parcel in, ClassLoader loader) { |
| 79 |
return new ParcelableParcel(in, loader); |
| 80 |
} |
| 81 |
|
| 82 |
public ParcelableParcel[] newArray(int size) { |
| 83 |
return new ParcelableParcel[size]; |
| 84 |
} |
| 85 |
}; |
| 86 |
} |