diff options
author | Ruchi Kandoi <kandoiruchi@google.com> | 2014-04-01 17:39:20 -0700 |
---|---|---|
committer | Ruchi Kandoi <kandoiruchi@google.com> | 2014-04-04 20:24:16 +0000 |
commit | f20a5eb279035d462e1f5d9895f4eb66cc152215 (patch) | |
tree | 9201efaeab6f8407f83c6921ca80b38f59c666ff | |
parent | 0a0454fdcc7aeac6e57f9466da8f39bcf5f3f6ec (diff) | |
download | frameworks_base-f20a5eb279035d462e1f5d9895f4eb66cc152215.zip frameworks_base-f20a5eb279035d462e1f5d9895f4eb66cc152215.tar.gz frameworks_base-f20a5eb279035d462e1f5d9895f4eb66cc152215.tar.bz2 |
PowerManager: add powerHint method
Add powerHint method to IPowerManager for passing power hints from other
processes.
Change-Id: Ic596ace2ed1796a6da4cddb2163dcc4536115e55
3 files changed, 17 insertions, 1 deletions
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl index d03b0c5..be3c0cc 100644 --- a/core/java/android/os/IPowerManager.aidl +++ b/core/java/android/os/IPowerManager.aidl @@ -23,7 +23,7 @@ import android.os.WorkSource; interface IPowerManager { - // WARNING: The first four methods must remain the first three methods because their + // WARNING: The first five methods must remain the first five methods because their // transaction numbers must not change unless IPowerManager.cpp is also updated. void acquireWakeLock(IBinder lock, int flags, String tag, String packageName, in WorkSource ws, String historyTag); @@ -31,6 +31,7 @@ interface IPowerManager int uidtoblame); void releaseWakeLock(IBinder lock, int flags); void updateWakeLockUids(IBinder lock, in int[] uids); + oneway void powerHint(int hintId, int data); void updateWakeLockWorkSource(IBinder lock, in WorkSource ws, String historyTag); boolean isWakeLockLevelSupported(int level); diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java index 80c3c8e..b85a506 100644 --- a/services/core/java/com/android/server/power/PowerManagerService.java +++ b/services/core/java/com/android/server/power/PowerManagerService.java @@ -406,6 +406,7 @@ public final class PowerManagerService extends com.android.server.SystemService private static native void nativeReleaseSuspendBlocker(String name); private static native void nativeSetInteractive(boolean enable); private static native void nativeSetAutoSuspend(boolean enable); + private static native void nativeSendPowerHint(int hintId, int data); public PowerManagerService(Context context) { super(context); @@ -2548,6 +2549,12 @@ public final class PowerManagerService extends com.android.server.SystemService } @Override // Binder call + public void powerHint(int hintId, int data) { + mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); + nativeSendPowerHint(hintId, data); + } + + @Override // Binder call public void acquireWakeLock(IBinder lock, int flags, String tag, String packageName, WorkSource ws, String historyTag) { if (lock == null) { diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp index 151e134..3ee2b16 100644 --- a/services/core/jni/com_android_server_power_PowerManagerService.cpp +++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp @@ -189,6 +189,12 @@ static void nativeSetAutoSuspend(JNIEnv *env, jclass clazz, jboolean enable) { } } +static void nativeSendPowerHint(JNIEnv *env, jclass clazz, jint hintId, jint data) { + if (gPowerModule && gPowerModule->powerHint) { + gPowerModule->powerHint(gPowerModule, (power_hint_t)hintId, (void *)data); + } +} + // ---------------------------------------------------------------------------- static JNINativeMethod gPowerManagerServiceMethods[] = { @@ -205,6 +211,8 @@ static JNINativeMethod gPowerManagerServiceMethods[] = { (void*) nativeSetInteractive }, { "nativeSetAutoSuspend", "(Z)V", (void*) nativeSetAutoSuspend }, + { "nativeSendPowerHint", "(II)V", + (void*) nativeSendPowerHint }, }; #define FIND_CLASS(var, className) \ |