libcameraservice: Refactor the CameraServiceProxyWrapper into a class.

This is necessary for writing a unit test for camera permissions that
checks behavior when the device policy manager has disabled the camera.
Using the true DevicePolicyManager service would require a test be run
while the device has a work profile - a much simpler method would be to
fake the results from CameraServiceProxyWrapper::isCameraDisabled with
an override.

The CameraServiceProxyWrapper is now managed by a shared_ptr that
originates in CameraService, unless this is overridden by an outside
source (cameraservice_test). As a consequence of this, some refactoring
has been done to CameraSessionStatsWrapper class to avoid circular
ownership between it and its parent (CameraServiceProxyWrapper).

Change-Id: Iad4ee87f5c5ab849eee65b72f46f77faf37f4d25
Test: CtsCameraTestCases
diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp
index 20bf73d..65523bc 100644
--- a/services/camera/libcameraservice/api1/Camera2Client.cpp
+++ b/services/camera/libcameraservice/api1/Camera2Client.cpp
@@ -52,6 +52,7 @@
 
 Camera2Client::Camera2Client(const sp<CameraService>& cameraService,
         const sp<hardware::ICameraClient>& cameraClient,
+        std::shared_ptr<CameraServiceProxyWrapper> cameraServiceProxyWrapper,
         const String16& clientPackageName,
         const std::optional<String16>& clientFeatureId,
         const String8& cameraDeviceId,
@@ -62,7 +63,7 @@
         uid_t clientUid,
         int servicePid,
         bool overrideForPerfClass):
-        Camera2ClientBase(cameraService, cameraClient, clientPackageName,
+        Camera2ClientBase(cameraService, cameraClient, cameraServiceProxyWrapper, clientPackageName,
                 false/*systemNativeClient - since no ndk for api1*/, clientFeatureId,
                 cameraDeviceId, api1CameraId, cameraFacing, sensorOrientation, clientPid,
                 clientUid, servicePid, overrideForPerfClass, /*legacyClient*/ true),
@@ -478,7 +479,7 @@
     CameraService::Client::disconnect();
 
     int32_t closeLatencyMs = ns2ms(systemTime() - startTime);
-    CameraServiceProxyWrapper::logClose(mCameraIdStr, closeLatencyMs);
+    mCameraServiceProxyWrapper->logClose(mCameraIdStr, closeLatencyMs);
 
     return res;
 }