mtk ipo流程休眠通过powerkey长按弹窗点击standby进入,唤醒时通过长按powerkey唤醒
1. powerkey: 使用PMIC的powerkey
2. powerkey长按的时间是通过外部ic控制的,时长为1s
异常:休眠下去后长按powerkey发现机器无法唤醒
异常log:
源码:
#define LONG_PRESS_DEFAULT_DURATION 50
static int longPressDuration = LONG_PRESS_DEFAULT_DURATION;
static void* key_thread_routine(void *arg)
{
while(powerKeyPressed) {
usleep(1000*50); //200ms
ipod_log("start to exit_ipod-EXIT_POWER_UP"); //每200ms打印一次
if (gsensor_bt_Keycode == KEY_SENSORINT) {
property_set(GSENSOR_BOOT,"1");
property_set(IPO_RESUME_REASON,"gsensor");
ipod_log("<ipo resume system>IPO_RESUME_REASON:gsensor.\n");
exit_ipod(EXIT_POWER_UP);
gsensor_bt_Keycode = -1;
} else if(gsensor_bt_Keycode == KEY_BT_POWERKEY && bt_flag == 1) {
property_set(GSENSOR_BOOT,"1");
property_set(IPO_RESUME_REASON,"bt");
ipod_log("<wangxy><ipo resume system>IPO_RESUME_REASON:bt.\n");
exit_ipod(EXIT_POWER_UP);
gsensor_bt_Keycode = -1;
bt_flag = 0;
}
if(time_exceed(start, longPressDuration)) {
ipod_log("pwr key reaches boot condition"); //长按触发唤醒流程打印一次
//if(get_voltage() > VBAT_POWER_ON || tbl_bypass_batt_check()) {
// ready to boot up.
ipod_log("pwr key inotify_rm_watch.");
inotify_rm_watch(ufds[0].fd, wd);
if (keyDownPressed || keyUpPressed) {
/*modified for ALPS02661892*/
set_gpio_status();
ipod_log("keyDownPressed || keyUpPressed, start to exit_ipod-EXIT_REBOOT_UBOOT");
property_set(IPO_RESUME_REASON,"powerkey");
ipod_log("<ipo resume system>IPO_RESUME_REASON:powerkey.\n");
exit_ipod(EXIT_REBOOT_UBOOT);
} else {
property_set(IPO_RESUME_REASON,"powerkey");
ipod_log("<wangxy><ipo resume system>IPO_RESUME_REASON:powerkey.\n");
exit_ipod(EXIT_POWER_UP);
}
/*} else {
ipod_log("VBAT <= %d", VBAT_POWER_ON);
if ((access(VOLTAGE_AVG_PATH,F_OK)==-1)) {
exit_ipod(EXIT_POWER_UP);
} else
status_cb(EVENT_LOWBATT_FAIL_BOOT, 0, 0);
}*/
}
}
if (needShowChargingAnimation) {
ipod_log("check pwr key show anim..."); //powerkey不再按下时退出while循环打印
if (is_charging_source_available()) {
ipod_log("need to show anim");
start_charging_anim(TRIGGER_ANIM_KEY);
wait_wakelock(IPOD_CHARGING_WAKELOCK, WAIT_WAKELOCK_TIMEOUT);
}
needShowChargingAnimation = false;
}
}
从源码中可以看到几个关键点的log
1 powerkey循环每200ms打印一次的: ipod_log("start to exit_ipod-EXIT_POWER_UP");
2. 触发长按唤醒机器的log: ipod_log("pwr key reaches boot condition");
3.退出 powerkey循环打印的log: ipod_log("check pwr key show anim...");
根据异常log中 start to exit_ipod-EXIT_POWER_UP的时间间隔以及 check pwr key show anim的打印时间,判断出 外部长按1s的时长但是ipd检测powerkey按下的时长根本就不满足大于500ms所以无法唤醒机器,唤醒流程中的log:pwr key reaches boot condition也没打印
修复方案:
延长外部powerkey的时长让其触发ipo唤醒流程
正常流程log:
延长按下时间后可以看到关键log: pwr key reaches boot condition
ipo需要长按大于500ms才可以唤醒机器但是系统是通过检测/dev/input的事件来计算长按时长,所以会与外部实际按下powerkey的时长有差异