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

Commit a907221c authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Don't cancel AF when the device is disconnected

Under some conditions camera clients may be able to
call 'cancelAutoFocus' immediately after the
Camera2Client disconnects from the Camera3Device.
The device instance will remain valid but some
of the internal resources like the request thread
will be released.
Avoid possible invalid access by checking the
client parameter state and return appropriate
error status in case we are disconnected.

Bug: 323947800
Test: atest -c -d cts/tests/camera/src/android/hardware/cts/
Change-Id: I6e777212168ac92a28cc7b1bc16c7a0eeb7dbb2d
parent 618e9492
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1460,6 +1460,11 @@ status_t Camera2Client::cancelAutoFocus() {
    int triggerId;
    {
        SharedParameters::Lock l(mParameters);
        if (l.mParameters.state == Parameters::DISCONNECTED) {
            ALOGE("%s: Camera %d has been disconnected.", __FUNCTION__, mCameraId);
            return INVALID_OPERATION;
        }

        // Canceling does nothing in FIXED or INFINITY modes
        if (l.mParameters.focusMode == Parameters::FOCUS_MODE_FIXED ||
                l.mParameters.focusMode == Parameters::FOCUS_MODE_INFINITY) {