1
0
mirror of https://github.com/yurisieucuti/treble_evolution.git synced 2024-11-14 10:17:02 +00:00
treble_evolution/patches/platform_frameworks_av/0007-camera-Implement-property-to-override-default-camera.patch
2024-04-24 15:13:17 +00:00

63 lines
2.4 KiB
Diff

From a457829cc8a6f29f3236ff2209ebf78d333800c5 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 1 Jun 2022 16:56:46 -0400
Subject: [PATCH 07/25] camera: Implement property to override default camera
Complement to the frameworks/base patch.
Change-Id: I002bfa974bafc2cc01365eeea31c7a5dcb5a2028
---
.../common/CameraProviderManager.cpp | 22 +++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
index 1ba3de49a2..3fffb03da8 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -40,6 +40,7 @@
#include <functional>
#include <camera_metadata_hidden.h>
#include <android-base/parseint.h>
+#include <android-base/properties.h>
#include <android-base/logging.h>
#include <cutils/properties.h>
#include <hwbinder/IPCThreadState.h>
@@ -261,6 +262,15 @@ std::vector<std::string> CameraProviderManager::getCameraDeviceIds(std::unordere
}
}
}
+
+ int32_t altPrimaryCamera = property_get_int32("persist.sys.alt_primary_camera", 0);
+
+ if (altPrimaryCamera != 0 && deviceIds.size() > (size_t) altPrimaryCamera) {
+ const std::string origPrimary = deviceIds[0];
+ deviceIds[0] = deviceIds[altPrimaryCamera];
+ deviceIds[altPrimaryCamera] = origPrimary;
+ }
+
return deviceIds;
}
@@ -327,6 +337,18 @@ std::vector<std::string> CameraProviderManager::getAPI1CompatibleCameraDeviceIds
std::sort(systemDeviceIds.begin(), systemDeviceIds.end(), sortFunc);
deviceIds.insert(deviceIds.end(), publicDeviceIds.begin(), publicDeviceIds.end());
deviceIds.insert(deviceIds.end(), systemDeviceIds.begin(), systemDeviceIds.end());
+
+ // Default camera ID hack should match with android.hardware.camera2.CameraManager.sortCameraIds
+ // Note that the alt primary camera may not be available here due to filterLogicalCameraIdsLocked()
+ // in which case we will just ignore it.
+ int altPrimaryCameraId = base::GetIntProperty("persist.sys.alt_primary_camera", -1);
+
+ if (altPrimaryCameraId > 0 && altPrimaryCameraId < (int) deviceIds.size()) {
+ std::string origPrimary = deviceIds[0];
+ deviceIds[0] = deviceIds[altPrimaryCameraId];
+ deviceIds[altPrimaryCameraId] = origPrimary;
+ }
+
return deviceIds;
}
--
2.25.1