Android系统长按power实现键硬件关机—高通sdm845

1.软件层关机,跳过长按power键选择界面,直接关机
path:frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
长按键函数:

private void powerLongPress() {
…………
case LONG_PRESS_POWER_GLOBAL_ACTIONS:
            mPowerKeyHandled = true;
            performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
            /* modify start*/
            -showGlobalActionsInternal();
            +mWindowManagerFuncs.shutdown(false /* confirm */);
            /* modify end*/
            break;
}

showGlobalActionsInternal();函数调用关机选择界面
mWindowManagerFuncs.shutdown(false /* confirm */);直接调用关机函数
编译system.img烧录重启即可实现跳过长按power键选择界面,直接关机。

2.硬件层关机,长按power 15s关机
path:vendor/qcom/non-hlos/BOOT.XF.2.0/boot_images/QcomPkg/Library/PmicLib/target/sdm845_pm8998_pmi8998/system/src/pm_sbl_boot_oem.c
通过pmic直接控制power按键关机

pm_err_flag_type
pm_device_post_init(void)
{
………………
//These configurations is only used for development phones and should be commented out for production phones
  err_flag |= pm_app_pon_pshold_cfg(PM_APP_PON_CFG_WARM_RESET);
  -err_flag |= pm_app_pon_reset_cfg( PM_APP_PON_RESET_SOURCE_KPDPWR, PM_APP_PON_CFG_WARM_RESET, 10256, 2000); //PON KPDPWR PON Reset configuration
  +err_flag |= pm_pon_set_option_bit( 0, PM_PON_OPTION_KPDPWR_FEDGE_PON, TRUE); //Configure KPDPWR for edge trigger
  +err_flag |= pm_app_pon_reset_cfg( PM_APP_PON_RESET_SOURCE_KPDPWR, PM_APP_PON_CFG_DVDD_SHUTDOWN, 10256, 2000); //PON KPDPWR PON Shutdown configuration
  err_flag |= pm_app_pon_reset_cfg( PM_APP_PON_RESET_SOURCE_RESIN_AND_KPDPWR, PM_APP_PON_CFG_DVDD_HARD_RESET, 10256, 2000); //PON RESIN_AND_KPDPWR PON Reset configuration 

  err_flag |= pm_app_pon_reset_init();
}

编译xbl文件,烧录启动,长按power键15s,需要断开连接的usb(usb供电,会自动重启)。

你可能感兴趣的:(Android)