Skip to content

Commit 51d81f3

Browse files
committed
Use libsuspend to trigger suspend
Calling to libsuspend to trigger suspend instead of letting the power hal do it. Change-Id: I3cf51fea4d288f9fc19ce5aae39cdd581e8b44cb
1 parent 1c87360 commit 51d81f3

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

core/jni/Android.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ LOCAL_SHARED_LIBRARIES := \
218218
libusbhost \
219219
libharfbuzz \
220220
libz \
221+
libsuspend \
221222

222223
ifeq ($(USE_OPENGL_RENDERER),true)
223224
LOCAL_SHARED_LIBRARIES += libhwui

core/jni/android_os_Power.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <hardware/power.h>
2525
#include <hardware_legacy/power.h>
2626
#include <cutils/android_reboot.h>
27+
#include <suspend/autosuspend.h>
2728

2829
static struct power_module *sPowerModule;
2930

@@ -70,8 +71,14 @@ setLastUserActivityTimeout(JNIEnv *env, jobject clazz, jlong timeMS)
7071
static int
7172
setScreenState(JNIEnv *env, jobject clazz, jboolean on)
7273
{
73-
if (sPowerModule)
74-
sPowerModule->setInteractive(sPowerModule, on);
74+
if (on) {
75+
autosuspend_disable();
76+
sPowerModule->setInteractive(sPowerModule, true);
77+
} else {
78+
sPowerModule->setInteractive(sPowerModule, false);
79+
autosuspend_enable();
80+
}
81+
7582
return 0;
7683
}
7784

0 commit comments

Comments
 (0)