camera: delay initialization of lazy camera providers

Camera HALs can be declared as "lazy" which lets cameraservice
only bring them up as needed. However, due to a series of independent
changes, cameraservice was unconditionally bringing up all AIDL HALs
including lazy HALs at startup and keeping them alive throughout its
lifetime.

This CL defers the lazy HAL initialization to when needed, and caches
the remote object in a weak_ptr to allow it to be garbage collected
when not in use. This is the same logic that was used before, and what
HIDL uses to handle lazy HALs.

Bug: 319735068
Test: atest cameraservice_test passes
Test: atest virtual_camera_test passes
Test: Manually that virtual_camera which is registered as a lazy
      Provider is not created until camera service is forced to
      run some operation on it.
Change-Id: I8f6bc7486843065984c4c572aaf15d33205c4a3a
diff --git a/camera/camera_platform.aconfig b/camera/camera_platform.aconfig
index 076394d..63a514d 100644
--- a/camera/camera_platform.aconfig
+++ b/camera/camera_platform.aconfig
@@ -83,3 +83,10 @@
      description: "Enable using ro.board.api_level instead of ro.vndk.version to get VNDK version"
      bug: "312315580"
 }
+
+flag {
+     namespace: "camera_platform"
+     name: "delay_lazy_hal_instantiation"
+     description: "Only trigger lazy HAL instantiation when the HAL is needed for an operation."
+     bug: "319735068"
+}