Commit Graph

1168 Commits

Author SHA1 Message Date
Jakub Pawlowski
59880123d7 ScanRecord.getServiceData NPE fix
Bug: 109662587
Change-Id: I0e9653d9cd7e4b748870bacb6fbcecae535ebb2a
2018-06-11 14:43:42 +00:00
Jack He
896e129f5f Bluetooth: Fix HFP SCO logic and documentation
AudioService:
* Call setBtScoActiveDevice and setBluetoothScoOn both in AudioService's
  broadcast receiver so that these two methods must be triggerred in
  the same sequence as ACTIVE_DEVICE_CHANGED and AUDIO_STATE_CHANGED
  intents are sent and we no longer need to handle race condition by
  synchronously checking active device in setBluetoothScoOn
* Default sco audio mode when no headset is active should be virtual
  voice call, as many HFP devices do not accept SCO audio without an
  ongoing call
* Synchronize checkScoAudioState() method with mScoClients
* Add helper functions connectBluetoothScoHelper and
  disconnectBluetoothScoHelper to call various SCO setup and tear down
  methods based on sco audio mode
* Try raw, virtual call, and voice recognition mode when disconnecting
  externally started SCO
* Add new sco state SCO_STATE_DEACTIVATING to allow back to back calling
  of startBluetoothSco and stopBluetoothSco

Audio Manager:
* Modified AudioManager logic so that removed devices callback is called
  before newly added devices

BluetoothHeadset:
* Modified BluetoothHeadset so that start and stop SCO using virtual
  voice call no longer need a parameter and will use active device by
  default
* Modified documentation around various sco mangement APIs to match
  their expected behaviors

Bug: 76114959
Test: VoIP calls sanity test cases
Change-Id: Id50db88f4ff36069b0f392c81dd9d90c24cd2206
(cherry picked from commit 89f979849a)
2018-05-07 12:57:26 -07:00
Stanley Tng
505c05839b Fix spelling errors in BluetoothGatt documentation
Correct "paramter" to "parameter". Correct "connectoin" to connection.

Bug: 79198797
Test: Compile
Change-Id: I98646eec66da2aaa6f74ae2db35ea914c6a105a1
2018-05-03 20:43:40 +00:00
Pulkit Bhuwalka
979698bc2c Get/Set IO capability of Bluetooth device
Creates the hidden BluetoothAdapter APIs which can be used to
control IO capability settings on the local Bluetooth device.

Bug: 36015413
Test: Used a test activity to control getting/setting the value and
attempting pairing.

Change-Id: Ibbfdc5ae5a1d56c6e3d003ab3bf5d095dcb583e4
(cherry picked from commit 6043b7b90a27a836241bfc05e71eb46ce04c66cf)
2018-04-28 13:45:44 -07:00
Pavlin Radoslavov
9d36e6babc Fix the implementation of BluetoothCodecStatus.equals()
Previously, the BluetoothCodecStatus.equals() implementation
was incorrect when comparing arrays of capabilities.
In the new implementation, the arrays are compared correctly,
and also the ordering of the capabilities in each array is ignored.

Also, added unit tests for class BluetoothCodecConfig and class
BluetoothCodecStatus.

Bug: 73404858
Bug: 73379307
Test: Unit tests (in frameworks/base)
  runtest --path core/tests/bluetoothtests/src/android/bluetooth/BluetoothCodecConfigTest.java
  runtest --path core/tests/bluetoothtests/src/android/bluetooth/BluetoothCodecStatusTest.java

Change-Id: If22087465397b7c4175c33f7d1909a15d957fb24
2018-04-19 14:36:18 -07:00
Treehugger Robot
f493c66f39 Merge "Clarify API doc for BluetoothGattServer::addService" 2018-04-17 00:07:38 +00:00
Stanley Tng
dac8e14018 Cleanup documentation for LE CoC in BluetoothAdapter
Test: Compile
Bug: 77631591
Change-Id: Ic3c7f13e560534a048bf5c8b274fe62190c214c7
2018-04-16 22:33:31 +00:00
Stanley Tng
4b5cf48560 Clarify API doc for BluetoothGattServer::addService
Clarify that the caller has to wait for onServiceAdded callback before
calling BluetoothGattServer::addService again.

