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: Jayant Chowdhary <jchowdhary@google.com>
This commit is contained in:
Jayant Chowdhary
2021-05-26 22:37:42 -07:00
parent 19e79e066e
commit e1a464e141

View File

@@ -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());
}
/**