default_check() was used for checking state transition condition.
If there is any pmlock of the state checked which is not background status,
it is impossible to move next state.
default_check() follows same policy from all plugins.
To move from current display state to next display state, this function is necessary.
Thus, this function is added below display-state-transition.
int display_state_transition_check_state_transition_condition(enum state_t cur_state, enum state_t next_state);
Change-Id: I06adb467ac81a04596f22a7b0fe9b06c3b72d248
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
/* default transition, action fuctions */
static int default_trans(int evt);
static int default_action(int timeout);
-static int default_check(int curr, int next);
static int default_proc_change_state(unsigned int cond, pid_t pid);
static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
static struct state states[S_END] = {
{ S_START, "S_START", NULL, NULL, NULL, NULL },
- { S_NORMAL, "S_NORMAL", default_trans, default_action, default_check, NULL },
- { S_LCDDIM, "S_LCDDIM", default_trans, default_action, default_check, NULL },
- { S_LCDOFF, "S_LCDOFF", default_trans, default_action, default_check, NULL },
+ { S_NORMAL, "S_NORMAL", default_trans, default_action, NULL, NULL },
+ { S_LCDDIM, "S_LCDDIM", default_trans, default_action, NULL, NULL },
+ { S_LCDOFF, "S_LCDOFF", default_trans, default_action, NULL, NULL },
{ S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL },
- { S_SLEEP, "S_SLEEP", default_trans, default_action, default_check, NULL },
+ { S_SLEEP, "S_SLEEP", default_trans, default_action, NULL, NULL },
{ S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL },
};
{
struct state *st = &states[get_pm_cur_state()];
enum state_t next_state;
+ int ret = 0;
display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt);
/* check conditions */
- if (st->check && !st->check(get_pm_cur_state(), next_state)) {
+ ret = display_state_transition_check_state_transition_condition(get_pm_cur_state(), next_state);
+ if (ret < 0) {
/* There is a condition. */
_I("%s locked. Trans to %s failed.", states[get_pm_cur_state()].name,
states[next_state].name);
return 0;
}
-/*
- * default check function
- * return
- * 0 : can't transit, others : transitable
- */
-static int default_check(int curr, int next)
-{
- int trans_cond;
-
- makeup_trans_condition();
-
- trans_cond = get_trans_condition() & MASK_BIT;
-
- if (next == S_NORMAL) /* S_NORMAL is exceptional */
- return 1;
-
- switch (curr) {
- case S_NORMAL:
- trans_cond = trans_cond & MASK_NORMAL;
- break;
- case S_LCDDIM:
- trans_cond = trans_cond & MASK_DIM;
- break;
- case S_LCDOFF:
- trans_cond = trans_cond & MASK_OFF;
- break;
- default:
- trans_cond = 0;
- break;
- }
-
- if (trans_cond != 0) {
- print_node(curr);
- return 0;
- }
-
- return 1; /* transitable */
-}
-
static void default_saving_mode(int onoff)
{
if (onoff)
*/
#define LOCK_SCREEN_CONTROL_TIMEOUT 5000
-#define ALWAYS_ON_TIMEOUT 360000000
#define GESTURE_STR "gesture"
#define POWER_KEY_STR "powerkey"
/* default transition, action fuctions */
static int default_trans(int evt);
static int default_action(int timeout);
-static int default_check(int curr, int next);
static int default_proc_change_state(unsigned int cond, pid_t pid);
static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
static struct state states[S_END] = {
{ S_START, "S_START", NULL, NULL, NULL, NULL },
- { S_NORMAL, "S_NORMAL", default_trans, default_action, default_check, NULL },
- { S_LCDDIM, "S_LCDDIM", default_trans, default_action, default_check, NULL },
- { S_LCDOFF, "S_LCDOFF", default_trans, default_action, default_check, NULL },
+ { S_NORMAL, "S_NORMAL", default_trans, default_action, NULL, NULL },
+ { S_LCDDIM, "S_LCDDIM", default_trans, default_action, NULL, NULL },
+ { S_LCDOFF, "S_LCDOFF", default_trans, default_action, NULL, NULL },
{ S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL },
- { S_SLEEP, "S_SLEEP", default_trans, default_action, default_check, NULL },
+ { S_SLEEP, "S_SLEEP", default_trans, default_action, NULL, NULL },
{ S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL },
};
{
struct state *st = &states[get_pm_cur_state()];
enum state_t next_state;
+ int ret = 0;
display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt);
/* check conditions */
- if (st->check && !st->check(get_pm_cur_state(), next_state)) {
+ ret = display_state_transition_check_state_transition_condition(get_pm_cur_state(), next_state);
+ if (ret < 0) {
/* There is a condition. */
_I("%s locked. Trans to %s failed.", states[get_pm_cur_state()].name,
states[next_state].name);
return 0;
}
-/*
- * default check function
- * return
- * 0 : can't transit, others : transitable
- */
-static int default_check(int curr, int next)
-{
- int trans_cond;
-
- makeup_trans_condition();
-
- trans_cond = get_trans_condition() & MASK_BIT;
-
- if (next == S_NORMAL) /* S_NORMAL is exceptional */
- return 1;
-
- switch (curr) {
- case S_NORMAL:
- trans_cond = trans_cond & MASK_NORMAL;
- break;
- case S_LCDDIM:
- trans_cond = trans_cond & MASK_DIM;
- break;
- case S_LCDOFF:
- trans_cond = trans_cond & MASK_OFF;
- break;
- default:
- trans_cond = 0;
- break;
- }
-
- if (trans_cond != 0) {
- print_node(curr);
- return 0;
- }
-
- return 1; /* transitable */
-}
-
static void default_saving_mode(int onoff)
{
if (onoff)
/* default transition, action fuctions */
static int default_trans(int evt);
static int default_action(int timeout);
-static int default_check(int curr, int next);
static int default_proc_change_state(unsigned int cond, pid_t pid);
static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
static struct state states[S_END] = {
{ S_START, "S_START", NULL, NULL, NULL, NULL },
- { S_NORMAL, "S_NORMAL", default_trans, default_action, default_check, NULL },
- { S_LCDDIM, "S_LCDDIM", default_trans, default_action, default_check, NULL },
- { S_LCDOFF, "S_LCDOFF", default_trans, default_action, default_check, NULL },
+ { S_NORMAL, "S_NORMAL", default_trans, default_action, NULL, NULL },
+ { S_LCDDIM, "S_LCDDIM", default_trans, default_action, NULL, NULL },
+ { S_LCDOFF, "S_LCDOFF", default_trans, default_action, NULL, NULL },
{ S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL },
- { S_SLEEP, "S_SLEEP", default_trans, default_action, default_check, NULL },
+ { S_SLEEP, "S_SLEEP", default_trans, default_action, NULL, NULL },
{ S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL },
};
{
struct state *st = &states[get_pm_cur_state()];
enum state_t next_state;
+ int ret = 0;
display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt);
/* check conditions */
- if (st->check && !st->check(get_pm_cur_state(), next_state)) {
+ ret = display_state_transition_check_state_transition_condition(get_pm_cur_state(), next_state);
+ if (ret < 0) {
/* There is a condition. */
_I("%s locked. Trans to %s failed.", states[get_pm_cur_state()].name,
states[next_state].name);
return 0;
}
-/*
- * default check function
- * return
- * 0 : can't transit, others : transitable
- */
-static int default_check(int curr, int next)
-{
- int trans_cond;
-
- makeup_trans_condition();
-
- trans_cond = get_trans_condition() & MASK_BIT;
-
- if (next == S_NORMAL) /* S_NORMAL is exceptional */
- return 1;
-
- switch (curr) {
- case S_NORMAL:
- trans_cond = trans_cond & MASK_NORMAL;
- break;
- case S_LCDDIM:
- trans_cond = trans_cond & MASK_DIM;
- break;
- case S_LCDOFF:
- trans_cond = trans_cond & MASK_OFF;
- break;
- default:
- trans_cond = 0;
- break;
- }
-
- if (trans_cond != 0) {
- print_node(curr);
- return 0;
- }
-
- return 1; /* transitable */
-}
-
static void default_saving_mode(int onoff)
{
if (onoff)
/* default transition, action fuctions */
static int default_trans(int evt);
static int default_action(int timeout);
-static int default_check(int curr, int next);
static int default_proc_change_state(unsigned int cond, pid_t pid);
static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
static struct state states[S_END] = {
{ S_START, "S_START", NULL, NULL, NULL, NULL },
- { S_NORMAL, "S_NORMAL", default_trans, default_action, default_check, NULL },
- { S_LCDDIM, "S_LCDDIM", default_trans, default_action, default_check, NULL },
- { S_LCDOFF, "S_LCDOFF", default_trans, default_action, default_check, NULL },
+ { S_NORMAL, "S_NORMAL", default_trans, default_action, NULL, NULL },
+ { S_LCDDIM, "S_LCDDIM", default_trans, default_action, NULL, NULL },
+ { S_LCDOFF, "S_LCDOFF", default_trans, default_action, NULL, NULL },
{ S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL },
- { S_SLEEP, "S_SLEEP", default_trans, default_action, default_check, NULL },
+ { S_SLEEP, "S_SLEEP", default_trans, default_action, NULL, NULL },
{ S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL },
};
display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt);
/* check conditions */
- if (st->check && !st->check(get_pm_cur_state(), next_state)) {
+ ret = display_state_transition_check_state_transition_condition(get_pm_cur_state(), next_state);
+ if (ret < 0) {
/* There is a condition. */
_I("%s locked. Trans to %s failed.", states[get_pm_cur_state()].name,
states[next_state].name);
return 0;
}
-/*
- * default check function
- * return
- * 0 : can't transit, others : transitable
- */
-static int default_check(int curr, int next)
-{
- int trans_cond;
-
- makeup_trans_condition();
-
- trans_cond = get_trans_condition() & MASK_BIT;
-
- if (next == S_NORMAL) /* S_NORMAL is exceptional */
- return 1;
-
- switch (curr) {
- case S_NORMAL:
- trans_cond = trans_cond & MASK_NORMAL;
- break;
- case S_LCDDIM:
- trans_cond = trans_cond & MASK_DIM;
- break;
- case S_LCDOFF:
- trans_cond = trans_cond & MASK_OFF;
- break;
- default:
- trans_cond = 0;
- break;
- }
-
- if (trans_cond != 0) {
- print_node(curr);
- return 0;
- }
-
- return 1; /* transitable */
-}
-
static void default_saving_mode(int onoff)
{
if (onoff) {
return -EOPNOTSUPP;
}
-int display_plugin_state_do_default_check(enum state_t state, int curr, int next)
-{
- if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->check)
- return g_display_plugin.display_states[state]->check(curr, next);
-
- return -EOPNOTSUPP;
-}
-
int display_plugin_state_get_name(enum state_t state, const char **state_name)
{
if (!state_name)
int display_plugin_state_do_default_trans(enum state_t state, int evt);
bool display_plugin_state_is_there_default_trans(enum state_t state);
int display_plugin_state_do_default_action(enum state_t state, int timeout);
-int display_plugin_state_do_default_check(enum state_t state, int curr, int next);
int display_plugin_state_get_name(enum state_t state, const char **state_name);
int display_plugin_state_set_timeout(enum state_t state, int state_timeout);
int display_plugin_state_get_timeout(enum state_t state, int *state_timeout);
display_plugin_state_get_timeout(S_LCDDIM, &dim_state_timeout);
_I("Normal: NORMAL timeout is set by %d ms", normal_state_timeout);
_I("Normal: DIM timeout is set by %d ms", dim_state_timeout);
+}
+
+static bool is_display_state_valid_for_transition(enum state_t state)
+{
+ switch(state) {
+ case S_NORMAL:
+ case S_LCDDIM:
+ case S_LCDOFF:
+ case S_SLEEP:
+ return true;
+ default:
+ return false;
+ }
+
+ return false;
+}
+
+int display_state_transition_check_state_transition_condition(enum state_t cur_state, enum state_t next_state)
+{
+ int trans_cond;
+
+ if (!is_display_state_valid_for_transition(cur_state))
+ return -EPERM;
+
+ makeup_trans_condition();
+
+ trans_cond = get_trans_condition() & MASK_BIT;
+
+ if (next_state == S_NORMAL) /* S_NORMAL is exceptional */
+ return 0;
+
+ switch (cur_state) {
+ case S_NORMAL:
+ trans_cond = trans_cond & MASK_NORMAL;
+ break;
+ case S_LCDDIM:
+ trans_cond = trans_cond & MASK_DIM;
+ break;
+ case S_LCDOFF:
+ trans_cond = trans_cond & MASK_OFF;
+ break;
+ default:
+ trans_cond = 0;
+ break;
+ }
+
+ if (trans_cond != 0) {
+ print_node(cur_state);
+ return -EPERM;
+ }
+
+ return 0; /* transitable */
}
\ No newline at end of file
int display_state_transition_set_lock_screen_timeout(int timeout);
int display_state_transition_get_lock_screen_timeout(int *timeout);
void display_state_transition_update_display_state_timeout_by_priority(void);
+int display_state_transition_check_state_transition_condition(enum state_t cur_state, enum state_t next_state);
#endif /* __DISPLAY_STATE_TRANSITION_H__ */
\ No newline at end of file