Bundle.java revision b3af535adec8003d42c38d289ca514c92373c1fe
1/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.os;
18
19import android.util.ArrayMap;
20import android.util.SparseArray;
21
22import java.io.Serializable;
23import java.util.ArrayList;
24import java.util.List;
25import java.util.Set;
26
27/**
28 * A mapping from String values to various Parcelable types.
29 *
30 */
31public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
32    public static final Bundle EMPTY;
33    static final Parcel EMPTY_PARCEL;
34
35    static {
36        EMPTY = new Bundle();
37        EMPTY.mMap = ArrayMap.EMPTY;
38        EMPTY_PARCEL = BaseBundle.EMPTY_PARCEL;
39    }
40
41    private boolean mHasFds = false;
42    private boolean mFdsKnown = true;
43    private boolean mAllowFds = true;
44
45    /**
46     * Constructs a new, empty Bundle.
47     */
48    public Bundle() {
49        super();
50    }
51
52    /**
53     * Constructs a Bundle whose data is stored as a Parcel.  The data
54     * will be unparcelled on first contact, using the assigned ClassLoader.
55     *
56     * @param parcelledData a Parcel containing a Bundle
57     */
58    Bundle(Parcel parcelledData) {
59        super(parcelledData);
60
61        mHasFds = mParcelledData.hasFileDescriptors();
62        mFdsKnown = true;
63    }
64
65    /* package */ Bundle(Parcel parcelledData, int length) {
66        super(parcelledData, length);
67
68        mHasFds = mParcelledData.hasFileDescriptors();
69        mFdsKnown = true;
70    }
71
72    /**
73     * Constructs a new, empty Bundle that uses a specific ClassLoader for
74     * instantiating Parcelable and Serializable objects.
75     *
76     * @param loader An explicit ClassLoader to use when instantiating objects
77     * inside of the Bundle.
78     */
79    public Bundle(ClassLoader loader) {
80        super(loader);
81    }
82
83    /**
84     * Constructs a new, empty Bundle sized to hold the given number of
85     * elements. The Bundle will grow as needed.
86     *
87     * @param capacity the initial capacity of the Bundle
88     */
89    public Bundle(int capacity) {
90        super(capacity);
91    }
92
93    /**
94     * Constructs a Bundle containing a copy of the mappings from the given
95     * Bundle.
96     *
97     * @param b a Bundle to be copied.
98     */
99    public Bundle(Bundle b) {
100        super(b);
101
102        mHasFds = b.mHasFds;
103        mFdsKnown = b.mFdsKnown;
104    }
105
106    /**
107     * Constructs a Bundle containing a copy of the mappings from the given
108     * PersistableBundle.
109     *
110     * @param b a Bundle to be copied.
111     */
112    public Bundle(PersistableBundle b) {
113        super(b);
114    }
115
116    /**
117     * Make a Bundle for a single key/value pair.
118     *
119     * @hide
120     */
121    public static Bundle forPair(String key, String value) {
122        Bundle b = new Bundle(1);
123        b.putString(key, value);
124        return b;
125    }
126
127    /**
128     * Changes the ClassLoader this Bundle uses when instantiating objects.
129     *
130     * @param loader An explicit ClassLoader to use when instantiating objects
131     * inside of the Bundle.
132     */
133    @Override
134    public void setClassLoader(ClassLoader loader) {
135        super.setClassLoader(loader);
136    }
137
138    /**
139     * Return the ClassLoader currently associated with this Bundle.
140     */
141    @Override
142    public ClassLoader getClassLoader() {
143        return super.getClassLoader();
144    }
145
146    /** @hide */
147    public boolean setAllowFds(boolean allowFds) {
148        boolean orig = mAllowFds;
149        mAllowFds = allowFds;
150        return orig;
151    }
152
153    /**
154     * Clones the current Bundle. The internal map is cloned, but the keys and
155     * values to which it refers are copied by reference.
156     */
157    @Override
158    public Object clone() {
159        return new Bundle(this);
160    }
161
162    /**
163     * Removes all elements from the mapping of this Bundle.
164     */
165    @Override
166    public void clear() {
167        super.clear();
168
169        mHasFds = false;
170        mFdsKnown = true;
171    }
172
173    /**
174     * Inserts all mappings from the given Bundle into this Bundle.
175     *
176     * @param bundle a Bundle
177     */
178    public void putAll(Bundle bundle) {
179        unparcel();
180        bundle.unparcel();
181        mMap.putAll(bundle.mMap);
182
183        // fd state is now known if and only if both bundles already knew
184        mHasFds |= bundle.mHasFds;
185        mFdsKnown = mFdsKnown && bundle.mFdsKnown;
186    }
187
188    /**
189     * Reports whether the bundle contains any parcelled file descriptors.
190     */
191    public boolean hasFileDescriptors() {
192        if (!mFdsKnown) {
193            boolean fdFound = false;    // keep going until we find one or run out of data
194
195            if (mParcelledData != null) {
196                if (mParcelledData.hasFileDescriptors()) {
197                    fdFound = true;
198                }
199            } else {
200                // It's been unparcelled, so we need to walk the map
201                for (int i=mMap.size()-1; i>=0; i--) {
202                    Object obj = mMap.valueAt(i);
203                    if (obj instanceof Parcelable) {
204                        if ((((Parcelable)obj).describeContents()
205                                & Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0) {
206                            fdFound = true;
207                            break;
208                        }
209                    } else if (obj instanceof Parcelable[]) {
210                        Parcelable[] array = (Parcelable[]) obj;
211                        for (int n = array.length - 1; n >= 0; n--) {
212                            if ((array[n].describeContents()
213                                    & Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0) {
214                                fdFound = true;
215                                break;
216                            }
217                        }
218                    } else if (obj instanceof SparseArray) {
219                        SparseArray<? extends Parcelable> array =
220                                (SparseArray<? extends Parcelable>) obj;
221                        for (int n = array.size() - 1; n >= 0; n--) {
222                            if ((array.valueAt(n).describeContents()
223                                    & Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0) {
224                                fdFound = true;
225                                break;
226                            }
227                        }
228                    } else if (obj instanceof ArrayList) {
229                        ArrayList array = (ArrayList) obj;
230                        // an ArrayList here might contain either Strings or
231                        // Parcelables; only look inside for Parcelables
232                        if (!array.isEmpty() && (array.get(0) instanceof Parcelable)) {
233                            for (int n = array.size() - 1; n >= 0; n--) {
234                                Parcelable p = (Parcelable) array.get(n);
235                                if (p != null && ((p.describeContents()
236                                        & Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0)) {
237                                    fdFound = true;
238                                    break;
239                                }
240                            }
241                        }
242                    }
243                }
244            }
245
246            mHasFds = fdFound;
247            mFdsKnown = true;
248        }
249        return mHasFds;
250    }
251
252    /**
253     * Inserts a Boolean value into the mapping of this Bundle, replacing
254     * any existing value for the given key.  Either key or value may be null.
255     *
256     * @param key a String, or null
257     * @param value a Boolean, or null
258     */
259    @Override
260    public void putBoolean(String key, boolean value) {
261        super.putBoolean(key, value);
262    }
263
264    /**
265     * Inserts a byte value into the mapping of this Bundle, replacing
266     * any existing value for the given key.
267     *
268     * @param key a String, or null
269     * @param value a byte
270     */
271    @Override
272    public void putByte(String key, byte value) {
273        super.putByte(key, value);
274    }
275
276    /**
277     * Inserts a char value into the mapping of this Bundle, replacing
278     * any existing value for the given key.
279     *
280     * @param key a String, or null
281     * @param value a char, or null
282     */
283    @Override
284    public void putChar(String key, char value) {
285        super.putChar(key, value);
286    }
287
288    /**
289     * Inserts a short value into the mapping of this Bundle, replacing
290     * any existing value for the given key.
291     *
292     * @param key a String, or null
293     * @param value a short
294     */
295    @Override
296    public void putShort(String key, short value) {
297        super.putShort(key, value);
298    }
299
300    /**
301     * Inserts a float value into the mapping of this Bundle, replacing
302     * any existing value for the given key.
303     *
304     * @param key a String, or null
305     * @param value a float
306     */
307    @Override
308    public void putFloat(String key, float value) {
309        super.putFloat(key, value);
310    }
311
312    /**
313     * Inserts a CharSequence value into the mapping of this Bundle, replacing
314     * any existing value for the given key.  Either key or value may be null.
315     *
316     * @param key a String, or null
317     * @param value a CharSequence, or null
318     */
319    @Override
320    public void putCharSequence(String key, CharSequence value) {
321        super.putCharSequence(key, value);
322    }
323
324    /**
325     * Inserts a Parcelable value into the mapping of this Bundle, replacing
326     * any existing value for the given key.  Either key or value may be null.
327     *
328     * @param key a String, or null
329     * @param value a Parcelable object, or null
330     */
331    public void putParcelable(String key, Parcelable value) {
332        unparcel();
333        mMap.put(key, value);
334        mFdsKnown = false;
335    }
336
337    /**
338     * Inserts an array of Parcelable values into the mapping of this Bundle,
339     * replacing any existing value for the given key.  Either key or value may
340     * be null.
341     *
342     * @param key a String, or null
343     * @param value an array of Parcelable objects, or null
344     */
345    public void putParcelableArray(String key, Parcelable[] value) {
346        unparcel();
347        mMap.put(key, value);
348        mFdsKnown = false;
349    }
350
351    /**
352     * Inserts a List of Parcelable values into the mapping of this Bundle,
353     * replacing any existing value for the given key.  Either key or value may
354     * be null.
355     *
356     * @param key a String, or null
357     * @param value an ArrayList of Parcelable objects, or null
358     */
359    public void putParcelableArrayList(String key,
360            ArrayList<? extends Parcelable> value) {
361        unparcel();
362        mMap.put(key, value);
363        mFdsKnown = false;
364    }
365
366    /** {@hide} */
367    public void putParcelableList(String key, List<? extends Parcelable> value) {
368        unparcel();
369        mMap.put(key, value);
370        mFdsKnown = false;
371    }
372
373    /**
374     * Inserts a SparceArray of Parcelable values into the mapping of this
375     * Bundle, replacing any existing value for the given key.  Either key
376     * or value may be null.
377     *
378     * @param key a String, or null
379     * @param value a SparseArray of Parcelable objects, or null
380     */
381    public void putSparseParcelableArray(String key,
382            SparseArray<? extends Parcelable> value) {
383        unparcel();
384        mMap.put(key, value);
385        mFdsKnown = false;
386    }
387
388    /**
389     * Inserts an ArrayList<Integer> value into the mapping of this Bundle, replacing
390     * any existing value for the given key.  Either key or value may be null.
391     *
392     * @param key a String, or null
393     * @param value an ArrayList<Integer> object, or null
394     */
395    @Override
396    public void putIntegerArrayList(String key, ArrayList<Integer> value) {
397        super.putIntegerArrayList(key, value);
398    }
399
400    /**
401     * Inserts an ArrayList<String> value into the mapping of this Bundle, replacing
402     * any existing value for the given key.  Either key or value may be null.
403     *
404     * @param key a String, or null
405     * @param value an ArrayList<String> object, or null
406     */
407    @Override
408    public void putStringArrayList(String key, ArrayList<String> value) {
409        super.putStringArrayList(key, value);
410    }
411
412    /**
413     * Inserts an ArrayList<CharSequence> value into the mapping of this Bundle, replacing
414     * any existing value for the given key.  Either key or value may be null.
415     *
416     * @param key a String, or null
417     * @param value an ArrayList<CharSequence> object, or null
418     */
419    @Override
420    public void putCharSequenceArrayList(String key, ArrayList<CharSequence> value) {
421        super.putCharSequenceArrayList(key, value);
422    }
423
424    /**
425     * Inserts a Serializable value into the mapping of this Bundle, replacing
426     * any existing value for the given key.  Either key or value may be null.
427     *
428     * @param key a String, or null
429     * @param value a Serializable object, or null
430     */
431    @Override
432    public void putSerializable(String key, Serializable value) {
433        super.putSerializable(key, value);
434    }
435
436    /**
437     * Inserts a boolean array value into the mapping of this Bundle, replacing
438     * any existing value for the given key.  Either key or value may be null.
439     *
440     * @param key a String, or null
441     * @param value a boolean array object, or null
442     */
443    @Override
444    public void putBooleanArray(String key, boolean[] value) {
445        super.putBooleanArray(key, value);
446    }
447
448    /**
449     * Inserts a byte array value into the mapping of this Bundle, replacing
450     * any existing value for the given key.  Either key or value may be null.
451     *
452     * @param key a String, or null
453     * @param value a byte array object, or null
454     */
455    @Override
456    public void putByteArray(String key, byte[] value) {
457        super.putByteArray(key, value);
458    }
459
460    /**
461     * Inserts a short array value into the mapping of this Bundle, replacing
462     * any existing value for the given key.  Either key or value may be null.
463     *
464     * @param key a String, or null
465     * @param value a short array object, or null
466     */
467    @Override
468    public void putShortArray(String key, short[] value) {
469        super.putShortArray(key, value);
470    }
471
472    /**
473     * Inserts a char array value into the mapping of this Bundle, replacing
474     * any existing value for the given key.  Either key or value may be null.
475     *
476     * @param key a String, or null
477     * @param value a char array object, or null
478     */
479    @Override
480    public void putCharArray(String key, char[] value) {
481        super.putCharArray(key, value);
482    }
483
484    /**
485     * Inserts a float array value into the mapping of this Bundle, replacing
486     * any existing value for the given key.  Either key or value may be null.
487     *
488     * @param key a String, or null
489     * @param value a float array object, or null
490     */
491    @Override
492    public void putFloatArray(String key, float[] value) {
493        super.putFloatArray(key, value);
494    }
495
496    /**
497     * Inserts a CharSequence array value into the mapping of this Bundle, replacing
498     * any existing value for the given key.  Either key or value may be null.
499     *
500     * @param key a String, or null
501     * @param value a CharSequence array object, or null
502     */
503    @Override
504    public void putCharSequenceArray(String key, CharSequence[] value) {
505        super.putCharSequenceArray(key, value);
506    }
507
508    /**
509     * Inserts a Bundle value into the mapping of this Bundle, replacing
510     * any existing value for the given key.  Either key or value may be null.
511     *
512     * @param key a String, or null
513     * @param value a Bundle object, or null
514     */
515    public void putBundle(String key, Bundle value) {
516        unparcel();
517        mMap.put(key, value);
518    }
519
520    /**
521     * Inserts an {@link IBinder} value into the mapping of this Bundle, replacing
522     * any existing value for the given key.  Either key or value may be null.
523     *
524     * <p class="note">You should be very careful when using this function.  In many
525     * places where Bundles are used (such as inside of Intent objects), the Bundle
526     * can live longer inside of another process than the process that had originally
527     * created it.  In that case, the IBinder you supply here will become invalid
528     * when your process goes away, and no longer usable, even if a new process is
529     * created for you later on.</p>
530     *
531     * @param key a String, or null
532     * @param value an IBinder object, or null
533     */
534    public void putBinder(String key, IBinder value) {
535        unparcel();
536        mMap.put(key, value);
537    }
538
539    /**
540     * Inserts an IBinder value into the mapping of this Bundle, replacing
541     * any existing value for the given key.  Either key or value may be null.
542     *
543     * @param key a String, or null
544     * @param value an IBinder object, or null
545     *
546     * @deprecated
547     * @hide This is the old name of the function.
548     */
549    @Deprecated
550    public void putIBinder(String key, IBinder value) {
551        unparcel();
552        mMap.put(key, value);
553    }
554
555    /**
556     * Returns the value associated with the given key, or false if
557     * no mapping of the desired type exists for the given key.
558     *
559     * @param key a String
560     * @return a boolean value
561     */
562    @Override
563    public boolean getBoolean(String key) {
564        return super.getBoolean(key);
565    }
566
567    /**
568     * Returns the value associated with the given key, or defaultValue if
569     * no mapping of the desired type exists for the given key.
570     *
571     * @param key a String
572     * @param defaultValue Value to return if key does not exist
573     * @return a boolean value
574     */
575    @Override
576    public boolean getBoolean(String key, boolean defaultValue) {
577        return super.getBoolean(key, defaultValue);
578    }
579
580    /**
581     * Returns the value associated with the given key, or (byte) 0 if
582     * no mapping of the desired type exists for the given key.
583     *
584     * @param key a String
585     * @return a byte value
586     */
587    @Override
588    public byte getByte(String key) {
589        return super.getByte(key);
590    }
591
592    /**
593     * Returns the value associated with the given key, or defaultValue if
594     * no mapping of the desired type exists for the given key.
595     *
596     * @param key a String
597     * @param defaultValue Value to return if key does not exist
598     * @return a byte value
599     */
600    @Override
601    public Byte getByte(String key, byte defaultValue) {
602        return super.getByte(key, defaultValue);
603    }
604
605    /**
606     * Returns the value associated with the given key, or (char) 0 if
607     * no mapping of the desired type exists for the given key.
608     *
609     * @param key a String
610     * @return a char value
611     */
612    @Override
613    public char getChar(String key) {
614        return super.getChar(key);
615    }
616
617    /**
618     * Returns the value associated with the given key, or defaultValue if
619     * no mapping of the desired type exists for the given key.
620     *
621     * @param key a String
622     * @param defaultValue Value to return if key does not exist
623     * @return a char value
624     */
625    @Override
626    public char getChar(String key, char defaultValue) {
627        return super.getChar(key, defaultValue);
628    }
629
630    /**
631     * Returns the value associated with the given key, or (short) 0 if
632     * no mapping of the desired type exists for the given key.
633     *
634     * @param key a String
635     * @return a short value
636     */
637    @Override
638    public short getShort(String key) {
639        return super.getShort(key);
640    }
641
642    /**
643     * Returns the value associated with the given key, or defaultValue if
644     * no mapping of the desired type exists for the given key.
645     *
646     * @param key a String
647     * @param defaultValue Value to return if key does not exist
648     * @return a short value
649     */
650    @Override
651    public short getShort(String key, short defaultValue) {
652        return super.getShort(key, defaultValue);
653    }
654
655    /**
656     * Returns the value associated with the given key, or 0.0f if
657     * no mapping of the desired type exists for the given key.
658     *
659     * @param key a String
660     * @return a float value
661     */
662    @Override
663    public float getFloat(String key) {
664        return super.getFloat(key);
665    }
666
667    /**
668     * Returns the value associated with the given key, or defaultValue if
669     * no mapping of the desired type exists for the given key.
670     *
671     * @param key a String
672     * @param defaultValue Value to return if key does not exist
673     * @return a float value
674     */
675    @Override
676    public float getFloat(String key, float defaultValue) {
677        return super.getFloat(key, defaultValue);
678    }
679
680    /**
681     * Returns the value associated with the given key, or null if
682     * no mapping of the desired type exists for the given key or a null
683     * value is explicitly associated with the key.
684     *
685     * @param key a String, or null
686     * @return a CharSequence value, or null
687     */
688    @Override
689    public CharSequence getCharSequence(String key) {
690        return super.getCharSequence(key);
691    }
692
693    /**
694     * Returns the value associated with the given key, or defaultValue if
695     * no mapping of the desired type exists for the given key or if a null
696     * value is explicitly associatd with the given key.
697     *
698     * @param key a String, or null
699     * @param defaultValue Value to return if key does not exist or if a null
700     *     value is associated with the given key.
701     * @return the CharSequence value associated with the given key, or defaultValue
702     *     if no valid CharSequence object is currently mapped to that key.
703     */
704    @Override
705    public CharSequence getCharSequence(String key, CharSequence defaultValue) {
706        return super.getCharSequence(key, defaultValue);
707    }
708
709    /**
710     * Returns the value associated with the given key, or null if
711     * no mapping of the desired type exists for the given key or a null
712     * value is explicitly associated with the key.
713     *
714     * @param key a String, or null
715     * @return a Bundle value, or null
716     */
717    public Bundle getBundle(String key) {
718        unparcel();
719        Object o = mMap.get(key);
720        if (o == null) {
721            return null;
722        }
723        try {
724            return (Bundle) o;
725        } catch (ClassCastException e) {
726            typeWarning(key, o, "Bundle", e);
727            return null;
728        }
729    }
730
731    /**
732     * Returns the value associated with the given key, or null if
733     * no mapping of the desired type exists for the given key or a null
734     * value is explicitly associated with the key.
735     *
736     * @param key a String, or null
737     * @return a Parcelable value, or null
738     */
739    public <T extends Parcelable> T getParcelable(String key) {
740        unparcel();
741        Object o = mMap.get(key);
742        if (o == null) {
743            return null;
744        }
745        try {
746            return (T) o;
747        } catch (ClassCastException e) {
748            typeWarning(key, o, "Parcelable", e);
749            return null;
750        }
751    }
752
753    /**
754     * Returns the value associated with the given key, or null if
755     * no mapping of the desired type exists for the given key or a null
756     * value is explicitly associated with the key.
757     *
758     * @param key a String, or null
759     * @return a Parcelable[] value, or null
760     */
761    public Parcelable[] getParcelableArray(String key) {
762        unparcel();
763        Object o = mMap.get(key);
764        if (o == null) {
765            return null;
766        }
767        try {
768            return (Parcelable[]) o;
769        } catch (ClassCastException e) {
770            typeWarning(key, o, "Parcelable[]", e);
771            return null;
772        }
773    }
774
775    /**
776     * Returns the value associated with the given key, or null if
777     * no mapping of the desired type exists for the given key or a null
778     * value is explicitly associated with the key.
779     *
780     * @param key a String, or null
781     * @return an ArrayList<T> value, or null
782     */
783    public <T extends Parcelable> ArrayList<T> getParcelableArrayList(String key) {
784        unparcel();
785        Object o = mMap.get(key);
786        if (o == null) {
787            return null;
788        }
789        try {
790            return (ArrayList<T>) o;
791        } catch (ClassCastException e) {
792            typeWarning(key, o, "ArrayList", e);
793            return null;
794        }
795    }
796
797    /**
798     * Returns the value associated with the given key, or null if
799     * no mapping of the desired type exists for the given key or a null
800     * value is explicitly associated with the key.
801     *
802     * @param key a String, or null
803     *
804     * @return a SparseArray of T values, or null
805     */
806    public <T extends Parcelable> SparseArray<T> getSparseParcelableArray(String key) {
807        unparcel();
808        Object o = mMap.get(key);
809        if (o == null) {
810            return null;
811        }
812        try {
813            return (SparseArray<T>) o;
814        } catch (ClassCastException e) {
815            typeWarning(key, o, "SparseArray", e);
816            return null;
817        }
818    }
819
820    /**
821     * Returns the value associated with the given key, or null if
822     * no mapping of the desired type exists for the given key or a null
823     * value is explicitly associated with the key.
824     *
825     * @param key a String, or null
826     * @return a Serializable value, or null
827     */
828    @Override
829    public Serializable getSerializable(String key) {
830        return super.getSerializable(key);
831    }
832
833    /**
834     * Returns the value associated with the given key, or null if
835     * no mapping of the desired type exists for the given key or a null
836     * value is explicitly associated with the key.
837     *
838     * @param key a String, or null
839     * @return an ArrayList<String> value, or null
840     */
841    @Override
842    public ArrayList<Integer> getIntegerArrayList(String key) {
843        return super.getIntegerArrayList(key);
844    }
845
846    /**
847     * Returns the value associated with the given key, or null if
848     * no mapping of the desired type exists for the given key or a null
849     * value is explicitly associated with the key.
850     *
851     * @param key a String, or null
852     * @return an ArrayList<String> value, or null
853     */
854    @Override
855    public ArrayList<String> getStringArrayList(String key) {
856        return super.getStringArrayList(key);
857    }
858
859    /**
860     * Returns the value associated with the given key, or null if
861     * no mapping of the desired type exists for the given key or a null
862     * value is explicitly associated with the key.
863     *
864     * @param key a String, or null
865     * @return an ArrayList<CharSequence> value, or null
866     */
867    @Override
868    public ArrayList<CharSequence> getCharSequenceArrayList(String key) {
869        return super.getCharSequenceArrayList(key);
870    }
871
872    /**
873     * Returns the value associated with the given key, or null if
874     * no mapping of the desired type exists for the given key or a null
875     * value is explicitly associated with the key.
876     *
877     * @param key a String, or null
878     * @return a boolean[] value, or null
879     */
880    @Override
881    public boolean[] getBooleanArray(String key) {
882        return super.getBooleanArray(key);
883    }
884
885    /**
886     * Returns the value associated with the given key, or null if
887     * no mapping of the desired type exists for the given key or a null
888     * value is explicitly associated with the key.
889     *
890     * @param key a String, or null
891     * @return a byte[] value, or null
892     */
893    @Override
894    public byte[] getByteArray(String key) {
895        return super.getByteArray(key);
896    }
897
898    /**
899     * Returns the value associated with the given key, or null if
900     * no mapping of the desired type exists for the given key or a null
901     * value is explicitly associated with the key.
902     *
903     * @param key a String, or null
904     * @return a short[] value, or null
905     */
906    @Override
907    public short[] getShortArray(String key) {
908        return super.getShortArray(key);
909    }
910
911    /**
912     * Returns the value associated with the given key, or null if
913     * no mapping of the desired type exists for the given key or a null
914     * value is explicitly associated with the key.
915     *
916     * @param key a String, or null
917     * @return a char[] value, or null
918     */
919    @Override
920    public char[] getCharArray(String key) {
921        return super.getCharArray(key);
922    }
923
924    /**
925     * Returns the value associated with the given key, or null if
926     * no mapping of the desired type exists for the given key or a null
927     * value is explicitly associated with the key.
928     *
929     * @param key a String, or null
930     * @return a float[] value, or null
931     */
932    @Override
933    public float[] getFloatArray(String key) {
934        return super.getFloatArray(key);
935    }
936
937    /**
938     * Returns the value associated with the given key, or null if
939     * no mapping of the desired type exists for the given key or a null
940     * value is explicitly associated with the key.
941     *
942     * @param key a String, or null
943     * @return a CharSequence[] value, or null
944     */
945    @Override
946    public CharSequence[] getCharSequenceArray(String key) {
947        return super.getCharSequenceArray(key);
948    }
949
950    /**
951     * Returns the value associated with the given key, or null if
952     * no mapping of the desired type exists for the given key or a null
953     * value is explicitly associated with the key.
954     *
955     * @param key a String, or null
956     * @return an IBinder value, or null
957     */
958    public IBinder getBinder(String key) {
959        unparcel();
960        Object o = mMap.get(key);
961        if (o == null) {
962            return null;
963        }
964        try {
965            return (IBinder) o;
966        } catch (ClassCastException e) {
967            typeWarning(key, o, "IBinder", e);
968            return null;
969        }
970    }
971
972    /**
973     * Returns the value associated with the given key, or null if
974     * no mapping of the desired type exists for the given key or a null
975     * value is explicitly associated with the key.
976     *
977     * @param key a String, or null
978     * @return an IBinder value, or null
979     *
980     * @deprecated
981     * @hide This is the old name of the function.
982     */
983    @Deprecated
984    public IBinder getIBinder(String key) {
985        unparcel();
986        Object o = mMap.get(key);
987        if (o == null) {
988            return null;
989        }
990        try {
991            return (IBinder) o;
992        } catch (ClassCastException e) {
993            typeWarning(key, o, "IBinder", e);
994            return null;
995        }
996    }
997
998    public static final Parcelable.Creator<Bundle> CREATOR =
999        new Parcelable.Creator<Bundle>() {
1000        @Override
1001        public Bundle createFromParcel(Parcel in) {
1002            return in.readBundle();
1003        }
1004
1005        @Override
1006        public Bundle[] newArray(int size) {
1007            return new Bundle[size];
1008        }
1009    };
1010
1011    /**
1012     * Report the nature of this Parcelable's contents
1013     */
1014    @Override
1015    public int describeContents() {
1016        int mask = 0;
1017        if (hasFileDescriptors()) {
1018            mask |= Parcelable.CONTENTS_FILE_DESCRIPTOR;
1019        }
1020        return mask;
1021    }
1022
1023    /**
1024     * Writes the Bundle contents to a Parcel, typically in order for
1025     * it to be passed through an IBinder connection.
1026     * @param parcel The parcel to copy this bundle to.
1027     */
1028    @Override
1029    public void writeToParcel(Parcel parcel, int flags) {
1030        final boolean oldAllowFds = parcel.pushAllowFds(mAllowFds);
1031        try {
1032            super.writeToParcelInner(parcel, flags);
1033        } finally {
1034            parcel.restoreAllowFds(oldAllowFds);
1035        }
1036    }
1037
1038    /**
1039     * Reads the Parcel contents into this Bundle, typically in order for
1040     * it to be passed through an IBinder connection.
1041     * @param parcel The parcel to overwrite this bundle from.
1042     */
1043    public void readFromParcel(Parcel parcel) {
1044        super.readFromParcelInner(parcel);
1045        mHasFds = mParcelledData.hasFileDescriptors();
1046        mFdsKnown = true;
1047    }
1048
1049    @Override
1050    public synchronized String toString() {
1051        if (mParcelledData != null) {
1052            if (mParcelledData == EMPTY_PARCEL) {
1053                return "Bundle[EMPTY_PARCEL]";
1054            } else {
1055                return "Bundle[mParcelledData.dataSize=" +
1056                        mParcelledData.dataSize() + "]";
1057            }
1058        }
1059        return "Bundle[" + mMap.toString() + "]";
1060    }
1061
1062}
1063