Commit Graph

1894 Commits

Author SHA1 Message Date
Rahul Sabnis
5a623c1a6d Add BluetoothLeAudio to BluetoothAdapter#getProfileProxy and
BluetoothAdapter#closeProfileProxy

Tag: #feature
Bug: 15083918
Test: Manual
Change-Id: Ia46dc4e50d42dbd574588b531045cb680aa09d94
2021-06-23 16:10:07 -07:00
TreeHugger Robot
24b23c4587 Merge "Unhide BluetoothProfile.LE_AUDIO and getGroupId for the App usage." into sc-dev-plus-aosp am: 893020512f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14572662

Change-Id: I63e5a559dac4bbec7146a253b7e13e2a21c53098
2021-06-21 15:47:01 +00:00
TreeHugger Robot
d6821cf042 Merge "Adds rahulsabnis@ as an owner for all Bluetooth files in frameworks/base" into sc-dev am: b389f98256 am: c961456aeb
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15028266

Change-Id: Ib6f6e05d8f4f84e124949463e11f79b1953c647d
2021-06-21 12:02:16 +00:00
TreeHugger Robot
893020512f Merge "Unhide BluetoothProfile.LE_AUDIO and getGroupId for the App usage." into sc-dev-plus-aosp 2021-06-18 22:20:06 +00:00
Treehugger Robot
efc94c3852 Merge "Adds rahulsabnis@ as an owner for all Bluetooth files in frameworks/base" am: 87a2d5bf91 am: 04d39400db
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1741394

Change-Id: I0cae32f20979a121f64011d5e2f4fab676c79355
2021-06-18 19:59:53 +00:00
Rahul Sabnis
4571f15931 Adds rahulsabnis@ as an owner for all Bluetooth files in frameworks/base
Tag: #feature
Bug: 191481598
Test: Manual
Merged-In: I6c8606c8e4802b74e80555e8ebf78932863d3f5b
Change-Id: I6c8606c8e4802b74e80555e8ebf78932863d3f5b
2021-06-18 12:27:11 -07:00
Treehugger Robot
87a2d5bf91 Merge "Adds rahulsabnis@ as an owner for all Bluetooth files in frameworks/base" 2021-06-18 19:21:16 +00:00
Rahul Sabnis
165faf4460 Adds rahulsabnis@ as an owner for all Bluetooth files in frameworks/base
Tag: #feature
Bug: 191481598
Test: Manual
Change-Id: I6c8606c8e4802b74e80555e8ebf78932863d3f5b
2021-06-18 10:31:26 -07:00
Jakub Pawlowski
37c700dbbe Bluetooth: fix comments on Volume Control Profile review
Bug: 150670922
Test: compilation
Merged-In: I72b36b77aa97aa9501d13ecdfe0b9b7f49bcce2c
Change-Id: I72b36b77aa97aa9501d13ecdfe0b9b7f49bcce2c
2021-06-18 17:26:43 +00:00
Łukasz Rymanowski
a5a3d32839 DO NOT MERGE Bluetooth: add Volume Control Profile boilerpalate
This is very simple API to allow Android to connect VCP profile.

Bug: 150670922
Test: compilation
Sponsor: jpawlowski@
CTS-Coverage-Bug: 190833351
Merged-In: Ib20d967fcf6797077abf83b40b0eda526e5ab89d
Change-Id: Ib20d967fcf6797077abf83b40b0eda526e5ab89d
2021-06-18 14:33:41 +02:00
Jakub Pawlowski
d8ad48746d DO NOT MERGE Revert "Bluetooth: add Volume Control Profile boilerpalate"
This reverts commit 690b89ec89.

Merged-In: Ib20d967fcf6797077abf83b40b0eda526e5ab89d
Change-Id: I164fcdeddab6579cf10174c1123984e856fa6f20
2021-06-18 14:33:03 +02:00
Alice Kuo
7579fa3425 Unhide BluetoothProfile.LE_AUDIO and getGroupId for the App usage.
This change contains two item,
1. public BluetoothProfile.LE_AUDIO that App can use
BluetoothProfile.ServiceLister with LE Audio profile, such as HFP, A2DP
and hearing aid profile.
2. public getGroupId API that App can use this api to identify which
devices are in the same group

