mirror of
https://github.com/yurisieucuti/treble_evolution.git
synced 2024-11-24 12:06:19 +00:00
60 lines
2.5 KiB
Diff
60 lines
2.5 KiB
Diff
From 7e6a9ed0bce8027ea6b6cd43cbbf13a9026872ab 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/56] 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 ccc39b6080d7..a21bfdce6f05 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.renderscript.Allocation;
|
|
import android.renderscript.Element;
|
|
import android.renderscript.RSIllegalArgumentException;
|
|
@@ -409,6 +410,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 c80124c4c2ec..b13979d2359b 100644
|
|
--- a/core/java/android/hardware/camera2/CameraManager.java
|
|
+++ b/core/java/android/hardware/camera2/CameraManager.java
|
|
@@ -2077,6 +2077,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
|
|
|