Bug: 72717069
Test: Compile
Change-Id: I20b031c724ba64bfd71cf10e58e587f69e4a2555
2018-04-16 13:12:52 -07:00
Stanley Tng
0980006a2a Merge "Add min_ce/max_ce parameters to requestLeConnectionUpdate()" 2018-04-12 14:36:12 +00:00
Treehugger Robot
d61e87ad08 Merge "Bluetooth: Add hidden API to get current user of HID Device (1/3)" 2018-04-06 21:54:06 +00:00
Hansong Zhang
347ef4099e Bluetooth: Add hidden API to get current user of HID Device (1/3)
Bug: 69136526
Test: test with apps using HID Device profile
Change-Id: If0e49840257c877c975c2da176a08e613668cbc3
2018-04-03 12:12:53 -07:00
Stanley Tng
148dd5bf86 Add min_ce/max_ce parameters to requestLeConnectionUpdate()
Add new test parameters, min_ce and max_ce, to the SL4A tests for LE
Connection-oriented Channel (CoC) feature. This CL passes these 2
parameters to native stack.

Test: Run cmd: act.py -c $MY_SL4A_CONFIG -tc BleCoc2ConnTest
Bug: 77528723

Change-Id: I9d3d74f671772014209f8114c2d1b8ba606c54d5
2018-04-03 11:36:51 -07:00
Hansong Zhang
8d799f8340 Hearing Aid: change get/set active device (3/3)
* setActiveDevice() returns false in error case, e.g. when the device is
not connected
* add getActiveDevices() instead of isActiveDevice(), which returns a list
that must have two elements: left and right, or empty list on error

Test: manual
Bug: 69623109
Change-Id: I48f3388c56434d0c21e09bd8b794e58848cd8794
2018-03-29 17:54:24 -07:00
Hansong Zhang
dbc6d14f6e Bluetooth HIDD: Remove unplug()
Remove the hidden unplug() API because it is not used and it can cause
the remote device to be unpaired. System apps should use unbond() and
user apps should not use reflection to invoke it.

Bug: 67866553
Test: SL4A
Change-Id: I1bdc06dbb5460c9fd52230b78cbf9434a4349d24
2018-03-28 20:11:18 +00:00
Hansong Zhang
7ca303c3b8 Hearing Aid Profile: set and get activeDevice
Add setActiveDevice() for Hearing Aid Profile in SettingsLib

Bug: 69623109
Test: robolectric test and manual test
Change-Id: I70eafe030747053876e2ab8a125d5dd01c5e0eb9
Merged-In: I70eafe030747053876e2ab8a125d5dd01c5e0eb9
(cherry picked from commit d7b3591659)
2018-03-23 12:27:33 -07:00
Treehugger Robot
8085d6f247 Merge "HIDD: Address API Review concerns" 2018-03-22 21:50:57 +00:00
Ivan Podogov
f2f5dc355f HIDD: Address API Review concerns
* Replace bare field usage with getter methods;
 * Remove Builder;
 * Move BluetoothHidDeviceCallback to inner class;
 * Remove toArray() and equals();
 * Throw IllegalArgumentException where applicable;
 * Add an Executor parameter before Callback;

Bug: 72168436, 72168126
Test: make update-api, make, make sl4a.Common
Change-Id: I13095458bf3ded7a376e8d20fd13df12ef426693
2018-03-21 09:44:57 -07:00
Ajay Panicker
38c3073ba2 Add the AVRCP Target Service (2/2)
Add the AVRCP Target constant to Bluetooth Profile. Also remove redundant
public static final modifier on the constants.

Bug: 68854188
Test: Compiles and local test with service enabled
Change-Id: If2ec607fc704c225f8903d438fe970dfafac25f1
2018-03-16 18:22:00 +00:00
Miao-chen Chou
9d3389d17e Bluetooth: preserve one advertisement slot for GMS core
This brings back the check on the multiple advertisement support before
granting any Bluetooth LE advertiser. In other words, one slot is preserved
for GMS core.

