Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83f6c7f7 authored by Alexandru-Andrei Rotaru's avatar Alexandru-Andrei Rotaru Committed by android-build-merger
Browse files

Merge "StringParceledListSlice throws exception when the IPC memory threshold...

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

Change-Id: Id6236ee2229b1a03fbddb5b408fb956f8e6ece09
parents ac2afd4e afe28cdf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
+24 −7
Original line number Diff line number Diff line
@@ -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.
     */