OSDN Git Service

Camera2: Handle (0, 0) size for deferred OutputConfiguration
authorShuzhen Wang <shuzhenwang@google.com>
Wed, 25 Jan 2017 19:53:22 +0000 (11:53 -0800)
committerShuzhen Wang <shuzhenwang@google.com>
Wed, 25 Jan 2017 20:22:01 +0000 (12:22 -0800)
We need to handle below sequence of events:
1. OutputConfiguration(Size(0, 0), klass)
2. addSurface(surface)
3. createCameraCaptureSession

In this case, allow the addSurface() to succeed.

Test: camera works in keep/hangouts/contacts
Bug: 34697112
Change-Id: I726c60cce9a11c69b050aad47f4ed4a0a7a0870e

core/java/android/hardware/camera2/params/OutputConfiguration.java

index 2d5c4ce..6b7546f 100644 (file)
@@ -358,7 +358,12 @@ public final class OutputConfiguration implements Parcelable {
             throw new IllegalArgumentException("Exceeds maximum number of surfaces");
         }
 
-        if (!mConfiguredSize.equals(SurfaceUtils.getSurfaceSize(surface))) {
+        // TODO: b/34697112. This needs to be reverted once app fix is merged.
+        // Do not throw exception for below case:
+        // - OutputConfiguration(Size(0, 0), klass)
+        // - addSurface(surface)
+        if ((mConfiguredSize.getWidth() != 0 || mConfiguredSize.getHeight() != 0) &&
+                !mConfiguredSize.equals(SurfaceUtils.getSurfaceSize(surface))) {
             throw new IllegalArgumentException("The size of added surface doesn't match");
         }
         if (mConfiguredDataspace != SurfaceUtils.getSurfaceDataspace(surface)) {