Commit Graph

768 Commits

Author SHA1 Message Date
Pavlin Radoslavov
2199339c39 Add a mechanism to configure the default A2DP codec priorities
Previously, the relative codec priorities were hard-codec internally.
The new mechanism uses the following configurable resources in
packages/apps/Bluetooth/res/values/config.xml to re-assign the
default codec priorities per device, or to explicitly disable a codec.

 - a2dp_source_codec_priority_sbc
 - a2dp_source_codec_priority_aac
 - a2dp_source_codec_priority_aptx
 - a2dp_source_codec_priority_aptx_hd
 - a2dp_source_codec_priority_ldac

Those values are assigned on startup.
Also, they can be changed per device by using an overlay:
device/<VENDOR>/<DEVICE>/overlay/packages/apps/Bluetooth/res/values/config.xml

Test: Manually streaming to a headset
Change-Id: Ic4da3a51ac73f00cbae731156cb7878c8fadee06
2017-02-06 13:07:23 -08:00
Pavlin Radoslavov
b37f181c98 Update the A2DP Codec Config API
Previously, the JNI upcall would contain only the current codec config.
In the new API, the upcall contains:
 1. The current codec config
 2. The list of codecs containing the local codecs capabilities
 3. The list of codecs containing the selectable codecs capabilities.
    This list is the intersection of the local codecs capabilities
    and the capabilities of the paired device.

Also, refactored the Java internals to accomodate the extra information:
 * Added new class BluetoothCodecStatus that contains the extra info:
   current codec config, local codecs capabilities and selectable
   codecs capabilities
 * Renamed method getCodecConfig() to getCodecStatus() and return the
   corresponding BluetoothCodecStatus object.
 * Updates to class BluetoothCodecConfig:
   new methods isValid(), getCodecName(), and updated toString()
   so it is more user friendly
 * Removed BluetoothCodecConfig.EXTRA_CODEC_CONFIG and
   EXTRA_PREVIOUS_CODEC_CONFIG.
   The former is superseded by BluetoothCodecStatus.EXTRA_CODEC_STATUS;
   the latter is not really used.

Test: A2DP streaming with headsets and switching the codecs
Change-Id: Ia1af2c22e521e863e28a360610aca49f7e62d31b
2017-01-31 18:58:27 +00:00
Marie Janssen
23a4833157 Bluetooth: add getDiscoveryEndMillis() call
Method to tell when the adapter finished (or will finish) being in
discovery mode.

Test: compiles and still can scan
Bug: 34395439
Change-Id: I41b48c2b934c0a1d5e1727cec08f3f762e3cb309
2017-01-27 18:48:11 -08:00
Pavlin Radoslavov
b33bd5bc2e Integration of the AAC codec for A2DP source
Test: A2DP streaming to AAC headsets
Bug: 30958229
Change-Id: I1b530f1c5c495b8231fd68bed788d4567096683d
2017-01-26 09:06:02 -08:00
Sanket Agarwal
a3ae5c4e24 Change HFP Client API to support multi device
- Adds BluetoothDevice as a parameter where required
- Gets rid of device management APIs that can be done via
  BluetoothProfiles instead

Test: Manual sanity tests
Bug: b/33554547
Bug: b/30984220
Change-Id: I3485ac5bfe1fcb29c774ad040fdd608e1cacb8df
(cherry picked from commit 039eeb81b5)
2017-01-20 19:30:35 -08:00
Neil Fuller
7fd724611b Refactor RFCOMM / BluetoothSocket usage of LocalSocket
LocalSocket is used by BluetoothSocket. BluetoothSocket
passes a pre-created file descriptor to LocalSocket that
is then given to the LocalSocketImpl.

Commit b08c7bc0bd broke the
behavior. Commit 7a8c36aa4e
put in a minimal fix.

This change tidies up LocalSocket and associated classes
and replaces a specialist constructor with a factory method
to highlight the special case. While there an unnecessary
exception has been removed.

Bug: 34111534
Test: Boot device
Test: vogar --mode app_process tests/tests/net/src/android/net/cts/LocalSocketTest.java
Change-Id: I4ba2f2d9ea361a950ff8bc8d64fc800d998c3210
2017-01-06 14:18:07 +00:00
Pavlin Radoslavov
fad8b730d2 Integration of the LDAC codec for A2DP source
The codec can be used if the encoding shared library is installed
on the device:
 libldacBT_enc.so

