1
0
mirror of https://github.com/yurisieucuti/treble_evolution.git synced 2024-11-14 10:17:02 +00:00
treble_evolution/patches/platform_frameworks_av/0018-Add-a-prop-to-change-Samsung-flash-strength.patch
2024-04-24 15:13:17 +00:00

65 lines
3.1 KiB
Diff

From fce268c782f493033ece8a182b03d42bf393e64a 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/25] 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 1ece884867..6599763814 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 aefd6c3d4f..2412f82c37 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));
@@ -804,7 +806,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.25.1