summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothA2dp.java
AgeCommit message (Collapse)Author
2022-06-30Revert "Revert "Reuse SynchronousResultReceivers instead of creating new.""Neha Jain
This reverts commit dd85e91cea26c7f706af36c852e79d5b4ca1f173. Bug: 217366135 Reason for revert: Need this to fix a crash bug in tm-dev Change-Id: I2a94c278edc0681c5b8af6ea0a0171b71d72c650 (cherry picked from commit dbaf406ccb0ed887d4e93057c9ec0d3457f14457) Merged-In: I2a94c278edc0681c5b8af6ea0a0171b71d72c650
2022-06-29Revert "Reuse SynchronousResultReceivers instead of creating new."Neha Jain
This reverts commit 02dcbe72b3564559eaa9c2e2714824e4aac6f18c. Reason for revert: Causing builds to fail b/237471430 Change-Id: I6165d838abf312085050359377f67a68a5f8b51a (cherry picked from commit f5dd42bbd05e68f7763ccaa9fae5642acc4ceba1) Merged-In: I6165d838abf312085050359377f67a68a5f8b51a
2022-06-29Reuse SynchronousResultReceivers instead of creating new.Etienne Ruffieux
Bug: 217366135 Tag: #feature Test: manual Ignore-AOSP-First: to be chery-picked Change-Id: If8ae530a284151888a3f89a51d2c58f2a5cd3644 (cherry picked from commit 02dcbe72b3564559eaa9c2e2714824e4aac6f18c) Merged-In: If8ae530a284151888a3f89a51d2c58f2a5cd3644
2022-03-29Merge "Removed SDK comparison to fix errorprone target"Etienne Ruffieux
2022-03-29Merge "API-REVIEW: add detail in codec switch javadoc"Treehugger Robot
2022-03-29Removed SDK comparison to fix errorprone targetEtienne Ruffieux
Bug: 227275330 Test: manual Tag: #feature Change-Id: I358b1d6249dc75f04b7a5194ac4713a008733a14
2022-03-29API-REVIEW: add detail in codec switch javadocWilliam Escande
Fix: 222434921 Test: no test for doc Tag: #refactor Change-Id: Icc11f11cdb95f71705c7c82b69bc957b86fedfd4
2022-03-25API Review: Update api for S+: Throw / PrivilegedWilliam Escande
> Please throw the exception for apps targeting S+. > You don't seem to be using any privileged permission: > please either make the API a public API or enforce the permission for > apps targeting S+ (check go/android-api-types) Bug: 222434921 Tag: #refactor Test: build Change-Id: I002b972b3a1fd5cd0b1af8aae81a49124fc9273d
2022-03-16[API review] add/expand documentation for Optional CodecsEtienne Ruffieux
Bug: 220890821 Tag: #feature Test: build Change-Id: Id7d94c129ebe7b66fb6e007ceb7b925f09480dd1
2022-02-14API Changes needed for apex to buildWilliam Escande
internal cherry-pick Bug: 216476895 Test: Compile Tag: #refactor Change-Id: I09108622038b174104457ca18ac6ec7949978f66 Merged-In: I09108622038b174104457ca18ac6ec7949978f66 CTS-Coverage-Bug: 217352944
2021-12-16Remove allowBlocking from all BluetoothProfilesWilliam Escande
Since Bluetooth is becoming a mainline module, it can no longer call the allowBlocking hidden api. Instead, all interface are moved to be oneway and use a synchronous data to handle the return value. Bug: 200200870 Test: Build + start Bt and play something on speaker Tag: #refactor Merged-In: I776a6322faadca1504bce24f2b6b041e756b6448 Change-Id: I776a6322faadca1504bce24f2b6b041e756b6448
2021-12-14Copy attributable to BluetoothWilliam Escande
Attributable is called by bluetooth and it's hidden. By copying into bluetooth we are now allowed to call it Bug: 210467788 Test: build Tag: #refactor Change-Id: I73ea07c9439988ab5477c82799f718c6d81513be
2021-07-27Require calls to BluetoothA2dp#setBufferLengthMillis to pass aRahul Sabnis
non-negative value Tag: #feature Bug: 194837771 Test: Manual Change-Id: I3c1d2da1d28a494d8b393c4502521b3f0699adf6
2021-06-03More Binder call AttributionSource assignment.Jeff Sharkey
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-04-24Long-tail of AttributionSource plumbing.Jeff Sharkey
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-23More AttributionSource plumbing.Jeff Sharkey
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-21Annotations for Bluetooth broadcast intents.Jeff Sharkey
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-16More Bluetooth API annotation updates.Jeff Sharkey
This change adds a "BluetoothPermissionChecker" that ensures that all Bluetooth permission annotations are consistent. In addition, it verifies that all Bluetooth public APIs have been audited to be permission protected where relevant. 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. This change is only annotations and has no behavior changes. Bug: 183626724 Test: ./build/soong/soong_ui.bash --make-mode Bluetooth RUN_ERROR_PRONE=true Change-Id: Ie80b15b058359bf1e9a6ee881b89cb3e5b584ca1
2021-04-14Update Bluetooth API annotations.Jeff Sharkey
Recent work has introduced a new "Nearby devices" runtime permission which protects all existing Bluetooth APIs; we've done this by defining a <split-permission> to convert the old BLUETOOTH and BLUETOOTH_ADMIN permissions into one of three new permissions: * BLUETOOTH_ADVERTISE: Required to be able to advertise to nearby Bluetooth devices. * BLUETOOTH_CONNECT: Allows applications to connect to paired bluetooth devices. * BLUETOOTH_SCAN: Required to be able to discover and pair nearby Bluetooth devices. At its core, this change begins updating the Bluetooth APIs to have correct @RequiresPermission indicating which permission is actually enforced internally. To ensure alignment across Binder, the newly added "RequiresPermissionChecker" Error Prone checker was used to discover any inconsistencies, ensuring correctness from server-side enforcement up through to the public APIs. In addition, since developers will continue building apps for both modern and legacy platforms, this change introduces new auto-doc annotations which will emit helpful consistent documentation describing the behavior of older devices that are still using the old permission model. Bug: 183626724 Test: ./build/soong/soong_ui.bash --make-mode Bluetooth RUN_ERROR_PRONE=true Change-Id: I02aa127e8e07f239561f4f2a3bbdfc6fccb82f7f
2021-03-09Derestrict some APIs.Mathew Inwood
They were retricted because we thought they were unused, but it turns out that they are needed afterall. NoNonSdkCheck: 170729553 Bug: 181103983 Test: N/A Change-Id: Iddf7916456be27d60d2a7520d7cadcda1d04cac6
2021-02-19Update BluetoothA2dp APIMore Kuo
- Rename setBufferMillis to setBufferLengthMillis - Rename getCodec to forCodec Bug: 179814567 Test: Build Change-Id: Iadb1b9e2b42ecab98f70b8bf6500e7a97aaf0aab
2021-01-21Merge "Dynamic Audio Buffer (1/3)"Zach Johnson
2021-01-20Dynamic Audio Buffer (1/3)More Kuo
Add APIs in BluetoothA2dp to: 1. Get the supported type of the dynamic audio buffer. 2. Get the dynamic audio buffer millis. 3. Set dynamic audio buffer millis. Add BufferConstraints class to access the buffer millis of different codec. Bug: 163968696 Tag: #feature Test: Run dynamic audio buffer test Change-Id: If097d94be861dbb0c4d8f67fe7caf70a99093e34
2021-01-07Derestrict some non-SDK APIs.Mathew Inwood
Per request from a partner, these APIs will not be restricted as they are in use. This is conceptually a partial revert of change 049f0f5f419. NoNonSdkCheck: b/170729553 Bug: 171933273 Test: Treehugger Change-Id: Ibb525e9a9e2fc90248b74f45f3cdcb0be7487c3a
2020-11-04Add maxTargetSdk restriction to unused APIs.Mathew Inwood
These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. Bug: 170729553 Test: Treehugger Merged-In: I626caf7c1fe46c5ab1f39c2895b42a34319f771a Change-Id: I54e5ecd11e76ca1de3c5893e3a98b0108e735413
2020-03-21Add BLUETOOTH_PRIVILEGED permission as a requirement for all new Bluetooth ↵Rahul Sabnis
SystemApis and for hidden connect/disconnect APIs. Hide some APIs that were previously marked as @UnsupportedAppUsage and re-add annotation as changing the permissions for these SystemApis would break the unsupported app contract that was previously there. Therefore, we're choosing to hide them until we have a good story on how to deal with them next release. Bug: 148689314 Test: Manual Merged-In: I33ee2c7ccd3827db3d23d6447cf82d9ffc36836a Change-Id: I33ee2c7ccd3827db3d23d6447cf82d9ffc36836a
2020-03-18Revert "Revert "Require user pass in a non-null BluetoothDevice ..."Rahul Sabnis
Revert "Revert "Pass in active device to all BluetoothA2dp APIs ..." Revert "Revert "Pass in active device to all BluetoothA2dp APIs ..." Revert submission 10303287-revert-10253996-bt-a2dp-no-null-FQRXACWPIA Reason for revert: Fixing breakage Reverted Changes: I4d9f2f819:Revert "Make sure calls to BluetoothA2dp APIs pass... I771ca0d57:Revert "Need to now pass in active device instead ... I76529c7a1:Revert "Pass in active device to all BluetoothA2dp... I297bda68d:Revert "Require user pass in a non-null BluetoothD... I525327959:Revert "Pass in active device to all BluetoothA2dp... I1d8660b11:Revert "Pass in active device to all BluetoothA2dp... Bug: 147287141 Test: Manual Merged-In: I91ee6878cac1b84bd289278a1b965658a26fe4db Merged-In: I4d7d971af75bff8967fd807d34dad90c32e24eba Change-Id: I4d7d971af75bff8967fd807d34dad90c32e24eba
2020-01-10Use new UnsupportedAppUsage annotation.Artur Satayev
Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I6ab53570aca580fbee1fcc927871caa09780f58f Merged-In: I6ab53570aca580fbee1fcc927871caa09780f58f
2019-12-06Resolve BluetoothA2dp hidden APIs to resolve dependenciesRahul Sabnis
Bug: 143240341 Test: Manual Change-Id: Ib55e0fb106fa7b91ef4d3559da12ea2c048f1ae5
2019-12-04Make BluetoothUuid constants and some functions System ApisRahul Sabnis
Bug: 143245929 Test: Manual Change-Id: I5519a379a2bb5d56fe25745d8bdeaa5cf52d9e92
2019-12-02Rename priority to connection policy in bluetooth apisRahul Sabnis
Bug: 145005327 Test: Manual Change-Id: I43ad57feb7dd70f39005ad7a01bc7dac6fb7b639
2019-05-02Fix binder leakage when turning off BluetoothUgo Yu
* In current design, Bluetooth AdapterState stops all BR/EDR profiles' service and triggers onServiceDisconnected callback to all binder clients before BluetoothManagerService invokes onBluetoothStateChange(false), which means unbind service would never be called in framework. * Do unbind service when onServiceDisconnected is invoked. * Move profile binder logic to BluetoothProfileConnector except: - BluetoothHeadset: its binder logic is in BluetoothManagerService - BluetoothPbap: it has an individual ServiceListener Bug: 129037442 Bug: 129437895 Test: Bluetooth ON/OFF stress test. adb shell dumpsys activity services | egrep "com.android.bluetooth" to check whether AppBindRecord for com.android.bluetooth grows Change-Id: Id0d85866d386962b94d2d966f0a864b1da165d13
2019-03-14Merge "Avoid IllegalArgumentException when bluetooth is disabled" am: ↵Deqiang Chen
4b7400c35c am: 981551ae46 am: 684368381a Change-Id: Idb94b41924023ba3fab9694c93f17ed4ce4d01b4
2019-03-12Avoid IllegalArgumentException when bluetooth is disabledDeqiang Chen
When the corresponding profile service is not available on device, bluetoothA2dp, bluetoothHidHost and bluetoothPbap will report IllegalArgumentException when bluetooth is disabled. This change avoid that exception. Bug: 127359897 Test: local test and observe there is no IllegalArgumentException when bluetooth is disabled Change-Id: I457e5225b8710dd5d02c405ef558892e99d1736f (cherry picked from commit ee8371007b82ff8c6d26e8ac90c6e3d3cf6bf2a8)
2019-01-25AudioDeviceBroker in audio serviceJean-Michel Trivi
New AudioDeviceBroker class running in audio service. Has dedicated message loop for handling audio device connections and disconnections. New helper classes for AudioDeviceBroker: - BtHelper for Bluetooth - AudioDeviceInventory to manage list of devices Bug: 112863932 Test: media CTS + audio CTS Verifier Change-Id: I3e8f662a9d82fa7245695888e14fac7f4fc6e728
2018-12-28Limit access to suspected false positives.Mathew Inwood
Members modified herein are suspected to be false positives: i.e. things that were added to the greylist in P, but subsequent data analysis suggests that they are not, in fact, used after all. Add a maxTargetSdk=P to these APIs. This is lower-risk that simply removing these things from the greylist, as none of out data sources are perfect nor complete. For APIs that are not supported yet by annotations, move them to hiddenapi-greylist-max-p.txt instead which has the same effect. Exempted-From-Owner-Approval: Automatic changes to the codebase affecting only @UnsupportedAppUsage annotations, themselves added without requiring owners approval earlier. Bug: 115609023 Test: m Change-Id: Ia937d8c41512e7f1b6e7f67b9104c1878b5cc3a0 Merged-In: I020a9c09672ebcae64c5357abc4993e07e744687
2018-12-28Limit access to suspected false positives.Mathew Inwood
Members modified herein are suspected to be false positives: i.e. things that were added to the greylist in P, but subsequent data analysis suggests that they are not, in fact, used after all. Add a maxTargetSdk=P to these APIs. This is lower-risk that simply removing these things from the greylist, as none of out data sources are perfect nor complete. For APIs that are not supported yet by annotations, move them to hiddenapi-greylist-max-p.txt instead which has the same effect. Exempted-From-Owner-Approval: Automatic changes to the codebase affecting only @UnsupportedAppUsage annotations, themselves added without requiring owners approval earlier. Bug: 115609023 Test: m Change-Id: I020a9c09672ebcae64c5357abc4993e07e744687
2018-10-22Move some members to the "Q blacklist".Mathew Inwood
Based on some analysis, these fields/methods are likely false positives. Set maxTargetSdk=P so that any apps using them are required to migrate off them in future. See the bug for more details. Exempted-From-Owner-Approval: Automatic changes to the codebase affecting only @UnsupportedAppUsage annotations, themselves added without requiring owners approval earlier. Bug: 115609023 Test: m Merged-In: I719b5c94e5b1f4fa562dd5d655953422958ad37e Change-Id: I719b5c94e5b1f4fa562dd5d655953422958ad37e (cherry picked from commit 7e50b2e0ee2efa6ca61a9f0116ccc0839f40e4f8)
2018-09-14Move some members to the "Q blacklist".Mathew Inwood
Based on some analysis, these fields/methods are likely false positives. Set maxTargetSdk=P so that any apps using them are required to migrate off them in future. See the bug for more details. Exempted-From-Owner-Approval: Automatic changes to the codebase affecting only @UnsupportedAppUsage annotations, themselves added without requiring owners approval earlier. Bug: 115609023 Test: m Change-Id: I719b5c94e5b1f4fa562dd5d655953422958ad37e
2018-08-21Be the current user to get A2DP proxyCheney Ni
After user switched, Bluetooth process will be restarted to run as secondary user and some system process like AudioService keeps as primary user. When BluetoothA2dp did rebind, it still used primary UID for those system process and caused they could not invoke A2DP APIs. This changes to use current user ID when rebinding to A2dpService and system process can get correct A2DP proxy after user switched. Bug: 112469503 Test: manual Change-Id: If5ee945b0dcf2044ef2baedd762751fa6ef3d09a
2018-08-06Merge "Add @UnsupportedAppUsage annotations"Mathew Inwood
am: b40b37910d Change-Id: Ic3de9e4c6d17687d4a1f64c02026e5c0711e8fd1
2018-08-01Add @UnsupportedAppUsage annotationsMathew Inwood
For packages: android.bluetooth.le android.bluetooth This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: Ifcf24c0617acd7facc0e03f30a95c3a6b09b205c Merged-In: I88a1311e27c5f9a5f9d1035db76034f86f650efc
2018-03-01Merge "Bluetooth: Remove adjustAvrcpAbsoluteVolume" am: a11cf63eef am: ↵Ajay Panicker
a91742e95f am: cb1bb7d7be Change-Id: Id99f889cb15789f36bc2c9c57ebdc58f730eb800
2018-03-01Bluetooth: Remove adjustAvrcpAbsoluteVolumeAjay Panicker
The AudioManager now handles all calculations for volume stepping now and no longer uses adjustAvrcpAbsoluteVolume. Bug: 68812037 Test: Compile Change-Id: I9cbf7989e49738c7a43fe3142aced5803111271e
2018-02-03Pass in the user defined by Context.Jeff Sharkey
The majority of Manager-style classes already use Context.getUserId() when making calls into the OS, so clean up the remaining callers to unify behind this strategy. This gives @SystemApi developers a nice clean interface to interact across user boundaries, instead of manually adding "AsUser" or "ForUser" method variants, which would quickly become unsustainable. Test: builds, boots Bug: 72863821 Exempt-From-Owner-Approval: trivial changes Change-Id: Ib772ec4438e57a2ad4950821b9432f9842998451
2018-01-26Add support for Multi-A2DP state machines per devicePavlin Radoslavov
* 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 164b38b96f225cef9eab6edebf589215071aec48)
2018-01-25Add support for Multi-A2DP state machines per devicePavlin Radoslavov
* 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
2018-01-05Added internal API to get/set the A2DP Active DevicePavlin Radoslavov
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
2017-08-24Fix checkstyle errors (2/2)Jack He
* 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-24Fix checkstyle errors (1/2)Jack He
* Automatic style corrections through IDE Bug: 63596319 Test: make checkbuild, no manual changes, no functional changes Change-Id: I2397d55abc34c9b7a9b748bec6137778df3421a7