Camera: Prevent simultenous HAL initialization If camera client fails to initialize then connectHelper just return error code without explicitly disconnect the client. This could cause the HAL to be initialized between the conflicting devies, if multiple camera connect attempt is invoked simultaneously. This patch will prevent the situation by explicitly disconnecting the client before returning the error code. Bug: 290325991 Test: Manual test with the OEM application Change-Id: I2d7a14c01ed5ae6e0f4335f1f0be5742c637b8ee
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 668a51a..d1351cf 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp
@@ -2040,6 +2040,9 @@ if (err != OK) { ALOGE("%s: Could not initialize client from HAL.", __FUNCTION__); // Errors could be from the HAL module open call or from AppOpsManager + mServiceLock.unlock(); + client->disconnect(); + mServiceLock.lock(); switch(err) { case BAD_VALUE: return STATUS_ERROR_FMT(ERROR_ILLEGAL_ARGUMENT,