Commit Graph

1049 Commits

Author SHA1 Message Date
Jakub Pawlowski
05c1578c16 Bluetooth: thread-safe callback invocation
Bug: 65596701
Test: manual
Change-Id: I92a436328a3070ea842e8e652891e485406c2ed7
Merged-In: I92a436328a3070ea842e8e652891e485406c2ed7
(cherry picked from commit 3eb569fc72)
2017-09-14 02:37:45 +00:00
Jakub Pawlowski
93703a08c7 Bluetooth: fix GATT race conditions when using Handler
Bug: 65596701
Test: manual
Change-Id: Id703cea0543626bdd5a583da95615b650bbcc331
Merged-In: Id703cea0543626bdd5a583da95615b650bbcc331
2017-09-13 22:43:09 +00:00
Amith Yamasani
172dd5c652 Javadoc update for permission requirements
Bluetooth scanning requires holding these permissions for results
to be delivered.

Bug: 65013767
Test: N/A
Change-Id: I0b5fa9efa7fc8d5cff25319fbd7719cedee6a4aa
2017-09-07 23:42:27 +00:00
Jack He
0146463d70 Bluetooth: Thread-safe binder invocation
* Binder object may become null between null check and actual invocation
  if using a instance private variable assignable by service connection
  callbacks
* The solution to this problem without locking is to assign existing
  binder variable to a local final variable before the null check
* Any further invocation to a disconnected binder object will result in
  RemoteException that is caught by the try-catch block
* Read and write to volatile variable is always atomic and hence thread-safe
* Removed unnecessary synchronization in BluetoothAdapter constructor
* Private mConnection objects should be final
* Simplfied several return statements where booleans can be returned
  directly
* Removed unnecessary catches for NPE since there won't be any

Bug: 64724692
Test: make, pair and use devices, no functional change
Change-Id: Ifc9d6337c0d451a01484b61243230725d5314f8e
(cherry picked from commit 16eeac356c)
2017-09-07 08:43:16 +00:00
Jakub Pawlowski
f507490404 Fix GATT client leakage when scan is throttled (1/2)
Currently, scan throttling happens after client is registered, but
before the scan is started. This might lead to scan client being leaked.
This patch fixed that by moving check before client registration.

Bug: 64887233
Test: manual
Change-Id: I22ae624a0c51110cb69679f796926e3b2b36d0ac
Merged-In: I22ae624a0c51110cb69679f796926e3b2b36d0ac
(cherry picked from commit ee02e1ce77)
2017-08-29 17:26:23 +00:00
TreeHugger Robot
4a5fd86da3 Merge "Bluetooth: Fix startAdvertisingSet error handling" into oc-mr1-dev 2017-08-18 00:30:13 +00:00
Jakub Pawlowski
d56a8bec5c Bluetooth: Fix startAdvertisingSet error handling
Calls to old advertising API (startAdvertising), should never throw
exceptions. Instead, it used to post failure callback. This behaviour
was accidentally modified when implementing new API. Right now, instead
of posting error callback, we throw IllegalArgumentException if we fail
to obtain BluetoothGatt object, or the call to startAdvertisingSet
fails.

This patch brings back the old behaviour to the API. It also makes new
API post callback instead of throwing exception in this error case.

Bug: 63819108
Test: manual
Change-Id: I897b99839f899ca3f3dc609918d665c8c327b777
Merged-In: I897b99839f899ca3f3dc609918d665c8c327b777
(cherry picked from commit f7bd6b26c7)
2017-08-17 22:34:40 +00:00
Jakub Pawlowski
4cf705e17e Bluetooth: Don't throw exception when stopAdvertisingSet fails
When advertising is stopped while Bluetooth is disabled, we should not
throw any exceptions, just log the failure.
This was the default behaviour before the AdvertisingSet was introduced.