Test: A2DP streaming to LDAC headsets
Bug: 30958229

Change-Id: I524805fd308b5181427515617eda05625a7c4ae5
2017-01-04 18:07:29 -08:00
Pavlin Radoslavov
feeb9b245c Integration of the aptX and aptX-HD codecs for A2DP source
Each of the codecs can be used if the corresponding encoding
shared library is installed on the device:
 - aptX: libaptX.so
 - aptX-HD: libaptXHD.so

Test: A2DP streaming to aptX and aptX-HD headsets
Bug: 30958229
Change-Id: I24faddc8cd88ae3e1370922c633f30e13124a867
2017-01-04 16:30:35 -08:00
Ivan Podogov
f33a71d017 Merge "HID Device role API fixes" 2017-01-04 10:32:41 +00:00
Pavlin Radoslavov
44a4ef0aa9 Add a mechanism for configuring the A2DP Source codecs
* Added a new class BluetoothCodecConfig that contains codec-related
  configuration or capabilities: codec type, priority, sample rate,
  bits per sample, channel mode, and codec specific fields.

* Extended the Bluetooth A2DP AIDL interface to get/set the current
  codec configuration

* Added new call handleBluetoothA2dpDeviceConfigChange() to the Media
  Framework that is called when there are changes in the
  Bluetooth A2DP device configuration - e.g., the A2DP codec is changed.

Test: A2DP streaming to headsets, TestPlans/71390
Bug: 30958229
Change-Id: I9a82716cbc2a5efbe77352a031ac80c88f6a2459
2017-01-03 17:52:52 -08:00
Ivan Podogov
dd87cd3bb6 HID Device role API fixes
This change makes HIDD API more like the other ones, i.e.
supporting multiple devices, and implements missing methods.

While the underlying implementation may still only support a
single device at a time, the "device" parameter can still be
useful for checking if the application is trying to send the
data to a correct device.

Test: make
Change-Id: I55fe04c0762a96fcddd6c6678e790361d648111a
2017-01-03 22:36:30 +00:00
Marie Janssen
9cc7ebe7d9 Merge "Bluetooth: track enabling in dumpsys" 2016-12-29 19:32:36 +00:00
Marie Janssen
5980456040 Bluetooth: track enabling in dumpsys
Move basic state dumpsys to here from AdapterService.

Track which apps are enabling and disabling Bluetooth, including BLE
apps, and show the apps in the dumpsys logs.

Test: start phone and enable/disable, take bug report
Bug: 33692282
Change-Id: I6ea62ebdcfd7873d0be1bb5c5c520bbce3737a40
2016-12-29 19:22:14 +00:00
Ivan Podogov
0afe190af5 Rename the Bluetooth profile classes for HID Device role.
We already have BluetoothInputDevice class, so adding something
called BluetoothHidDevice seems confusing. On the other hand,
the new class is designed to connect to HID Host devices, so
naming it BluetoothInputHost makes sense and goes in line with
the existing BluetoothInputDevice.

The same goes for the new constant HID_DEVICE that is just as
confusing to have together with the INPUT_DEVICE one.

This CL also renames the "connection state changed" broadcast
(for the same reasons), declares it as an SDK constant, and also
adds some javadoc to it.

Note that BluetoothHidDeviceApp* classes remained unchanged, as
those correspond to the app that implements the Device (and
connects to the Host).

Test: make
Change-Id: I5075ca5b97db3c1dd403c2e9660eecc7380cffe2
2016-12-29 14:30:40 +00:00
Hemant Gupta
e88fd4b594 Bluetooth: Add support for HID Device Role
This patch adds the HID Device Role support in Bluetooth framework.
Also AIDL and callback related files for HID Device role are added
to provide interface for third party applications to communicate with
HID Device Service.

Change-Id: Id03a362b7bcfa2e76056fa0197eaac12ce49b5a2
2016-12-29 14:29:53 +00:00
Marie Janssen
cb21ad71ed Bluetooth: log message improvements
Some log improvements:
 - Reduce logspam
 - Use names for states in logs instead of numbers
 - Be more consistent with messages