Bug: 74819586
Test: Run an BLE application and verify the number of advertisements
Change-Id: Iac3b47c76c6f699018982a69e9b04a9d8c631bfb
2018-03-14 16:35:11 -07:00
Jack He
ee81f99150 Bluetooth: Use enums for adapter connection states
Bug: 69478930
Test: make, no user visible change
Change-Id: I999d0c445fe3b24aca72961c40c3428901542bc1
2018-03-05 11:23:31 -08:00
Ajay Panicker
2a216f3999 Bluetooth: Remove adjustAvrcpAbsoluteVolume
The AudioManager now handles all calculations for volume stepping now
and no longer uses adjustAvrcpAbsoluteVolume.

Bug: 68812037
Test: Compile
Change-Id: I9cbf7989e49738c7a43fe3142aced5803111271e
2018-03-01 19:04:55 +00:00
Jakub Pawlowski
5027679041 Use assigned UUID for Hearing Aid Service
Test: manual
Bug: 64038649
Change-Id: Iab748db944df3bba8927973d0a55d95514b9f8ed
2018-02-26 18:12:19 +00:00
Jakub Pawlowski
ea580fa1d1 Hearing Aid profile
This is implementation of Hearing Aid Profile that will in future
be connected to Bluetooth Manager - see TODOs in BluetoothHearingAid.java

Bug: 69623109
Test: compilation. Manual test with HA.
Change-Id: I79643ea1e14e9df7f5771169359c964a60c56618
2018-02-14 14:24:44 -08:00
Stanley Tng
918c5241c0 Add function to change LE Tx Data Length
As part of new SL4A tests for LE CoC to measure data throughput, this
commit adds a function to set the LE Tx Data Length parameter to its
maximum.

Test: Ran the new ACTS Tests for LE CoC (BleCocTest and BleCoc2ConnTest)
Bug: 70683224
Change-Id: Iea93f6cb9f4f7cc484f121afa158d7dae18d1ef1
2018-02-04 15:55:39 -08:00
Stanley Tng
6da1ddaa53 Add function to update LE connection parameters
As part of new SL4A tests for LE CoC to measure data throughput
performance, this commit will add a function to enable the CoC Facade
to modify the LE Connection Parameters especially the Connection
Intervals.

Test: Ran the new ACTS Tests for LE CoC
Bug: 70683224
Change-Id: Ie071b09a44d68fe063198a39eb788c434b092442
2018-02-01 15:27:14 -08:00
Pavlin Radoslavov
080a0e781c Add support for Multi-A2DP state machines per device
* Update usage of A2dpService API calls that take BluetoothDevice
  as an additional argument
* Update the description for BluetoothA2dp.connect()

Exempt-From-Owner-Approval: De-facto owner of the relevant changes is
the Bluetooth team.
Bug: 69269748
Test: Manual
Change-Id: I190ed48ef65bbc8b88b45f84ebd6ab3d21cf0b4e
Merged-In: I190ed48ef65bbc8b88b45f84ebd6ab3d21cf0b4e
(cherry picked from commit 502af2192c)
2018-01-26 13:08:00 -08:00
Treehugger Robot
e1992384e0 Merge "Added APIs for Connection-oriented channels" 2018-01-18 16:42:33 +00:00
Treehugger Robot
877cbe1dc2 Merge "Added internal API getMaxConnectedAudioDevices()" 2018-01-18 00:46:57 +00:00
Pavlin Radoslavov
a513792e9e Added internal API getMaxConnectedAudioDevices()
The API can be used to obtain the maximum number of connected
devices for A2DP or HFP.

Test: Manual
Bug: 64767509
Change-Id: I80b8a1c85e33ae0b23fdc4812f8991a4202d9abc
2018-01-17 02:09:53 -08:00
Stanley Tng
e48468d8be Added APIs for Connection-oriented channels
Experimental and hidden APIs are defined for the Connection-oriented Channel
(CoC) features. The APIs using PSM are implemented.

Test: Can compile
Bug: 70683224
Change-Id: Icdb5fa190b0e21881a60437fa48cd575371ee1e4
2018-01-12 07:26:14 -08:00
Joseph Pirozzo
843d380cf1 Bluetooth in band ring
Add a flag to the BluetoothHeadsetClientCall indicating the current
status of in band ring on the connected phone.