Bug: 63819108
Test: manual
Change-Id: I518e071b77b127973aee6f24fa6ced4f28bc9531
Merged-In: I518e071b77b127973aee6f24fa6ced4f28bc9531
(cherry picked from commit f73863dc29)
2017-08-17 22:34:31 +00:00
Vinay Kalia
7d06d7bd79 Merge "Fix BLE scan leaks" into oc-dr1-dev
am: 604a4b7171

Change-Id: I9e3f7a0d3b871e5c5e2a740ec69eacaa2cbc41e2
2017-07-29 22:17:03 +00:00
Vinay Kalia
9722971cb4 Fix BLE scan leaks
If an app starts multiple scans with same callback then
there is a collision in mLeScanClients hash map which
results in leaking first scan. This change fixes it by
not allowing the second scan with same callback.

BUG: 62389939
BUG: 38198694

Test: Tested applications which started multiple scans with
       same callback.

Change-Id: I569069a40b6f8b4b8bb070731225e732c6b23ec8
2017-07-28 23:39:15 +00:00
Jack He
79bf7d755f GATT: Expose opportunistic client API to Java
* Allow Java based programs to create an opportunistic GATT client
* Such client does not hold a GATT connection. It automatically
  disconnects when no other GATT connections are active for the
  remote device.

Bug: 63347806
Test: make, run battery service
Change-Id: Ib9333817d7f17a1fa3ddacfa51c680890bac19ec
Merged-In: Ib9333817d7f17a1fa3ddacfa51c680890bac19ec
(cherry picked from commit 13f52c8118)
2017-07-12 00:35:54 +00:00
Jack He
f0efa2c810 Merge "GATT: Expose opportunistic client API to Java"
am: 782ba0aca8

Change-Id: If29bc145c1947f2e10472565ae753696e8057dd1
2017-07-11 20:23:53 +00:00
Jack He
13f52c8118 GATT: Expose opportunistic client API to Java
* Allow Java based programs to create an opportunistic GATT client
* Such client does not hold a GATT connection. It automatically
  disconnects when no other GATT connections are active for the
  remote device.

Bug: 63347806
Test: make, run battery service
Change-Id: Ib9333817d7f17a1fa3ddacfa51c680890bac19ec
2017-07-11 18:02:52 +00:00
Jack He
266499d9d8 Support battery level reporting via Apple VSC (1/2)
* Add related constants to BluetoothHeadset

Bug: 35874078
Test: make, test with supporting headsets
Change-Id: I9f49ea28efdf6de0e751a377d879fe13a47655d5
Merged-In: I9f49ea28efdf6de0e751a377d879fe13a47655d5
(cherry picked from commit 679d0bc8f9)
2017-06-30 10:41:18 +00:00
Jack He
fff37da08d Support battery level reporting via Plantronics XEVENT (1/2)
* Add related constants to BluetoothHeadset

Bug: 35874078
Test: make, test with supporting headsets
Change-Id: Ied089a065bf9caa0d03f681950fefa2ea990bb3e
Merged-In: Ied089a065bf9caa0d03f681950fefa2ea990bb3e
(cherry picked from commit 0fcbba25b7)
2017-06-30 08:39:44 +00:00
Jack He
dfd8618b2d HFP: Modify comments for ACTION_HF_INDICATORS_VALUE_CHANGED (1/2)
* Per HFP 1.7.1 spec page 102 of 144
  EXTRA_HF_INDICATORS_IND_ID should be int
  EXTRA_HF_INDICATORS_IND_VALUE should be int

Bug: 35874078
Test: make, PTS test, unit tests
runtest -c com.android.bluetooth.btservice.RemoteDevicesTest bluetooth
Change-Id: Idd316a82bab164b6ea1701bb261b1cc3dee196f1
Merged-In: Idd316a82bab164b6ea1701bb261b1cc3dee196f1
(cherry picked from commit 73795440a5)
2017-06-30 06:22:46 +00:00
Jack He
2b07bbafa2 Add APIs to get remote device's battery level (1/2)
* Add BluetoothDevice.getBatteryLevel() API to retreive battery level
  information of remote device
