From 0da47dae492323900ae10b50e7d3bcaef08156ae Mon Sep 17 00:00:00 2001 From: Ken Sumrall Date: Mon, 7 Mar 2011 23:42:39 -0800 Subject: [PATCH] Teach the framework to use the new android_reboot() function. The new android_reboot() function is a nicer way to reboot. It can optionally sync(2) and remount as read-only writable filesystems. This fixes bug 3350709. Change-Id: I792fa3f726f8d685a696f52cf760e731567ed8d4 --- core/jni/android_os_Power.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/jni/android_os_Power.cpp b/core/jni/android_os_Power.cpp index a46c2dd5b90a8..5cfb9b1f6fcb6 100644 --- a/core/jni/android_os_Power.cpp +++ b/core/jni/android_os_Power.cpp @@ -20,7 +20,7 @@ #include "android_runtime/AndroidRuntime.h" #include #include -#include +#include namespace android { @@ -77,25 +77,26 @@ setScreenState(JNIEnv *env, jobject clazz, jboolean on) static void android_os_Power_shutdown(JNIEnv *env, jobject clazz) { - sync(); #ifdef HAVE_ANDROID_OS - reboot(RB_POWER_OFF); + android_reboot(ANDROID_RB_POWEROFF, 0, 0); +#else + sync(); #endif } static void android_os_Power_reboot(JNIEnv *env, jobject clazz, jstring reason) { - sync(); #ifdef HAVE_ANDROID_OS if (reason == NULL) { - reboot(RB_AUTOBOOT); + android_reboot(ANDROID_RB_RESTART, 0, 0); } else { const char *chars = env->GetStringUTFChars(reason, NULL); - __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, - LINUX_REBOOT_CMD_RESTART2, (char*) chars); + android_reboot(ANDROID_RB_RESTART2, 0, (char *) chars); env->ReleaseStringUTFChars(reason, chars); // In case it fails. } jniThrowIOException(env, errno); +#else + sync(); #endif }