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

Commit 25fd1afa authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "StringParceledListSlice throws exception when the IPC memory threshold is exceeded"

parents b33a2163 2682fa70
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.
     */