* Add BluetoothDevice.ACTION_BATTERY_LEVEL_CHANGED intent to notify user
  that remote device's battery level has changed

Bug: 35874078
Test: make, pair with devices and use them
Change-Id: I41051ee25383f5f3a1e505aef6f8c526385f58bd
Merged-In: I41051ee25383f5f3a1e505aef6f8c526385f58bd
(cherry picked from commit 1d312bfa78)
2017-06-30 04:01:36 +00:00
Jack He
9fd5d0da1e Merge "Support battery level reporting via Apple VSC (1/2)"
am: 874af710b7

Change-Id: Id65e6e11308c66893cb701af8909df9fee3a131f
2017-06-29 17:53:10 +00:00
Jack He
679d0bc8f9 Support battery level reporting via Apple VSC (1/2)
* Add related constants to BluetoothHeadset

Bug: 35874078
Test: make, test with supporting headsets
Change-Id: I9f49ea28efdf6de0e751a377d879fe13a47655d5
2017-06-29 17:43:32 +00:00
Jack He
c286110c1a Merge "Support battery level reporting via Plantronics XEVENT (1/2)"
am: c79c4240ec

Change-Id: I6aa50e541763adfa9ebe738d98d86152cf0cd1d5
2017-06-29 17:25:26 +00:00
Jack He
0fcbba25b7 Support battery level reporting via Plantronics XEVENT (1/2)
* Add related constants to BluetoothHeadset

Bug: 35874078
Test: make, test with supporting headsets
Change-Id: Ied089a065bf9caa0d03f681950fefa2ea990bb3e
2017-06-29 17:17:14 +00:00
Andre Eisenbach
df1831d2ee Merge "HFP: Modify comments for ACTION_HF_INDICATORS_VALUE_CHANGED (1/2)"
am: 5790bae2f4

Change-Id: I480ef38d5aa61aa153ee53d325e8b249c1eab222
2017-06-29 08:39:40 +00:00
Jack He
73795440a5 HFP: Modify comments for ACTION_HF_INDICATORS_VALUE_CHANGED (1/2)
* Per HFP 1.7.1 spec page 102 of 144
  EXTRA_HF_INDICATORS_IND_ID should be int
  EXTRA_HF_INDICATORS_IND_VALUE should be int

Bug: 35874078
Test: make, PTS test, unit tests
runtest -c com.android.bluetooth.btservice.RemoteDevicesTest bluetooth

Change-Id: Idd316a82bab164b6ea1701bb261b1cc3dee196f1
2017-06-29 08:30:37 +00:00
Jack He
96f98f255b Merge "Add APIs to get remote device's battery level (1/2)"
am: ceaccbfe70

Change-Id: Ic3253ef666632aaaffe8e1547dc563cd3bca9e37
2017-06-28 08:32:54 +00:00
Jack He
1d312bfa78 Add APIs to get remote device's battery level (1/2)
* Add BluetoothDevice.getBatteryLevel() API to retreive battery level
  information of remote device
* Add BluetoothDevice.ACTION_BATTERY_LEVEL_CHANGED intent to notify user
  that remote device's battery level has changed

Bug: 35874078
Test: make, pair with devices and use them
Change-Id: I41051ee25383f5f3a1e505aef6f8c526385f58bd
2017-06-27 16:53:09 -07:00
Marie Janssen
f71b0bedcf Merge "Bluetooth: minor documentation fix to de-confuse" am: 5a56873612
am: 3205ff1331

Change-Id: I0cd44ad8d22da154d0bf666b9075a3fcbc655439
2017-06-23 03:38:17 +00:00
Marie Janssen
553c8c7753 Bluetooth: minor documentation fix to de-confuse
It was somewhat unclear which is the preferred method of retrieving a
BluetoothAdapter.  Make it clear that using BluetoothManager is
preferred, and remove references to the old method in BluetoothManager
docs since it is only avaialable in API 18 or higher.

