1
0
mirror of https://github.com/yurisieucuti/treble_evolution.git synced 2024-11-24 12:06:19 +00:00
treble_evolution/patches/trebledroid/platform_frameworks_av/0019-Add-a-prop-to-change-Samsung-flash-strength.patch
2024-03-10 06:48:11 +00:00

65 lines
3.0 KiB
Diff

From e9e77d5e28dbea793d4336af48f3fcf758226e3e 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 19/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 3136bbd30f..7ef870c1eb 100644
--- a/services/camera/libcameraservice/Android.bp
+++ b/services/camera/libcameraservice/Android.bp
@@ -177,6 +177,8 @@ cc_library_shared {
"android.hardware.camera.device-V2-ndk",
"vendor.samsung.hardware.camera.provider@3.0",
"vendor.samsung.hardware.camera.provider@4.0",
+ "vendor.samsung.hardware.camera.device@5.0",
+ "vendor.samsung.hardware.camera.device@4.0",
"media_permission-aidl-cpp",
],
diff --git a/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp b/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp
index 587d3eeda7..a345d6a2bf 100644
--- a/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp
+++ b/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp
@@ -29,6 +29,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));
@@ -783,7 +785,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