PowerManager: add powerHint method

Add powerHint method to IPowerManager for passing power hints from other
processes.

Change-Id: Ic596ace2ed1796a6da4cddb2163dcc4536115e55
This commit is contained in:
Ruchi Kandoi
2014-04-01 17:39:20 -07:00
parent 0a0454fdcc
commit f20a5eb279
3 changed files with 17 additions and 1 deletions

View File

@@ -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);

View File

@@ -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);
@@ -2547,6 +2548,12 @@ public final class PowerManagerService extends com.android.server.SystemService
acquireWakeLock(lock, flags, tag, packageName, new WorkSource(uid), null);
}
@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) {

View File

@@ -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) \