Commit Graph

1077 Commits

Author SHA1 Message Date
Jack He
5dfce858ea Merge "PBAP: Use ACTION_CONNECTION_STATE_CHANGED intent" am: cfe51aabd2
am: 8057ba832e

Change-Id: I946cce466bb5e048ad7b19cd97caa466dab27a52
2017-10-04 17:42:26 +00:00
Jack He
8057ba832e Merge "PBAP: Use ACTION_CONNECTION_STATE_CHANGED intent"
am: cfe51aabd2

Change-Id: I6e2337a0b0f4722b82a91c53c340618b9277f3f6
2017-10-04 17:22:28 +00:00
Jack He
37ab815c96 PBAP: Use ACTION_CONNECTION_STATE_CHANGED intent
* Use ACTION_CONNECTION_STATE_CHANGED to broadcast connection state
  change to comply with BluetoothProfile interface requirement
* Use BluetoothProfile.STATE_* variables to represent connection
  states for PBAP profile

Bug: 63873163
Test: Connect to car kits
Change-Id: I7dfcfc1b3a3e4868ea5e313f62ad5e504d58b9c2
2017-10-04 16:22:57 +00:00
Hansong Zhang
a51244c781 DO NOT MERGE ANYWHERE: Revert "Merge "Bluetooth HID Device: Fix a typo" am: d30e47ecfc am: 849805b804"
This reverts commit 45f17f4533.

Merged-In: I06ffc536f5912d53319b4d325f77991d65ab04f2
Change-Id: I74271f26bbe28b02117d688a6aa0bf83f0be3780
2017-10-02 22:34:23 +00:00
Hansong Zhang
849805b804 Merge "Bluetooth HID Device: Fix a typo"
am: d30e47ecfc

Change-Id: Ibd3c731781359861d89a7f396ead2f9a7b377821
2017-09-30 04:48:28 +00:00
Hansong Zhang
ecd09fb952 Bluetooth HID Device: Fix a typo
Fixed a typo in BluetoothInputHost. "DIGITIZER_TABLED" should be
"DIGITIZER_TABLET".

Test: Not needed.
Change-Id: I06ffc536f5912d53319b4d325f77991d65ab04f2
2017-09-29 20:56:00 +00:00
Pulkit Bhuwalka
c037004fd9 Merge "Modify Bluetooth Class of Device from Android stack"
am: f4ec2ab706

Change-Id: I9a0b06f44d2fe7be343fc38ce240d82f1b309d7d
2017-09-27 20:04:32 +00:00
Treehugger Robot
f4ec2ab706 Merge "Modify Bluetooth Class of Device from Android stack" 2017-09-27 19:43:17 +00:00
Pulkit Bhuwalka
66d6123880 Modify Bluetooth Class of Device from Android stack
Bug: 36015415
Test: Modified Class of Device using sample app and verified device icon
change when discovering from a remote device.

Change-Id: Ie25f10be5560f9c090ebe489d5f3bb00cbca81ef
2017-09-20 15:51:49 -07:00
Ruina Liu
8c65620d31 Merge "Fix extracting 32-bit uuid error via calling method uuidToBytes"
am: ac421b8f44

Change-Id: I9c6b453e0ef71a70cd972a47763d042943fe3f36
2017-09-18 17:53:31 +00:00
Ruina Liu
044e0fe5c5 Fix extracting 32-bit uuid error via calling method uuidToBytes
A new defined method of uuidToBytes is used to convert
Bluetooth uuid to bytes in the case of BLE advertising.
But the most significant 16 bits of a 32-bit uuid
will be cleared after the and operations with
0X0000FFFF00000000L in the function of
getServiceIdentifierFromParcelUuid.
0XFFFFFFFF00000000L should be used as bit mask.

Change-Id: I83e22ffbecd718540e644289fee12bf9c3b66305
Test: Advertise with payload contains 32-bit uuid
2017-09-15 17:08:32 -07:00
Jakub Pawlowski
3aa179fabd Merge changes from topic "incl_svc_parsing_fix"
am: fee4546fd6

Change-Id: If7ee44287dbec54e49df9fc350b2ebdfcdaeb431
2017-09-14 23:36:00 +00:00
Jakub Pawlowski
8dde5e1ce0 Fix included service parsing (3/3)
Bug: 65637368
Test: sl4a GattIncludedServiceTest
Change-Id: Idb967df9d5064b0532db7f5c250f677d1dbbc54c
2017-09-14 19:37:40 +00:00
Jakub Pawlowski
8ab1ed1789 Merge "Bluetooth: fix parameter name in onConnectionUpdated"
am: 1f53eb76e4