Bug: 150670922
Test: Manual test
Ignore-AOSP-First: prevent merge conflict
Change-Id: I32865720a8195b7c5ae29411cd1f3de95e7fc9b5
2021-06-18 09:26:46 +00:00
Łukasz Rymanowski
c6d6653d96 DO NOT MERGE Bluetooth: add Volume Control Profile boilerpalate
This is very simple API to allow Android to connect VCP profile.

Bug: 150670922
Test: compilation
Sponsor: jpawlowski@
CTS-Coverage-Bug: 190833351
Merged-In: Ib20d967fcf6797077abf83b40b0eda526e5ab89d
Change-Id: Ib20d967fcf6797077abf83b40b0eda526e5ab89d
2021-06-18 09:23:35 +00:00
Jakub Pawlowski
55ece29ae2 DO NOT MERGE Revert "Bluetooth: add Volume Control Profile boilerpalate"
This reverts commit 690b89ec89.

Merged-In: Ib20d967fcf6797077abf83b40b0eda526e5ab89d
Change-Id: I164fcdeddab6579cf10174c1123984e856fa6f20
2021-06-18 09:23:14 +00:00
Treehugger Robot
2248a568e4 Merge "Fix NPE in logging" am: ceba9c2521 am: 01ca11578f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1736917

Change-Id: I34e9ac464bf0f2d35f86c7fbf716c0a006d6ecb4
2021-06-18 02:18:47 +00:00
Treehugger Robot
ceba9c2521 Merge "Fix NPE in logging" 2021-06-17 23:55:09 +00:00
Jakub Pawlowski
ef956abe7a Merge "Bluetooth: add Volume Control Profile boilerpalate" am: 0778be8099 am: 46a57e4af2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1736553

Change-Id: Ic5e77ef574940ec720f82e3d13026e6d74863bc2
2021-06-17 22:10:24 +00:00
Jakub Pawlowski
0778be8099 Merge "Bluetooth: add Volume Control Profile boilerpalate" 2021-06-17 21:34:30 +00:00
Martin Brabham
22f1dcf528 Fix NPE in logging
Bug: 191268917
Test: Manual test app, log OobData
Tag: #stability
Change-Id: I975722642298cb580081de9a324302d7a3282d3c
2021-06-17 20:36:06 +00:00
Rahul Sabnis
739f69bc0c Update nullability checks to use Objects#requireNonNull
instead of deprecated method in Preconditions class

Tag: #feature
Bug: 190767948
Test: Manual
Merged-In: Ie7f7282b89c13f587fdfe1bf3288eb4a3c7dcc6e
Change-Id: Ie7f7282b89c13f587fdfe1bf3288eb4a3c7dcc6e
2021-06-14 23:40:27 +00:00
Rahul Sabnis
710f462a5f Update nullability checks to use Objects#requireNonNull
instead of deprecated method in Preconditions class

Tag: #feature
Bug: 190767948
Test: Manual
Change-Id: Ie7f7282b89c13f587fdfe1bf3288eb4a3c7dcc6e
2021-06-14 14:57:21 -07:00
Łukasz Rymanowski
690b89ec89 Bluetooth: add Volume Control Profile boilerpalate
This is very simple API to allow Android to connect VCP profile.

Bug: 150670922
Test: compilation
Sponsor: jpawlowski@
CTS-Coverage-Bug: 190833351
Change-Id: Ib20d967fcf6797077abf83b40b0eda526e5ab89d
Merged-In: Ib20d967fcf6797077abf83b40b0eda526e5ab89d
2021-06-14 15:18:05 +00:00
Jeff Sharkey
fde28483d7 Merge "More Binder call AttributionSource assignment." into sc-dev 2021-06-04 04:07:17 +00:00
Jeff Sharkey
17bb873156 CloseGuard for more Bluetooth components.
We've seen evidence of IBluetoothProfileServiceConnection and
IBluetoothStateChangeCallback references being leaked, so attempt to
unregister them when an object is finalized without closing.

