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

Commit 94d00245 authored by Todd Poynor's avatar Todd Poynor
Browse files

Power HAL PowerManagerService hookup



Use PowerHAL to set system awake/suspend state.

Change-Id: If58a6f548564ea141b68f304455997d9ff04eace
Signed-off-by: default avatarTodd Poynor <toddpoynor@google.com>
parent 4e753e08
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -104,4 +104,6 @@ public class Power
    }

    private static native void rebootNative(String reason) throws IOException ;

    public static native int powerInitNative();
}
+22 −1
Original line number Diff line number Diff line
@@ -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 },
};

+1 −0
Original line number Diff line number Diff line
@@ -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.