Also remove some commented out dead code.

Test: run on phone, observe more useful logs
Change-Id: I32163278e148be144c03d4e8aaf0eb761226c94c
2016-12-14 09:51:30 -08:00
Svetoslav Ganov
c2ac5bde6f DO NOT MERGE Add Bluetooth toggle prompts - framework
If permission review is enabled toggling bluetoth on or off
results in a user prompt to collect consent. This applies
only to legacy apps, i.e. ones that don't support runtime
permissions as they target SDK 22.

Also added a configuration resource which controls whether
permission review mode is enabled. By default it is not and
an OEM can change this via an overlay. For now we also keep
the old mechanism to toggle review mode via a build property
which is still used and will be removed when clients have
transitioned.

bug:28715749
Change-Id: I77bca2305f9d0f20034b2c8fc5b58e0565d5e617
2016-12-12 09:50:24 -08:00
Jakub Pawlowski
673c0e5596 Merge "Bluetooth: report proper advertiser status on error"
am: b509957e62

Change-Id: I1bb0a029a9044c3931e158c7ef02ffee4cb0f1cd
2016-11-23 01:58:03 +00:00
Jakub Pawlowski
76f517a173 Bluetooth: report proper advertiser status on error
When advertiser is not started because too many advertisers are
registered, return proper error code.

Bug: 30622771
Test: sl4a ConcurrentBleAdvertisingTest
Change-Id: I57384ff30132e9a7ee17dcf191ff89baa7abf1ef
2016-11-22 13:38:15 -08:00
Jakub Pawlowski
e3b71cd572 Merge "Bluetooth: advertising improvements"
am: 82c9ba9c55

Change-Id: I662ba0f326aa204f9f07ce88bc9d48f5b06770cb
2016-11-11 23:48:51 +00:00
Jakub Pawlowski
3d83b0e90b Bluetooth: advertising improvements
This patch removes isPeripheralModeSupported(), hidden public method
which is always returning true. It also modify the BluetoothLeAdvertiser
to be able to use advertising instance with instance id equal 0.

Bug: 30622771
Bug: 24099160
Change-Id: Id31582621dbe56d5c3a8d4ee5cd296af66a5f026
2016-11-11 23:28:32 +00:00
Jakub Pawlowski
c3cfff6ef6 Merge "BLE OOB Pairing - parse address type (5/5)"
am: 97d9fe0a2f

Change-Id: I935cc35d9f7f1eea5459f0091ad14dc8b200bc02
2016-11-10 20:07:39 +00:00
Jakub Pawlowski
f465823f6d BLE OOB Pairing - parse address type (5/5)
When address type is not parsed, creating bond to devices not using
random address is impossible.

Bug: 32780409
Test: try pairing with nRF52DK using random address
Change-Id: Ie6cc1f8c008d43b2acd021b47f9bbfb1f63472e8
2016-11-10 19:51:49 +00:00
Joseph Pirozzo
b13240028b MAP MCE
am: b8fc0679e8

Change-Id: Id82f047bc2d0eb7e4f04c14cfc216854e066156f
2016-11-02 01:05:14 +00:00
Joseph Pirozzo
d94c280a7f MAP MCE
am: 631768d814

Change-Id: I155fd0e8b44539bf79cec2c6ddb2a4d71b0c23d9
2016-11-02 01:03:51 +00:00
Joseph Pirozzo
b8fc0679e8 MAP MCE
Fix @LINK to @link in javadoc.

Bug: 30467210
Change-Id: Icac176947bee971c3f5d11fd4166cf8ceb0a437e
(cherry picked from commit f5fba751d360bbe8294c4640f5ad12a990f13122)
2016-11-01 17:39:16 -07:00
Joseph Pirozzo
631768d814 MAP MCE
Add MAP client code into packages/apps/Bluetooth.  Changes here are to
define the MAP MCE interface and enable its selection when running on a
device that is also running a PBAP client (Car Kitt).

Bug: 30467210
Change-Id: Ifa2cdea7d67f63a2b5f3d971df8ec6d321dc5fee
(cherry picked from commit 433b3054847951e8e7b3864d11990604a66b8651)
2016-11-01 17:39:16 -07:00
Bryce Lee
6f84631d8d Merge "Add a way to query for supported Bluetooth profiles."
am: 0a86c936a6

