1
0
mirror of https://github.com/ponces/treble_aosp.git synced 2024-11-24 21:26:23 +00:00
treble_aosp/patches/trebledroid/platform_frameworks_base/0006-Implement-a-persistent-property-to-override-the-defa.patch
2024-07-21 01:50:08 +01:00

60 lines
2.4 KiB
Diff

From f13ab9cf0dd4846bffd85f894cbccd410b186004 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/54] 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 1c36a88726b8..3ec40136e084 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 d2e4a614202f..b5a00b192edc 100644
--- a/core/java/android/hardware/camera2/CameraManager.java
+++ b/core/java/android/hardware/camera2/CameraManager.java
@@ -2196,6 +2196,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.34.1