From: Youngjae Cho Date: Mon, 13 Jun 2022 05:09:27 +0000 (+0900) Subject: Change format of EventAction properties X-Git-Tag: submit/tizen/20220624.005127~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa73bf6c049d7808c4eb0209b079acdbb0c86eca;p=platform%2Fcore%2Fsystem%2Fdeviced.git Change format of EventAction properties There were two types of Action= property, one is broadcasting and the other is changing state. Separate them to have different property name, Broadcast= and ChangeState=. - Action=broadcast -> ActionBroadcast=yes - Action=curr,next -> ActionChangeState=curr,next In addition to this, changed Duration= to clarify its meaning. - Duration -> DetectionRangeMsec This is intermediate patch. Therefore in this version, the property 'ActionBroadcast=yes' won't work properly. Change-Id: I00440c9bc30557812618b95f1a25663e9466158a Signed-off-by: Youngjae Cho --- diff --git a/conf/battery.conf b/conf/battery.conf index 0fcb21c2..d3c9c76b 100644 --- a/conf/battery.conf +++ b/conf/battery.conf @@ -14,18 +14,19 @@ ChargerWakeLockEnabled=yes # define event-action, iot-headless only # DeviceNotifier= # - define which event(device-notifiy) is filtered -# Action= +# ChangeState= # - define action for the event +# ActionBroadcast=yes +# - broadcast upon occuring the event + [EventAction] Name=CHARGER_CONNECTED Enum=2001 DeviceNotifier=DEVICE_NOTIFIER_BATTERY_CHARGER_CONNECTED -Action=sleep,sleep -Action=normal,normal +ActionBroadcast=yes [EventAction] Name=CHARGER_DISCONNECTED Enum=2002 DeviceNotifier=DEVICE_NOTIFIER_BATTERY_CHARGER_DISCONNECTED -Action=sleep,sleep -Action=normal,normal +ActionBroadcast=yes diff --git a/conf/init.conf b/conf/init.conf index e9df34f7..22c910d7 100644 --- a/conf/init.conf +++ b/conf/init.conf @@ -2,10 +2,10 @@ #INITIAL_STATE_BY_POWERKEY_BOOTING Enum=3000 BootReason=powerkey -Action=start,normal +ActionChangeState=start,normal [EventAction] #INITIAL_STATE_BY_CHARGER_BOOTING Enum=3001 BootReason=charger -Action=start,sleep +ActionChangeState=start,sleep diff --git a/conf/input-profile-iot-headless.conf b/conf/input-profile-iot-headless.conf index 5640a99b..8cf5d8b8 100644 --- a/conf/input-profile-iot-headless.conf +++ b/conf/input-profile-iot-headless.conf @@ -6,53 +6,53 @@ # integer in broadcasting dbus signal. # Keycode=integer # - define keycode to filter key event -# Duration=integer,integer +# DetectionRangeMsec=integer,integer # - define time window in milisecond for filtering key event. -1 means no limit. # TriggerType=level/edge # - define event type -# Action=broadcast -# - define broadcast action for the event. -# Action=current,next +# ActionBroadcast=yes +# - Broadcast upon occuring an event, default no. +# ActionChangeState=current,next # - define state transition action for the event. [EventAction] Name=BLINKKEY_EDGE Enum=1000 Keycode=bluetooth -Duration=0,2000 +DetectionRangeMsec=0,2000 TriggerType=edge -Action=sleep,sleep +ActionBroadcast=yes [EventAction] Name=SHORTKEY_LEVEL Enum=1001 Keycode=power -Duration=2000,-1 +DetectionRangeMsec=2000,-1 TriggerType=level -Action=broadcast +ActionBroadcast=yes [EventAction] Name=SHORTKEY_EDGE Enum=1002 Keycode=power -Duration=2000,7000 +DetectionRangeMsec=2000,7000 TriggerType=edge -Action=normal,sleep -Action=sleep,normal +ActionChangeState=normal,sleep +ActionChangeState=sleep,normal [EventAction] Name=LONGKEY_LEVEL Enum=1003 Keycode=power -Duration=7000,-1 +DetectionRangeMsec=7000,-1 TriggerType=level -Action=broadcast +ActionBroadcast=yes [EventAction] Name=LONGKEY_EDGE Enum=1004 Keycode=power -Duration=7000,-1 +DetectionRangeMsec=7000,-1 TriggerType=edge ConditionVconf=memory/sysman/charger_status,int,0 -Action=normal,poweroff +ActionChangeState=normal,poweroff diff --git a/plugins/iot-headless/battery/battery-plugin.c b/plugins/iot-headless/battery/battery-plugin.c index 95a427db..99c9aef9 100644 --- a/plugins/iot-headless/battery/battery-plugin.c +++ b/plugins/iot-headless/battery/battery-plugin.c @@ -33,6 +33,9 @@ struct battery_event_handler { char *name; int id; + /* broadcast upon occuring this event */ + int broadcast; + /* which action to do on receiving an event */ enum device_notifier_type action; void *user_data; @@ -99,8 +102,10 @@ static void parse_event_action_property(gpointer data, gpointer user_data) sscanf(prop->value, "%d", &handler->id); } else if (MATCH(prop->key, "DeviceNotifier")) { parse_device_notifier(handler, prop->value); - } else if (MATCH(prop->key, "Action")) { + } else if (MATCH(prop->key, "ActionChangeState")) { parse_action(handler, prop->value); + } else if (MATCH(prop->key, "ActionBroadcast")) { + handler->broadcast = MATCH(prop->value, "yes"); } } diff --git a/plugins/iot-headless/input/input-config.c b/plugins/iot-headless/input/input-config.c index 46351590..a8dd609d 100644 --- a/plugins/iot-headless/input/input-config.c +++ b/plugins/iot-headless/input/input-config.c @@ -143,15 +143,12 @@ static void add_action_transition_info(struct input_event_unit *ieu, char *curr, SYS_G_LIST_APPEND(*action_list, ti); } -static void parse_action(struct input_event_unit *ieu, const char *action) +static void parse_change_state(struct input_event_unit *ieu, const char *action) { char curr[16] = { 0, }; char next[16] = { 0, }; - if (MATCH(action, "broadcast")) { - ieu->notifier = DEVICE_NOTIFIER_INPUT_BROADCAST_SIGNAL; - ieu->user_data = (void *) ieu; - } else if (sscanf(action, "%15[^,],%15s", curr, next) == 2) { + if (sscanf(action, "%15[^,],%15s", curr, next) == 2) { ieu->notifier = DEVICE_NOTIFIER_REQUEST_TRANSITION_STATE; /* append transition info to ieu->user_data */ add_action_transition_info(ieu, curr, next); @@ -176,14 +173,16 @@ static void parse_event_action_property(gpointer data, gpointer user_data) sscanf(prop->value, "%d", &ieu->id); } else if (MATCH(prop->key, "Keycode")) { parse_keycode(ieu, prop->value); - } else if (MATCH(prop->key, "Duration")) { + } else if (MATCH(prop->key, "DetectionRangeMsec")) { parse_duration(ieu, prop->value); } else if (MATCH(prop->key, "TriggerType")) { parse_trigger_type(ieu, prop->value); } else if (MATCH(prop->key, "ConditionVconf")) { parse_condition_vconf(ieu, prop->value); - } else if (MATCH(prop->key, "Action")) { - parse_action(ieu, prop->value); + } else if (MATCH(prop->key, "ActionChangeState")) { + parse_change_state(ieu, prop->value); + } else if (MATCH(prop->key, "ActionBroadcast")) { + ieu->broadcast = MATCH(prop->value, "yes"); } } diff --git a/plugins/iot-headless/input/input-config.h b/plugins/iot-headless/input/input-config.h index 8e192a6e..9d7d060c 100644 --- a/plugins/iot-headless/input/input-config.h +++ b/plugins/iot-headless/input/input-config.h @@ -50,6 +50,9 @@ struct input_event_unit { /* condition for triggering action */ struct condition_vconf cv; + /* broadcast upon occuring this event */ + int broadcast; + /* which action to do on receiving an event */ enum device_notifier_type notifier; void *user_data; diff --git a/plugins/iot-headless/input/input-handler.c b/plugins/iot-headless/input/input-handler.c index cce01be8..dd31b2c6 100644 --- a/plugins/iot-headless/input/input-handler.c +++ b/plugins/iot-headless/input/input-handler.c @@ -38,24 +38,26 @@ static gboolean level_triggered(gpointer data) ieu->timer = 0; - if (check_input_event_condition(ieu)) { - _D("Trigger(level) event=%s(%d), action=%d", ieu->name, ieu->id, ieu->notifier); - device_notify(ieu->notifier, ieu->user_data); - } else { + if (check_input_event_condition(ieu) == 0) { _D("Skip(level) event=%s(%d), condition=%s isn't meet", ieu->name, ieu->id, ieu->cv.keyname); + return G_SOURCE_REMOVE; } + _D("Trigger(level) event=%s(%d), action=%d", ieu->name, ieu->id, ieu->notifier); + device_notify(ieu->notifier, ieu->user_data); + return G_SOURCE_REMOVE; } static void edge_triggered(struct input_event_unit *ieu) { - if (check_input_event_condition(ieu)) { - _D("Trigger(edge) event=%s(%d), action=%d", ieu->name, ieu->id, ieu->notifier); - device_notify(ieu->notifier, ieu->user_data); - } else { + if (check_input_event_condition(ieu) == 0) { _D("Skip(edge) event=%s(%d), condition=%s isn't meet", ieu->name, ieu->id, ieu->cv.keyname); + return; } + + _D("Trigger(edge) event=%s(%d), action=%d", ieu->name, ieu->id, ieu->notifier); + device_notify(ieu->notifier, ieu->user_data); } static void start_event_timer(struct input_config *ic) @@ -145,24 +147,8 @@ static int input_handler_execute(void *data) return 0; } -static int broadcast_input_signal_cb(void *data) -{ - struct input_event_unit *ieu = (struct input_event_unit *) data; - - if (!ieu) - return 0; - - _D("Broadcast siganl, event=%s(%d)", ieu->name, ieu->id); - gdbus_signal_emit(NULL, DEVICED_PATH_INPUT, DEVICED_INTERFACE_INPUT, - "Key", g_variant_new("(i)", ieu->id)); - - return 0; -} - static void input_handler_init(void *data) { - register_notifier(DEVICE_NOTIFIER_INPUT_BROADCAST_SIGNAL, broadcast_input_signal_cb); - init_input_config(); } diff --git a/src/power/power-boot.c b/src/power/power-boot.c index f33bbd4f..9926b683 100644 --- a/src/power/power-boot.c +++ b/src/power/power-boot.c @@ -138,7 +138,7 @@ static void parse_init_ti(const struct parse_result *result) SYS_G_LIST_FOREACH(result->props, elem, prop) { if (MATCH(prop->key, "Enum")) init_ti.reason = atoi(prop->value); - else if (MATCH(prop->key, "Action")) + else if (MATCH(prop->key, "ActionChangeState")) parse_transition_info(prop->value); } } diff --git a/src/shared/device-notifier.c b/src/shared/device-notifier.c index badf4e75..77980fb1 100644 --- a/src/shared/device-notifier.c +++ b/src/shared/device-notifier.c @@ -94,10 +94,6 @@ static const char *device_notifier_type_str[DEVICE_NOTIFIER_MAX] = { NOTIFY_STR(DEVICE_NOTIFIER_KEY_PRESS), NOTIFY_STR(DEVICE_NOTIFIER_KEY_RELEASE), - /* action triggered by input event */ - NOTIFY_STR(DEVICE_NOTIFIER_INPUT_TRIGGER_POWEROFF), - NOTIFY_STR(DEVICE_NOTIFIER_INPUT_BROADCAST_SIGNAL), - /* Purpose of calling methods of different modules * Use prefix DEVICE_NOTIFIER_REQUEST */ NOTIFY_STR(DEVICE_NOTIFIER_REQUEST_TRANSITION_STATE), diff --git a/src/shared/device-notifier.h b/src/shared/device-notifier.h index 3acf22e8..c81db6ae 100644 --- a/src/shared/device-notifier.h +++ b/src/shared/device-notifier.h @@ -67,10 +67,6 @@ enum device_notifier_type { DEVICE_NOTIFIER_KEY_PRESS, DEVICE_NOTIFIER_KEY_RELEASE, - /* action triggered by input event */ - DEVICE_NOTIFIER_INPUT_TRIGGER_POWEROFF, - DEVICE_NOTIFIER_INPUT_BROADCAST_SIGNAL, - /* Purpose of calling methods of different modules * Use prefix DEVICE_NOTIFIER_REQUEST */ DEVICE_NOTIFIER_REQUEST_TRANSITION_STATE,