Bug: 189091551
Test: manual
Change-Id: I23792d48d94578acd7fc7a5164a95171801ee721
2021-06-03 15:38:17 -06:00
Jeff Sharkey
22ca72a675 More Binder call AttributionSource assignment.
Since developers can use a BluetoothDevice object can make remote
calls, it needs to have an accurate AttributionSource.  Previous CLs
had updated many places where these BluetoothDevice instances were
passed across Binder interfaces, but this change updates several
remaining locations which had been missed.

Introduces new "Attributable" marker interface to offer consistent
tooling when applying AttributionSource updates.

Bug: 187097694
Test: atest BluetoothInstrumentationTests
Change-Id: Icad3b9726591f0fbad58a493cefa5a0af7648280
2021-06-03 12:14:17 -06:00
Jeff Sharkey
6e8cafb843 Merge "Relax ACTION_TETHERING_STATE_CHANGED permissions." into sc-dev 2021-05-20 23:47:30 +00:00
Jeff Sharkey
263d880cf9 Relax ACTION_TETHERING_STATE_CHANGED permissions.
This broadcast doesn't contain any sensitive BluetoothDevice extras;
it only contains a single boolean indicating tethering state, so
relax it to no longer require the BLUETOOTH_CONNECT permission.

Bug: 188706031
Test: atest BluetoothInstrumentationTests
Change-Id: I2ff5c501844186a5813b2347246bbc83c190222d
2021-05-20 08:20:53 -06:00
Rahul Sabnis
b8cfbebbec Merge "Update BluetoothDevice#setAlias based on API council feedback: now accepts null input and returns an int (with error codes). Update CompanionDeviceManager#canPairWithoutPrompt to take a UserHandle instead of an int. Adds BluetoothStatusCodes class for all new Bluetooth error / success codes. Moved OOB and hci disconnect constants to the new BluetoothStatusCodes class." into sc-dev 2021-05-19 16:00:04 +00:00
Rahul Sabnis
d6b43bb520 Update BluetoothDevice#setAlias based on API council feedback: now
accepts null input and returns an int (with error codes).
Update CompanionDeviceManager#canPairWithoutPrompt to take a
UserHandle instead of an int. Adds BluetoothStatusCodes class for all
new Bluetooth error / success codes. Moved OOB and hci disconnect
constants to the new BluetoothStatusCodes class.

Tag: #feature
Bug: 184714087
Test: atest BluetoothDeviceTest#test_setAlias_getAlias
Change-Id: Ife03506f2cf68800f5824cb5fa94fec8aa34a39c
2021-05-17 16:47:55 -07:00
Jeff Sharkey
dd6dd3b1fb Apply AttributionSource during Intent delivery.
There are some Parcelables which offer to perform Binder calls, and
when these are delivered via Intent extras they fallback to
ActivityThread.currentAttributionSource(), instead of being tagged
based on the relevant app component.

This change begins using Intent.prepareToEnterProcess() as a hook to
fix-up AttributionSource when those extras finally land in the
destination process.  It uses the relevant AttributionSource based
on the Activity or Service the Intent is delivered to, which
developers have control over via AppComponentFactory.

In the case of <receiver> manifest elements, this change applies the
first android:attributionTags value to the Context used for that
BroadcastReceiver.

Bug: 187097694
Test: atest AttributionTest
Change-Id: I8f5197db7e8d7277d34f0ef2bb90bfdf1871186a
2021-05-15 09:48:14 -06:00
Treehugger Robot
ff3c817ba8 Merge "Bluetooth ScanFilter: Allow null in setDeviceAddress" am: 561b4c8aad am: 05c6b40a84 am: 32712787a0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1702025

Change-Id: I48df730d65443e2417acf24d563ef7d7ad780340
2021-05-12 00:37:15 +00:00
Rahul Sabnis
30002e7cd3 Merge "Update docs for BluetoothDevice#fetchUuidsWithSdp to reflect that if the device is bonding, we either broadcast cached UUIDs or wait for SDP to be performed after the device is bonded." am: d8c539d8b8 am: 27918f0cf2 am: 634cd45795
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1698769

