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