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/services/camera/libcameraservice/common/CameraProviderManager.h b/services/camera/libcameraservice/common/CameraProviderManager.h
index 53a2102..fc0172c 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.h
+++ b/services/camera/libcameraservice/common/CameraProviderManager.h
@@ -178,9 +178,15 @@
     // Proxy to inject fake services in test.
     class AidlServiceInteractionProxy {
       public:
-        // Returns the Aidl service with the given serviceName
+        // Returns the Aidl service with the given serviceName. Will wait indefinitely
+        // for the service to come up if not running.
         virtual std::shared_ptr<aidl::android::hardware::camera::provider::ICameraProvider>
-        getAidlService(const std::string& serviceName) = 0;
+        getService(const std::string& serviceName) = 0;
+
+        // Attempts to get an already running AIDL service of the given serviceName.
+        // Returns nullptr immediately if service is not running.
+        virtual std::shared_ptr<aidl::android::hardware::camera::provider::ICameraProvider>
+        tryGetService(const std::string& serviceName) = 0;
 
         virtual ~AidlServiceInteractionProxy() = default;
     };
@@ -190,7 +196,10 @@
     class AidlServiceInteractionProxyImpl : public AidlServiceInteractionProxy {
       public:
         virtual std::shared_ptr<aidl::android::hardware::camera::provider::ICameraProvider>
-        getAidlService(const std::string& serviceName) override;
+        getService(const std::string& serviceName) override;
+
+        virtual std::shared_ptr<aidl::android::hardware::camera::provider::ICameraProvider>
+        tryGetService(const std::string& serviceName) override;
     };
 
     /**