SC200L Android10启动和关机修改
SC200L默认的PowerKey连接方式
根据原理图可知,低电有效,查询代码,默认低电6S以上触发开机或关机菜单
由于项目硬件设计,需改为高电平启动,低电平时无需手动确认,直接关机。因此需修改uboot(改开机)和framework(改关机)
开机修改
查看开机uboot log
发现开机按键相关log,查找到对应代码位置
SC200L\BSP\bootloader\u-boot15\drivers\misc\check_reboot.c
int power_button_pressed(void)
{
int eic_value,ret;
//maybe get button status from eic API is batter
sprd_eic_request(EIC_PBINT);
udelay(3000);
eic_value = sprd_eic_get(EIC_PBINT);
debugf("power_button_pressed status %x\n", eic_value);
#ifdef CONFIG_POWERKEY_DEFAULT_HIGH
if (eic_value == 0)
ret = KEY_PRESSED;
else
ret = KEY_NOT_PRESSED;
#else
if (eic_value == 0)
ret = KEY_NOT_PRESSED;
else
ret = KEY_PRESSED;
#endif
return ret;
}
由代码可知,关键部分在宏CONFIG_POWERKEY_DEFAULT_HIGH
在SC200L\BSP\bootloader\u-boot15\include\configs\sl8541e_1h10.h中注释掉宏定义即可
关机修改
关机参照 DeepCoder【 Android 10 系统启动 】系列 -- ShutdownThread(关机流程)
直接修改powerLongPress()函数即可
// frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
private void powerLongPress() {
final int behavior = getResolvedLongPressOnPowerBehavior();
switch (behavior) {
case LONG_PRESS_POWER_NOTHING:
break;
case LONG_PRESS_POWER_GLOBAL_ACTIONS:
mPowerKeyHandled = true;
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, false,
"Power - Long Press - Global Actions");
//showGlobalActionsInternal();
//上方代码为原处理方式(换出菜单)下方代码为直接关机代码
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
mWindowManagerFuncs.shutdown(false);
break;
case LONG_PRESS_POWER_SHUT_OFF:
case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM:
mPowerKeyHandled = true;
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, false,
"Power - Long Press - Shut Off");
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
mWindowManagerFuncs.shutdown(behavior == LONG_PRESS_POWER_SHUT_OFF);
break;
case LONG_PRESS_POWER_GO_TO_VOICE_ASSIST:
mPowerKeyHandled = true;
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, false,
"Power - Long Press - Go To Voice Assist");
// Some devices allow the voice assistant intent during setup (and use that intent
// to launch something else, like Settings). So we explicitly allow that via the
// config_allowStartActivityForLongPressOnPowerInSetup resource in config.xml.
launchVoiceAssist(mAllowStartActivityForLongPressOnPowerDuringSetup);
break;
case LONG_PRESS_POWER_ASSISTANT:
mPowerKeyHandled = true;
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, false,
"Power - Long Press - Go To Assistant");
final int powerKeyDeviceId = Integer.MIN_VALUE;
launchAssistAction(null, powerKeyDeviceId);
break;
}
}
重新编译烧录,满足需求。至此修改完成。