Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56fbbeab authored by Eino-Ville Talvala's avatar Eino-Ville Talvala
Browse files

Camera2: Fix parallel session and device close() exception

It's possible for the device to have close() called on it
during the session close sequence such that the session still
tries to do a stream reconfiguration on the closed device.

Handle the exception thrown by this attempt.

Bug: 17661765

Change-Id: Iee63c5c559405abe5c044ae251ad56edd1fb3e79
parent 381d22f7
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -657,9 +657,9 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession {
                    }

                    // Slow path: #close was called explicitly on this session; unconfigure first
                    mUnconfigureDrainer.taskStarted();

                    try {
                        mUnconfigureDrainer.taskStarted();
                        mDeviceImpl
                                .configureOutputsChecked(null); // begin transition to unconfigured
                    } catch (CameraAccessException e) {
@@ -667,6 +667,11 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession {
                        Log.e(TAG, mIdString + "Exception while configuring outputs: ", e);

                        // TODO: call onError instead of onClosed if this happens
                    } catch (IllegalStateException e) {
                        // Camera is already closed, so go straight to the close callback
                        if (VERBOSE) Log.v(TAG, mIdString +
                                "Camera was already closed or busy, skipping unconfigure");
                        mUnconfigureDrainer.taskFinished();
                    }

                    mUnconfigureDrainer.beginDrain();