Loading core/java/android/os/Parcelable.java +31 −2 Original line number Diff line number Diff line Loading @@ -99,6 +99,35 @@ public interface Parcelable { @Retention(RetentionPolicy.SOURCE) public @interface ContentsFlags {} /** @hide */ @IntDef(flag = true, prefix = { "PARCELABLE_STABILITY_" }, value = { PARCELABLE_STABILITY_LOCAL, PARCELABLE_STABILITY_VINTF, }) @Retention(RetentionPolicy.SOURCE) public @interface Stability {} /** * Something that is not meant to cross compilation boundaries. * * Note: unlike binder/Stability.h which uses bitsets to detect stability, * since we don't currently have a notion of different local locations, * higher stability levels are formed at higher levels. * * For instance, contained entirely within system partitions. * @see #getStability() * @see ParcelableHolder * @hide */ public static final int PARCELABLE_STABILITY_LOCAL = 0x0000; /** * Something that is meant to be used between system and vendor. * @see #getStability() * @see ParcelableHolder * @hide */ public static final int PARCELABLE_STABILITY_VINTF = 0x0001; /** * Descriptor bit used with {@link #describeContents()}: indicates that * the Parcelable object's flattened representation includes a file descriptor. Loading Loading @@ -129,8 +158,8 @@ public interface Parcelable { * @return true if this parcelable is stable. * @hide */ default boolean isStable() { return false; default @Stability int getStability() { return PARCELABLE_STABILITY_LOCAL; } /** Loading core/java/android/os/ParcelableHolder.java +10 −9 Original line number Diff line number Diff line Loading @@ -37,10 +37,10 @@ public final class ParcelableHolder implements Parcelable { * if {@link ParcelableHolder} contains value, otherwise, both are null. */ private Parcel mParcel; private boolean mIsStable = false; private @Parcelable.Stability int mStability = Parcelable.PARCELABLE_STABILITY_LOCAL; public ParcelableHolder(boolean isStable) { mIsStable = isStable; public ParcelableHolder(@Parcelable.Stability int stability) { mStability = stability; } private ParcelableHolder() { Loading @@ -50,11 +50,11 @@ public final class ParcelableHolder implements Parcelable { /** * {@link ParcelableHolder}'s stability is determined by the parcelable * which contains this ParcelableHolder. * For more detail refer to {@link Parcelable#isStable}. * For more detail refer to {@link Parcelable#getStability}. */ @Override public boolean isStable() { return mIsStable; public @Parcelable.Stability int getStability() { return mStability; } @NonNull Loading @@ -81,7 +81,8 @@ public final class ParcelableHolder implements Parcelable { * @return {@code false} if the parcelable's stability is more unstable ParcelableHolder. */ public synchronized boolean setParcelable(@Nullable Parcelable p) { if (p != null && this.isStable() && !p.isStable()) { // a ParcelableHolder can only hold things at its stability or higher if (p != null && this.getStability() > p.getStability()) { return false; } mParcelable = p; Loading Loading @@ -123,7 +124,7 @@ public final class ParcelableHolder implements Parcelable { * Read ParcelableHolder from a parcel. */ public synchronized void readFromParcel(@NonNull Parcel parcel) { this.mIsStable = parcel.readBoolean(); this.mStability = parcel.readInt(); mParcelable = null; Loading @@ -145,7 +146,7 @@ public final class ParcelableHolder implements Parcelable { @Override public synchronized void writeToParcel(@NonNull Parcel parcel, int flags) { parcel.writeBoolean(this.mIsStable); parcel.writeInt(this.mStability); if (mParcel != null) { parcel.writeInt(mParcel.dataSize()); Loading Loading
core/java/android/os/Parcelable.java +31 −2 Original line number Diff line number Diff line Loading @@ -99,6 +99,35 @@ public interface Parcelable { @Retention(RetentionPolicy.SOURCE) public @interface ContentsFlags {} /** @hide */ @IntDef(flag = true, prefix = { "PARCELABLE_STABILITY_" }, value = { PARCELABLE_STABILITY_LOCAL, PARCELABLE_STABILITY_VINTF, }) @Retention(RetentionPolicy.SOURCE) public @interface Stability {} /** * Something that is not meant to cross compilation boundaries. * * Note: unlike binder/Stability.h which uses bitsets to detect stability, * since we don't currently have a notion of different local locations, * higher stability levels are formed at higher levels. * * For instance, contained entirely within system partitions. * @see #getStability() * @see ParcelableHolder * @hide */ public static final int PARCELABLE_STABILITY_LOCAL = 0x0000; /** * Something that is meant to be used between system and vendor. * @see #getStability() * @see ParcelableHolder * @hide */ public static final int PARCELABLE_STABILITY_VINTF = 0x0001; /** * Descriptor bit used with {@link #describeContents()}: indicates that * the Parcelable object's flattened representation includes a file descriptor. Loading Loading @@ -129,8 +158,8 @@ public interface Parcelable { * @return true if this parcelable is stable. * @hide */ default boolean isStable() { return false; default @Stability int getStability() { return PARCELABLE_STABILITY_LOCAL; } /** Loading
core/java/android/os/ParcelableHolder.java +10 −9 Original line number Diff line number Diff line Loading @@ -37,10 +37,10 @@ public final class ParcelableHolder implements Parcelable { * if {@link ParcelableHolder} contains value, otherwise, both are null. */ private Parcel mParcel; private boolean mIsStable = false; private @Parcelable.Stability int mStability = Parcelable.PARCELABLE_STABILITY_LOCAL; public ParcelableHolder(boolean isStable) { mIsStable = isStable; public ParcelableHolder(@Parcelable.Stability int stability) { mStability = stability; } private ParcelableHolder() { Loading @@ -50,11 +50,11 @@ public final class ParcelableHolder implements Parcelable { /** * {@link ParcelableHolder}'s stability is determined by the parcelable * which contains this ParcelableHolder. * For more detail refer to {@link Parcelable#isStable}. * For more detail refer to {@link Parcelable#getStability}. */ @Override public boolean isStable() { return mIsStable; public @Parcelable.Stability int getStability() { return mStability; } @NonNull Loading @@ -81,7 +81,8 @@ public final class ParcelableHolder implements Parcelable { * @return {@code false} if the parcelable's stability is more unstable ParcelableHolder. */ public synchronized boolean setParcelable(@Nullable Parcelable p) { if (p != null && this.isStable() && !p.isStable()) { // a ParcelableHolder can only hold things at its stability or higher if (p != null && this.getStability() > p.getStability()) { return false; } mParcelable = p; Loading Loading @@ -123,7 +124,7 @@ public final class ParcelableHolder implements Parcelable { * Read ParcelableHolder from a parcel. */ public synchronized void readFromParcel(@NonNull Parcel parcel) { this.mIsStable = parcel.readBoolean(); this.mStability = parcel.readInt(); mParcelable = null; Loading @@ -145,7 +146,7 @@ public final class ParcelableHolder implements Parcelable { @Override public synchronized void writeToParcel(@NonNull Parcel parcel, int flags) { parcel.writeBoolean(this.mIsStable); parcel.writeInt(this.mStability); if (mParcel != null) { parcel.writeInt(mParcel.dataSize()); Loading