Camera2: Fix missing capture result callback issue

When configuring output right after submitting some capture request, the
waitUntilIdle clears the capture mCaptureListenerMap and
mRepeatingRequestIdDeletedList. This caused the listener is cleared before
the capture result is delivered to application side. Since the listener is
already removed properly, it is really not needed to clear them right after
idling the device.

It also doesn't make sense to add the repeating request id that has no
listener hooked up to the mRepeatingRequestIdDeletedList, this caused
out of sync between id deleted list and the mCaptureListenerMap for
repeating request.

Bug: 13730119
Change-Id: I94ab7a5515f841ffd97b103c2c1b71d92afd955a
diff --git a/core/java/android/hardware/camera2/impl/CameraDevice.java b/core/java/android/hardware/camera2/impl/CameraDevice.java
index 2c8a5c2..ecc461e 100644
--- a/core/java/android/hardware/camera2/impl/CameraDevice.java
+++ b/core/java/android/hardware/camera2/impl/CameraDevice.java
@@ -335,7 +335,9 @@
                 mRepeatingRequestId = REQUEST_ID_NONE;
 
                 // Queue for deletion after in-flight requests finish
-                mRepeatingRequestIdDeletedList.add(requestId);
+                if (mCaptureListenerMap.get(requestId) != null) {
+                    mRepeatingRequestIdDeletedList.add(requestId);
+                }
 
                 try {
                     mRemoteDevice.cancelRequest(requestId);
@@ -367,8 +369,6 @@
             }
 
             mRepeatingRequestId = REQUEST_ID_NONE;
-            mRepeatingRequestIdDeletedList.clear();
-            mCaptureListenerMap.clear();
         }
     }