BT_ERR("Set vconf failed\n");
}
}
+
/* Switch Off visibility in Bluez */
_bt_set_discoverable_mode(BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, 0);
visible_timer.alarm_id = 0;
+
return 0;
}
}
}
-int __bt_set_visible_time(int timeout)
+int _bt_start_visibility_timer(int timeout)
{
int result;
- alarm_id_t alarm_id;
+ alarm_id_t alarm_id = 0;
#ifdef TIZEN_FEATURE_BT_DPM
int discoverable_state = DPM_BT_ERROR;
#endif
+ if (timeout <= 0) {
+ BT_ERR("Invalid timeout : %d", timeout);
+ return BLUETOOTH_ERROR_INVALID_PARAM;
+ }
+
+#ifdef TIZEN_FEATURE_BT_DPM
+ _bt_dpm_get_bluetooth_limited_discoverable_state(&discoverable_state);
+ if (discoverable_state != DPM_RESTRICTED) {
+ BT_ERR("Limited discoverable mode is not allowed");
+ return BLUETOOTH_ERROR_ACCESS_DENIED;
+ }
+#endif
+
__bt_visibility_alarm_remove();
- visible_timer.timeout = timeout;
+ result = _bt_service_set_alarm(timeout, __bt_visibility_alarm_cb, NULL,
+ &alarm_id);
+ if (result != BLUETOOTH_ERROR_NONE) {
+ BT_ERR("_bt_service_set_alarm is failed : 0x%X", result);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
if (!TIZEN_PROFILE_WEARABLE) {
-#ifdef TIZEN_FEATURE_BT_DPM
- _bt_dpm_get_bluetooth_limited_discoverable_state(&discoverable_state);
- if (discoverable_state != DPM_RESTRICTED) {
-#endif
if (vconf_set_int(BT_FILE_VISIBLE_TIME, timeout) != 0)
BT_ERR("Set vconf failed");
-#ifdef TIZEN_FEATURE_BT_DPM
- }
-#endif
}
-
- if (timeout <= 0)
- return BLUETOOTH_ERROR_NONE;
-
- result = _bt_service_set_alarm(visible_timer.timeout,
- __bt_visibility_alarm_cb, NULL, &alarm_id);
- if (result != BLUETOOTH_ERROR_NONE)
- return BLUETOOTH_ERROR_INTERNAL;
+ visible_timer.timeout = timeout;
visible_timer.alarm_id = alarm_id;
/* Take start time */
time(&(visible_timer.start_time));
- visible_timer.event_id = g_timeout_add_seconds(1,
- __bt_timeout_handler, NULL);
+ visible_timer.event_id = g_timeout_add_seconds(1, __bt_timeout_handler, NULL);
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_stop_visibility_timer(void)
+{
+ __bt_visibility_alarm_remove();
+
+ visible_timer.timeout = 0;
+
+ if (!TIZEN_PROFILE_WEARABLE) {
+ if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
+ BT_ERR("Set vconf failed");
+ }
return BLUETOOTH_ERROR_NONE;
}
#ifdef TIZEN_FEATURE_BT_DPM
_bt_dpm_get_bluetooth_limited_discoverable_state(&discoverable_state);
if (discoverable_mode != BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE &&
- discoverable_state == DPM_RESTRICTED) {
+ discoverable_state == DPM_RESTRICTED) {
if (headed_plugin_info->plugin_headed_enabled)
headed_plugin_info->headed_plugin->bt_launch_dpmpopup("DPM_POLICY_DISABLE_BT_HANDSFREE");
return BLUETOOTH_ERROR_ACCESS_DENIED;
}
- if (discoverable_mode != BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE &&
- discoverable_state == DPM_RESTRICTED) {
+
+ if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE &&
+ discoverable_state == DPM_RESTRICTED) {
if (headed_plugin_info->plugin_headed_enabled)
headed_plugin_info->headed_plugin->bt_launch_dpmpopup("DPM_POLICY_DISABLE_BT");
return BLUETOOTH_ERROR_INTERNAL;
}
- if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE)
- timeout = -1;
-
- ret = __bt_set_visible_time(timeout);
+ if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE) {
+ ret = _bt_stop_visibility_timer();
+ if (!TIZEN_PROFILE_WEARABLE) {
+ if (vconf_set_int(BT_FILE_VISIBLE_TIME, -1) != 0)
+ BT_ERR("Set vconf failed");
+ }
+ } else if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE) {
+ ret = _bt_start_visibility_timer(timeout);
+ } else {
+ ret = _bt_stop_visibility_timer();
+ }
g_variant_unref(result);