Merge "StringParceledListSlice throws exception when the IPC memory threshold is exceeded" into oc-mr1-dev

This commit is contained in:
TreeHugger Robot
2017-08-24 10:08:15 +00:00
committed by Android (Google) Code Review
2 changed files with 25 additions and 8 deletions

View File

@@ -102,7 +102,7 @@ abstract class BaseParceledListSlice<T> implements Parcelable {
return;
}
while (i < N && reply.readInt() != 0) {
final T parcelable = reply.readCreator(creator, loader);
final T parcelable = readCreator(creator, reply, loader);
verifySameType(listElementClass, parcelable.getClass());
mList.add(parcelable);

View File

@@ -2,9 +2,11 @@ package android.content.pm;
import android.os.Parcel;
import android.os.Parcelable;
import junit.framework.TestCase;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ParceledListSliceTest extends TestCase {
@@ -91,15 +93,10 @@ public class ParceledListSliceTest extends TestCase {
}
}
public void testStringList() throws Exception {
final int objectCount = 400;
List<String> list = new ArrayList<String>();
for (long i = 0; i < objectCount; i++) {
list.add(Long.toString(i * (6 - i)));
}
private void sendParcelStringList(List<String> list) {
StringParceledListSlice slice;
Parcel parcel = Parcel.obtain();
try {
parcel.writeParcelable(new StringParceledListSlice(list), 0);
parcel.setDataPosition(0);
@@ -113,6 +110,26 @@ public class ParceledListSliceTest extends TestCase {
assertEquals(list, slice.getList());
}
public void testStringList() throws Exception {
final int objectCount = 400;
List<String> list = new ArrayList<String>();
for (long i = 0; i < objectCount; i++) {
list.add(Long.toString(i * (6 - i)));
}
sendParcelStringList(list);
}
public void testLargeStringList() throws Exception {
final int thresholdBytes = 256 * 1024;
final String value = Long.toString(Long.MAX_VALUE);
final int objectCount = 2 * thresholdBytes / value.length();
final List<String> list = Collections.nCopies(objectCount, value);
sendParcelStringList(list);
}
/**
* Test that only homogeneous elements may be unparceled.
*/