mirror of
https://github.com/ponces/treble_aosp.git
synced 2024-11-22 05:26:14 +00:00
63 lines
2.4 KiB
Diff
63 lines
2.4 KiB
Diff
From 60a4a39afdd196e229363f0f5bb063b3bdedf2fc 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/24] 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 15e2755a98..60e4eb7b42 100644
|
|
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
|
|
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
|
|
@@ -41,6 +41,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>
|
|
@@ -278,6 +279,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;
|
|
}
|
|
|
|
@@ -344,6 +354,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.34.1
|
|
|