From 8907b9860a68c97591a413ec5765396f8234f414 Mon Sep 17 00:00:00 2001 From: Adithya R Date: Fri, 13 Sep 2024 16:19:09 +0530 Subject: [PATCH] sm8350-common: parts: Fix setting default thermal profile When the app's default thermal profile was different from the standard one, it resulted in not being able to set it back to the default mode. Fixes 37a15544 ("sm8350-common: parts: Automatically determine thermal profile for apps") Change-Id: I5029cfc72194a93f7ab693b6b6aa966066d7c3bf --- .../org/lineageos/settings/thermal/ThermalUtils.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/parts/src/org/lineageos/settings/thermal/ThermalUtils.java b/parts/src/org/lineageos/settings/thermal/ThermalUtils.java index 9caae92..683be77 100644 --- a/parts/src/org/lineageos/settings/thermal/ThermalUtils.java +++ b/parts/src/org/lineageos/settings/thermal/ThermalUtils.java @@ -43,7 +43,7 @@ import java.util.Map; public final class ThermalUtils { - private static final String THERMAL_CONTROL = "thermal_control"; + private static final String THERMAL_CONTROL = "thermal_control_v2"; protected static final int STATE_DEFAULT = 0; protected static final int STATE_BENCHMARK = 1; @@ -75,6 +75,7 @@ public final class ThermalUtils { private static final String THERMAL_NAVIGATION = "thermal.navigation="; private static final String THERMAL_STREAMING = "thermal.streaming="; private static final String THERMAL_VIDEO = "thermal.video="; + private static final String THERMAL_DEFAULT = "thermal.default="; private static final String THERMAL_SCONFIG = "/sys/class/thermal/thermal_message/sconfig"; @@ -105,7 +106,7 @@ public final class ThermalUtils { if (value == null || value.isEmpty()) { value = THERMAL_BENCHMARK + ":" + THERMAL_BROWSER + ":" + THERMAL_CAMERA + ":" + THERMAL_DIALER + ":" + THERMAL_GAMING + ":" + THERMAL_NAVIGATION + ":" + - THERMAL_STREAMING + ":" + THERMAL_VIDEO; + THERMAL_STREAMING + ":" + THERMAL_VIDEO + ":" + THERMAL_DEFAULT; writeValue(value); } return value; @@ -142,10 +143,13 @@ public final class ThermalUtils { case STATE_VIDEO: modes[7] = modes[7] + packageName + ","; break; + case STATE_DEFAULT: + modes[8] = modes[8] + packageName + ","; + break; } finalString = modes[0] + ":" + modes[1] + ":" + modes[2] + ":" + modes[3] + ":" + - modes[4] + ":" + modes[5] + ":" + modes[6] + ":" + modes[7]; + modes[4] + ":" + modes[5] + ":" + modes[6] + ":" + modes[7] + ":" + modes[8]; writeValue(finalString); } @@ -170,6 +174,8 @@ public final class ThermalUtils { state = STATE_STREAMING; } else if (modes[7].contains(packageName + ",")) { state = STATE_VIDEO; + } else if (modes[8].contains(packageName + ",")) { + state = STATE_DEFAULT; } else { // derive a default state based on package name state = getDefaultStateForPackage(packageName);