}
+static void parse_condition_vconf(struct input_event_unit *ieu, const char *str)
+{
+ int retval;
+
+ char vconfkey[128] = { 0, };
+ char vconftype[16] = { 0, };
+ char vconfvalue[64] = { 0, };
+
+ retval = sscanf(str, "%127[^,],%15[^,],%63s", vconfkey, vconftype, vconfvalue);
+ if (retval != 3)
+ return;
+
+ _D("Condition vconf: key=%s, type=%s, value=%s", vconfkey, vconftype, vconfvalue);
+
+ if (!strncasecmp(vconftype, "bool", sizeof("bool"))) {
+ ieu->cv.type = VCONF_TYPE_BOOL;
+ sscanf(vconfvalue, "%d", &ieu->cv.b);
+ } else if (!strncasecmp(vconftype, "int", sizeof("int"))) {
+ ieu->cv.type = VCONF_TYPE_INT;
+ sscanf(vconfvalue, "%d", &ieu->cv.i);
+ } else if (!strncasecmp(vconftype, "double", sizeof("double"))) {
+ ieu->cv.type = VCONF_TYPE_DOUBLE;
+ sscanf(vconfvalue, "%lf", &ieu->cv.d);
+ } else if (!strncasecmp(vconftype, "string", sizeof("string"))) {
+ ieu->cv.type = VCONF_TYPE_STRING;
+ ieu->cv.s = strndup(vconfvalue, 128);
+ } else {
+ _E("Invalid condition vconf type");
+ return;
+ }
+
+ ieu->cv.keyname = strndup(vconfkey, 128);
+}
+
static void add_action_transition_info(struct input_event_unit *ieu, char *curr, char *next)
{
struct trans_info *ti = NULL;
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);
}
return 0;
}
+/* return 1 if the condition met, otherwise return 0 */
+int check_input_event_condition(const struct input_event_unit *ieu)
+{
+ char *keyname;
+ int retval, ret;
+ char buffer[256] = { 0, };
+
+ int b;
+ int i;
+ double d;
+ char *s;
+
+ if (!ieu)
+ return 0;
+
+ if (!ieu->cv.keyname)
+ return 1;
+
+ keyname = ieu->cv.keyname;
+
+ switch (ieu->cv.type) {
+ case VCONF_TYPE_BOOL:
+ retval = vconf_get_bool(keyname, &b);
+ if (retval < 0) {
+ _E("Failed to get vconf=%s", keyname);
+ return 0;
+ }
+ snprintf(buffer, sizeof(buffer), "expected=%d, current=%d", ieu->cv.b, b);
+ ret = (b == ieu->cv.b);
+ break;
+ case VCONF_TYPE_INT:
+ retval = vconf_get_int(keyname, &i);
+ if (retval < 0) {
+ _E("Failed to get vconf=%s", keyname);
+ return 0;
+ }
+ snprintf(buffer, sizeof(buffer), "expected=%d, current=%d", ieu->cv.i, i);
+ ret = (i == ieu->cv.i);
+ break;
+ case VCONF_TYPE_DOUBLE:
+ retval = vconf_get_dbl(keyname, &d);
+ if (retval < 0) {
+ _E("Failed to get vconf=%s", keyname);
+ return 0;
+ }
+ snprintf(buffer, sizeof(buffer), "expected=%lf, current=%lf", ieu->cv.d, d);
+ ret = (d == ieu->cv.d);
+ break;
+ case VCONF_TYPE_STRING:
+ s = vconf_get_str(keyname);
+ if (!s) {
+ _E("Failed to get vconf=%s", keyname);
+ return 0;
+ }
+ snprintf(buffer, sizeof(buffer), "expected=%s, current=%s", ieu->cv.s, s);
+ ret = (strncmp(s, ieu->cv.s, 128) == 0);
+ free(s);
+ break;
+ default:
+ return 0;
+ }
+
+ _D("Check condition vconf=%s(%s)", keyname, buffer);
+
+ return ret;
+}
+
void init_input_config(void)
{
libsys_config_parse_by_section(INPUT_CONF_PATH, parse_event_action, NULL);
ieu->timer = 0;
- if (ieu->notifier > 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 {
+ _D("Skip(level) event=%s(%d), condition=%s isn't meet", ieu->name, ieu->id, ieu->cv.keyname);
}
return G_SOURCE_REMOVE;
static void edge_triggered(struct input_event_unit *ieu)
{
- _D("Trigger(edge) event=%s(%d), action=%d", ieu->name, ieu->id, ieu->notifier);
- device_notify(ieu->notifier, ieu->user_data);
+ 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 {
+ _D("Skip(edge) event=%s(%d), condition=%s isn't meet", ieu->name, ieu->id, ieu->cv.keyname);
+ }
}
static void start_event_timer(struct input_config *ic)