From d453f76b5000aebffbbf7dbfcf336f6142940135 Mon Sep 17 00:00:00 2001 From: Katharine Chui Date: Sat, 3 Feb 2024 02:26:18 +0800 Subject: [PATCH 1/3] call /system/etc/(post/pre)_sleep.sh before and after sleep, allow module probing --- suspend/1.0/default/SystemSuspend.cpp | 5 +++++ suspend/1.0/default/android.system.suspend@1.0-service.rc | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/suspend/1.0/default/SystemSuspend.cpp b/suspend/1.0/default/SystemSuspend.cpp index 9d88441..e1ae78b 100644 --- a/suspend/1.0/default/SystemSuspend.cpp +++ b/suspend/1.0/default/SystemSuspend.cpp @@ -33,6 +33,7 @@ #include #include +#include using ::android::base::GetBoolProperty; using ::android::base::GetProperty; @@ -292,6 +293,8 @@ bool SystemSuspend::forceSuspend() { // or reset mSuspendCounter, it just ignores them. When the system // returns from suspend, the wakelocks and SuspendCounter will not have // changed. + std::system("/system/bin/sh /system/etc/pre_sleep.sh"); + auto counterLock = std::unique_lock(mCounterLock); bool success = WriteStringToFd(getSleepState(), mStateFd); counterLock.unlock(); @@ -302,6 +305,8 @@ bool SystemSuspend::forceSuspend() { // light the screen up after suspend attempt, regardless of it failed or not // that way the user would know to try and sleep the device again if they want to mPwrbtnd->sendKeyWakeup(); + std::system("/system/bin/sh /system/etc/post_sleep.sh"); + return success; } diff --git a/suspend/1.0/default/android.system.suspend@1.0-service.rc b/suspend/1.0/default/android.system.suspend@1.0-service.rc index f353302..afbc6dd 100644 --- a/suspend/1.0/default/android.system.suspend@1.0-service.rc +++ b/suspend/1.0/default/android.system.suspend@1.0-service.rc @@ -2,4 +2,4 @@ service system_suspend /system/bin/hw/android.system.suspend@1.0-service class hal user system group system wakelock uhid input - capabilities BLOCK_SUSPEND + capabilities BLOCK_SUSPEND SYS_MODULE From 078f377755367a340b5b42532f658c21f36dc2cf Mon Sep 17 00:00:00 2001 From: Katharine Chui Date: Sat, 3 Feb 2024 23:21:47 +0800 Subject: [PATCH 2/3] run suspend hal as root so that sleep hooks can do anything --- .../1.0/default/android.system.suspend@1.0-service.rc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/suspend/1.0/default/android.system.suspend@1.0-service.rc b/suspend/1.0/default/android.system.suspend@1.0-service.rc index afbc6dd..05a2f33 100644 --- a/suspend/1.0/default/android.system.suspend@1.0-service.rc +++ b/suspend/1.0/default/android.system.suspend@1.0-service.rc @@ -1,5 +1,8 @@ service system_suspend /system/bin/hw/android.system.suspend@1.0-service class hal - user system - group system wakelock uhid input - capabilities BLOCK_SUSPEND SYS_MODULE + #user system + #group system wakelock uhid input + #capabilities BLOCK_SUSPEND + user root + group root + seclabel u:r:su:s0 From 8466bea860581474f5c018bc5d70237f53d38bdd Mon Sep 17 00:00:00 2001 From: Katharine Chui Date: Fri, 9 Feb 2024 00:32:32 +0800 Subject: [PATCH 3/3] run /vendor/etc/(pre|post)_sleep.sh as well because https://github.com/BlissRoms-x86/platform_system_hardware_interfaces/pull/7#issuecomment-1930082563 aka Huy Minh <39849246+hmtheboy154@users.noreply.github.com> said so --- suspend/1.0/default/SystemSuspend.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/suspend/1.0/default/SystemSuspend.cpp b/suspend/1.0/default/SystemSuspend.cpp index e1ae78b..1f02992 100644 --- a/suspend/1.0/default/SystemSuspend.cpp +++ b/suspend/1.0/default/SystemSuspend.cpp @@ -294,6 +294,7 @@ bool SystemSuspend::forceSuspend() { // returns from suspend, the wakelocks and SuspendCounter will not have // changed. std::system("/system/bin/sh /system/etc/pre_sleep.sh"); + std::system("/system/bin/sh /vendor/etc/pre_sleep.sh"); auto counterLock = std::unique_lock(mCounterLock); bool success = WriteStringToFd(getSleepState(), mStateFd); @@ -306,6 +307,7 @@ bool SystemSuspend::forceSuspend() { // that way the user would know to try and sleep the device again if they want to mPwrbtnd->sendKeyWakeup(); std::system("/system/bin/sh /system/etc/post_sleep.sh"); + std::system("/system/bin/sh /vendor/etc/post_sleep.sh"); return success; }