Requires: %{name}-compat = %{version}-%{release}
Recommends: %{name}-driver-standard = %{version}-%{release}
-Requires: configuration-compat = %{version}-%{release}
-Recommends: %{name}-conf-level6 = %{version}-%{release}
-
%description
feedback daemon
%description driver-circle
Feedbackd binaries with circle plugin. Required by main feedbackd package
-%package conf-level3
-Summary: Feedbackd configuration file
-Provides: configuration-compat = %{version}-%{release}
-Conflicts: %{name}-conf-level6
-%description conf-level3
-Feedbackd configuration file.
-
-%package conf-level6
-Summary: Feedbackd configuration file
-Provides: configuration-compat = %{version}-%{release}
-Conflicts: %{name}-conf-level3
-%description conf-level6
-Feedbackd configuration file.
-
%package auto-test
Summary: Feedbackd auto test tool
Group: System/Utilities
systemctl stop feedbackd.service
fi
-%post conf-level3
-mv %{_sysconfdir}/feedbackd/haptic-level3.conf %{_sysconfdir}/feedbackd/haptic.conf
-
-%post conf-level6
-mv %{_sysconfdir}/feedbackd/haptic-level6.conf %{_sysconfdir}/feedbackd/haptic.conf
-
%files -n feedbackd
%manifest %{name}.manifest
%license LICENSE.Apache-2.0
%manifest %{name}.manifest
%{_bindir}/feedbackd.circle
-%files conf-level3
-%license LICENSE.Apache-2.0
-%manifest %{name}.manifest
-%config %{_sysconfdir}/feedbackd/haptic-level3.conf
-
-%files conf-level6
-%license LICENSE.Apache-2.0
-%manifest %{name}.manifest
-%config %{_sysconfdir}/feedbackd/haptic-level6.conf
-
%files auto-test
%license LICENSE.Apache-2.0
%manifest %{name}.manifest
#include "core/config-parser.h"
#include "haptic.h"
-#define HAPTIC_CONF_PATH "/etc/feedbackd/haptic.conf"
#define SIGNAL_CHANGE_HARDKEY "ChangeHardkey"
#define SIGNAL_POWEROFF_STATE "ChangeState"
#define SIGNAL_VIBRATOR_INITIATED "InitiateVibrator"
#define HARDKEY_VIB_DURATION 30
#define HAPTIC_FEEDBACK_STEP 20
#define DEFAULT_FEEDBACK_LEVEL 3
+#define HIGH_FEEDBACK_LEVEL 100
+#define LOW_FEEDBACK_LEVEL 0
/* power on, power off vibration variable */
#define POWER_ON_VIB_DURATION 300
static bool haptic_disabled;
struct haptic_config {
- int level;
- int *level_arr;
int sound_capture;
};
return 0;
}
-static int convert_magnitude_by_conf(int level)
-{
- int i, step;
-
- assert(level >= 0 && level <= 100);
-
- step = 100 / (haptic_conf.level-1);
- for (i = 0; i < haptic_conf.level; ++i) {
- if (level <= i*step) {
- _D("level changed : %d -> %d", level, haptic_conf.level_arr[i]);
- return haptic_conf.level_arr[i];
- }
- }
-
- _D("play default level");
- return DEFAULT_FEEDBACK_LEVEL * HAPTIC_FEEDBACK_STEP;
-}
-
GVariant *hdbus_get_count(GDBusConnection *conn,
const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
-
{
int ret, val;
g_variant_get(param, "(uiii)", &handle, &duration, &level, &priority);
- /* convert as per conf value */
- level = convert_magnitude_by_conf(level);
- if (level < 0) {
- ret = -EINVAL;
- goto exit;
- }
+ if (level < LOW_FEEDBACK_LEVEL)
+ level = LOW_FEEDBACK_LEVEL;
+ else if (level > HIGH_FEEDBACK_LEVEL)
+ level = HIGH_FEEDBACK_LEVEL;
+
if (priority < PRIORITY_MIN)
priority = PRIORITY_MIN;
else if (priority > PRIORITY_TOP)
data = g_variant_get_fixed_array(pvar, &size, sizeof(char));
g_variant_unref(pvar);
- /* convert as per conf value */
- level = convert_magnitude_by_conf(level);
- if (level < 0) {
- ret = -EINVAL;
- goto exit;
- }
+ if (level < LOW_FEEDBACK_LEVEL)
+ level = LOW_FEEDBACK_LEVEL;
+ else if (level > HIGH_FEEDBACK_LEVEL)
+ level = HIGH_FEEDBACK_LEVEL;
ret = h_ops->vibrate_buffer(handle, data, iteration, level, priority, &e_handle);
if (ret >= 0)
g_variant_get(param, "(usii)", &handle, &pattern, &level, &priority);
- /* convert as per conf value */
- level = convert_magnitude_by_conf(level);
- if (level < 0) {
- ret = -EINVAL;
- goto exit;
- }
+ if (level < LOW_FEEDBACK_LEVEL)
+ level = LOW_FEEDBACK_LEVEL;
+ else if (level > HIGH_FEEDBACK_LEVEL)
+ level = HIGH_FEEDBACK_LEVEL;
if (priority < PRIORITY_MIN)
priority = PRIORITY_MIN;
else if (priority > PRIORITY_TOP)
haptic_start();
}
+/* Left for the case of sound_capture in use
static int parse_section(struct parse_result *result, void *user_data, int index)
{
struct haptic_config *conf = (struct haptic_config *)user_data;
if (MATCH(result->name, "sound_capture")) {
conf->sound_capture = atoi(result->value);
- } else if (MATCH(result->name, "level")) {
- conf->level = atoi(result->value);
- if (conf->level < 0 || conf->level >= INT_MAX - 1) {
- _E("You must set level with positive number in integer range");
- return -EINVAL;
- }
- conf->level_arr = calloc(sizeof(int), conf->level);
- if (!conf->level_arr) {
- _E("failed to allocate memory for level");
- return -errno;
- }
- } else if (MATCH(result->name, "value")) {
- if (index < 0)
- return -EINVAL;
- conf->level_arr[index] = atoi(result->value);
}
return 0;
static int haptic_load_config(struct parse_result *result, void *user_data)
{
- struct haptic_config *conf = (struct haptic_config *)user_data;
- char name[NAME_MAX];
int ret;
- static int index;
if (!result)
return 0;
if (!result->section || !result->name || !result->value)
return 0;
- /* Parsing 'Haptic' section */
+ // Parsing 'Haptic' section
if (MATCH(result->section, "Haptic")) {
ret = parse_section(result, user_data, -1);
if (ret < 0) {
goto out;
}
- /* Parsing 'Level' section */
- for (index = 0; index < conf->level; ++index) {
- snprintf(name, sizeof(name), "level%d", index);
- if (MATCH(result->section, name)) {
- ret = parse_section(result, user_data, index);
- if (ret < 0) {
- _E("failed to parse [level] section : %d", ret);
- return ret;
- }
- goto out;
- }
- }
-
out:
return 0;
}
+*/
static const dbus_method_s hdbus_methods[] = {
{ "GetCount", NULL, "i", hdbus_get_count },
{
int r;
- /* get haptic data from configuration file */
- r = config_parse(HAPTIC_CONF_PATH, haptic_load_config, &haptic_conf);
- if (r < 0) {
- _E("failed to load configuration file(%s) : %d", HAPTIC_CONF_PATH, r);
- safe_free(haptic_conf.level_arr);
- }
-
/* init dbus interface */
r = dbus_handle_register_dbus_object(NULL, VIBRATOR_PATH_HAPTIC, &dbus_interface);
if (r < 0)
unsubscribe_dbus_signal(NULL, id_sig_change_hardkey);
unsubscribe_dbus_signal(NULL, id_sig_pwr_off_state);
- /* release haptic data memory */
- safe_free(haptic_conf.level_arr);
-
if (!CHECK_VALID_OPS(h_ops, r))
return;