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

Commit 08bbffb0 authored by Bjorn Bringert's avatar Bjorn Bringert Committed by Mike LeBeau
Browse files

Support CharSequence lists+arrays in Bundle+Intent

Fixes http://b/issue?id=2468093

Change-Id: Id82686f6ca8c9501f6db8a07018278a78ddacd05
parent 16f6354b
Loading
Loading
Loading
Loading
+112 −0
Original line number Original line Diff line number Diff line
@@ -36445,6 +36445,32 @@
<parameter name="defaultValue" type="char">
<parameter name="defaultValue" type="char">
</parameter>
</parameter>
</method>
</method>
<method name="getCharSequenceArrayExtra"
 return="java.lang.CharSequence[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
</method>
<method name="getCharSequenceArrayListExtra"
 return="java.util.ArrayList&lt;java.lang.CharSequence&gt;"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
</method>
<method name="getCharSequenceExtra"
<method name="getCharSequenceExtra"
 return="java.lang.CharSequence"
 return="java.lang.CharSequence"
 abstract="false"
 abstract="false"
@@ -36906,6 +36932,21 @@
<exception name="URISyntaxException" type="java.net.URISyntaxException">
<exception name="URISyntaxException" type="java.net.URISyntaxException">
</exception>
</exception>
</method>
</method>
<method name="putCharSequenceArrayListExtra"
 return="android.content.Intent"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
<parameter name="value" type="java.util.ArrayList&lt;java.lang.CharSequence&gt;">
</parameter>
</method>
<method name="putExtra"
<method name="putExtra"
 return="android.content.Intent"
 return="android.content.Intent"
 abstract="false"
 abstract="false"
@@ -37248,6 +37289,21 @@
>
>
<parameter name="name" type="java.lang.String">
<parameter name="name" type="java.lang.String">
</parameter>
</parameter>
<parameter name="value" type="java.lang.CharSequence[]">
</parameter>
</method>
<method name="putExtra"
 return="android.content.Intent"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
<parameter name="value" type="android.os.Bundle">
<parameter name="value" type="android.os.Bundle">
</parameter>
</parameter>
</method>
</method>
@@ -112461,6 +112517,32 @@
<parameter name="key" type="java.lang.String">
<parameter name="key" type="java.lang.String">
</parameter>
</parameter>
</method>
</method>
<method name="getCharSequenceArray"
 return="java.lang.CharSequence[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="key" type="java.lang.String">
</parameter>
</method>
<method name="getCharSequenceArrayList"
 return="java.util.ArrayList&lt;java.lang.CharSequence&gt;"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="key" type="java.lang.String">
</parameter>
</method>
<method name="getDouble"
<method name="getDouble"
 return="double"
 return="double"
 abstract="false"
 abstract="false"
@@ -112949,6 +113031,36 @@
<parameter name="value" type="java.lang.CharSequence">
<parameter name="value" type="java.lang.CharSequence">
</parameter>
</parameter>
</method>
</method>
<method name="putCharSequenceArray"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="key" type="java.lang.String">
</parameter>
<parameter name="value" type="java.lang.CharSequence[]">
</parameter>
</method>
<method name="putCharSequenceArrayList"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="key" type="java.lang.String">
</parameter>
<parameter name="value" type="java.util.ArrayList&lt;java.lang.CharSequence&gt;">
</parameter>
</method>
<method name="putDouble"
<method name="putDouble"
 return="void"
 return="void"
 abstract="false"
 abstract="false"
