From 8443e6a758ad4eb11fa15b5cbd6867bb3c8f5213 Mon Sep 17 00:00:00 2001 From: Hikari-no-Tenshi Date: Thu, 10 Mar 2022 15:19:36 +0300 Subject: [PATCH] fw_av: libcameraservice: add TARGET_CAMERA_NEEDS_CLIENT_INFO_LIB Directly set camera package name by using OnePlusCameraProvider service. Signed-off-by: Semavi Ulusoy Change-Id: I2dbefb5fa290da13160f94102e96850125feeb8a --- services/camera/libcameraservice/Android.bp | 1 + .../camera/libcameraservice/CameraService.cpp | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/services/camera/libcameraservice/Android.bp b/services/camera/libcameraservice/Android.bp index 5f99c7cdf58..b165130606c 100644 --- a/services/camera/libcameraservice/Android.bp +++ b/services/camera/libcameraservice/Android.bp @@ -39,6 +39,7 @@ cc_library_shared { name: "libcameraservice", defaults: [ "no_cameraserver_defaults", + "camera_needs_client_info_lib_defaults", ], // Camera service source diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 40c74dc4bfc..6538c5ebe0b 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -78,6 +78,10 @@ #include "utils/CameraThreadState.h" #include "utils/CameraServiceProxyWrapper.h" +#ifdef CAMERA_NEEDS_CLIENT_INFO_LIB +#include +#endif + namespace { const char* kPermissionServiceName = "permission"; }; // namespace anonymous @@ -97,6 +101,9 @@ using hardware::camera2::ICameraInjectionCallback; using hardware::camera2::ICameraInjectionSession; using hardware::camera2::utils::CameraIdAndSessionConfiguration; using hardware::camera2::utils::ConcurrentCameraIdCombination; +#ifdef CAMERA_NEEDS_CLIENT_INFO_LIB +using ::vendor::oneplus::hardware::camera::V1_0::IOnePlusCameraProvider; +#endif // ---------------------------------------------------------------------------- // Logging support -- this is for debugging only @@ -134,6 +141,9 @@ static const String16 sCameraOpenCloseListenerPermission( static const String16 sCameraInjectExternalCameraPermission("android.permission.CAMERA_INJECT_EXTERNAL_CAMERA"); const char *sFileName = "lastOpenSessionDumpFile"; +#ifdef CAMERA_NEEDS_CLIENT_INFO_LIB +static const sp gVendorCameraProviderService = IOnePlusCameraProvider::getService(); +#endif static constexpr int32_t kVendorClientScore = resource_policy::PERCEPTIBLE_APP_ADJ; static constexpr int32_t kVendorClientState = ActivityManager::PROCESS_STATE_PERSISTENT_UI; @@ -3254,7 +3264,9 @@ status_t CameraService::BasicClient::startCameraOps() { // Notify listeners of camera open/close status sCameraService->updateOpenCloseStatus(mCameraIdStr, true/*open*/, mClientPackageName); - +#ifdef CAMERA_NEEDS_CLIENT_INFO_LIB + gVendorCameraProviderService->setPackageName(String8(mClientPackageName).string()); +#endif return OK; } @@ -3326,7 +3338,6 @@ status_t CameraService::BasicClient::finishCameraStreamingOps() { mClientPackageName, mClientFeatureId); mOpsStreaming = false; } - return OK; }