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

Unverified Commit 65b15e31 authored by atinm's avatar atinm Committed by Michael Bestas
Browse files

Use RECOVERY_PRE_COMMAND before calling __reboot() recovery



For the Power menu,
frameworks/base/core/jni/android_os_Power.cpp#L180
already uses RECOVERY_PRE_COMMAND if
TARGET_RECOVERY_PRE_COMMAND is defined in the
BoardConfig.mk for a device to make a system() call before
calling __reboot() for recovery. This commit adds
the same thing to the other places that we know we are
getting into recovery using __reboot(), namely,
adb reboot recovery, the reboot binary and init
in the case of errors.

Signed-off-by: default avatarHumberto Borba <humberos@gmail.com>

Conflicts:
	libcutils/Android.mk
	libcutils/android_reboot.c

Change-Id: Id0fb6675accd732f46d4b10e0fce459d2582875c

libcutils : reboot mount fix

On aries for eg, cache needs to be rw for the RECOVERY_PRE_COMMAND to
work because we write to /cache/.startrecovery

This patchset moves the RECOVERY_PRE_COMMAND prior to the remount.

Conflicts:
	libcutils/android_reboot.c

Change-Id: I4bd97517e00cdd117191d29b610e9623ad7d9255

RECOVERY_PRE_COMMAND_CLEAR_REASON and extended reboot arguments

fix the 2 new warnings created by our 4-lines recovery patch ;p

Allow also to override toolbox reboot applet, for bootmenu

Conflicts:
	libcutils/Android.mk
	libcutils/android_reboot.c
	toolbox/Android.mk

Change-Id: I2bff30b5f911e7b9ba8f26593523368223b12814

android_reboot: execute recovery pre command while rw mounted

The TARGET_RECOVERY_PRE_COMMAND might need to write to mounted
partitions, so execute it before re-mounting everything as read-
only.

Change-Id: I66b2e81b8c05b9aa6eeddbfb589619ce53e36e2b
parent 4984ad1c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -117,6 +117,14 @@ LOCAL_SRC_FILES_x86_64 += \
        arch-x86_64/android_memset16.S \
        arch-x86_64/android_memset32.S \

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

ifeq ($(TARGET_RECOVERY_PRE_COMMAND_CLEAR_REASON),true)
    LOCAL_CFLAGS += -DRECOVERY_PRE_COMMAND_CLEAR_REASON
endif

LOCAL_C_INCLUDES := $(libcutils_c_includes)
LOCAL_STATIC_LIBRARIES := liblog
ifneq ($(ENABLE_CPUSETS),)
+27 −6
Original line number Diff line number Diff line
@@ -213,26 +213,47 @@ int android_reboot_with_callback(
    int cmd, int flags __unused, const char *arg,
    void (*cb_on_remount)(const struct mntent*))
{
    int ret;
    int ret = 0;
    int reason = -1;

#ifdef RECOVERY_PRE_COMMAND
    if (cmd == (int) ANDROID_RB_RESTART2) {
        if (arg && strlen(arg) > 0) {
            char cmd[PATH_MAX];
            sprintf(cmd, RECOVERY_PRE_COMMAND " %s", arg);
            system(cmd);
        }
    }
#endif

    remount_ro(cb_on_remount);
    switch (cmd) {
        case ANDROID_RB_RESTART:
            ret = reboot(RB_AUTOBOOT);
            reason = RB_AUTOBOOT;
            break;

        case ANDROID_RB_POWEROFF:
            ret = reboot(RB_POWER_OFF);
            break;
            return ret;

        case ANDROID_RB_RESTART2:
            ret = syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
                           LINUX_REBOOT_CMD_RESTART2, arg);
            // REBOOT_MAGIC
            break;

        default:
            ret = -1;
            return -1;
    }

#ifdef RECOVERY_PRE_COMMAND_CLEAR_REASON
    reason = RB_AUTOBOOT;
#endif

    if (reason != -1)
        ret = reboot(reason);
    else
        ret = syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
                      LINUX_REBOOT_CMD_RESTART2, arg);

    return ret;
}