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

Commit f8419f7b authored by Steve Kondik's avatar Steve Kondik
Browse files

Call system services when shutting down/rebooting.

parent 9db3d07b
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <utils/misc.h>
#include <hardware_legacy/power.h>
#include <sys/reboot.h>
#include <cutils/properties.h>

namespace android
{
@@ -79,7 +80,7 @@ static void android_os_Power_shutdown(JNIEnv *env, jobject clazz)
{
    sync();
#ifdef HAVE_ANDROID_OS
    reboot(RB_POWER_OFF);
    property_set("ctl.start", "poweroff");
#endif
}

@@ -87,15 +88,7 @@ static void android_os_Power_reboot(JNIEnv *env, jobject clazz, jstring reason)
{
    sync();
#ifdef HAVE_ANDROID_OS
    if (reason == NULL) {
        reboot(RB_AUTOBOOT);
    } else {
        const char *chars = env->GetStringUTFChars(reason, NULL);
        __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
                 LINUX_REBOOT_CMD_RESTART2, (char*) chars);
        env->ReleaseStringUTFChars(reason, chars);  // In case it fails.
    }
    jniThrowIOException(env, errno);
    property_set("ctl.start", "reboot");
#endif
}