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

Commit 376f04c2 authored by Shuzhen Wang's avatar Shuzhen Wang
Browse files

Camera: Stop waiting if device enters ERROR state

If device runs into ERROR state while being disconnected,
waitUntilDrained() should be able to return asap rather than
until timeout.

Otherwise we run into long delay and potential watchdog bite
during shutdown.

Test: Camera CTS, vendor testing
Bug: 282904703
Change-Id: Id8d328c065e00464f1e13fc537a431cbade51408
parent 0ca47c2b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1645,6 +1645,10 @@ status_t Camera3Device::waitUntilStateThenRelock(bool active, nsecs_t timeout,
    bool stateSeen = false;
    nsecs_t startTime = systemTime();
    do {
        if (mStatus == STATUS_ERROR) {
            // Device in error state. Return right away.
            break;
        }
        if (active == (mStatus == STATUS_ACTIVE) &&
            (requestThreadInvocation || !mStatusIsInternal)) {
            // Desired state is current
@@ -1674,6 +1678,11 @@ status_t Camera3Device::waitUntilStateThenRelock(bool active, nsecs_t timeout,
        // they are not paused. This avoids intermediate pause signals from reconfigureCamera as it
        // changes the status to active right after.
        for (size_t i = startIndex; i < mRecentStatusUpdates.size(); i++) {
            if (mRecentStatusUpdates[i].status == STATUS_ERROR) {
                // Device in error state. Return right away.
                stateSeen = true;
                break;
            }
            if (active == (mRecentStatusUpdates[i].status == STATUS_ACTIVE) &&
                (requestThreadInvocation || !mRecentStatusUpdates[i].isInternal)) {
                stateSeen = true;