From 65ff796c7477d405fbc97e3a3cc4605d8da5f7e6 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Fri, 24 Feb 2017 18:07:14 +0900 Subject: Remove build dependencies on profile - Remove build dependencies of check.c - Check the profile on runtime Change-Id: I256fffa813091a49877d18e936e77c62854e0fef Signed-off-by: pr.jung --- wearable/src/check.c | 425 --------------------------------------------------- 1 file changed, 425 deletions(-) delete mode 100644 wearable/src/check.c (limited to 'wearable') diff --git a/wearable/src/check.c b/wearable/src/check.c deleted file mode 100644 index f845be3..0000000 --- a/wearable/src/check.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - * libfeedback - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include - -#include "feedback.h" -#include "feedback-ids-internal.h" -#include "profiles.h" -#include "log.h" - - -static const char *wearable_str_type[] = { - "FEEDBACK_TYPE_NONE", - "FEEDBACK_TYPE_SOUND", - "FEEDBACK_TYPE_VIBRATION", -}; - -static const char *wearable_str_pattern[] = { - "FEEDBACK_PATTERN_TAP", - "FEEDBACK_PATTERN_SIP", - "", - "", - "", - "", - "FEEDBACK_PATTERN_KEY0", - "FEEDBACK_PATTERN_KEY1", - "FEEDBACK_PATTERN_KEY2", - "FEEDBACK_PATTERN_KEY3", - "FEEDBACK_PATTERN_KEY4", - "FEEDBACK_PATTERN_KEY5", - "FEEDBACK_PATTERN_KEY6", - "FEEDBACK_PATTERN_KEY7", - "FEEDBACK_PATTERN_KEY8", - "FEEDBACK_PATTERN_KEY9", - "FEEDBACK_PATTERN_KEY_STAR", - "FEEDBACK_PATTERN_KEY_SHARP", - "FEEDBACK_PATTERN_KEY_BACK", - "FEEDBACK_PATTERN_HOLD", - "", - "FEEDBACK_PATTERN_HW_TAP", - "FEEDBACK_PATTERN_HW_HOLD", - - "FEEDBACK_PATTERN_MESSAGE", - "FEEDBACK_PATTERN_MESSAGE_ON_CALL", - "FEEDBACK_PATTERN_EMAIL", - "FEEDBACK_PATTERN_EMAIL_ON_CALL", - "FEEDBACK_PATTERN_WAKEUP", - "FEEDBACK_PATTERN_WAKEUP_ON_CALL", - "FEEDBACK_PATTERN_SCHEDULE", - "FEEDBACK_PATTERN_SCHEDULE_ON_CALL", - "FEEDBACK_PATTERN_TIMER", - "FEEDBACK_PATTERN_TIMER_ON_CALL", - "FEEDBACK_PATTERN_GENERAL", - "FEEDBACK_PATTERN_GENERAL_ON_CALL", - "", - - "FEEDBACK_PATTERN_POWERON", - "FEEDBACK_PATTERN_POWEROFF", - "FEEDBACK_PATTERN_CHARGERCONN", - "FEEDBACK_PATTERN_CHARGERCONN_ON_CALL", - "FEEDBACK_PATTERN_CHARGING_ERROR", - "FEEDBACK_PATTERN_CHARGING_ERROR_ON_CALL", - "FEEDBACK_PATTERN_FULLCHARGED", - "FEEDBACK_PATTERN_FULLCHARGED_ON_CALL", - "FEEDBACK_PATTERN_LOWBATT", - "FEEDBACK_PATTERN_LOWBATT_ON_CALL", - "FEEDBACK_PATTERN_LOCK", - "FEEDBACK_PATTERN_UNLOCK", - "", - "", - "", - "", - "", - "", - "", - "FEEDBACK_PATTERN_VIBRATION_ON", - "FEEDBACK_PATTERN_SILENT_OFF", - "FEEDBACK_PATTERN_BT_CONNECTED", - "FEEDBACK_PATTERN_BT_DISCONNECTED", - "", - "", - "FEEDBACK_PATTERN_SCREEN_CAPTURE", - "FEEDBACK_PATTERN_LIST_REORDER", - "FEEDBACK_PATTERN_LIST_SLIDER", - "FEEDBACK_PATTERN_VOLUME_KEY", - - "", - "", - "", - "", - "", - "", - "", - "", - "", - "FEEDBACK_PATTERN_SEND_SOS_MESSAGE", - "FEEDBACK_PATTERN_RINGER", - "FEEDBACK_PATTERN_NOTIFICATION", - "FEEDBACK_PATTERN_INFO", - "FEEDBACK_PATTERN_WARNING", - "FEEDBACK_PATTERN_ERROR", - "FEEDBACK_PATTERN_EMERGENCY", -}; - -static int callstatus; -static int camerastatus; -static int shutter_sndstatus; -static int noti_vibstatus; -static int vib_level; -static int noti_level; -static int feedbackstatus; - -static void feedback_callstatus_cb(keynode_t *key, void* data) -{ - callstatus = vconf_keynode_get_int(key); -} - -static void feedback_camerastatus_cb(keynode_t *key, void* data) -{ - camerastatus = vconf_keynode_get_int(key); -} - -static void feedback_noti_vibstatus_cb(keynode_t *key, void* data) -{ - noti_vibstatus = vconf_keynode_get_bool(key); -} - -static void feedback_vib_cb(keynode_t *key, void* data) -{ - vib_level = vconf_keynode_get_int(key); -} - -static void feedback_noti_cb(keynode_t *key, void* data) -{ - noti_level = vconf_keynode_get_int(key); -} - -static void feedback_feedbackstatus_cb(keynode_t *key, void* data) -{ - feedbackstatus = vconf_keynode_get_bool(key); -} - -static void wearable_init(void) -{ - /* check call status */ - if (vconf_get_int(VCONFKEY_CALL_STATE, &callstatus) < 0) - _W("VCONFKEY_CALL_STATE ==> FAIL!!"); - - /* check camera status */ - if (vconf_get_int(VCONFKEY_CAMERA_STATE, &camerastatus) < 0) - _W("VCONFKEY_CAMERA_STATE ==> FAIL!!"); - - /* shutter sound policy */ - /* This vconf is read just once, because this value is not changed in running time. */ - if (vconf_get_int(VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY, &shutter_sndstatus) < 0) - _W("VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY ==> FAIL!!"); - - /* check vibration status */ - if (vconf_get_bool(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, ¬i_vibstatus) < 0) - _W("VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL ==> FAIL!!"); - - /* check vib_level */ - if (vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &vib_level) < 0) - _W("VCONFKEY_FEEDBACK_VIBRATION_LEVEL_INT ==> FAIL!!"); - - /* check noti_level */ - if (vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, ¬i_level) < 0) - _W("VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT ==> FAIL!!"); - - /* feedback Init */ - if (vconf_get_bool(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, &feedbackstatus) < 0) - _W("VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL ==> FAIL!!"); - - /* add watch for status value */ - vconf_notify_key_changed(VCONFKEY_CALL_STATE, feedback_callstatus_cb, NULL); - vconf_notify_key_changed(VCONFKEY_CAMERA_STATE, feedback_camerastatus_cb, NULL); - vconf_notify_key_changed(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, feedback_noti_vibstatus_cb, NULL); - vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, feedback_vib_cb, NULL); - vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, feedback_noti_cb, NULL); - vconf_notify_key_changed(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, feedback_feedbackstatus_cb, NULL); -} - -static void wearable_exit(void) -{ - /* remove watch */ - vconf_ignore_key_changed(VCONFKEY_CALL_STATE, feedback_callstatus_cb); - vconf_ignore_key_changed(VCONFKEY_CAMERA_STATE, feedback_camerastatus_cb); - vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, feedback_noti_vibstatus_cb); - vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, feedback_vib_cb); - vconf_ignore_key_changed(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, feedback_noti_cb); - vconf_ignore_key_changed(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, feedback_feedbackstatus_cb); -} - -static bool wearable_get_switched_pattern(int pattern, int *switched) -{ - if (!switched) - return false; - - if (callstatus == VCONFKEY_CALL_OFF) - return false; - - /* in case of call connected or connecting */ - _D("Call status is connected or connecting."); - if (pattern == FEEDBACK_PATTERN_MESSAGE) - *switched = FEEDBACK_PATTERN_MESSAGE_ON_CALL; - else if (pattern == FEEDBACK_PATTERN_EMAIL) - *switched = FEEDBACK_PATTERN_EMAIL_ON_CALL; - else if (pattern == FEEDBACK_PATTERN_WAKEUP) - *switched = FEEDBACK_PATTERN_WAKEUP_ON_CALL; - else if (pattern == FEEDBACK_PATTERN_SCHEDULE) - *switched = FEEDBACK_PATTERN_SCHEDULE_ON_CALL; - else if (pattern == FEEDBACK_PATTERN_TIMER) - *switched = FEEDBACK_PATTERN_TIMER_ON_CALL; - else if (pattern == FEEDBACK_PATTERN_GENERAL) - *switched = FEEDBACK_PATTERN_GENERAL_ON_CALL; - else if (pattern == FEEDBACK_PATTERN_CHARGERCONN) - *switched = FEEDBACK_PATTERN_CHARGERCONN_ON_CALL; - else if (pattern == FEEDBACK_PATTERN_CHARGING_ERROR) - *switched = FEEDBACK_PATTERN_CHARGING_ERROR_ON_CALL; - else if (pattern == FEEDBACK_PATTERN_FULLCHARGED) - *switched = FEEDBACK_PATTERN_FULLCHARGED_ON_CALL; - else if (pattern == FEEDBACK_PATTERN_LOWBATT) - *switched = FEEDBACK_PATTERN_LOWBATT_ON_CALL; - else - return false; - - return true; -} - -static bool wearable_is_notification_type(int pattern) -{ - switch (pattern) { - case FEEDBACK_PATTERN_WAKEUP: - case FEEDBACK_PATTERN_WAKEUP_ON_CALL: - case FEEDBACK_PATTERN_TIMER: - case FEEDBACK_PATTERN_TIMER_ON_CALL: - return false; - case FEEDBACK_PATTERN_MESSAGE ... FEEDBACK_PATTERN_EMAIL_ON_CALL: - case FEEDBACK_PATTERN_SCHEDULE: - case FEEDBACK_PATTERN_SCHEDULE_ON_CALL: - case FEEDBACK_PATTERN_GENERAL ... FEEDBACK_PATTERN_LOWBATT_ON_CALL: - return true; - } - return false; -} - -static bool wearable_is_system_type(int pattern) -{ - switch (pattern) { - case FEEDBACK_PATTERN_POWERON ... FEEDBACK_PATTERN_VOLUME_KEY: - return true; - } - return false; -} - -static int wearable_get_priority(int pattern) -{ - return PRIORITY_MIDDLE; -} - -static bool wearable_get_always_alert_case(int type, int pattern) -{ - if (CHECK_SOUND(type)) { - switch (pattern) { - case FEEDBACK_PATTERN_WAKEUP: - case FEEDBACK_PATTERN_WAKEUP_ON_CALL: - return true; - case FEEDBACK_PATTERN_MESSAGE_ON_CALL: - case FEEDBACK_PATTERN_EMAIL_ON_CALL: - case FEEDBACK_PATTERN_GENERAL_ON_CALL: - break; - case FEEDBACK_PATTERN_SEND_SOS_MESSAGE: - return true; - case FEEDBACK_PATTERN_SCREEN_CAPTURE: - if (camerastatus && shutter_sndstatus) - return true; - break; - case FEEDBACK_PATTERN_OUTGOING_CALL: - return true; - default: - break; - } - } else if (CHECK_VIBRATION(type)) { - switch (pattern) { - case FEEDBACK_PATTERN_TAP: - case FEEDBACK_PATTERN_KEY0 ... FEEDBACK_PATTERN_KEY_BACK: - case FEEDBACK_PATTERN_HOLD: - if (feedbackstatus) - return true; - break; - case FEEDBACK_PATTERN_MESSAGE: - case FEEDBACK_PATTERN_EMAIL: - case FEEDBACK_PATTERN_GENERAL: - case FEEDBACK_PATTERN_SCHEDULE: - if (noti_vibstatus) - return true; - break; - case FEEDBACK_PATTERN_SIP: - case FEEDBACK_PATTERN_TIMER: - case FEEDBACK_PATTERN_TIMER_ON_CALL: - case FEEDBACK_PATTERN_WAKEUP: - case FEEDBACK_PATTERN_WAKEUP_ON_CALL: - case FEEDBACK_PATTERN_MESSAGE_ON_CALL: - case FEEDBACK_PATTERN_EMAIL_ON_CALL: - case FEEDBACK_PATTERN_GENERAL_ON_CALL: - case FEEDBACK_PATTERN_CHARGERCONN_ON_CALL: - case FEEDBACK_PATTERN_CHARGING_ERROR_ON_CALL: - case FEEDBACK_PATTERN_LOWBATT_ON_CALL: - case FEEDBACK_PATTERN_BT_DISCONNECTED: - case FEEDBACK_PATTERN_SEND_SOS_MESSAGE: - case FEEDBACK_PATTERN_OUTGOING_CALL: - return true; - default: - break; - } - } - return false; -} - -static bool wearable_get_always_off_case(int type, int pattern) -{ - int ret; - - if (CHECK_SOUND(type)) { - if ((wearable_is_notification_type(pattern) || wearable_is_system_type(pattern)) && - callstatus) { - _W("skip %s sound during call", wearable_str_pattern[pattern]); - return true; - } - /* check if the state of voice recorder is recording */ - if (vconf_get_int(VCONFKEY_RECORDER_STATE, &ret) == 0 && - ret == VCONFKEY_RECORDER_STATE_RECORDING) { - _D("voice recording status is RECORDING"); - return true; - } - - switch (pattern) { - case FEEDBACK_PATTERN_TAP: - case FEEDBACK_PATTERN_HOLD ... FEEDBACK_PATTERN_HW_HOLD: - if (!is_touch_sndstatus()) - return true; - break; - case FEEDBACK_PATTERN_KEY0 ... FEEDBACK_PATTERN_KEY_BACK: - if (!is_keytone_sndstatus()) - return true; - break; - default: - break; - } - } else if (CHECK_VIBRATION(type)) { - switch (pattern) { - case FEEDBACK_PATTERN_TAP: - case FEEDBACK_PATTERN_KEY0 ... FEEDBACK_PATTERN_KEY_BACK: - case FEEDBACK_PATTERN_HOLD: - if (!feedbackstatus) - return true; - break; - default: - break; - } - } - return false; -} - -static int wearable_get_strength_type(int type, int pattern) -{ - if (CHECK_SOUND(type)) { - if (pattern == FEEDBACK_PATTERN_TAP) - return VOLUME_TYPE_SYSTEM|VOLUME_GAIN_TOUCH; - else if (pattern >= FEEDBACK_PATTERN_KEY0 && pattern <= FEEDBACK_PATTERN_KEY_BACK) - return VOLUME_TYPE_SYSTEM|VOLUME_GAIN_DIALER; - else if (pattern == FEEDBACK_PATTERN_VOLUME_KEY || pattern == FEEDBACK_PATTERN_SILENT_OFF) - return VOLUME_TYPE_RINGTONE; - else if (camerastatus && shutter_sndstatus && pattern == FEEDBACK_PATTERN_SCREEN_CAPTURE) - return VOLUME_TYPE_FIXED; - return VOLUME_TYPE_SYSTEM; - } else if (CHECK_VIBRATION(type)) { - if (pattern >= FEEDBACK_PATTERN_TAP && pattern <= FEEDBACK_PATTERN_HW_HOLD) { - _D("use default level"); - return DEFAULT_VIB_LEVEL * HAPTIC_FEEDBACK_STEP; - } - /* if call status is ON, vibration magnitude is 20% */ - if (pattern != FEEDBACK_PATTERN_RINGER && - (callstatus == VCONFKEY_CALL_VOICE_ACTIVE || callstatus == VCONFKEY_CALL_VIDEO_ACTIVE)) { - _W("force change weak level"); - return HAPTIC_FEEDBACK_STEP; - } - return noti_level * HAPTIC_FEEDBACK_STEP; - } - return -EINVAL; -} - -static const struct profile_ops wearable_profile_ops = { - .profile = "wearable", - .init = wearable_init, - .exit = wearable_exit, - .get_switched_pattern = wearable_get_switched_pattern, - .get_always_alert_case = wearable_get_always_alert_case, - .get_always_off_case = wearable_get_always_off_case, - .get_strength_type = wearable_get_strength_type, - .get_priority = wearable_get_priority, - .is_notification_type = wearable_is_notification_type, - .max_type = FEEDBACK_TYPE_END, - .max_pattern = FEEDBACK_PATTERN_INTERNAL_END, - .str_type = wearable_str_type, - .str_pattern = wearable_str_pattern, -}; - -PROFILE_OPS_REGISTER(&wearable_profile_ops); -- cgit v1.2.3