mmi_charger:use orderly shutdown in factory mode

On user-debug build, use an orderly shutdown for factory kill instead
of a kernel power off. The orderly shutdown will attempt to call the
reboot binary from userspace first, and then fallback to kernel power
off if it fails.

Change-Id: Ia3d80b828670a5098afccbca2d934f9d32255a93
Signed-off-by: zhuwg1 <zhuwg1@motorola.com>
Reviewed-on: https://gerrit.mot.com/2145390
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Yonghua Yan <yanyh2@motorola.com>
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
zhuwg1 2021-12-15 19:56:30 +08:00
commit bcb890a074
2 changed files with 7 additions and 3 deletions

View file

@ -3,6 +3,10 @@ EXTRA_CFLAGS += -Wall
EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/power/mmi_charger
EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/include
ifeq ($(TARGET_BUILD_VARIANT),userdebug)
EXTRA_CFLAGS += -DMMI_GKI_API_ALLOWANCE
endif
obj-m += mmi_charger.o
KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../../mmi_info/$(GKI_OBJ_MODULE_DIR)/Module.symvers

View file

@ -2014,10 +2014,10 @@ static void mmi_charger_heartbeat_work(struct work_struct *work)
chip->factory_kill_armed = true;
} else if (chip->factory_kill_armed && !factory_kill_disable) {
mmi_warn(chip, "Factory kill power off\n");
#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE
kernel_power_off();
#else
#if (KERNEL_VERSION(5, 10, 0) > LINUX_VERSION_CODE) || defined(MMI_GKI_API_ALLOWANCE)
orderly_poweroff(true);
#else
kernel_power_off();
#endif
} else {
chip->factory_kill_armed = false;