Test: recompile, check that documentation is updated
Fix: 33355430
Change-Id: Ia20b4e45dca03bc2f13c2ab477799b89c5e14f45
2017-06-22 20:49:55 +00:00
Amith Yamasani
ef863368b4 Merge "Clarify startScan API on how to get results" into oc-dev
am: 78f3a0f722

Change-Id: Ibc04014f224ecbc666c8296a2b25d939fbfc9921
2017-06-22 13:48:51 +00:00
Amith Yamasani
5d45ac6e68 Merge "Clarify startScan API on how to get results" into oc-dev
am: 78f3a0f722

Change-Id: Ib58abc3ef4eb3c525af9ec2bb6f66e794b659030
2017-06-22 01:20:36 +00:00
TreeHugger Robot
78f3a0f722 Merge "Clarify startScan API on how to get results" into oc-dev 2017-06-22 01:14:18 +00:00
Amith Yamasani
9622137f3f Clarify startScan API on how to get results
Make it clear in BluetoothLeScanner on how to get results
when starting a scan for a PendingIntent.

Bug: 38365430
Test: make offline-sdk-docs
Change-Id: I0bf88d751c89a8a478db985713357e153ac08595
2017-06-21 14:06:44 -07:00
Jakub Pawlowski
50bad313e4 Merge "Remove legacy advertiser from map after it's no longer used" into oc-dev
am: 271e0aa02a

Change-Id: I9e8645c808d1b1cbee242e8a953be93fbf71e4e1
2017-06-20 01:47:01 +00:00
Jakub Pawlowski
bfa502c6a6 Remove legacy advertiser from map after it's no longer used
Test: manual
Bug: 62597369
Change-Id: Ief1e1b054f29b59b1ed72514b138d4f209f9847a
2017-06-19 23:37:19 +00:00
Jakub Pawlowski
8dce179b79 Merge "Remove legacy advertiser from map after it's no longer used" am: 42b1578867
am: de1f0d7607

Change-Id: I89b5be7443dff10a3a52a0b6dbee76a5d34b8173
2017-06-19 19:40:38 +00:00
Jakub Pawlowski
2489b415ff Remove legacy advertiser from map after it's no longer used
Test: manual
Bug: 62597369
Change-Id: Ief1e1b054f29b59b1ed72514b138d4f209f9847a
2017-06-19 17:33:16 +00:00
Jakub Pawlowski
25278b0197 Merge "Bluetooth: fix connectGatt overload invocations" into oc-dev
am: 556b10a4e6

Change-Id: I9477ac6e3990a4e2db4a8254f11702b1557591f3
2017-06-09 00:03:31 +00:00
Jakub Pawlowski
3b852973e3 Merge "Bluetooth: fix connectGatt overload invocations" am: 404e9f209f
am: c0fed83b84

Change-Id: I871bc30dcd7aeb5c4a6f6c15d84b43dee84994f2
2017-06-08 21:20:27 +00:00
Jakub Pawlowski
dbf5a0a20b Bluetooth: fix connectGatt overload invocations
Merged-In: I726252e85e78bff2c9585332d2748a0d92a9f6d3
Test: sl4a GattOverBrEdrTest
Bug: 62387078
Change-Id: I5bfb87683e25f8862587e8000eb4c9bb6ff14f99
2017-06-08 21:01:24 +00:00
Jakub Pawlowski
ba1e26578e Bluetooth: fix connectGatt overload invocations
Test: sl4a GattOverBrEdrTest
Bug: 62387078
Change-Id: I5bfb87683e25f8862587e8000eb4c9bb6ff14f99
2017-06-08 17:54:29 +00:00
Jeff Sharkey
7a2e4a8486 Merge "Annotate @SystemApi with required permissions." into oc-dev
am: c1406978a4

