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

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

camera2: Fix parcelling of sensor pixel modes.



OutputConfiguration.writeToParcel previously used writeList to parcel
the List<Integer> mSensorPixelModesUsed. The Integer list read from a
Parcel into a vector of int32_ts in cameraserver native code, doesn't get read correctly
(values sent are not the ones received).
Therefore, instead we explicitly convert the Integer list into an int[]
before parcelling using writeIntArray. We also explicitly use
readInt32Vector on the native side in readFromParcel now.

Bug: 184396641

Test: atest RobustnessTest.java#testConfigureInvalidSensorPixelModes

Change-Id: Ie0a8d0da2f89c959df6a3529d4836889e235fa93
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent 19e79e06
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -846,6 +846,14 @@ public final class OutputConfiguration implements Parcelable {
        return 0;
    }

    private static int[] convertIntegerToIntList(List<Integer> integerList) {
        int[] integerArray = new int[integerList.size()];
        for (int i = 0; i < integerList.size(); i++) {
            integerArray[i] = integerList.get(i);
        }
        return integerArray;
    }

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

    /**