Switch Bundle's implementation over to ArrayMap.
That was... um... easier than I thought it was going to be.
Change-Id: Id8f2211c1d5f8145e0bb009dca0f62a590f2b860
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 0916ea9..12f7915 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -17,6 +17,7 @@
package android.os;
import android.text.TextUtils;
+import android.util.ArrayMap;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
@@ -572,7 +573,7 @@
* allows you to avoid mysterious type errors at the point of marshalling.
*/
public final void writeMap(Map val) {
- writeMapInternal((Map<String,Object>) val);
+ writeMapInternal((Map<String, Object>) val);
}
/**
@@ -593,6 +594,23 @@
}
/**
+ * Flatten an ArrayMap into the parcel at the current dataPosition(),
+ * growing dataCapacity() if needed. The Map keys must be String objects.
+ */
+ /* package */ void writeArrayMapInternal(ArrayMap<String,Object> val) {
+ if (val == null) {
+ writeInt(-1);
+ return;
+ }
+ final int N = val.size();
+ writeInt(N);
+ for (int i=0; i<N; i++) {
+ writeValue(val.keyAt(i));
+ writeValue(val.valueAt(i));
+ }
+ }
+
+ /**
* Flatten a Bundle into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
*/
@@ -2258,6 +2276,16 @@
}
}
+ /* package */ void readArrayMapInternal(ArrayMap outVal, int N,
+ ClassLoader loader) {
+ while (N > 0) {
+ Object key = readValue(loader);
+ Object value = readValue(loader);
+ outVal.append(key, value);
+ N--;
+ }
+ }
+
private void readListInternal(List outVal, int N,
ClassLoader loader) {
while (N > 0) {