Change-Id: I305967cad945a807c3f8234efabaad0ef8b591d1
2017-06-05 22:28:21 +00:00
Jeff Sharkey
d86b8fea43 Annotate @SystemApi with required permissions.
Most @SystemApi methods should be protected with system (or higher)
permissions, so annotate common methods with @RequiresPermission to
make automatic verification easier.

Verification is really only relevant when calling into system
services (where permissions checking can happen on the other side of
a Binder call), so annotate managers with the new @SystemService
annotation, which is now automatically documented.

This is purely a docs change; no logic changes are being made.

Test: make -j32 update-api && make -j32 offline-sdk-docs
Bug: 62263906
Change-Id: I2554227202d84465676aa4ab0dd336b5c45fc651
2017-06-05 13:27:11 -06:00
Jack He
099328f38b Merge "HFP: Allow SCO audio to be forcibly connected" am: 93d7c84726 am: 10cb6f3b4c
am: 0998ec224c

Change-Id: I35533ed7e2b8f8deff741cb3296156e9ccf5e076
2017-06-01 07:15:13 +00:00
Jack He
1dd1e03f1f HFP: Allow SCO audio to be forcibly connected
* Normally, Android only allows SCO audio to be connected in several
  allowed cases (e.g. in call, in ringing, in virtual call state, etc)
* Sometimes, it is necessary to force a SCO audio connection (e.g.
  during PTS test)
* This change adds setForceScoAudio(boolean) hidden, system only method
  to allow such behaviour

Bug: 38040125
Test: PTS HFP tests
Change-Id: I28f295c98da5bebb837c2a5423c7acde81af73f7
2017-05-31 15:41:30 -07:00
Jakub Pawlowski
50f8f3db27 Add 32 and 128 bit Service Data parsing.
Bug: 62078132
Change-Id: I79ff75cd5ccbe346dca79693b074ff3cd09112dd
(cherry picked from commit 45033a7e57)
2017-05-26 16:24:40 -07:00
Jakub Pawlowski
bf79e36f57 Merge "Add 32 and 128 bit Service Data parsing." am: 725e212de3 am: 2acc8e28dd
am: 138f75bbc8

Change-Id: I8c821ed86a85892af7a77c4a8080a1e9fde9fdfa
2017-05-26 23:14:27 +00:00
Jakub Pawlowski
45033a7e57 Add 32 and 128 bit Service Data parsing.
Bug: 62078132
Change-Id: I79ff75cd5ccbe346dca79693b074ff3cd09112dd
2017-05-26 21:11:24 +00:00
Jakub Pawlowski
9fd4462c09 Merge "Discover primary service by UUID for PTS tests (4/4)" am: abb732fc40 am: 7e80b882b7
am: 23105d57d5

Change-Id: I764d8b206940a39906c6793fef24e6d5b19a8589
2017-05-16 20:55:37 +00:00
Jakub Pawlowski
09ad0b27bb Discover primary service by UUID for PTS tests (4/4)
Bug: 38123054
Test: manual
Change-Id: I89e088e60f4325f1ece59d22efda0c907a3b716a
(cherry picked from commit fe2bf16a2b)
2017-05-16 13:50:11 -07:00
Jakub Pawlowski
fe2bf16a2b Discover primary service by UUID for PTS tests (4/4)
Bug: 38123054
Test: manual
Change-Id: I89e088e60f4325f1ece59d22efda0c907a3b716a
2017-05-16 11:37:00 -07:00
Andre Eisenbach
1360c6227e Merge "Bluetooth: HID: Add support for Set Idle and Get Idle Commands (3/4)" am: 51876abe82 am: 9413fd9e1f
am: 01d1188a8b

Change-Id: Ie92cbd1f5795d7b9f55d0e51503e7d08b61e8732
2017-05-11 01:33:18 +00:00