Camera: Support lazy HALs
Drop camera HAL references when unused.
Use ro.camera.enableLazyHal property to toggle behavior on or off.
* If true, the cameraserver drops references to ICameraProvider HALs
when they are not being used for either camera or torch.
* If false (or unset), stores a strong reference to each ICameraProvider
that is registered. This is the same as the old behavior.
Bug: 79374634
Test: Apply CL that lets camera HAL exit when unused. Open camera/enable
torch, close camera/disable torch, check ps -A to see if HAL exits.
Change-Id: I1842f9bf9e862ab74e4ec8aa72fc46fc47782ed0
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 32b07fa..6003607 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -2215,6 +2215,8 @@
sCameraService->removeByClient(this);
sCameraService->logDisconnected(mCameraIdStr, mClientPid,
String8(mClientPackageName));
+ sCameraService->mCameraProviderManager->removeRef(CameraProviderManager::DeviceMode::CAMERA,
+ mCameraIdStr.c_str());
sp<IBinder> remote = getRemote();
if (remote != nullptr) {