Change-Id: I45642dfbb8ed8bb90a1306d066844d18aa1962b3
2017-09-14 19:35:24 +00:00
Jakub Pawlowski
cf733cd020 Bluetooth: fix typo in comment
Test: none
Change-Id: I48c674049df88285268145d4140870eb4ab79a62
2017-09-14 19:24:28 +00:00
Jakub Pawlowski
14a381bc3e Bluetooth: fix parameter name in onConnectionUpdated
Test: compilation
Change-Id: I625e4ca63477b795310ebb42ca5e9a0549523cc5
2017-09-14 19:23:59 +00:00
Jakub Pawlowski
c416035448 Merge "Bluetooth: thread-safe callback invocation"
am: f8c7572b8f

Change-Id: Iac79926b7131949367b1dad2565b6d0b405ef832
2017-09-13 22:12:16 +00:00
Jakub Pawlowski
9054e03cf4 Merge "Bluetooth: fix GATT race conditions when using Handler"
am: 06b29a87d7

Change-Id: I2760ebf88cb96e29a754a65d1ce3f5ae879d7ccc
2017-09-13 22:08:00 +00:00
Jakub Pawlowski
3eb569fc72 Bluetooth: thread-safe callback invocation
Bug: 65596701
Test: manual
Change-Id: I92a436328a3070ea842e8e652891e485406c2ed7
2017-09-13 17:31:43 +00:00
Jakub Pawlowski
eb6b3da4fc Bluetooth: fix GATT race conditions when using Handler
Bug: 65596701
Test: manual
Change-Id: Id703cea0543626bdd5a583da95615b650bbcc331
2017-09-13 17:31:24 +00:00
Vinay Kalia
be7ccdf6e9 Merge "Update ScanSettings documentation for scan modes"
am: 8157ab2a0e

Change-Id: I15a77489072925f6e99e9a0a658910616164aef3
2017-09-08 19:58:33 +00:00
Vinay Kalia
8157ab2a0e Merge "Update ScanSettings documentation for scan modes" 2017-09-08 19:50:36 +00:00
Jack He
a672ffa42f Merge "Bluetooth: Thread-safe binder invocation"
am: 94f1fd0da2

Change-Id: I8f9c76996f02c70b8d2ea21d4eb567eaa9da246a
2017-09-06 00:30:09 +00:00
Jack He
16eeac356c 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
2017-09-06 00:09:47 +00:00
Vinay Kalia
04d061e891 Merge "Update documentation for startScan"
am: 7d2219d170

Change-Id: I5ea7a5a9b0a69168a1715986e4850276299af78a
2017-09-06 00:08:24 +00:00
Vinay Kalia
958154b5e2 Update ScanSettings documentation for scan modes
SCAN_MODE_LOW_POWER is enforced for applications running
in background.

Test: BLE scanning applications.
BUG: 38198694
BUG: 62491228
Change-Id: Ib2b6c297298e05f1b088411e94cfe4789dde0821
2017-09-05 13:51:58 -07:00
Vinay Kalia
875d27e45e Update documentation for startScan
With change c4a1e1, unfiltered BLE scans are stopped on screen off
and resumed when screen is turned back on. This is done to save power.
This change updates the documentation accordingly.

BUG: 62264269
Test: Documentation update.
Change-Id: I2d8e9f9f122f978c4d4f59d4139cb51cd4e4a123
2017-09-05 11:52:35 -07:00
Jakub Pawlowski
d019cce887 Merge "Fix GATT client leakage when scan is throttled (1/2)"
am: 3cc1ad87f0

Change-Id: Ieda555f6f8bda35201327c6c6e0c97621b88671e
2017-08-29 08:09:15 +00:00
Jakub Pawlowski
ee02e1ce77 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
2017-08-28 18:09:03 +00:00
Jack He
8ae5462199 Merge changes from topic "bt-fix-checkstyle-errors"
am: 838ab94a0f

Change-Id: I4e619cb17582a6cc954814654820cd945f66e1cc
2017-08-24 21:43:08 +00:00
Jack He
2992cd084c Fix checkstyle errors (2/2)
* Manual style corrections with IDE assistance
* Variable name refactors are done through IDE
* Corrected general style errors such as:
  - "final private var" -> "private final var"
  - "&&", "+", "||" should not be at the end of line
  - Non-static private variable should be like "mVar"
  - Private static variable should be like "sVar"
  - Code file should always end with newline
  - Inherited methods should be annotated with @Override
    and no @hide tags
  - Public methods should always have a JavaDoc entry
  - "int[] array" is preferred over "int array[]"
  - private methods should be accessed without "this."
    when there is no name collisions.
  - "boolean ? true : false" -> boolean
  - "boolean ? false : true" -> !boolean
  - "boolean == true" OR "boolean != false" -> boolean
  - "boolean != true" OR "boolean == false" -> !boolean