Change-Id: I0b4ae79183c1b6e72c75369a25ca375acd4e5331
2021-05-10 21:21:20 +00:00
Myles Watson
025714ff33 Bluetooth ScanFilter: Allow null in setDeviceAddress
Bug: 187076761
Test: manual scan filter test
Change-Id: I6456be4baab4b2a2b6d4607619ff92370b8b457d
2021-05-10 13:52:32 -07:00
Rahul Sabnis
d8c539d8b8 Merge "Update docs for BluetoothDevice#fetchUuidsWithSdp to reflect that if the device is bonding, we either broadcast cached UUIDs or wait for SDP to be performed after the device is bonded." 2021-05-10 17:41:36 +00:00
Rahul Sabnis
6f92ae94ab Update docs for BluetoothDevice#fetchUuidsWithSdp to reflect that if the
device is bonding, we either broadcast cached UUIDs or wait for SDP to
be performed after the device is bonded.

Tag: #feature
Bug: 187157597
Test: Manual
Change-Id: I1bd694195c4e974b7cd72f81848a6343b45c98fd
2021-05-07 19:13:25 -07:00
Jeff Sharkey
9a9fa815f1 Merge "Ensure privileged APIs require runtime permission." into sc-dev 2021-04-29 22:22:25 +00:00
Martin Brabham
329a11f7c6 Merge changes from topic "bluetooth_oob_api" am: 2e67798711 am: 8411b5d7b3 am: 50e294ad9b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1686315

Change-Id: I00dc7f393edb9b562c97147d053302159c12fcdb
2021-04-29 21:33:10 +00:00
Martin Brabham
d50c8e0703 OOB: Remove static creator methods in favor of public constructors am: 1cd46165dd am: e897917de7 am: 2d3dbcab8f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1684129

Change-Id: Ia4d99bf5f2dcee3d688796dfa3e11c1d104132a1
2021-04-29 21:32:57 +00:00
Jeff Sharkey
b8e4b883ae Ensure privileged APIs require runtime permission.
When users revoke a runtime permission, they expect all interactions
to be blocked, including those protected by the BLUETOOTH_PRIVILEGED
permission.

This change finishes applying that policy to any remaining Bluetooth
APIs which didn't already implement it.  To keep the implementation
straightforward, this change does "data delivery" checks when
registering for callbacks; the ideal behavior would be to wait
until data is actually delivered through the callbacks, but
RemoteCallbackList doesn't have support for AttributionSource yet.

Bug: 186405452
Test: atest BluetoothInstrumentationTests
Change-Id: Idd7be143eb8baff020a0718065293baae708041b
2021-04-29 13:55:07 -06:00
Jeff Sharkey
0cab9b7480 Preserve legacy permission check behavior.
As part of the new "Nearby devices" permission work, the
registerStateChangeCallback() API has been relaxed to no longer
require permissions.  However, we've discovered that some apps were
depending on that SecurityException being thrown, so this change
restores throwing behavior for those legacy apps.

Bug: 186176507
Test: atest BluetoothInstrumentationTests
Change-Id: Ife536dee246b300ffb3dd78aef0b059a230f3835
2021-04-28 09:25:38 -06:00
Martin Brabham
b0d691b3a1 Convert onOobData parameter for OobData from @Nullable to @NonNull
Bug: 185603183
Test: Compiles, test app works
Tag: #feature
Change-Id: I52636769f50f50b5ad2d135f54472bdeb1c25ee5
2021-04-27 09:36:41 -07:00
Martin Brabham
1cd46165dd OOB: Remove static creator methods in favor of public constructors
Bug: 184370881
Tag: #feature
Test: Manual compile
Change-Id: I502cdf5adde324b7a41cfb6974f0b43b0064a911
2021-04-26 09:35:54 -07:00
Jeff Sharkey
dd5a4f39c8 Long-tail of AttributionSource plumbing.
Wires up AttributionSource across the remaining long-tail of
Bluetooth AIDL interfaces, ensuring that developers can accurately
make calls chained back to a specific Context.

Moves "for data delivery" permission checks to happen in a single
location on each interface to ensure they're performed consistently
with the new AttributionSource arguments.  Note that "for data
delivery" isn't the best name; it's designed to represent that the
requested action was performed and should result in the relevant
appop being noted for the caller.

