AVDTP_CONNECT_TIMEOUT controls the delay between HSP/HFP
connection establishment and AVDTP signal channel establishment.
The original value of 1 sec. is too short to avoid racing for AVDTP
connection establishment (eg., if the device continues to configure
the HFP service level connection with additional AT cmds).
Some devices have broken AVDTP implementations that just cannot
handle the race conditions that arise if both devices are attempting
stream establishment at the same time. However, these conditions arise
only when the remote device is the ACL initiator (and in practice, the
RFCOMM initiator as well). This fix bumps out the timeout value only
when the headset has initiated the link.
To make sure the SCO link is really disconnected we should wait for
POLLERR since POLLHUP does not necessarily means the link is
completely disconnected just that no further data can be sent/received.
Note that this depend on a fix of SCO socket shutdown in kernel to wait
for disconnect confimation to then kill/destroy the socket indicating
the err/reason using POLLERR.
To prevent a crash in the event that there is a request to remove
the audio connection when it has already been disconnected by the
remote.
Set headset state to connected directly if there is no SCO socket.
In situations where application wants to switch profiles e.g HFP to A2DP
it normally needs to wait SCO to be disconnected to resume A2DP due to
resource limitations on headset.
There seems to be an issue in the kernel side which prevent this to work
properly, apparently shutdown does not wait the link to be disconnected,
but it is under investigation.
This fixes bluetoothd exit when AT+VTS command is badly formatted,
e.g. as AT+VTS\xfe\xfe[...]=1
Verification it done for the numeric value to be larger than 0x23,
that corresponds to the hash '#', and to be lower than 0x44, that
corresponds to 'D', such that the tone is in {0-9, *, #, A, B, C, D}.
Current code only prevent duplicate D-Bus signals, so in case headset
changes the volume a client may set the same volume level again which
would be send as new volume level.
To fix this headset_set_gain now return -EALREADY if nothing has changed
so code using it can just ignore the change instead of sending to remote
device.
HFP state variables in telephony.h need to be reset when telephony_exit
is called. This is even more important now that telephony_init/exit get
called simply by toggling the adapter powered state.
Since no telephony driver supports this command at the moment the
correct behavior is to always return an error. Therefore, a new
"not supported" value is needed for the respective state variable.
DBus error handling in BlueZ is a mess. This is the first patch to unify
all DBus error handling like in ConnMan and oFono. This unifies all
.InvalidArguments errors.
To avoid the issue of applications thinking that the headset is muted if
it hasn't sent any update for the gain values it's better to initialize
them to the maximum (15) instead of the minimum (0).
Headsets for proper disconnecting need to disconnect profiles in specified
order(by ex. disconnect a2dp, then sink and hfp at the end). Instead of
adding separate callbacks for disconnecting each profile, now adding only
one callback in audio/device.c for calling audio disconnect functions in
correct order. New disconnect callback works similarly to dev_disconnect
from audio/device.c
Audio.conf is updated to support fast connectable mode. Set
FastConnectable to true to enable and to false to disable. Headset
initialization and call indicators are updated respectively. It is
disabled by default.
Both D-Bus signals and +VG command are being sent without checking if their
values have really changed, this is similar to ignore redundant option used
in telephony indicators so we don't disturb the connections with redundant
information.
Data from previous connection should be reset once disconnected, to fix
this a new structure is introduced called headset_slc which represents
the Service Level Connection and hold the connection data which is freed
when disconnected.