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

Commit 0e4a8ce6 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

power: Allow shutdownthread to invoke an external reboot command

This is for use in devices where the kernel doesn't react to arguments
in the reboot syscall, and need some other toggle or command

Activate with, for example:
TARGET_RECOVERY_PRE_COMMAND := "/system/bin/setup-recovery"

Note that this applies only to system_server, not the native layer

Change-Id: I55671a282cb53f7708460ba32fb4763fb40b5e96
parent db5456b6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -243,6 +243,10 @@ ifeq ($(WITH_MALLOC_LEAK_CHECK),true)
	LOCAL_CFLAGS += -DMALLOC_LEAK_CHECK
endif

ifneq ($(TARGET_RECOVERY_PRE_COMMAND),)
	LOCAL_CFLAGS += -DRECOVERY_PRE_COMMAND='$(TARGET_RECOVERY_PRE_COMMAND)'
endif

LOCAL_MODULE:= libandroid_runtime

include $(BUILD_SHARED_LIBRARY)
+4 −0
Original line number Diff line number Diff line
@@ -91,6 +91,10 @@ static void android_os_Power_reboot(JNIEnv *env, jobject clazz, jstring reason)
        reboot(RB_AUTOBOOT);
    } else {
        const char *chars = env->GetStringUTFChars(reason, NULL);
#ifdef RECOVERY_PRE_COMMAND
	if (!strncmp(chars,"recovery",8))
		system( RECOVERY_PRE_COMMAND );
#endif
        __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
                 LINUX_REBOOT_CMD_RESTART2, (char*) chars);
        env->ReleaseStringUTFChars(reason, chars);  // In case it fails.