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

Commit ebbb0ce8 authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

OutputConfiguration: fix CREATOR readList for sensor pixel modes.



OutputConfiguration uses writeIntArray in writeToParcel. It must use
readIntArray in createFromParcel instead of readList.

Bug: 188675581

Test: Sample app which tries to write invalid data into an
      OutputConfiguration parcel. When read again, the exception is
      thrown and not swallowed.

Test: create OutputConfiguration; add certain sensorPixelModes;
      writeToParcel; set parcel's data position to 0; create
      OutputConfiguration from same parcel and read sensor pixel modes.
      They match.

Change-Id: Id50396d328ba6fc830012a1c359934cf82249764
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent 6b0bcd60
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -735,8 +735,7 @@ public final class OutputConfiguration implements Parcelable {
        source.readTypedList(surfaces, Surface.CREATOR);
        String physicalCameraId = source.readString();
        boolean isMultiResolutionOutput = source.readInt() == 1;
        ArrayList<Integer> sensorPixelModesUsed = new ArrayList<Integer>();
        source.readList(sensorPixelModesUsed, Integer.class.getClassLoader());
        int[] sensorPixelModesUsed = source.createIntArray();
        checkArgumentInRange(rotation, ROTATION_0, ROTATION_270, "Rotation constant");

        mSurfaceGroupId = surfaceSetId;
@@ -760,7 +759,7 @@ public final class OutputConfiguration implements Parcelable {
        }
        mPhysicalCameraId = physicalCameraId;
        mIsMultiResolution = isMultiResolutionOutput;
        mSensorPixelModesUsed = sensorPixelModesUsed;
        mSensorPixelModesUsed = convertIntArrayToIntegerList(sensorPixelModesUsed);
    }

    /**
@@ -848,6 +847,17 @@ public final class OutputConfiguration implements Parcelable {
        return integerArray;
    }

    private static ArrayList<Integer> convertIntArrayToIntegerList(int[] intArray) {
        ArrayList<Integer> integerList = new ArrayList<Integer>();
        if (intArray == null) {
            return integerList;
        }
        for (int i = 0; i < intArray.length; i++) {
            integerList.add(intArray[i]);
        }
        return integerList;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        if (dest == null) {
@@ -865,7 +875,6 @@ public final class OutputConfiguration implements Parcelable {
        dest.writeInt(mIsMultiResolution ? 1 : 0);
        // writeList doesn't seem to work well with Integer list.
        dest.writeIntArray(convertIntegerToIntList(mSensorPixelModesUsed));
        //dest.writeArray(mSensorPixelModesUsed.toArray());
    }

    /**