Release 4.102.0 (non-official)

This commit separates the patches reused/backported from upstream BlueZ
from the ones developed downstream.
build-sys: Disable deprecated warnings

There's not much point in having -Wdeprecated-declarations in this
version of BlueZ. Right now it's throwing the following warning:

audio/gstavdtpsink.c: In function 'gst_avdtp_sink_finalize':
audio/gstavdtpsink.c:198:2: error: 'g_mutex_free' is deprecated (declared at /usr/include/glib-2.0/glib/deprecated/gthread.h:273) [-Werror=deprecated-declarations]
audio/gstavdtpsink.c: In function 'gst_avdtp_sink_init':
audio/gstavdtpsink.c:1049:2: error: 'g_mutex_new' is deprecated (declared at /usr/include/glib-2.0/glib/deprecated/gthread.h:271) [-Werror=deprecated-declarations]
cc1: all warnings being treated as errors
audio/gsta2dpsink.c: In function 'gst_a2dp_sink_finalize':
audio/gsta2dpsink.c:82:2: error: 'g_mutex_free' is deprecated (declared at /usr/include/glib-2.0/glib/deprecated/gthread.h:273) [-Werror=deprecated-declarations]
audio/gsta2dpsink.c: In function 'gst_a2dp_sink_init':
audio/gsta2dpsink.c:711:2: error: 'g_mutex_new' is deprecated (declared at /usr/include/glib-2.0/glib/deprecated/gthread.h:271) [-Werror=deprecated-declarations]
cc1: all warnings being treated as errors

These functions were already removed from upstream, so there's not much
point in applying a patch upstream and backporting it. So use
-Wno-deprecated-functions instead.
build-sys: Disable -Werror

This breaks build in gcc >= 4.8. And it breaks in places it's not
relevant to upstream. Just disable -Werror and select which warnings
we are going to fix without having to fix all of them.

audio/gstsbcenc.c: In function 'gst_sbc_enc_get_type':
/usr/include/glib-2.0/glib/gmacros.h:162:53: error: typedef '_GStaticAssertCompileTimeAssertion_0' locally defined but not used [-Werror=unused-local-typedefs]
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]
                                                     ^
build-sys: Don't use G_DISABLE_DEPRECATED
AVDTP: Support canceling discovery

Extend the internal API to cancel an ongoing session discovery.
source: Cancel connection attempt if Disconnect()

If a Disconnect() call is received while there is an ongoing connection
attempt, cancel it. If an AVDTP discovery is in process, cancel it.
source: Fix segfault if unpaired during connecting

If an A2DP source is performing service discovery when the device is
unpaired, freed memory is accessed leading to a segmentation fault as
described in the traces below. In order to fix this, stop discovery
specifically:

