Mark a component as idle before reconfigure camera is called

reconfigureCamera is currently responsible for marking a component as
idle. This can pose problems when we are in a state where we are waiting
for a component to be marked as idle (for eg in createInputStream) and
also hold the locks that reconfigureCamera needs to execute. In this
case, CreateInputStream will end up waiting forever as reconfigureCamera
cannot be executed.

Instead mark a component as idle directly in the threadLoop before
calling reconfigureCamera.

Bug: 241137777
Test: Existing tests pass. Very difficult to create a scenario in which
we could test this, but this fix handles the theoretical scenario that a
vendor actually stumbled upon. A component never became idle and the
control couldn't exist createInputStream as it occupied both mLock and
mInterfaceLock needed by reconfigureCamera.

Change-Id: I9b0beacf1de5f70671c8e8b522e80ea5c3f02fe3
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index acee2ab..22a9663 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -2231,7 +2231,6 @@
     if (mStatus == STATUS_ACTIVE) {
         markClientActive = true;
         mPauseStateNotify = true;
-        mStatusTracker->markComponentIdle(clientStatusId, Fence::NO_FENCE);
 
         rc = internalPauseAndWaitLocked(maxExpectedDuration);
     }
@@ -3448,6 +3447,10 @@
         if (res == OK) {
             sp<Camera3Device> parent = mParent.promote();
             if (parent != nullptr) {
+                sp<StatusTracker> statusTracker = mStatusTracker.promote();
+                if (statusTracker != nullptr) {
+                    statusTracker->markComponentIdle(mStatusId, Fence::NO_FENCE);
+                }
                 mReconfigured |= parent->reconfigureCamera(mLatestSessionParams, mStatusId);
             }
             setPaused(false);