Change format of EventAction properties 17/276217/9
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 13 Jun 2022 05:09:27 +0000 (14:09 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Wed, 15 Jun 2022 05:22:09 +0000 (14:22 +0900)
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 <y0.cho@samsung.com>
conf/battery.conf
conf/init.conf
conf/input-profile-iot-headless.conf
plugins/iot-headless/battery/battery-plugin.c
plugins/iot-headless/input/input-config.c
plugins/iot-headless/input/input-config.h
plugins/iot-headless/input/input-handler.c
src/power/power-boot.c
src/shared/device-notifier.c
src/shared/device-notifier.h

index 0fcb21c..d3c9c76 100644 (file)
@@ -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
index e9df34f..22c910d 100644 (file)
@@ -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
index 5640a99..8cf5d8b 100644 (file)
@@ -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
index 95a427d..99c9aef 100644 (file)
@@ -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");
        }
 }
 
index 4635159..a8dd609 100644 (file)
@@ -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");
        }
 }
 
index 8e192a6..9d7d060 100644 (file)
@@ -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;
index cce01be..dd31b2c 100644 (file)
@@ -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();
 }
 
index f33bbd4..9926b68 100644 (file)
@@ -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);
        }
 }
index badf4e7..77980fb 100644 (file)
@@ -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),
index 3acf22e..c81db6a 100644 (file)
@@ -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,