summaryrefslogtreecommitdiff
path: root/plugins/policy.c
Commit message (Collapse)AuthorAgeFilesLines
* policy: Change AutoEnable default to trueLuiz Augusto von Dentz2022-04-141-1/+5
| | | | | | | This changes the default of AutoEnable to true so controllers are power up by default. Fixes: https://github.com/bluez/bluez/issues/328
* build: Replace use of g_memdup with util_memdupLuiz Augusto von Dentz2022-01-061-3/+4
| | | | | | | | | | | This replaces the uses of g_memdup with util_memdup since the former has been deprecated: warning: ‘g_memdup’ is deprecated: Use 'g_memdup2' instead [-Wdeprecated-declarations] g_memdup2 requires bumping glib version which would likely have its own problems thus why util_memdup was introduced.
* policy: Use btd_service_is_initiatorLuiz Augusto von Dentz2021-09-171-3/+3
| | | | | | | | Instead of using BTD_SERVICE_STATE_CONNECTING use btd_service_is_initiator to determine if the service initiated the connection and then proceed to connect other service immediately. Fixes: https://github.com/bluez/bluez/issues/205
* plugins: Use timeout_add_secondsFrédéric Danis2021-03-161-45/+46
| | | | | Replace calls to g_timeout_add_seconds() by the timeout_add_seconds() wrapper which takes care of 0 delay.
* core: Rename hcid.h to btd.hLuiz Augusto von Dentz2020-10-291-1/+1
| | | | | Since we use btd term for daemon APIs it makes sense to use it also for the header name instead of hcid.
* plugins: Add SPDX License IdentifierTedd Ho-Jeong An2020-09-211-14/+1
| | | | | | | | | | | | | | | | | | This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 7 License: GPL-2.0-or-later plugins/autopair.c plugins/hostname.c plugins/neard.c plugins/policy.c plugins/sixaxis.c plugins/wiimote.c plugins/external-dummy.c
* adapter: Add btd_ prefix to has_kernel_featureLuiz Augusto von Dentz2020-09-151-1/+1
| | | | APIs exposed to plugins shall have btd_ prefix.
* policy: Reconnect audio on controller resumeAbhishek Pandit-Subedi2020-09-141-13/+68
| | | | | | | | During system suspend, all peer devices are disconnected. On resume, HID devices will reconnect but audio devices stay disconnected. As a quality of life improvement, mark audio devices that were disconnected due to suspend and attempt to reconnect them when the controller resumes (after a delay for better co-existence with Wi-Fi).
* policy: Enable reconnect for a2dp-sink in defaultsAbhishek Pandit-Subedi2020-09-141-1/+2
| | | | Add a2dp-sink to default reconnects list.
* policy: Add logic to connect a SinkLuiz Augusto von Dentz2018-06-261-0/+39
| | | | | | If HFP/HSP HS connects and the device also supports a Sink connect it as well since some devices (e.g. Sony MW600) may not connect it automatically.
* plugins: Fix reconnect_interval for cases of improper main.confERAMOTO Masaya2017-07-211-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two problems: - When main.conf is not found, bluetoothd copies short the default set of reconnecting intervals to reconnect_interval. It does not match the reconnct_interval_len used as the array length. So if a link of device is disconnected, bluetoothd is run over reconnect_interval as time proceeds and will not time out as expected. bluetooothd with --debug option outputed the following log in my box: plugins/policy.c:reconnect_set_timer() attempt 1/7 1 seconds plugins/policy.c:reconnect_timeout() Reconnecting profiles plugins/policy.c:conn_fail_cb() status 4 plugins/policy.c:reconnect_set_timer() attempt 2/7 2 seconds plugins/policy.c:reconnect_timeout() Reconnecting profiles plugins/policy.c:conn_fail_cb() status 4 plugins/policy.c:reconnect_set_timer() attempt 3/7 0 seconds plugins/policy.c:reconnect_timeout() Reconnecting profiles plugins/policy.c:conn_fail_cb() status 4 plugins/policy.c:reconnect_set_timer() attempt 4/7 0 seconds - When ReconnectIntervals in main.conf includes invalid characters, reconnct_interval_len value is bigger than the default array length. So if ReconnectAttempts value in main.conf is bigger than reconnct_interval_len value and a link of device is disconnected, bluetoothd is run over reconnect_interval as time proceeds and will not time out as expected. bluetooothd with --debug option outputed the following log in my box, if ReconnectAttempts value was 28 and ReconnectIntervals was inproper: ... plugins/policy.c:reconnect_set_timer() attempt 6/28 32 seconds plugins/policy.c:reconnect_timeout() Reconnecting profiles plugins/policy.c:conn_fail_cb() status 4 plugins/policy.c:reconnect_set_timer() attempt 7/28 64 seconds plugins/policy.c:reconnect_timeout() Reconnecting profiles plugins/policy.c:conn_fail_cb() status 4 plugins/policy.c:reconnect_set_timer() attempt 8/28 0 seconds ... plugins/policy.c:reconnect_set_timer() attempt 25/28 1 seconds plugins/policy.c:reconnect_timeout() Reconnecting profiles plugins/policy.c:conn_fail_cb() status 4 plugins/policy.c:reconnect_set_timer() attempt 26/28 3 seconds plugins/policy.c:reconnect_timeout() Reconnecting profiles plugins/policy.c:conn_fail_cb() status 4 plugins/policy.c:reconnect_set_timer() attempt 27/28 110683472 seconds This fix properly uses the default set of reconnecting intervals.
* policy: Fix removing reconnect flag while still connectingLuiz Augusto von Dentz2017-03-071-1/+1
| | | | | If a service connects it should stop new attempts but the current ones should continue so reconnection should not be reset.
* policy: Fix not reseting sink sourceLuiz Augusto von Dentz2017-01-241-1/+1
| | | | policy_connect_sink shall reset the sink_timer not source_timer.
* policy: Fix not reseting attempts when disconnectedLuiz Augusto von Dentz2016-10-251-0/+2
| | | | | | If the link is disconnected before any profile connects it shall still reset the attempts as the device actually has been connected, otherwise the number of attempts may not be respected.
* plugins/policy: Disable other connect policies while reconnect is activeLuiz Augusto von Dentz2016-07-291-19/+24
| | | | Other policies shall not interfere while reconnect is active.
* plugins/policy: Set list separatorLuiz Augusto von Dentz2016-07-291-0/+2
| | | | Set list separator to ',' as it is used in main.conf.
* plugins/policy: Revert patch 96db78604252eeb17614b9982ced95fd66c6c6fcLuiz Augusto von Dentz2016-07-291-2/+0
| | | | | | Patch 96db78604252eeb17614b9982ced95fd66c6c6fc actually breaks iterating to each attempt since the attempt++ is already done in reconnect_timeout callback.
* policy: Add AutoEnable config optionSzymon Janc2015-09-281-2/+27
| | | | | | | | | | | | | This option is used to configure policy for auto enabling adapters when found. This includes adapters found on start as well as adapters that are plugged in later on. Some distributions use legacy "hciconfig hci0 up" in boot-scripts to automatically enable controllers on start. But that is causing SMP kernel code to not being properly initialized. This patch allows distributions to automatically enable adapters in race free manner even if no agent is provided eg. in login screen.
* policy: Fix not incrementing attemptsLuiz Augusto von Dentz2015-05-071-0/+2
| | | | | The number of attempts and intervals maybe different causing the attempts to not be incremented properly.
* plugins/policy: Fix clang compile errorArman Uguray2015-05-051-4/+4
| | | | | | | | This patch fixes the following error when bluez is compiled with clang: plugins/policy.c:780:6: error: cast from 'int *' to 'size_t *' (aka 'unsigned long *') increases required alignment from 4 to 8 [-Werror,-Wcast-align] (size_t *) &reconnect_intervals_len, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* policy: Add parameters to control reconnectionLuiz Augusto von Dentz2015-04-081-28/+57
| | | | | This adds ReconnectAttempts and ReconnectIntervals so platforms can fine tune the reconnection strategy.
* plugins/policy: Try reconnect Control/Target servicesMarcin Kraglak2015-03-131-8/+49
| | | | | | | | | | If state of Control/Remote services changed from CONNECTING to DISCONNECTED, and error is set to -EAGAIN, set random timer and try reconnect. This approach is described in AVRCP Spec 1.5 4.1.1: "If both devices open an AVCTP channel at the same time both channels shall be closed and each device shall wait a random time (not more than 1 s and not less than 100ms) and then try to open the AVCTP channel again."
* plugins: Fix local libbluetooth includes orderMarcel Holtmann2015-02-281-0/+2
|
* plugins: Add explicit include for lib/bluetooth.hMarcel Holtmann2015-02-181-0/+1
|
* policy: Fix not removing timersLuiz Augusto von Dentz2015-02-021-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If service becomes unavailable, due to e.g. the device being removed, all the related timers should be removed as well otherwise it may cause crashes such as the following: Invalid read of size 8 at 0x4A6597: btd_device_get_service (device.c:5335) by 0x40F49F: policy_connect_ct (policy.c:112) by 0x4E7F552: ??? (in /usr/lib64/libglib-2.0.so.0.4200.1) by 0x4E7EAEA: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.4200.1) by 0x4E7EE87: ??? (in /usr/lib64/libglib-2.0.so.0.4200.1) by 0x4E7F1B1: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.4200.1) by 0x40BACF: main (main.c:631) Address 0x73b9ba8 is 360 bytes inside a block of size 592 free'd at 0x4C2ACE9: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x4E847FE: g_free (in /usr/lib64/libglib-2.0.so.0.4200.1) by 0x49C83F: device_free (device.c:624) by 0x4BDB29: remove_interface (object.c:658) by 0x4BE701: g_dbus_unregister_interface (object.c:1382) by 0x4A49DC: btd_device_unref (device.c:5173) by 0x41DC46: avdtp_free (avdtp.c:1138) by 0x41EE09: connection_lost (avdtp.c:1164) by 0x422EA5: session_cb (avdtp.c:2263) by 0x4E7EAEA: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.4200.1) by 0x4E7EE87: ??? (in /usr/lib64/libglib-2.0.so.0.4200.1) by 0x4E7F1B1: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.4200.1)
* plugins/policy: Both !uuids and !uuids[0] mean an empty listJohan Hedberg2014-05-151-3/+7
|
* plugins/policy: Remove reconnect timer in reconnect_reset()Johan Hedberg2014-05-151-0/+5
| | | | | | In the case that the remote starts connecting to us while we're waiting for the timeout to discover we shouldn't just reset the basic time keeping variables but also remove the timer.
* plugins/policy: Add support to retreive ReconnectUUIDs from main.confJohan Hedberg2014-05-151-5/+29
|
* plugins/policy: Rename UUIDs list variable to avoid name collisionsJohan Hedberg2014-05-151-4/+4
|
* plugins/policy: Add exponential backoff for reconnection attemptsJohan Hedberg2014-05-151-7/+23
|
* plugins/policy: Continue reconnections after connect attempt failureJohan Hedberg2014-05-151-0/+47
| | | | | This patch adds support for continuing reconnecting for several more times (up to 3 minutes) even when a connection attempt fails.
* plugins/policy: Add basic reconnection handlingJohan Hedberg2014-05-151-0/+190
|
* plugins/policy: Limit the number of retries to sink profileLuiz Augusto von Dentz2013-07-121-1/+7
| | | | The policy should only retry a limit number of times.
* plugins/policy: Limit the number of retries to source profileLuiz Augusto von Dentz2013-07-121-1/+7
| | | | The policy should only retry a limit number of times.
* audio/sink: Move stream retry logic to policy pluginLuiz Augusto von Dentz2013-07-121-2/+49
| | | | | policy plugin is a better place to have such a logic as it is already handling other connection policies related to such profiles.
* audio/source: Move stream retry logic to policy pluginLuiz Augusto von Dentz2013-07-121-2/+50
| | | | | policy plugin is a better place to have such a logic as it is already handling other connection policies related to such profiles.
* plugins/policy: Reword audio policy code in a simple pluginLuiz Augusto von Dentz2013-07-121-0/+330
This moves audio device policy to a plugin and removes any dependency of audio plugin to it.