summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jayant Chowdhary <jchowdhary@google.com> 2021-06-08 09:41:40 -0700
committer Jayant Chowdhary <jchowdhary@google.com> 2021-06-10 23:52:37 -0700
commitebbb0ce80098f34905cc483a2022a616c30427e1 (patch)
tree568a3090596c7a54a7d072a6a68a4808643b9bd7
parent6b0bcd60c81003e6a193aeccf44ee03f188e3984 (diff)
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: Jayant Chowdhary <jchowdhary@google.com>
-rw-r--r--core/java/android/hardware/camera2/params/OutputConfiguration.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/core/java/android/hardware/camera2/params/OutputConfiguration.java b/core/java/android/hardware/camera2/params/OutputConfiguration.java
index 1124b2665457..5bb7201eff65 100644
--- a/core/java/android/hardware/camera2/params/OutputConfiguration.java
+++ b/core/java/android/hardware/camera2/params/OutputConfiguration.java
@@ -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());
}
/**