1
0
mirror of https://github.com/ponces/treble_aosp.git synced 2024-11-22 05:26:14 +00:00
treble_aosp/patches/trebledroid/platform_frameworks_av/0018-Add-a-prop-to-change-Samsung-flash-strength.patch
2024-06-18 10:56:01 +01:00

65 lines
3.1 KiB
Diff

From 6e4ac3b041074f31659737d43b0088465496220c Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 16 Apr 2022 14:30:14 -0400
Subject: [PATCH 18/24] Add a prop to change Samsung flash strength
---
services/camera/libcameraservice/Android.bp | 2 ++
.../common/hidl/HidlProviderInfo.cpp | 20 ++++++++++++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/services/camera/libcameraservice/Android.bp b/services/camera/libcameraservice/Android.bp
index 6b7a74edb6..1e1423f42b 100644
--- a/services/camera/libcameraservice/Android.bp
+++ b/services/camera/libcameraservice/Android.bp
@@ -83,6 +83,8 @@ cc_defaults {
"android.hardware.camera.device@3.5",
"android.hardware.camera.device@3.6",
"android.hardware.camera.device@3.7",
+ "vendor.samsung.hardware.camera.device@5.0",
+ "vendor.samsung.hardware.camera.device@4.0",
"android.hardware.common-V2-ndk",
"android.hardware.common.fmq-V1-ndk",
"camera_platform_flags_c_lib",
diff --git a/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp b/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp
index c60c0c4ffa..9d9275c89c 100644
--- a/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp
+++ b/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp
@@ -30,6 +30,8 @@
#include <android/hardware/camera/device/3.7/ICameraDevice.h>
#include <vendor/samsung/hardware/camera/provider/3.0/ISehCameraProvider.h>
#include <vendor/samsung/hardware/camera/provider/4.0/ISehCameraProvider.h>
+#include <vendor/samsung/hardware/camera/device/5.0/ISehCameraDevice.h>
+#include <vendor/samsung/hardware/camera/device/4.0/ISehCameraDevice.h>
namespace {
const bool kEnableLazyHal(property_get_bool("ro.camera.enableLazyHal", false));
@@ -812,7 +814,23 @@ HidlProviderInfo::HidlDeviceInfo3::HidlDeviceInfo3(
status_t HidlProviderInfo::HidlDeviceInfo3::setTorchMode(bool enabled) {
using hardware::camera::common::V1_0::TorchMode;
const sp<hardware::camera::device::V3_2::ICameraDevice> interface = startDeviceInterface();
- Status s = interface->setTorchMode(enabled ? TorchMode::ON : TorchMode::OFF);
+ int32_t flashStrength = property_get_int32("persist.sys.phh.flash_strength", 1);
+
+ auto sehCast = vendor::samsung::hardware::camera::device::V5_0::ISehCameraDevice::castFrom(interface);
+ android::sp<vendor::samsung::hardware::camera::device::V5_0::ISehCameraDevice> seh = sehCast;
+
+ auto sehCast2 = vendor::samsung::hardware::camera::device::V4_0::ISehCameraDevice::castFrom(interface);
+ android::sp<vendor::samsung::hardware::camera::device::V4_0::ISehCameraDevice> seh2 = sehCast2;
+
+ Status s;
+ if(seh != nullptr) {
+ s = seh->sehSetTorchModeStrength(enabled ? TorchMode::ON : TorchMode::OFF, flashStrength);
+ } else if(seh2 != nullptr) {
+ s = seh2->sehSetTorchModeStrength(enabled ? TorchMode::ON : TorchMode::OFF, flashStrength);
+ } else {
+ s = interface->setTorchMode(enabled ? TorchMode::ON : TorchMode::OFF);
+ }
+
return mapToStatusT(s);
}
--
2.34.1