diff --git a/core/jni/Android.mk b/core/jni/Android.mk index 523b2d501b0dd..cd0959bb0b643 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -218,6 +218,7 @@ LOCAL_SHARED_LIBRARIES := \ libusbhost \ libharfbuzz \ libz \ + libsuspend \ ifeq ($(USE_OPENGL_RENDERER),true) LOCAL_SHARED_LIBRARIES += libhwui diff --git a/core/jni/android_os_Power.cpp b/core/jni/android_os_Power.cpp index 48845f6f402ee..a201d8bd0c632 100644 --- a/core/jni/android_os_Power.cpp +++ b/core/jni/android_os_Power.cpp @@ -24,6 +24,7 @@ #include #include #include +#include static struct power_module *sPowerModule; @@ -70,8 +71,14 @@ setLastUserActivityTimeout(JNIEnv *env, jobject clazz, jlong timeMS) static int setScreenState(JNIEnv *env, jobject clazz, jboolean on) { - if (sPowerModule) - sPowerModule->setInteractive(sPowerModule, on); + if (on) { + autosuspend_disable(); + sPowerModule->setInteractive(sPowerModule, true); + } else { + sPowerModule->setInteractive(sPowerModule, false); + autosuspend_enable(); + } + return 0; }