From: Youngjae Cho Date: Wed, 3 Aug 2022 02:33:50 +0000 (+0900) Subject: power: consider bootmode as well as bootreason X-Git-Tag: accepted/tizen/7.0/unified/hotfix/20221116.105704~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=06c5a75fd7728d32ccd884a6590cdb3195020fc4;p=platform%2Fcore%2Fsystem%2Fdeviced.git power: consider bootmode as well as bootreason Take consideration of bootmode as well as bootreason for the initial state transition. Change-Id: I2ba378cbf146215f315b4d413ec4fd4e470cafe1 Signed-off-by: Youngjae Cho --- diff --git a/conf/init.conf b/conf/init.conf index ee77c26..504fec7 100644 --- a/conf/init.conf +++ b/conf/init.conf @@ -1,3 +1,6 @@ +# BootMode= is optional. If it isn't specified then +# it is regarded as BootMode=normal + [EventAction] #INITIAL_STATE_BY_POWERKEY_BOOTING Enum=3000 @@ -11,7 +14,14 @@ BootReason=charger ActionChangeState=start,sleep [EventAction] -#INITIAL_STATE_BY_REBOOT +#INITIAL_STATE_BY_REBOOT_NORMAL Enum=3002 BootReason=reboot ActionChangeState=start,normal + +[EventAction] +#INITIAL_STATE_BY_REBOOT_SILENT +Enum=3003 +BootReason=reboot +BootMode=silent +ActionChangeState=start,sleep diff --git a/src/power/power-boot.c b/src/power/power-boot.c index ff6ba8a..75ed8db 100644 --- a/src/power/power-boot.c +++ b/src/power/power-boot.c @@ -47,6 +47,11 @@ static struct trans_info init_ti = { .next = 0, }; +static struct boot_condition { + char reason[64]; + char mode[64]; +} bc = { "unknown", "normal" }; + static guint sig_id[2] = {0, 0}; void remove_delayed_init_done_handler(void *data) @@ -143,37 +148,45 @@ static void parse_init_ti(const struct parse_result *result) } } -static int parse_matching_bootreason(const struct parse_result *result, void *data) +static int parse_matching_boot_condition(const struct parse_result *result, void *data) { GList *elem; struct section_property *prop; - char *bootreason = (char *) data; + struct boot_condition config_bc = { "", "normal" }; if (!MATCH(result->section, "EventAction")) return 0; SYS_G_LIST_FOREACH(result->props, elem, prop) { - if (MATCH(prop->key, "BootReason") && MATCH(prop->value, bootreason)) - parse_init_ti(result); + if (MATCH(prop->key, "BootReason")) + sscanf(prop->value, "%s", config_bc.reason); + else if (MATCH(prop->key, "BootMode")) + sscanf(prop->value, "%s", config_bc.mode); } + if (MATCH(bc.reason, config_bc.reason) && MATCH(bc.mode, config_bc.mode)) + parse_init_ti(result); + return 0; } -void initial_transition_by_bootreason(void) +void initial_transition_by_boot_condition(void) { int retval; - char bootreason[64] = "Unknown"; - retval = hal_device_board_get_boot_reason(bootreason, sizeof(bootreason)); + retval = hal_device_board_get_boot_reason(bc.reason, sizeof(bc.reason)); if (retval != 0) { _I("Failed to get BootReason, %d. Default change state to normal.", retval); power_request_change_state_strict(POWER_STATE_START, POWER_STATE_NORMAL, 1, NULL); return; } - CRITICAL_LOG("BootReason=%s", bootreason); - libsys_config_parse_by_section(INIT_CONF_PATH, parse_matching_bootreason, bootreason); + retval = hal_device_board_get_boot_mode(bc.mode, sizeof(bc.mode)); + if (retval != 0) + _I("Failed to get BootMode, %d", retval); + + CRITICAL_LOG("BootReason=%s, BootMode=%s", bc.reason, bc.mode); + libsys_config_parse_by_section(INIT_CONF_PATH, parse_matching_boot_condition, NULL); power_request_change_state_strict(init_ti.curr, init_ti.next, init_ti.reason, NULL); } diff --git a/src/power/power-boot.h b/src/power/power-boot.h index cdabd28..d3057ef 100644 --- a/src/power/power-boot.h +++ b/src/power/power-boot.h @@ -21,7 +21,7 @@ void add_delayed_init_done_handler(void *data); void remove_delayed_init_done_handler(void *data); -void initial_transition_by_bootreason(void); +void initial_transition_by_boot_condition(void); extern int silent_boot; diff --git a/src/power/power.c b/src/power/power.c index 01ee2df..519a126 100644 --- a/src/power/power.c +++ b/src/power/power.c @@ -314,10 +314,11 @@ void power_state_init(void *data) /* Take the first transition. * - * It is determined by bootreason to which state to transition, POWER_STATE_NORMAL or POWER_STATE_SLEEP. - * Or it may stay in POWER_STATE_START if there is no defined action for the matching bootreason. + * It is determined by bootreason and bootmode to which state to transition, POWER_STATE_NORMAL + * or POWER_STATE_SLEEP. it may stay in POWER_STATE_START if there is no defined action for the + * matching bootreason and bootmode. */ - initial_transition_by_bootreason(); + initial_transition_by_boot_condition(); } static const struct device_ops power_state_device_ops = {