summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodd Poynor <toddpoynor@google.com>2012-01-11 20:14:34 -0800
committerTodd Poynor <toddpoynor@google.com>2012-02-17 22:19:45 -0800
commit94d0024557f415b8463f085c9784a3e1d02b58c6 (patch)
treec1a3c37d8ce334975890b335f7d7b852ebf8f1d6
parent4e753e08d146ecd1a45a4402bb6b2e392d890a33 (diff)
downloadframeworks_base-94d0024557f415b8463f085c9784a3e1d02b58c6.zip
frameworks_base-94d0024557f415b8463f085c9784a3e1d02b58c6.tar.gz
frameworks_base-94d0024557f415b8463f085c9784a3e1d02b58c6.tar.bz2
Power HAL PowerManagerService hookup
Use PowerHAL to set system awake/suspend state. Change-Id: If58a6f548564ea141b68f304455997d9ff04eace Signed-off-by: Todd Poynor <toddpoynor@google.com>
-rw-r--r--core/java/android/os/Power.java2
-rw-r--r--core/jni/android_os_Power.cpp23
-rw-r--r--services/java/com/android/server/PowerManagerService.java1
3 files changed, 25 insertions, 1 deletions
diff --git a/core/java/android/os/Power.java b/core/java/android/os/Power.java
index 5a79215..58df940 100644
--- a/core/java/android/os/Power.java
+++ b/core/java/android/os/Power.java
@@ -104,4 +104,6 @@ public class Power
}
private static native void rebootNative(String reason) throws IOException ;
+
+ public static native int powerInitNative();
}
diff --git a/core/jni/android_os_Power.cpp b/core/jni/android_os_Power.cpp
index dc16990..48845f6 100644
--- a/core/jni/android_os_Power.cpp
+++ b/core/jni/android_os_Power.cpp
@@ -15,13 +15,18 @@
** limitations under the License.
*/
+#define LOG_TAG "Power-JNI"
+
#include "JNIHelp.h"
#include "jni.h"
#include "android_runtime/AndroidRuntime.h"
#include <utils/misc.h>
+#include <hardware/power.h>
#include <hardware_legacy/power.h>
#include <cutils/android_reboot.h>
+static struct power_module *sPowerModule;
+
namespace android
{
@@ -65,7 +70,9 @@ setLastUserActivityTimeout(JNIEnv *env, jobject clazz, jlong timeMS)
static int
setScreenState(JNIEnv *env, jobject clazz, jboolean on)
{
- return set_screen_state(on);
+ if (sPowerModule)
+ sPowerModule->setInteractive(sPowerModule, on);
+ return 0;
}
static void android_os_Power_shutdown(JNIEnv *env, jobject clazz)
@@ -85,12 +92,26 @@ static void android_os_Power_reboot(JNIEnv *env, jobject clazz, jstring reason)
jniThrowIOException(env, errno);
}
+static int android_os_Power_init(JNIEnv *env, jobject clazz)
+{
+ status_t err = hw_get_module(POWER_HARDWARE_MODULE_ID,
+ (hw_module_t const**)&sPowerModule);
+ ALOGE_IF(err, "couldn't load %s module (%s)",
+ POWER_HARDWARE_MODULE_ID, strerror(-err));
+
+ if (!err)
+ sPowerModule->init(sPowerModule);
+
+ return err;
+}
+
static JNINativeMethod method_table[] = {
{ "acquireWakeLock", "(ILjava/lang/String;)V", (void*)acquireWakeLock },
{ "releaseWakeLock", "(Ljava/lang/String;)V", (void*)releaseWakeLock },
{ "setLastUserActivityTimeout", "(J)I", (void*)setLastUserActivityTimeout },
{ "setScreenState", "(Z)I", (void*)setScreenState },
{ "shutdown", "()V", (void*)android_os_Power_shutdown },
+ { "powerInitNative", "()I", (void*)android_os_Power_init },
{ "rebootNative", "(Ljava/lang/String;)V", (void*)android_os_Power_reboot },
};
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index e953355..7b4372f 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -583,6 +583,7 @@ public class PowerManagerService extends IPowerManager.Stub
}
nativeInit();
+ Power.powerInitNative();
synchronized (mLocks) {
updateNativePowerStateLocked();
// We make sure to start out with the screen on due to user activity.