Bug: 63596319
Test: make checkbuild, no functional changes
Change-Id: Iabdc2be912a32dd63a53213d175cf1bfef268ccd
2017-08-24 19:09:58 +00:00
Jack He
a355e5efaf Fix checkstyle errors (1/2)
* Automatic style corrections through IDE

Bug: 63596319
Test: make checkbuild, no manual changes, no functional changes
Change-Id: I2397d55abc34c9b7a9b748bec6137778df3421a7
2017-08-24 19:09:48 +00:00
Jakub Pawlowski
915c02c96a Merge "Bluetooth: Don't throw exception when stopAdvertisingSet fails" am: b7cbb2fe49
am: 5d0f5f46ef

Change-Id: I063ce05f79b4feb518dc34c9a4651e96f65b324e
2017-08-17 23:16:59 +00:00
Jakub Pawlowski
5d0f5f46ef Merge "Bluetooth: Don't throw exception when stopAdvertisingSet fails"
am: b7cbb2fe49

Change-Id: I5ccf67621134fe1ba9204e2a8f3502ffacef0315
2017-08-17 23:06:14 +00:00
Jakub Pawlowski
94cd5b22c1 Merge "Bluetooth: Fix startAdvertisingSet error handling" am: ed12213b59
am: e9fe99571b

Change-Id: Ideb592bf11e483494b892f7b04bb156f323746ac
2017-08-17 22:58:02 +00:00
Treehugger Robot
b7cbb2fe49 Merge "Bluetooth: Don't throw exception when stopAdvertisingSet fails" 2017-08-17 22:51:23 +00:00
Jakub Pawlowski
e9fe99571b Merge "Bluetooth: Fix startAdvertisingSet error handling"
am: ed12213b59

Change-Id: I093e849e910428c521e73072121dfdfdceb28e0d
2017-08-17 22:47:38 +00:00
Jakub Pawlowski
f73863dc29 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
2017-08-17 07:39:02 -07:00
Jakub Pawlowski
f7bd6b26c7 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
2017-08-17 07:36:37 -07:00
Vinay Kalia
1199972de1 Merge "Fix BLE scan leaks" into oc-dev
am: 6e749c392b

Change-Id: Id43b33865e287ec19a2ae4c56815d12bb402ab09
2017-08-09 21:10:53 +00:00
Jakub Pawlowski
3ee6eed62f Merge "Bluetooth: AdvertiseData parceling simplification"
am: c7da241b3e

Change-Id: Iaf58ace037810d11fcb29c2696c79664d601e87c
2017-08-09 19:15:08 +00:00
Jakub Pawlowski
e8c3b91dc3 Bluetooth: AdvertiseData parceling simplification
Use writeTypedArray instead of writeList - this will not serialize
string with type name, which is unnecessary
Use createByteArray instead of readByteArra - it takes care of null and
empty array handling

Test: sl4a FilteringTest, BleAdvertiseApiTest
Change-Id: I6a22674a0bf9933e39691de7f2b2b52a060ae368
2017-08-09 17:26:14 +00:00
Vinay Kalia
c2fd144218 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
(cherry picked from commit 9722971cb4)
2017-08-09 09:03:52 -07:00
Jakub Pawlowski
3b38eaa3c2 resolve merge conflicts of 15658662fd to stage-aosp-master
Test: this fixes merge conflict that I skipped
Change-Id: I2e993d1f021b1bb671b07440cdc611853d6c3f08
2017-08-09 13:03:35 +00:00
Jakub Pawlowski
6732625aa0 Bluetooth: move AIDL files related to bluetooth into system/bt (1/2)
This patch moves *.aidl files from
frameworks/base/core/java/android/bluetooth into system/bt/binder. This
is in preparation to convert the Bluetooth deamon into native
implementation piece by piece.
In order to do that, one must have C++ header files, and paths to them
with AIDL files, and */java/* folder didn't seem as proper place for
that. Additionally, keeping AIDL files out of framework/base will not
require creating dependency on this huge project, which should help
keeping the compilation fast.

Test: compilation test
Change-Id: I9a6db8832c9ec3215c648e325d67278832ef22cc
Merged-In: I9a6db8832c9ec3215c648e325d67278832ef22cc
(cherry picked from commit 06ae9c665b)
2017-08-08 12:38:37 -07:00
xutianguo
a5325e18df Make BluetoothStateChangeCallback oneway to prevent waiting on response.
Test: Connected bluetooth devices(included Headset/HID devices), and
made bluetooth enabling/disabling over 1000 times, no other side effect
observed.

Bug: 38485770

Change-Id: Ia3959d2441aece39a79ab2d662b57790a78df674
Signed-off-by: xutianguo <xutianguo@xiaomi.com>
(cherry picked from commit 95e1e21a639318bb3399c394707624393cfa2300)
2017-07-17 11:52:24 -07: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
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