Change-Id: Id10ad10a5dbcab92e390a7a245772d2b551ad30c
2016-11-01 23:20:16 +00:00
Bryce Lee
f6b74dea04 Add a way to query for supported Bluetooth profiles.
Currently there is no way to get the profiles supported by the Bluetooth
adapter. Asking for a profile proxy of an unsupported profile does not
fail and can lead to code indefinitely waiting for the proxy response. This
new code will allow for checking the supported profiles before asking for
the proxies.

Bug: 26451648
Change-Id: I4b48e7151f5ca53851aa3b967c143fae140ecd34
(cherry picked from commit b1301fa284)
2016-11-01 15:13:04 -07:00
Marie Janssen
879a5169ec resolve merge conflicts of 6a31a5c to stage-aosp-master
Change-Id: I29f2085f4656b0b57896ef505ef6a50cdbd1b194
2016-10-31 11:00:06 -07:00
Marie Janssen
6a383a7d32 Bluetooth: prevent enabling BLE in airplane mode
Enabling BLE in airplane mode puts BluetoothManagerService in an
unexpected state which causes Bluetooth to be on when airplane mode
is disabled.

Also fixes a bug where a crash of a BLE client would trigger a restart
into ON mode.

Test: SL4A BleBackgroundScanTest:test_airplane_mode_disables_ble

Bug: 32140251
Bug: 32140271
Bug: 32369494

Change-Id: Ie65157e65c3a1ca914f567a7a0c631175d1e5835
2016-10-31 09:06:36 -07:00
Sanket Agarwal
958dab93cd Merge "Use UUIDs for call management in Headset Client (HF)"
am: 678ba24533

Change-Id: I77553f45f3d5de04e9b443e425f15afb8946e237
2016-10-28 20:13:57 +00:00
Sanket Agarwal
52a04e4467 Use UUIDs for call management in Headset Client (HF)
Using UUIDs that are managed by the service gives more control and error
handling in the service since it has control over assigning them.

Bug: b/29788044
Change-Id: I8483f8e61a33302ba95d544828947d7fb4a21be9
(cherry picked from commit dbeab2c6e12693fe9b06b6a680677da5325c9230)
(cherry picked from commit 40bb6f3f8f)
2016-10-28 18:16:53 +00:00
Jakub Pawlowski
81d5ecb7a6 Merge "Separate LE scanner from GATT client (1/4)"
am: 87c997ca21

Change-Id: I8fdf97a457d7566b4e0048624d47a6cfea693f13
2016-10-28 02:50:54 +00:00
Jakub Pawlowski
1b49e6eb04 Separate LE scanner from GATT client (1/4)
Right now, LE scanning functionality is combined with the GATT client.
This is the source of various bugs, like scans suddenly stoppinging when
a GATT client is killed. It also increases memory consumption, because
we associate many structures with a GATT client, which are not necessary
when just scanning.

Test: sl4a BleScanApiTest ConcurrentBleScanTest
Change-Id: I0c25bd4a58bb430eb0ee4100d5f2bbab194f9621
2016-10-27 23:09:35 +00:00
Svetoslav Ganov
f9e2ad0b3c Add Bluetooth toggle prompts - framework
If permission review is enabled toggling bluetoth on or off
results in a user prompt to collect consent. This applies
only to legacy apps, i.e. ones that don't support runtime
permissions as they target SDK 22.

Also added a configuration resource which controls whether
permission review mode is enabled. By default it is not and
an OEM can change this via an overlay. For now we also keep
the old mechanism to toggle review mode via a build property
which is still used and will be removed when clients have
transitioned.

bug:28715749

Change-Id: I94c5828ad6c8aa6b363622a26ff9da4fc2e2fac7
(cherry picked from commit ac69be543f)
2016-10-27 22:49:11 +00:00
Jakub Pawlowski
f169ecb76f Merge "Add helper method to convert Bluetooth UUID to bytes"
am: 8a0a58b218

