Commit Graph

1048 Commits

Author SHA1 Message Date
Vinay Kalia
8157ab2a0e Merge "Update ScanSettings documentation for scan modes" 2017-09-08 19:50:36 +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
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
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
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
5d0f5f46ef Merge "Bluetooth: Don't throw exception when stopAdvertisingSet fails"
am: b7cbb2fe49

Change-Id: I5ccf67621134fe1ba9204e2a8f3502ffacef0315
2017-08-17 23:06:14 +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
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
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
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
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
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
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
Hemant Gupta
cef9ce368c Bluetooth: HID: Add support for Set Idle and Get Idle Commands (3/4)
Provides an interface for application to send Set Idle
and Get Idle commands to remote HID Device. Support for these
two commands was missing from existing code, so existing code
design is reused to add support for these two commands.

Without this support following mandatory PTS test cases for HID 1.0
cannot be passed, TC_HOS_HID_BV_05/06.

Test: Executed PTS tests TC_HOS_HID_BV_05/06 and confirmed if they can
pass

Bug: 34344715
Change-Id: I548362cc328498920b2dae740f1a76b2cc2d6a67
2017-05-10 16:23:17 +00:00