From e1a464e141ebf3f17d14412ea7ae25e819a720b7 Mon Sep 17 00:00:00 2001 From: Jayant Chowdhary Date: Wed, 26 May 2021 22:37:42 -0700 Subject: [PATCH] camera2: Fix parcelling of sensor pixel modes. OutputConfiguration.writeToParcel previously used writeList to parcel the List 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 --- .../hardware/camera2/params/OutputConfiguration.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/java/android/hardware/camera2/params/OutputConfiguration.java b/core/java/android/hardware/camera2/params/OutputConfiguration.java index 0662f160a0098..8dfb787bb3ab3 100644 --- a/core/java/android/hardware/camera2/params/OutputConfiguration.java +++ b/core/java/android/hardware/camera2/params/OutputConfiguration.java @@ -846,6 +846,14 @@ public final class OutputConfiguration implements Parcelable { return 0; } + private static int[] convertIntegerToIntList(List 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()); } /**