bluetoothd[26047]: audio/avdtp.c:avdtp_ref() 0x55555582f460: ref=1
bluetoothd[26047]: audio/source.c:source_connect() stream creation in progress
bluetoothd[26047]: src/device.c:device_set_temporary() temporary 1
bluetoothd[26047]: src/device.c:device_remove() Removing device /org/bluez/26047/hci0/dev_90_84_0D_B2_C7_04
bluetoothd[26047]: src/device.c:device_set_bonded() bonded 0
bluetoothd[26047]: plugins/mgmtops.c:mgmt_unpair_device() index 0 addr 90:84:0D:B2:C7:04
bluetoothd[26047]: network/manager.c:network_remove() path /org/bluez/26047/hci0/dev_90_84_0D_B2_C7_04
bluetoothd[26047]: network/connection.c:path_unregister() Unregistered interface org.bluez.Network on path /org/bluez/26047/hci0/dev_90_84_0D_B2_C7_04
bluetoothd[26047]: src/device.c:btd_device_unref() 0x555555826bb0: ref=2
bluetoothd[26047]: serial/manager.c:serial_remove() path /org/bluez/26047/hci0/dev_90_84_0D_B2_C7_04
bluetoothd[26047]: serial/port.c:path_unregister() Unregistered interface org.bluez.Serial on path /org/bluez/26047/hci0/dev_90_84_0D_B2_C7_04
bluetoothd[26047]: audio/gateway.c:path_unregister() Unregistered interface org.bluez.HandsfreeGateway on path /org/bluez/26047/hci0/dev_90_84_0D_B2_C7_04
bluetoothd[26047]: audio/gateway.c:gateway_close() discovering 0 tmp_rfcomm=(nil) rfcomm=(nil) msg (nil)
bluetoothd[26047]: audio/source.c:path_unregister() Unregistered interface org.bluez.AudioSource on path /org/bluez/26047/hci0/dev_90_84_0D_B2_C7_04
bluetoothd[26047]: audio/avdtp.c:avdtp_unref() 0x55555582f460: ref=0
bluetoothd[26047]: audio/control.c:path_unregister() Unregistered interface org.bluez.Control on path /org/bluez/26047/hci0/dev_90_84_0D_B2_C7_04
bluetoothd[26047]: src/device.c:btd_device_unref() 0x555555826bb0: ref=1
bluetoothd[26047]: src/device.c:btd_device_unref() 0x555555826bb0: ref=0
bluetoothd[26047]: src/device.c:device_free() 0x555555826bb0
bluetoothd[26047]: plugins/mgmtops.c:mgmt_event() cond 1
bluetoothd[26047]: plugins/mgmtops.c:mgmt_event() Received 16 bytes from management socket
bluetoothd[26047]: plugins/mgmtops.c:mgmt_cmd_complete()
bluetoothd[26047]: plugins/mgmtops.c:mgmt_cmd_complete() unpair_device complete
bluetoothd[26047]: audio/avdtp.c:connection_lost() Disconnected from 90:84:0D:B2:C7:04
bluetoothd[26047]: audio/avdtp.c:avdtp_unref() 0x55555582f460: ref=-1
bluetoothd[26047]: audio/source.c:discovery_complete() connect:connect XCASE detected
bluetoothd[26047]: avdtp_set_state(): no matching audio device
bluetoothd[26047]: audio/source.c:stream_setup_retry() Stream setup failed, after XCASE connect:connect

Program received signal SIGSEGV, Segmentation fault.
gateway: Trivial variable rename to tmp_rfcomm

Follow the naming in headset.c to rename the prior gw->incoming to
gw->tmp_rfcomm, which is more generic.
gateway: Refactor to remove unregister_incoming()

Close the temporary RFCOMM inside gateway_close(), instead of having a
specific function to handle this.
gateway: Fix not closing temporary RFCOMM

If the gateway is closed during the RFCOMM stablishment (after service
records are gathered) the temporary RFCOMM channel was not closed. Fix
this by storing the channel reference in gw->tmp_rfcomm also for
outgoing connections.
gateway: Cancel discovery in gateway_close()

If service discovery is ongoing when gateway_close() is reached, cancel
it immediately.
gateway: Fix missing dbus_message_unref() calls

gw->msg was referenced with dbus_message_ref() but never unreferenced
correspondingly with dbus_message_unref().
gateway: Fix potential messages without reply

If gateway_close() is called while a pending connection call exists,
send a reply with a generic error message.
gateway: Cancel connection attempt if Disconnect()

If a Disconnect() call is received while there is an ongoing connection
attempt, cancel it. If an service discovery is in process or RFCOMM is
being stablished, cancel them.
Propagate disconnect reason to adapter

Internally propagate disconnect reason.
Propagate disconnect reason to device

Internally propagate disconnect reason in order to make it public in the
D-Bus API.
Send D-Bus signal to propagate disconnect reason

Propagate the disconnection reason through D-Bus, allowing other
components to react accordingly.
doc: Add D-Bus signal to provide disconnect reason

This signal is needed to propagate the reason in case of disconnection.
Some use-cases require this information, for example if there is a
policy to automatically reconnect in case of connection timeout.
gateway: Add log traces for connection debugging

Additional log traces can be helpful to distinguish when the different
states of the connection procedure are reached.
media: Increase hardcoded incoming MTU

When multiple SCO links are active, the packet size typically doubles.