diff options
| author | 2017-09-19 16:44:26 +0000 | |
|---|---|---|
| committer | 2017-09-19 16:44:26 +0000 | |
| commit | c26e534bef58ba679aa17334176a6d080d44ab8b (patch) | |
| tree | 8cc26bf576a98a9f23349c4a23dcf81daf8e1d52 | |
| parent | 836f2fe701595d4eccb4f1f9cd5dbc7addc0093f (diff) | |
| parent | 8b2e42102564b3ce989251b5dc3021207dd186da (diff) | |
Merge "Fix ImsCallProfile parceling and add protection for invalid parcelables." am: 99d28ebbda
am: 8b2e421025
Change-Id: I2b73595add333660c2a4b62538334b8cb38ac9cb
| -rw-r--r-- | telephony/java/com/android/ims/ImsCallProfile.java | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/telephony/java/com/android/ims/ImsCallProfile.java b/telephony/java/com/android/ims/ImsCallProfile.java index 36abfc9d288e..489c208a0d46 100644 --- a/telephony/java/com/android/ims/ImsCallProfile.java +++ b/telephony/java/com/android/ims/ImsCallProfile.java @@ -19,7 +19,9 @@ package com.android.ims; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; +import android.os.PersistableBundle; import android.telecom.VideoProfile; +import android.util.Log; import com.android.internal.telephony.PhoneConstants; @@ -216,6 +218,29 @@ public class ImsCallProfile implements Parcelable { public int mServiceType; public int mCallType; public int mRestrictCause = CALL_RESTRICT_CAUSE_NONE; + + /** + * Extras associated with this {@link ImsCallProfile}. + * <p> + * Valid data types include: + * <ul> + * <li>{@link Integer} (and int)</li> + * <li>{@link Long} (and long)</li> + * <li>{@link Double} (and double)</li> + * <li>{@link String}</li> + * <li>{@code int[]}</li> + * <li>{@code long[]}</li> + * <li>{@code double[]}</li> + * <li>{@code String[]}</li> + * <li>{@link PersistableBundle}</li> + * <li>{@link Boolean} (and boolean)</li> + * <li>{@code boolean[]}</li> + * <li>Other {@link Parcelable} classes in the {@code android.*} namespace.</li> + * </ul> + * <p> + * Invalid types will be removed when the {@link ImsCallProfile} is parceled for transmit across + * a {@link android.os.Binder}. + */ public Bundle mCallExtras; public ImsStreamMediaProfile mMediaProfile; @@ -315,16 +340,17 @@ public class ImsCallProfile implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { + Bundle filteredExtras = maybeCleanseExtras(mCallExtras); out.writeInt(mServiceType); out.writeInt(mCallType); - out.writeParcelable(mCallExtras, 0); + out.writeBundle(filteredExtras); out.writeParcelable(mMediaProfile, 0); } private void readFromParcel(Parcel in) { mServiceType = in.readInt(); mCallType = in.readInt(); - mCallExtras = in.readParcelable(null); + mCallExtras = in.readBundle(); mMediaProfile = in.readParcelable(null); } @@ -465,6 +491,31 @@ public class ImsCallProfile implements Parcelable { } /** + * Cleanses a {@link Bundle} to ensure that it contains only data of type: + * 1. Primitive data types (e.g. int, bool, and other values determined by + * {@link android.os.PersistableBundle#isValidType(Object)}). + * 2. Other Bundles. + * 3. {@link Parcelable} objects in the {@code android.*} namespace. + * @param extras the source {@link Bundle} + * @return where all elements are valid types the source {@link Bundle} is returned unmodified, + * otherwise a copy of the {@link Bundle} with the invalid elements is returned. + */ + private Bundle maybeCleanseExtras(Bundle extras) { + if (extras == null) { + return null; + } + + int startSize = extras.size(); + Bundle filtered = extras.filterValues(); + int endSize = filtered.size(); + if (startSize != endSize) { + Log.i(TAG, "maybeCleanseExtras: " + (startSize - endSize) + " extra values were " + + "removed - only primitive types and system parcelables are permitted."); + } + return filtered; + } + + /** * Determines if a video state is set in a video state bit-mask. * * @param videoState The video state bit mask. |