forked from PeterGSI/patches
60 lines
2.5 KiB
Diff
60 lines
2.5 KiB
Diff
From bd9fc170c2125e142f19805cceaaabe354ba6da8 Mon Sep 17 00:00:00 2001
|
|
From: Peter Cai <peter@typeblog.net>
|
|
Date: Wed, 1 Jun 2022 16:56:20 -0400
|
|
Subject: [PATCH 4/5] Implement a persistent property to override the default
|
|
primary camera (0)
|
|
|
|
Change-Id: I49b45d00bf71d7932591b3516d49a680e1b6568b
|
|
---
|
|
core/java/android/hardware/Camera.java | 6 ++++++
|
|
core/java/android/hardware/camera2/CameraManager.java | 9 +++++++++
|
|
2 files changed, 15 insertions(+)
|
|
|
|
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
|
|
index 3bdd39f5d7d7..fff46f20342b 100644
|
|
--- a/core/java/android/hardware/Camera.java
|
|
+++ b/core/java/android/hardware/Camera.java
|
|
@@ -45,6 +45,7 @@ import android.os.Message;
|
|
import android.os.Process;
|
|
import android.os.RemoteException;
|
|
import android.os.ServiceManager;
|
|
+import android.os.SystemProperties;
|
|
import android.renderscript.Allocation;
|
|
import android.renderscript.Element;
|
|
import android.renderscript.RSIllegalArgumentException;
|
|
@@ -408,6 +409,11 @@ public class Camera {
|
|
* @see #open(int)
|
|
*/
|
|
public static Camera open() {
|
|
+ int altPrimaryCamera = SystemProperties.getInt("persist.sys.alt_primary_camera", -1);
|
|
+ if (altPrimaryCamera > 0) {
|
|
+ return new Camera(altPrimaryCamera);
|
|
+ }
|
|
+
|
|
int numberOfCameras = getNumberOfCameras();
|
|
CameraInfo cameraInfo = new CameraInfo();
|
|
for (int i = 0; i < numberOfCameras; i++) {
|
|
diff --git a/core/java/android/hardware/camera2/CameraManager.java b/core/java/android/hardware/camera2/CameraManager.java
|
|
index d6d3a97687b5..c86c909a4109 100644
|
|
--- a/core/java/android/hardware/camera2/CameraManager.java
|
|
+++ b/core/java/android/hardware/camera2/CameraManager.java
|
|
@@ -1723,6 +1723,15 @@ public final class CameraManager {
|
|
}
|
|
}});
|
|
|
|
+ // HAXX: Allow overriding default primary camera (assumed to be camera 0) via property
|
|
+ // Should match with libcameraservice/common/CameraProviderManager.cpp
|
|
+ int altPrimaryCamera = SystemProperties.getInt("persist.sys.alt_primary_camera", -1);
|
|
+ if (altPrimaryCamera > 0 && altPrimaryCamera < cameraIds.length) {
|
|
+ String origPrimary = cameraIds[0];
|
|
+ cameraIds[0] = cameraIds[altPrimaryCamera];
|
|
+ cameraIds[altPrimaryCamera] = origPrimary;
|
|
+ }
|
|
+
|
|
}
|
|
|
|
public static boolean cameraStatusesContains(CameraStatus[] cameraStatuses, String id) {
|
|
--
|
|
2.37.2
|
|
|