From 10f101e14301c9a34cb5c74489b439edb6088aa6 Mon Sep 17 00:00:00 2001 From: Arian Date: Fri, 2 Jul 2021 12:30:21 +0200 Subject: [PATCH] sm6150-common: parts: Enable doze_status on screen off * This allows to enter the doze state faster when unlocking from lockscreen Change-Id: I1900436c974a605555275ef67b283ead2cf720b5 --- .../org/lineageos/settings/doze/DozeService.java | 6 ++++++ .../src/org/lineageos/settings/doze/DozeUtils.java | 13 ++++++++++--- rootdir/etc/init.target.rc | 2 ++ sepolicy/vendor/file_contexts | 1 + 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/parts/src/org/lineageos/settings/doze/DozeService.java b/parts/src/org/lineageos/settings/doze/DozeService.java index 84641e1..270eab7 100644 --- a/parts/src/org/lineageos/settings/doze/DozeService.java +++ b/parts/src/org/lineageos/settings/doze/DozeService.java @@ -72,6 +72,9 @@ public class DozeService extends Service { private void onDisplayOn() { if (DEBUG) Log.d(TAG, "Display on"); + if (DozeUtils.isAlwaysOnEnabled(this)) { + DozeUtils.setDozeStatus(DozeUtils.DOZE_STATUS_DISABLED); + } if (DozeUtils.isPickUpEnabled(this)) { mPickupSensor.disable(); } @@ -86,6 +89,9 @@ public class DozeService extends Service { private void onDisplayOff() { if (DEBUG) Log.d(TAG, "Display off"); + if (DozeUtils.isAlwaysOnEnabled(this)) { + DozeUtils.setDozeStatus(DozeUtils.DOZE_STATUS_ENABLED); + } if (DozeUtils.isPickUpEnabled(this)) { mPickupSensor.enable(); } diff --git a/parts/src/org/lineageos/settings/doze/DozeUtils.java b/parts/src/org/lineageos/settings/doze/DozeUtils.java index 889e60d..732f975 100644 --- a/parts/src/org/lineageos/settings/doze/DozeUtils.java +++ b/parts/src/org/lineageos/settings/doze/DozeUtils.java @@ -58,6 +58,11 @@ public final class DozeUtils { protected static final String DOZE_MODE_HBM = "1"; protected static final String DOZE_MODE_LBM = "0"; + private static final String DOZE_STATUS_PATH = + "/sys/devices/platform/soc/soc:qcom,dsi-display/doze_status"; + protected static final String DOZE_STATUS_ENABLED = "1"; + protected static final String DOZE_STATUS_DISABLED = "0"; + protected static final String DOZE_BRIGHTNESS_LBM = "0"; protected static final String DOZE_BRIGHTNESS_HBM = "1"; protected static final String DOZE_BRIGHTNESS_DARK = "2"; @@ -80,9 +85,7 @@ public final class DozeUtils { } public static void checkDozeService(Context context) { - if (isDozeEnabled(context) - && (!isAlwaysOnEnabled(context) || isDozeAutoBrightnessEnabled(context)) - && sensorsEnabled(context)) { + if (isDozeEnabled(context) && (isAlwaysOnEnabled(context) || sensorsEnabled(context))) { startService(context); } else { stopService(context); @@ -149,6 +152,10 @@ public final class DozeUtils { return FileUtils.writeLine(DOZE_MODE_PATH, value); } + protected static boolean setDozeStatus(String value) { + return FileUtils.writeLine(DOZE_STATUS_PATH, value); + } + protected static boolean isDozeAutoBrightnessEnabled(Context context) { return PreferenceManager.getDefaultSharedPreferences(context) .getString(DOZE_BRIGHTNESS_KEY, DOZE_BRIGHTNESS_LBM) diff --git a/rootdir/etc/init.target.rc b/rootdir/etc/init.target.rc index 8b985ed..31bbcf0 100644 --- a/rootdir/etc/init.target.rc +++ b/rootdir/etc/init.target.rc @@ -82,7 +82,9 @@ on boot # Set doze mode permissions chown system system /sys/devices/platform/soc/soc:qcom,dsi-display/doze_mode + chown system system /sys/devices/platform/soc/soc:qcom,dsi-display/doze_status chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display/doze_mode + chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display/doze_status on property:sys.boot_completed=1 # Set allocstall_threshold to 0 diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 35899bc..bf7e8eb 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -9,6 +9,7 @@ /sys/devices/platform/soc/soc:qcom,dsi-display/dc_enable u:object_r:sysfs_anti_flicker:s0 /sys/devices/platform/soc/soc:qcom,dsi-display/hbm u:object_r:sysfs_hbm:s0 /sys/devices/platform/soc/soc:qcom,dsi-display/doze_mode u:object_r:sysfs_doze:s0 +/sys/devices/platform/soc/soc:qcom,dsi-display/doze_status u:object_r:sysfs_doze:s0 # Fingerprint /dev/goodix_fp u:object_r:fingerprint_device:s0