Bug: 65673832
Test: runtest bluetooth -c
com.android.bluetooth.hfpclient.HeadsetClientStateMachineTest

Change-Id: I7e839f2790b1a27d336528e93bc8a4c8d8ff3036
(cherry picked from commit f780364a9a1f6171860cbdf4e1b41a01ee7d88c6)
2018-01-11 14:09:25 -08:00
Treehugger Robot
ff9bc3a88c Merge "Make Bluetooth constants used by gmscore a system api" 2018-01-11 20:22:05 +00:00
Selim Gurun
17a26c715f Make Bluetooth constants used by gmscore a system api
These constants are used by GMSCore car module via reflection. Make
them system API.

Bug: 67052734
Test: Manual - and using make update-api
Change-Id: I0709c0e0eb9fcb9fb29d575e9b74927a70b2a924
2018-01-09 16:04:12 -08:00
Jack He
bc9976e749 HFP: Add isInbandRingingEnabled() API (1/4)
* Use BluetoothHeadset.isInbandRingingEnabled() API to check whether
  in-band ringing is currently enabled in the system when deciding on
  audio routes for ringtone
* Add this as a hidden internal API for system components

Bug: 71646213
Test: make, toggle in-band ringing from Development Settings and observe
      whether Telecom service tries to open SCO when there is an
      incoming call

Change-Id: I1ef0dd2b54ace7649ddd1f043f0ef5847743a5c4
2018-01-09 15:17:34 -08:00
Myles Watson
fa792b97a5 BluetoothProfile: Add Object Push Profile (OPP)
Test: toggle Bluetooth
Change-Id: I5aec940ba3d6c6364c2de667426d98d0b3cea0c6
2018-01-09 00:13:03 +00:00
Jack He
05f4bc4074 HFP: Add APIs for set and get active device (1/3)
1. Call BluetoothHeadset.setActiveDevice(BluetoothDevice device) to set
   a connected HFP/HSP device as active.
2. Listen for BluetoothHeadset.ACTION_ACTIVE_DEVICE_CHANGED intent
   that will contain the latest active device (in EXTRA_DEVICE field).
   If the active device could not be changed, the EXTRA_DEVICE
   field could be null.
3. If setActiveDevice() is NOT in-progress, BluetoothA2dp.getActiveDevice()
   can be used. If setActiveDevice() is in-progress, the result is undefined.
4. BluetoothHeadset.setActiveDevice() could be called by some other parts of
   the system, so interested parties should always listen for
   BluetoothHeadset.ACTION_ACTIVE_DEVICE_CHANGED intents and prepared
   for active device updates.

Bug: 68951996
Test: manual
Change-Id: I22ca639a04fed7bf17df59c405ddeda90dafb8ff
2018-01-05 14:51:40 -08:00
Selim Gurun
4029fa6039 Add SystemApis annotations
There are some number of places where bluetooth APIs are used via
reflection from GMSCore. Add proper annotations.

Bug: 67052734
Test: Manual - and using make update-api
Change-Id: Ib6e3aa1ff5b6f9cdc78367f9be13ed00542d6f65
(cherry picked from commit 64bd35ef2c)
2018-01-05 14:50:30 -08:00
Pavlin Radoslavov
64a9435cc7 Added internal API to get/set the A2DP Active Device
1. Call BluetoothA2dp.setActiveDevice(BluetoothDevice device) to set
   a connected A2DP device as active.
   The value of "device" could be null to clear the active device
   and stop streaming audio to a Bluetooth device.
2. Listen for BluetoothA2dp.ACTION_ACTIVE_DEVICE_CHANGED intent
   that will contain the latest active device (in EXTRA_DEVICE field).
   If the active device could not be changed, the EXTRA_DEVICE
   field could be null.
3. If setActiveDevice() is NOT in-progress, BluetoothA2dp.getActiveDevice()
   can be used. If setActiveDevice() is in-progress, the result is undefined.
4. BluetoothA2dp.setActiveDevice() could be called by some other parts of
   the system, so interested parties should always listen for
   BluetoothA2dp.ACTION_ACTIVE_DEVICE_CHANGED intents and prepared
   for active device updates.

