1
0
mirror of https://github.com/yurisieucuti/treble_evolution.git synced 2024-11-28 04:44:30 +00:00
treble_evolution/patches/trebledroid/platform_frameworks_av/0007-camera-Implement-property-to-override-default-camera.patch
2024-03-10 06:48:11 +00:00

63 lines
2.4 KiB
Diff

From 66d6a4396d76bb4a88c5c3fafc7db79970889a95 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 fac6e4e189..0ec647a941 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -38,6 +38,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>
@@ -215,6 +216,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;
}
@@ -281,6 +291,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