Merge "camera3: Don't eagerly finish configuring bidi streams more than once" into jb-mr2-dev
diff --git a/services/camera/libcameraservice/Camera3Device.cpp b/services/camera/libcameraservice/Camera3Device.cpp
index 5f87e8b..5e5bfc2 100644
--- a/services/camera/libcameraservice/Camera3Device.cpp
+++ b/services/camera/libcameraservice/Camera3Device.cpp
@@ -1060,7 +1060,7 @@
     // TODO: Try to relax this later back to lazy completion, which should be
     // faster
 
-    if (mInputStream != NULL) {
+    if (mInputStream != NULL && mInputStream->isConfiguring()) {
         res = mInputStream->finishConfiguration(mHal3Device);
         if (res != OK) {
             SET_ERR_L("Can't finish configuring input stream %d: %s (%d)",
@@ -1070,11 +1070,15 @@
     }
 
     for (size_t i = 0; i < mOutputStreams.size(); i++) {
-        res = mOutputStreams.editValueAt(i)->finishConfiguration(mHal3Device);
-        if (res != OK) {
-            SET_ERR_L("Can't finish configuring output stream %d: %s (%d)",
-                    mOutputStreams[i]->getId(), strerror(-res), res);
-            return res;
+        sp<Camera3OutputStreamInterface> outputStream =
+            mOutputStreams.editValueAt(i);
+        if (outputStream->isConfiguring()) {
+            res = outputStream->finishConfiguration(mHal3Device);
+            if (res != OK) {
+                SET_ERR_L("Can't finish configuring output stream %d: %s (%d)",
+                        outputStream->getId(), strerror(-res), res);
+                return res;
+            }
         }
     }