Change-Id: I829135e559a9c3cf3c942258a16acee62c37c3ac
2016-10-25 21:47:35 +00:00
Jakub Pawlowski
f67ee83a22 Add helper method to convert Bluetooth UUID to bytes
Bug: 30622771
Test: sl4a ConcurrentBleAdvertisingTest
Change-Id: I7f646d1d357c51b82efc504a0e65d868ad363ddb
2016-10-25 12:30:24 -07:00
Jacky Cheung
046a5c3a00 Merge "Gradually increase the level of authentication on failed GATT operations."
am: 6071abdb92

Change-Id: If06babf4a23879acdfc358838cdc094d753c362b
2016-10-20 23:03:57 +00:00
Jacky Cheung
3854e22674 Gradually increase the level of authentication on failed GATT operations.
When lower layer returns insufficient authentication or insufficient
encryption on various GATT operations, gradually retry with increased
authentication level first to AUTHENTICATION_NO_MITM, then
AUTHENTICATION_MITM.

Test: ported from internal branch.

Change-Id: I6bcc4198ca493b7900ddd166a81d30cde896fa86
2016-10-20 13:59:04 -07:00
Sanket Agarwal
086be31642 Merge "Remove APIs that are not directly usable."
am: 9cff57312d

Change-Id: I1234db97ed82017ed3bca02e10818a53fdc33d3d
2016-10-17 21:28:05 +00:00
Sanket Agarwal
fb6322425a Remove APIs that are not directly usable.
The right way to expose this API is done via MediaBrowser.

Bug: b/28791287
Change-Id: I0a8a185934fd7aaa9f2b5eac7398955fa380060f
(cherry picked from commit b5fbb75aa2)
2016-10-17 12:47:10 -07:00
Jakub Pawlowski
4984d66b6a Merge "Fix connecting to profiles when bonding from local device (1/3)" am: 44c013d739 am: 6fe3900791
am: 56757a44a6

Change-Id: I3bdacc816923d012f061e5310d5e076fcaf9d387
2016-10-06 21:12:06 +00:00
Jakub Pawlowski
56757a44a6 Merge "Fix connecting to profiles when bonding from local device (1/3)" am: 44c013d739
am: 6fe3900791

Change-Id: I8e04aa89379c4a50031fade065c288fd1cc30668
2016-10-06 21:07:44 +00:00
Jakub Pawlowski
0278ab957a Fix connecting to profiles when bonding from local device (1/3)
When bond is created from Bluetooth Settings, profiles gets properly
auto connected when services are discovered. If pairing is done from any
other app, i.e. NFC app, the bond is not being recognized as initiated
from local device, and profiles are not connected.

This patch makes sure that if bonding is initiated, no matter from which
app, it will cause proper profiles to connect.

Bug: 30211618
Change-Id: I71131f33eb5b9db2f5b4a8737b191d541bf1fd3d
2016-10-04 17:29:37 +00:00
Jeremy Klein
8002b27512 Remove unused mContext from BluetoothGatt[Server]. am: adc26ec1b4
am: 140e5cce70

Change-Id: I11c459514e54bb486f3a90a1b0390453fc48b857
2016-09-28 15:44:23 +00:00
Jeremy Klein
adc26ec1b4 Remove unused mContext from BluetoothGatt[Server].
All that this member variable is doing right now is leaking a
reference to a context without any benefit.

Bug: 31752040
Bug: 31710795
Change-Id: If2241422533318b866340e8dcc9f5fbd9518349c
2016-09-28 07:09:38 +00:00
Ajay Panicker
e6558c2a54 Prevent NPE if someone creates a bad BluetoothHealthAppConfig object am: 74fa2d6846
am: 26803036be

Change-Id: I4aa3f463b688f941817e6df4a16ff1036d7be8c5
2016-09-26 18:37:58 +00:00
Ajay Panicker
74fa2d6846 Prevent NPE if someone creates a bad BluetoothHealthAppConfig object
Bug: 28271086
Change-Id: Ic8ebe3152e2b06c070316acc7e6a1f89763cd2a3
2016-09-23 22:08:26 +00:00
Marie Janssen
21688f8e34 Fix setPairingConfirmation permissions issue (2/2) am: 93326cfd9f am: 3106e3ae27 am: e3812fc048 am: 532d2b11a3 am: 6f514cc82b
am: dbb8ffc47d

Change-Id: I695df247f11b6bce15d3f771e4cc2edfd7c86f10
2016-09-21 02:20:22 +00:00