+74 −0
Original line number Original line Diff line number Diff line
@@ -3475,6 +3475,20 @@ public class Intent implements Parcelable, Cloneable {
        return mExtras == null ? null : mExtras.getStringArrayList(name);
        return mExtras == null ? null : mExtras.getStringArrayList(name);
    }
    }


    /**
     * Retrieve extended data from the intent.
     *
     * @param name The name of the desired item.
     *
     * @return the value of an item that previously added with putExtra()
     * or null if no ArrayList<CharSequence> value was found.
     *
     * @see #putCharSequenceArrayListExtra(String, ArrayList)
     */
    public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
        return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
    }

    /**
    /**
     * Retrieve extended data from the intent.
     * Retrieve extended data from the intent.
     *
     *
@@ -3601,6 +3615,20 @@ public class Intent implements Parcelable, Cloneable {
        return mExtras == null ? null : mExtras.getStringArray(name);
        return mExtras == null ? null : mExtras.getStringArray(name);
    }
    }


    /**
     * Retrieve extended data from the intent.
     *
     * @param name The name of the desired item.
     *
     * @return the value of an item that previously added with putExtra()
     * or null if no CharSequence array value was found.
     *
     * @see #putExtra(String, CharSequence[])
     */
    public CharSequence[] getCharSequenceArrayExtra(String name) {
        return mExtras == null ? null : mExtras.getCharSequenceArray(name);
    }

    /**
    /**
     * Retrieve extended data from the intent.
     * Retrieve extended data from the intent.
     *
     *
@@ -4303,6 +4331,29 @@ public class Intent implements Parcelable, Cloneable {
        return this;
        return this;
    }
    }


    /**
     * Add extended data to the intent.  The name must include a package
     * prefix, for example the app com.android.contacts would use names
     * like "com.android.contacts.ShowAll".
     *
     * @param name The name of the extra data, with package prefix.
     * @param value The ArrayList<CharSequence> data value.
     *
     * @return Returns the same Intent object, for chaining multiple calls
     * into a single statement.
     *
     * @see #putExtras
     * @see #removeExtra
     * @see #getCharSequenceArrayListExtra(String)
     */
    public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
        if (mExtras == null) {
            mExtras = new Bundle();
        }
        mExtras.putCharSequenceArrayList(name, value);
        return this;
    }

    /**
    /**
     * Add extended data to the intent.  The name must include a package
     * Add extended data to the intent.  The name must include a package
     * prefix, for example the app com.android.contacts would use names
     * prefix, for example the app com.android.contacts would use names
@@ -4533,6 +4584,29 @@ public class Intent implements Parcelable, Cloneable {
        return this;
        return this;
    }
    }


    /**
     * Add extended data to the intent.  The name must include a package
     * prefix, for example the app com.android.contacts would use names
     * like "com.android.contacts.ShowAll".
     *
     * @param name The name of the extra data, with package prefix.
     * @param value The CharSequence array data value.
     *
     * @return Returns the same Intent object, for chaining multiple calls
     * into a single statement.
     *
     * @see #putExtras
     * @see #removeExtra
     * @see #getCharSequenceArrayExtra(String)
     */
    public Intent putExtra(String name, CharSequence[] value) {
        if (mExtras == null) {
            mExtras = new Bundle();
        }
        mExtras.putCharSequenceArray(name, value);
        return this;
    }

    /**
    /**
     * Add extended data to the intent.  The name must include a package
     * Add extended data to the intent.  The name must include a package
     * prefix, for example the app com.android.contacts would use names
     * prefix, for example the app com.android.contacts would use names
+68 −0
Original line number Original line Diff line number Diff line
@@ -524,6 +524,18 @@ public final class Bundle implements Parcelable, Cloneable {
        mMap.put(key, value);
        mMap.put(key, value);
    }
    }


    /**
     * Inserts an ArrayList<CharSequence> value into the mapping of this Bundle, replacing
     * any existing value for the given key.  Either key or value may be null.
     *
     * @param key a String, or null
     * @param value an ArrayList<CharSequence> object, or null
     */
    public void putCharSequenceArrayList(String key, ArrayList<CharSequence> value) {
        unparcel();
        mMap.put(key, value);
    }

    /**
    /**
     * Inserts a Serializable value into the mapping of this Bundle, replacing
     * Inserts a Serializable value into the mapping of this Bundle, replacing
     * any existing value for the given key.  Either key or value may be null.
     * any existing value for the given key.  Either key or value may be null.
@@ -644,6 +656,18 @@ public final class Bundle implements Parcelable, Cloneable {
        mMap.put(key, value);
        mMap.put(key, value);
    }
    }


    /**
     * Inserts a CharSequence array value into the mapping of this Bundle, replacing
     * any existing value for the given key.  Either key or value may be null.
     *
     * @param key a String, or null
     * @param value a CharSequence array object, or null
     */
    public void putCharSequenceArray(String key, CharSequence[] value) {
        unparcel();
        mMap.put(key, value);
    }

    /**
    /**
     * Inserts a Bundle value into the mapping of this Bundle, replacing
     * Inserts a Bundle value into the mapping of this Bundle, replacing
     * any existing value for the given key.  Either key or value may be null.
     * any existing value for the given key.  Either key or value may be null.
@@ -1180,6 +1204,28 @@ public final class Bundle implements Parcelable, Cloneable {
        }
        }
    }
    }


    /**
     * Returns the value associated with the given key, or null if
     * no mapping of the desired type exists for the given key or a null
     * value is explicitly associated with the key.
     *
     * @param key a String, or null
     * @return an ArrayList<CharSequence> value, or null
     */
    public ArrayList<CharSequence> getCharSequenceArrayList(String key) {
        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (ArrayList<CharSequence>) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "ArrayList<CharSequence>", e);
            return null;
        }
    }

    /**
    /**
     * Returns the value associated with the given key, or null if
     * Returns the value associated with the given key, or null if
     * no mapping of the desired type exists for the given key or a null
     * no mapping of the desired type exists for the given key or a null
@@ -1378,6 +1424,28 @@ public final class Bundle implements Parcelable, Cloneable {
        }
        }
    }
    }


    /**
     * Returns the value associated with the given key, or null if
     * no mapping of the desired type exists for the given key or a null
     * value is explicitly associated with the key.
     *
     * @param key a String, or null
     * @return a CharSequence[] value, or null
     */
    public CharSequence[] getCharSequenceArray(String key) {
        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (CharSequence[]) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "CharSequence[]", e);
            return null;
        }
    }

    /**
    /**
     * Returns the value associated with the given key, or null if
     * Returns the value associated with the given key, or null if
     * no mapping of the desired type exists for the given key or a null
     * no mapping of the desired type exists for the given key or a null
+63 −2
Original line number Original line Diff line number Diff line
@@ -212,6 +212,7 @@ public final class Parcel {
    private static final int VAL_SERIALIZABLE = 21;
    private static final int VAL_SERIALIZABLE = 21;
    private static final int VAL_SPARSEBOOLEANARRAY = 22;
    private static final int VAL_SPARSEBOOLEANARRAY = 22;
    private static final int VAL_BOOLEANARRAY = 23;
    private static final int VAL_BOOLEANARRAY = 23;
    private static final int VAL_CHARSEQUENCEARRAY = 24;


    private static final int EX_SECURITY = -1;
    private static final int EX_SECURITY = -1;
    private static final int EX_BAD_PARCELABLE = -2;
    private static final int EX_BAD_PARCELABLE = -2;
@@ -410,6 +411,15 @@ public final class Parcel {
     */
     */
    public final native void writeString(String val);
    public final native void writeString(String val);


    /**
     * Write a CharSequence value into the parcel at the current dataPosition(),
     * growing dataCapacity() if needed.
     * @hide
     */
    public final void writeCharSequence(CharSequence val) {
        TextUtils.writeToParcel(val, this, 0);
    }

    /**
    /**
     * Write an object into the parcel at the current dataPosition(),
     * Write an object into the parcel at the current dataPosition(),
     * growing dataCapacity() if needed.
     * growing dataCapacity() if needed.
@@ -827,6 +837,21 @@ public final class Parcel {
        }
        }
    }
    }


    /**
     * @hide
     */
    public final void writeCharSequenceArray(CharSequence[] val) {
        if (val != null) {
            int N = val.length;
            writeInt(N);
            for (int i=0; i<N; i++) {
                writeCharSequence(val[i]);
            }
        } else {
            writeInt(-1);
        }
    }

    public final IBinder[] createBinderArray() {
    public final IBinder[] createBinderArray() {
        int N = readInt();
        int N = readInt();
        if (N >= 0) {
        if (N >= 0) {
@@ -1045,7 +1070,7 @@ public final class Parcel {
        } else if (v instanceof CharSequence) {
        } else if (v instanceof CharSequence) {
            // Must be after String
            // Must be after String
            writeInt(VAL_CHARSEQUENCE);
            writeInt(VAL_CHARSEQUENCE);
            TextUtils.writeToParcel((CharSequence) v, this, 0);
            writeCharSequence((CharSequence) v);
        } else if (v instanceof List) {
        } else if (v instanceof List) {
            writeInt(VAL_LIST);
            writeInt(VAL_LIST);
            writeList((List) v);
            writeList((List) v);
@@ -1061,6 +1086,10 @@ public final class Parcel {
        } else if (v instanceof String[]) {
        } else if (v instanceof String[]) {
            writeInt(VAL_STRINGARRAY);
            writeInt(VAL_STRINGARRAY);
            writeStringArray((String[]) v);
            writeStringArray((String[]) v);
        } else if (v instanceof CharSequence[]) {
            // Must be after String[] and before Object[]
            writeInt(VAL_CHARSEQUENCEARRAY);
            writeCharSequenceArray((CharSequence[]) v);
        } else if (v instanceof IBinder) {
        } else if (v instanceof IBinder) {
            writeInt(VAL_IBINDER);
            writeInt(VAL_IBINDER);
            writeStrongBinder((IBinder) v);
            writeStrongBinder((IBinder) v);
@@ -1256,6 +1285,14 @@ public final class Parcel {
     */
     */
    public final native String readString();
    public final native String readString();


    /**
     * Read a CharSequence value from the parcel at the current dataPosition().
     * @hide
     */
    public final CharSequence readCharSequence() {
        return TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(this);
    }

    /**
    /**
     * Read an object from the parcel at the current dataPosition().
     * Read an object from the parcel at the current dataPosition().
     */
     */
@@ -1388,6 +1425,27 @@ public final class Parcel {
        return array;
        return array;
    }
    }


    /**
     * Read and return a CharSequence[] object from the parcel.
     * {@hide}
     */
    public final CharSequence[] readCharSequenceArray() {
        CharSequence[] array = null;

        int length = readInt();
        if (length >= 0)
        {
            array = new CharSequence[length];

            for (int i = 0 ; i < length ; i++)
            {
                array[i] = readCharSequence();
            }
        }

        return array;
    }

    /**
    /**
     * Read and return a new ArrayList object from the parcel at the current
     * Read and return a new ArrayList object from the parcel at the current
     * dataPosition().  Returns null if the previously written list object was
     * dataPosition().  Returns null if the previously written list object was
@@ -1728,7 +1786,7 @@ public final class Parcel {
            return readInt() == 1;
            return readInt() == 1;


        case VAL_CHARSEQUENCE:
        case VAL_CHARSEQUENCE:
            return TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(this);
            return readCharSequence();


        case VAL_LIST:
        case VAL_LIST:
            return readArrayList(loader);
            return readArrayList(loader);
@@ -1742,6 +1800,9 @@ public final class Parcel {
        case VAL_STRINGARRAY:
        case VAL_STRINGARRAY:
            return readStringArray();
            return readStringArray();


        case VAL_CHARSEQUENCEARRAY:
            return readCharSequenceArray();

        case VAL_IBINDER:
        case VAL_IBINDER:
            return readStrongBinder();
            return readStrongBinder();