mirror of
https://github.com/yurisieucuti/treble_evolution.git
synced 2024-11-24 09:46:19 +00:00
60 lines
2.4 KiB
Diff
60 lines
2.4 KiB
Diff
From b36339eaa7cab43ec0c5eaa523ed75e42ca10c8e Mon Sep 17 00:00:00 2001
|
|
From: Peter Cai <peter@typeblog.net>
|
|
Date: Wed, 1 Jun 2022 16:56:20 -0400
|
|
Subject: [PATCH 06/51] 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 039644387715..26ba0ca39ab9 100644
|
|
--- a/core/java/android/hardware/Camera.java
|
|
+++ b/core/java/android/hardware/Camera.java
|
|
@@ -41,6 +41,7 @@ import android.os.Message;
|
|
import android.os.Process;
|
|
import android.os.RemoteException;
|
|
import android.os.ServiceManager;
|
|
+import android.os.SystemProperties;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import android.view.Surface;
|
|
@@ -404,6 +405,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 bcce4b65be18..ef2e0e570578 100644
|
|
--- a/core/java/android/hardware/camera2/CameraManager.java
|
|
+++ b/core/java/android/hardware/camera2/CameraManager.java
|
|
@@ -2234,6 +2234,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.25.1
|
|
|