Camera: Fix offline session close locking

The HIDL/AIDL session close is expected to trigger processCaptureResult
callbacks. Currently both methods will try to acquire the same
'mLock' which can result in a potential deadlock.
Revert back to the previous locking scheme where session close and
release are synchronized via 'mInterfaceLock' and 'mLock'
respectively.
Additionally handle failing offline client registration by
ensuring that the client is initialized before it gets released.
This will allow CameraHals to return/fail any pending offline
requests.

Bug: 267723307
Test: Camera CTS

Change-Id: Ib55d654bfa213ec2df0fc4590017f77c4492b28e
diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
index 2a8a103..b219cc8 100644
--- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
+++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
@@ -1851,6 +1851,10 @@
         mCompositeStreamMap.clear();
         mInputStream = {false, 0, 0, 0, 0};
     } else {
+        // In case we failed to register the offline client, ensure that it still initialized
+        // so that all failing requests can return back correctly once the object is released.
+        offlineClient->initialize(nullptr /*cameraProviderManager*/, String8()/*monitorTags*/);
+
         switch(ret) {
             case BAD_VALUE:
                 return STATUS_ERROR_FMT(CameraService::ERROR_ILLEGAL_ARGUMENT,