#include "aem_log.h" #include "aem_keypad.h" #include "aem_init.h" #include "aem_project.h" #include "aem_app_id.h" #include "aem_app_fwk.h" #include "aem_app_comm.h" #include "aem_launch_mgr.h" #include "aem_data_share.h" #include "aem_app_event.h" #include "aem_pop_if.h" #include "aem_pop_window_id.h" #include "aem_ble_data_share.h" #include "aem_watchface_mgr.h" #include "aem_low_power.h" #include "aem_sys.h" static void go_to_launch(void) { #ifndef CONFIG_SIMULATOR if (!is_aem_low_power_mode() || (is_aem_low_power_mode() && aem_get_battery_percentage() >= 20)) { aem_goback_to_launch(); } else #else if (!aem_app_is_actived(AEM_APP_ID_POWER_SAVING)) { aem_goback_to_launch(); } else #endif { if (aem_app_is_actived(AEM_APP_ID_POP_WINDOW)) { aem_app_close(AEM_APP_ID_POP_WINDOW); } } } static void home_key_process(void) { if (aem_app_is_actived(AEM_APP_ID_APP_LIST)) { go_to_launch(); } else { if (aem_app_is_actived(AEM_APP_ID_LAUNCH)) { if (aem_activity_is_actived(AEM_APP_LAUNCH)) { aem_app_run(AEM_APP_ID_APP_LIST); } else { go_to_launch(); } } else { if (aem_get_enter_app_from_applist() && !aem_app_is_actived(AEM_APP_ID_POP_WINDOW)) { aem_app_run(AEM_APP_ID_APP_LIST); } else { go_to_launch(); } } } } static void shortcut_key_process(void) { if (aem_app_is_actived(AEM_APP_ID_LAUNCH) || aem_app_is_actived(AEM_APP_ID_APP_LIST)) { aem_app_run(aem_share_get_shortcut_app_id()); } } static void shortcut_key_long_click_process(void) { aem_pop_power_info_t info = {0}; info.head.pop_id = AEM_POP_ID_POWER; AEM_LOG_I("power_pop!!!\r\n"); aem_send_app_evt_msg(APP_EVT_POP_WINDOW, (uint8_t *)&info, sizeof(aem_pop_power_info_t)); } #define SCREEN_KEY_TICK 500 static uint32_t s_scr_switch_key_tick = 0; static void screen_switch_key_click_process(void) { if (lv_tick_get() - s_scr_switch_key_tick > SCREEN_KEY_TICK) { AEM_LOG_I("screen key screen off \r\n"); aem_screen_force_off(); s_scr_switch_key_tick = lv_tick_get(); } AEM_LOG_I("aem_keypad_do_event screen key tick:%d \r\n", s_scr_switch_key_tick); } static int32_t default_keypad_handler(aem_key_evt_info_t *evt_info) { if (NULL == evt_info) { return 0; } AEM_LOG_I("def_keypad id:%s click:%s \n", get_aem_key_name(evt_info->key_id), get_aem_key_click_type_name(evt_info->key_click_type)); if (evt_info->key_id == AEM_HOME_KEY) { if (evt_info->key_click_type == AEM_KEY_SINGLE_CLICK) { home_key_process(); } else if (evt_info->key_click_type == AEM_KEY_LONG_6S) { aem_flash_write_allow_set_flag(false); } else { aem_flash_write_allow_set_flag(true); } } else if (evt_info->key_id == AEM_SHORTCUT_KEY) { if (evt_info->key_click_type == AEM_KEY_SINGLE_CLICK) { shortcut_key_process(); } else if (evt_info->key_click_type == AEM_KEY_LONG_6S) { shortcut_key_long_click_process(); } } else if (evt_info->key_id == AEM_SCREEN_SWITCH_KEY) { if (evt_info->key_click_type == AEM_KEY_SINGLE_CLICK) { screen_switch_key_click_process(); } } return 0; } int aem_def_keypad_init(void) { AEM_LOG_I("aem_def_keypad_init \r\n"); aem_keypad_default_handler_register(default_keypad_handler); return 0; } AEM_INIT(aem_def_keypad_init, UI_SERVICE_INIT, 0);