From 3fa56c8361355fe880ac902cf20563cffa095899 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 | 3 +++ suspend/1.0/default/android.system.suspend@1.0-service.rc | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/suspend/1.0/default/SystemSuspend.cpp b/suspend/1.0/default/SystemSuspend.cpp index 6d8cebb..d324e90 100644 --- a/suspend/1.0/default/SystemSuspend.cpp +++ b/suspend/1.0/default/SystemSuspend.cpp @@ -36,6 +36,7 @@ #include #include using namespace std::chrono_literals; +#include using ::aidl::android::system::suspend::ISystemSuspend; using ::aidl::android::system::suspend::IWakeLock; @@ -406,6 +407,7 @@ 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 autosuspendLock = std::unique_lock(mAutosuspendLock); bool success = WriteStringToFd(getSleepState(), mStateFd); autosuspendLock.unlock(); @@ -414,6 +416,7 @@ bool SystemSuspend::forceSuspend() { PLOG(VERBOSE) << "error writing to /sys/power/state for forceSuspend"; } 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 c0c2f5c..220ee4e 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 early_hal user system group system wakelock uhid input - capabilities BLOCK_SUSPEND + capabilities BLOCK_SUSPEND SYS_MODULE From e1834ddd8405233b6032291fbac3517580a68936 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 220ee4e..8f1ae0f 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 early_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 cec2ee486688e0367cf19b6c2a39e1a6c90b3301 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 d324e90..3c3b233 100644 --- a/suspend/1.0/default/SystemSuspend.cpp +++ b/suspend/1.0/default/SystemSuspend.cpp @@ -408,6 +408,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 autosuspendLock = std::unique_lock(mAutosuspendLock); bool success = WriteStringToFd(getSleepState(), mStateFd); autosuspendLock.unlock(); @@ -417,6 +418,7 @@ bool SystemSuspend::forceSuspend() { } mPwrbtnd->sendKeyWakeup(); std::system("/system/bin/sh /system/etc/post_sleep.sh"); + std::system("/system/bin/sh /vendor/etc/post_sleep.sh"); return success; }