Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f20a5eb2 authored by Ruchi Kandoi's avatar Ruchi Kandoi
Browse files

PowerManager: add powerHint method

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

Change-Id: Ic596ace2ed1796a6da4cddb2163dcc4536115e55
parent 0a0454fd
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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);
+7 −0
Original line number Diff line number Diff line
@@ -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) {
+8 −0
Original line number Diff line number Diff line
@@ -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) \