This change has the positive side effect of ensuring that all
interfaces are consistently enforcing the BLUETOOTH_CONNECT
permission, even in the case where BLUETOOTH_PRIVILEGED is also
required; this is what ensures that revoking the "Nearby devices"
permission takes effect for all callers.

Additionally, standardizing on enforcing permissions closer to the
AIDL entry point reduces the need for @RequiresPermission annotations
to be carried around inside the Bluetooth stack.

Bug: 183626112
Test: atest BluetoothInstrumentationTests
Change-Id: I8023dda654e325b8bfa2f0cdb994ad63a2b429d4
2021-04-24 08:31:43 -06:00
Jeff Sharkey
efe1110be8 More AttributionSource plumbing.
To prepare for future work which will plumb AttributionSource values
through all remaining AIDLs, we need profiles to interact directly
with the specific BluetoothAdapter they were created from.  This is
how we'll ensure that the relevant AttributionSource can be chained
down from the original Context they're obtained from.

This change also marks getDefaultAdapter() as deprecated to clearly
communicate that BluetoothManager.getAdapter() is the best-practice
path to obtaining a correctly scoped BluetoothAdapter instance.

Bug: 183626112
Test: atest BluetoothInstrumentationTests
Change-Id: I1e15170d7679019bbb6e396279d6e633e3dad4d6
2021-04-23 08:51:49 -06:00
Oli Lan
52f8d4c9c3 Pass attribution source to BT APIs.
This adds attribution source to BT method calls. This is now
required to allow the app ops for the new BT permissions
(BLUETOOTH_CONNECT, BLUETOOTH_ADVERTISE, and BLUETOOTH_SCAN)
to be noted.

Bug: 183626112
Test: atest BluetoothInstrumentationTests
Change-Id: I81598553b762e491d6364064a2e1ef41dec89bf9
2021-04-22 14:47:39 -06:00
Jeff Sharkey
67d4e1e079 Refinement of AttributionSource handling.
Previous CLs had started passing AttributionSource values across
Binder calls inside BluetoothDevice instances, but this can cause
confuse the permission check logic in the future; we should instead
always aim to use the AttributionSource closest to the app making
the call, instead of parceling it.

This change also improves logging to highlight when we're quietly
treating a permission as denied, and when a UID is mismatched.

Bug: 186106084
Test: atest BluetoothInstrumentationTests
Change-Id: I5d3fdb3c573cb9e77474952d8680caa4c4c464eb
2021-04-22 12:46:06 -06:00
Jeff Sharkey
c1b024d280 Merge "Pass AttributionSource to AdapterService methods." into sc-dev 2021-04-21 22:40:20 +00:00
Jeff Sharkey
d4b3fcac16 Merge "Annotations for Bluetooth broadcast intents." into sc-dev 2021-04-21 22:23:48 +00:00
Jeff Sharkey
f459828358 Annotations for Bluetooth broadcast intents.
Recent work has been using Error Prone rules and annotations to
reflect the current state of permission enforcement across the
Bluetooth stack, and we're now in a position were we can add new
permission enforcement that had been missing.

We've currently standardized on saying that APIs that return device
or Bluetooth state information (without sharing details about any
particular remote Bluetooth device) do not need to be permission
protected.

Bug: 183626724
Test: ./build/soong/soong_ui.bash --make-mode Bluetooth RUN_ERROR_PRONE=true
Change-Id: I53ac7a4fe1dea57316048c3cac4fa237b6ba3d38
2021-04-21 12:59:38 -06:00
Oli Lan
141edf9ef6 Pass AttributionSource to AdapterService methods.
This adds attribution source to AdapterService bluetooth method
calls. This is now required to allow the app ops for the new
bluetooth permissions (BLUETOOTH_CONNECT, BLUETOOTH_ADVERTISE,
and BLUETOOTH_SCAN) to be noted.

Bug: 183626112
Test: atest AdapterServiceTest
Test: atest CtsPermissionTestCases:android.permission.cts.NearbyDevicesPermissionTest
Change-Id: I8d1fe41ca9945a3baab584f248a17b3a1eb255f7
2021-04-21 17:59:06 +01:00