1
0
mirror of https://github.com/yurisieucuti/treble_evolution.git synced 2024-11-24 08:36:19 +00:00
treble_evolution/patches/platform_frameworks_base/0023-backlight-Fix-backlight-control-on-Galaxy-S9.patch
2024-04-24 15:13:17 +00:00

122 lines
5.0 KiB
Diff

From 5a779616bac07395d4ae23eb3d37c65716836804 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 24 Mar 2018 08:01:48 +0100
Subject: [PATCH 23/51] backlight: Fix backlight control on Galaxy S9(+)
Change-Id: I1fbbb47939c377597ef8ad6b88b2acea5f4acaa6
:backlight: S9 brightness override only for screen
Change-Id: Ie16a46336fa64850014b962429f7a20ff569222f
:backlight: [WIP] Fix OP6 brightness
Change-Id: If08959ece6cac1f27e1f1a0bd966ee8e1813241d
:backlight: Try to make brightness more generic using property set by rw-system
Change-Id: I0f20ca4b1f0fa1fcfd19833aa291fbdf16d6eedd
:backlight: Add Qualcomm starlte
Change-Id: I12a445344deb8b2e59a2f6ce6b24c1ffe5675092
:backlight: Switch samsung light fingerprint match to regexp, to include Note9
Change-Id: I2995f7bab615aec125927a5a027ad8f9ae43405f
Add a property toggle to enable high brightness range on samsung device
Change-Id: I649a3985ef87f46a5515a63935fdae9cdcbd8ec5
:backlight: Add japanese S9
Change-Id: I5e245469f5f51fed14c6080e5be72506e10389e0
:backlight: Fix backlight on S10*. Add an additional property to check, so testers can try it more easily
Change-Id: Ia224e641cad8561201b4dee3d896362bee80c903
:backlight: Make samsung light HAL more overridable
Change-Id: Ie04f394f8a614da8070f330bcadbcbe12895bed0
Use new backlight control API only for backlight, not for other lights
Change-Id: I35c35fabff8b275f35671dcb8578b96dcad526f1
:backlight: fixup
Change-Id: I4e85178327d2bb63d5d0a37786058843662a89ba
---
.../android/server/lights/LightsService.java | 46 +++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
index 6124b553498c..67f6932921f6 100644
--- a/services/core/java/com/android/server/lights/LightsService.java
+++ b/services/core/java/com/android/server/lights/LightsService.java
@@ -31,6 +31,7 @@ import android.os.Looper;
import android.os.PermissionEnforcer;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.SystemProperties;
import android.os.Trace;
import android.provider.Settings;
import android.util.Slog;
@@ -297,6 +298,51 @@ public class LightsService extends SystemService {
return;
}
int brightnessInt = BrightnessSynchronizer.brightnessFloatToInt(brightness);
+
+ if(mHwLight.id == 0) {
+ String fp = SystemProperties.get("ro.vendor.build.fingerprint", "hello");
+ if(fp.matches(".*astarqlte.*")) {
+ int newBrightness = brightnessInt;
+ if(SystemProperties.getBoolean("persist.sys.samsung.full_brightness", false)) {
+ newBrightness = (int) (brightnessInt * 365.0 / 255.0);
+ }
+ setLightLocked(newBrightness, LIGHT_FLASH_HARDWARE, 0, 0, brightnessMode);
+ return;
+ }
+
+ int useSamsungBacklight = SystemProperties.getInt("persist.sys.phh.samsung_backlight", -1);
+ if(useSamsungBacklight != 0) {
+ if(useSamsungBacklight > 0 ||
+ fp.matches(".*beyond.*lte.*") ||
+ fp.matches(".*(crown|star)[q2]*lte.*") ||
+ fp.matches(".*(SC-0[23]K|SCV3[89]).*")) {
+ int ratio = 100;
+ if(useSamsungBacklight > 1)
+ ratio = useSamsungBacklight;
+ int newBrightness = brightnessInt * ratio;
+ if(SystemProperties.getBoolean("persist.sys.samsung.full_brightness", false)) {
+ newBrightness = (int) (brightnessInt * 40960.0 / 255.0);
+ }
+ setLightLocked(newBrightness, LIGHT_FLASH_HARDWARE, 0, 0, brightnessMode);
+ return;
+ }
+ }
+
+ boolean qcomExtendBrightness = SystemProperties.getBoolean("persist.extend.brightness", false);
+ int scale = SystemProperties.getInt("persist.display.max_brightness", 1023);
+ //This is set by vndk-detect
+ int qcomScale = SystemProperties.getInt("persist.sys.qcom-brightness", -1);
+ if(qcomScale != -1) {
+ qcomExtendBrightness = true;
+ scale = qcomScale;
+ }
+
+ if(qcomExtendBrightness) {
+ setLightLocked(brightnessInt * scale / 255, LIGHT_FLASH_NONE, 0, 0, brightnessMode);
+ return;
+ }
+ }
+
int color = brightnessInt & 0x000000ff;
color = 0xff000000 | (color << 16) | (color << 8) | color;
setLightLocked(color, LIGHT_FLASH_NONE, 0, 0, brightnessMode);
--
2.25.1