Bug: 71555243
Test: Manual
Change-Id: I661b6882e8e6b437db50210aec1dd12a10199969
2018-01-05 21:44:59 +00:00
Hansong Zhang
b06bb2186a BluetoothHidDevice: rename onIntrData to onInterruptData (1/5)
Bug: 63384609
Test: make
Merged-In: I3b55f7383d2a84162d681ebf3740ddc9e8a55bbb
Change-Id: I3b55f7383d2a84162d681ebf3740ddc9e8a55bbb
(cherry picked from commit 42324278bf)
2017-12-20 11:10:53 -08:00
Hansong Zhang
88f3891d1e Publish Bluetooth HID Device Profile Service API
Enable the BluetoothHidDevice API in framework.

Bug: 63384609
Test: SL4A HID test; test with apps using BluetoothHidDevice
Merged-In: I52ca4674f11179f865bdff22e0289dfe893c40f5
Change-Id: I52ca4674f11179f865bdff22e0289dfe893c40f5
(cherry picked from commit 7bb587d72b)
2017-12-15 16:12:00 -08:00
Treehugger Robot
f7a69aeeab Merge "Bluetooth: Add convenience method to convert connection state to string" 2017-12-12 22:41:13 +00:00
Hansong Zhang
fef6d81156 Make BluetoothPbap implement BluetoothProfile (1/3)
* BluetoothPbap will implement BluetoothProfile to be consistent with
other profiles
* Changed the method names to match the BluetoothProfile method
signatures
* Removed doesClassMatchSink() as it is never used
* Disable default DEBUG logs

Test: test with carkits
Bug: 69417672
Change-Id: I0766188f77468808d7505780c781f5fd8608af60
2017-12-11 13:36:45 -08:00
Jack He
5252b97d6c Bluetooth: Add convenience method to convert connection state to string
* Add method to convert the following state values to string
  - BluetoothHeadset.STATE_DISCONNECTED
  - BluetoothHeadset.STATE_CONNECTING
  - BluetoothHeadset.STATE_CONNECTED
  - BluetoothHeadset.STATE_DISCONNECTING

Test: make
Change-Id: Iaa5b6e35d3214ded8edbe29d626e0869651417d1
2017-12-11 13:18:13 -08:00
Treehugger Robot
ea7363402c Merge "BT: Remove dead code in BluetoothHeadset" 2017-12-08 01:14:59 +00:00
Treehugger Robot
0d3990b235 Merge "Bluetooth HID Device: format code, fix docstring, hide unplug()" 2017-12-07 21:37:45 +00:00
Jack He
887e2a1e14 BT: Remove dead code in BluetoothHeadset
The following hidden API methods are not implemented by the stack and
should be removed:
 - getBatteryUsageHint()
 - acceptIncomingConnect()
 - rejectIncomingConnect()

The following hidden API methods are no longer needed due to lack of
usage and should be removed:
 - enableWBS()
 - disableWBS()
 - bindResponse()

Bug: 70336991
Test: make
Change-Id: I75bd6735573e4cbc61b5bef8722b8badac2e9170
2017-12-07 12:06:21 -08:00
Hansong Zhang
53f5412beb Bluetooth HID Device: format code, fix docstring, hide unplug()
* Reformat code with google-java-format
* Add the note that When an application is registered, the HID Host service
will be disabled until it is unregistered
* Fix the links in docstring
* Add @hide to unplug(); this is not a public API

Bug: 63384609
Test: make
Change-Id: I5dfcaab58b02c19e5745461c16602064a0ad8b83
2017-12-06 16:34:15 -08:00
Xin Li
5364be50cd DO NOT MERGE: Merge Oreo MR1 into master
Exempt-From-Owner-Approval: Changes already landed internally
Change-Id: I727a014df2fb05a4b13cb67b1fcb760a8b387523
2017-12-06 14:24:49 -08:00
Treehugger Robot
8ab47567b2 Merge "Bluetooth HID Device: Remove BluetoothHidDeviceAppConfiguration (2/4)" 2017-12-06 19:34:22 +00:00
Myles Watson
125b5456f1 Auto-format BluetoothAdapter.java
Test: build
Change-Id: I7bfc729373a24cceee05e443195640ff7f6d43b9
2017-12-06 16:42:23 +00:00