From 51d81f3c3e0ca2c04da68e93b7f4981843b74604 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 3 May 2012 17:56:47 -0700 Subject: [PATCH] Use libsuspend to trigger suspend Calling to libsuspend to trigger suspend instead of letting the power hal do it. Change-Id: I3cf51fea4d288f9fc19ce5aae39cdd581e8b44cb --- core/jni/Android.mk | 1 + core/jni/android_os_Power.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) 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; }