Skip to content

Commit 43ee0ab

Browse files
author
Dianne Hackborn
committed
Fix issue #5433910: RTE while adding an account from settings
Make the new marshalling/unmarshalling code for the long sparse array of ints always consistent. And sane. Change-Id: Ifbfbe6e56f59e469acb66257c504b1168d6566fa
1 parent 421fa27 commit 43ee0ab

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

core/java/android/widget/AbsListView.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,14 +1443,13 @@ private SavedState(Parcel in) {
14431443
inActionMode = in.readByte() != 0;
14441444
checkedItemCount = in.readInt();
14451445
checkState = in.readSparseBooleanArray();
1446-
long[] idState = in.createLongArray();
1447-
int[] idPositions = in.createIntArray();
1448-
1449-
final int idLength = idState.length;
1450-
if (idLength > 0) {
1446+
final int N = in.readInt();
1447+
if (N > 0) {
14511448
checkIdState = new LongSparseArray<Integer>();
1452-
for (int i = 0; i < idLength; i++) {
1453-
checkIdState.put(idState[i], idPositions[i]);
1449+
for (int i=0; i<N; i++) {
1450+
final long key = in.readLong();
1451+
final int value = in.readInt();
1452+
checkIdState.put(key, value);
14541453
}
14551454
}
14561455
}
@@ -1467,15 +1466,11 @@ public void writeToParcel(Parcel out, int flags) {
14671466
out.writeByte((byte) (inActionMode ? 1 : 0));
14681467
out.writeInt(checkedItemCount);
14691468
out.writeSparseBooleanArray(checkState);
1470-
out.writeLongArray(checkIdState != null ? checkIdState.getKeys() : new long[0]);
1471-
1472-
int size = checkIdState != null ? checkIdState.size() : 0;
1473-
int[] idPositions = new int[size];
1474-
if (size > 0) {
1475-
for (int i = 0; i < size; i++) {
1476-
idPositions[i] = checkIdState.valueAt(i);
1477-
}
1478-
out.writeIntArray(idPositions);
1469+
final int N = checkIdState != null ? checkIdState.size() : 0;
1470+
out.writeInt(N);
1471+
for (int i=0; i<N; i++) {
1472+
out.writeLong(checkIdState.keyAt(i));
1473+
out.writeInt(checkIdState.valueAt(i));
14791474
}
14801475
}
14811476

0 commit comments

Comments
 (0)