.android系统的关机,重启代码位于frameworks\base\core\jni\android_os_Power.cpp,里面有static void android_os_Power_shutdown(JNIEnv *env, jobject clazz) {/*关机*/ sync(); #ifdef HAVE_ANDROID_OS reboot(RB_POWER_OFF); #endif } 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); #endif } 2.最终会调用到linux中的sys_reboot,所以我们还是可以做到在android中加入重启功能的;
|