summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothHeadsetClient.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-11Update getSignalStrength() javadocSal Savage
Tag: #refactor Bug: 219820175 Test: N/A, comment updates only Change-Id: I9e7e8921e56114dccefb988c8750323ffd432cd9
2022-03-07Merge "Address API Council Feedback for NetworkServiceState APIs" into tm-devSal Savage
2022-03-05Merge "Remove newly introduced audio state APIs that shouldn't be public" ↵Sal Savage
into tm-dev
2022-03-04Address API Council Feedback for NetworkServiceState APIsSal Savage
This changes: (1) Updates getOperatorName to getNetworkOperatorName. This is in line with both the HFP specs wording and the related TelephonyManager API. (2) Adds an IntRange annotation to the getSignalStrength. This annotation was chosen because the spec doesn't have definitive wording on how the 0 to 5 numbers are derived, despite the fact that we generally treat them as (None/Unknown, Very Poor, Poor, Moderate, Good, Great). IntRange adds some clarity around the domain of values without making any claims about the exact meanings. Tag: #refactor Bug: 219820175 Ignore-AOSP-First: Mainline related API Council Feedback change Test: atest BluetoothInstrumentationTests Change-Id: I5974bc4ee39113a3ebbffaacd28c0d5af70483ad
2022-02-28Remove newly introduced audio state APIs that shouldn't be publicSal Savage
Bug: 216476895 Test: make -j Change-Id: If3cfdf8f063f61e3903d4e7a3c289c2ef7a54b34
2022-02-25Update public function documentation and address removed spacingSal Savage
This change inherits the documentation from the parent class definitions where it can, so our profile proxy can be more in line with others. It alse seems an auto-formatter removed a lot of the white space in the class at somepoint. This change puts back spaces between methods and some of the constants. Tag: #refactor Bug: 216832546 Test: atest BluetoothInstrumentationTests Change-Id: Iac740cca2a62273b1cc84558a65f2aba294ec031
2022-02-08Add HFP Client NetworkServiceState APIsSal Savage
Tag: #feature Bug: 218377110 Test: atest BluetoothInstrumentationTests Change-Id: I7a0c23deceaeaee62648674ab49f1dccff0c4b65
2022-02-01API Changes needed for apex to buildWilliam Escande
Bug: 216476895 Test: Compile Tag: #refactor Ignore-AOSP-First: AOSP will be updated later Change-Id: I09108622038b174104457ca18ac6ec7949978f66 CTS-Coverage-Bug: 217352944
2022-01-28The BluetoothHeadsetClient connection action no longer matches manifestSal Savage
This change changes the name back to what it should have been and allows the existing manifest content making the broadcast a protected broadcast still work as is. Tag: #refactor Bug: 161145287 Test: atest BluetoothInstrumentationTests Change-Id: Ieffe7da80d3ebab36af7a8e71e7453f3a3e8c4a1
2022-01-24Make BluetoothHeadsetClient and associated functions @SystemApiSal Savage
The BluetoothHeadsetClient class is currently @hide. This CL annotates it to @SystemApi. This CL also adds explicit @hide to all public class members that we're not ready to commit to at this time. New System APIs include: - getConnectionState - getConnectedDevices - getDevicesMatchingConnectionState - getConnectionPolicy - setConnectionPolicy - ACTION_CONNECTION_STATE_CHANGED Tag: #feature Bug: 206035301 Test: atest BluetoothInstrumentationTests; atest BluetoothHostTest; Change-Id: Ib47efd90ad75309cab04e16720d2b172e7cceab1
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-10-29Merge "Rectify comment in getCurrentAgEvents"Treehugger Robot
2021-10-25Rectify comment in getCurrentAgEventsHarshad Ulhas Dhabu
Bug: 143946839 Bug: 199827901 Test: IOP and BCST Tag: #refactor Change-Id: I1c91d941f5383e8682e2b664120ffe6de4dfdef4 (cherry picked from commit 322c15bdaaa6ec44bc4cf6ea723b403b0e8ec1a8)
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-18Add missing Bluetooth API permission enforcement.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: I37a9e03ecdca6f7a6eb9d7f094e2f95a97036612
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
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-10-29Add 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. This is a resubmit of ag/12929664 with some APIs excluded that caused test failures; see bugs 171886397, 171888296, 171864568. APIs excluded: Landroid/bluetooth/le/ScanRecord;->parseFromBytes([B)Landroid/bluetooth/le/ScanRecord; Landroid/os/Process;->myPpid()I Landroid/os/SharedMemory;->getFd()I Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I Bug: 170729553 Test: Treehugger Change-Id: I8285daa8530260251ecad6f3f38f98e263629ca7
2020-10-28Revert "Add maxTargetSdk restriction to unused APIs."Hongwei Wang
This reverts commit bc9a809f18a3b0ec23cbc39802fb4928c2074ea3. Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397 Bug: 171886397 Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
2020-10-27Add 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 Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
2020-06-24Remove unnecessarily @System/TestApi annotationsMakoto Onuki
We can't expose APIs if the enclosing class is hidden, so these annotations are redundant. We need to remove them so that we can enable the check. Exempt-From-Owner-Approval: Cherry-pick from goog/master Bug: 159121253 Test: treehugger (i.e. this shouldn't trigger "API has changed" error.) Merged-in: Ie1841a670bdf6c6f4b25a1fc5deed8ec2d18cda2 Change-Id: I36e3562b72e64b51e4febd1d42a3bc8e4dc60988
2020-06-23Remove unnecessarily @System/TestApi annotationsMakoto Onuki
We can't expose APIs if the enclosing class is hidden, so these annotations are redundant. We need to remove them so that we can enable the check. Bug: 159121253 Test: treehugger (i.e. this shouldn't trigger "API has changed" error.) Change-Id: Ie1841a670bdf6c6f4b25a1fc5deed8ec2d18cda2
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-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 Change-Id: I33ee2c7ccd3827db3d23d6447cf82d9ffc36836a
2020-01-22Use @ConnectionPolicy annotation more consistently in classes withRahul Sabnis
methods setConnectionPolicy and getConnectionPolicy Bug: 147669289 Test: Manual Change-Id: I2b9b0391a02d01623c1cd253f2da12b2baaea599
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-04Refactor BluetoothHeadset APIs used by SettingsRahul Sabnis
Bug: 143244793 Test: Manual Change-Id: I399a1e0f93cb01c44817604edfcaa8fe5061142f
2019-12-02Rename priority to connection policy in bluetooth apisRahul Sabnis
Bug: 145005327 Test: Manual Change-Id: I43ad57feb7dd70f39005ad7a01bc7dac6fb7b639
2019-07-12Define intent for receive vendor specific response and define a function to ↵Deqiang Chen
send vendor AT command from Hfp client Bug: 132813146 Test: Local test with Kitchensink: able to send vendor command and receive response. Change-Id: I9a6debbacb1a5ad6445416c067d3d35849906685
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 Merged-In: Id0d85866d386962b94d2d966f0a864b1da165d13 Change-Id: Id0d85866d386962b94d2d966f0a864b1da165d13
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-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
2017-09-06Bluetooth: Thread-safe binder invocationJack He
* 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-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
2017-01-20Change HFP Client API to support multi deviceSanket Agarwal
- Adds BluetoothDevice as a parameter where required - Gets rid of device management APIs that can be done via BluetoothProfiles instead Test: Manual sanity tests Bug: b/33554547 Bug: b/30984220 Change-Id: I3485ac5bfe1fcb29c774ad040fdd608e1cacb8df
2016-11-07Detect non-oneway calls leaving system_server.Jeff Sharkey
To protect system stability, any Binder calls leaving the system_server must carefully be performed using FLAG_ONEWAY (or the 'oneway' verb in AIDL) which prevents the call from blocking indefinitely on the remote process. In this CL, the system_server uses the new Binder.setWarnOnBlocking() method to enable detection by default for all remote Binder interfaces. It can also use Binder.allowBlocking() to allow blocking calls on certain remote interfaces that have been determined to be safe. This CL adds the 'oneway' verb to several interfaces and methods where it should have been added, and marks a handful of system ContentProviders as being safe to call into. Also, we assume that any services obtained from ServiceManager are part of the core OS, and are okay to make blocking calls to. Test: builds, boots, runs with minimal logs triggered Bug: 32715088 Change-Id: Ide476e120cb40436a94b7faf7615c943d691f4c0
2016-06-29Use UUIDs for call management in Headset Client (HF)Sanket Agarwal
Using UUIDs that are managed by the service gives more control and error handling in the service since it has control over assigning them. Bug: b/29788044 Change-Id: I8483f8e61a33302ba95d544828947d7fb4a21be9 (cherry picked from commit dbeab2c6e12693fe9b06b6a680677da5325c9230)
2015-10-28Add ability to set whether audio route is allowed in BluetoothHeadsetClientBryce Lee
Bug: 25332357 Change-Id: I942ac0dea3e4f8580c44e027a570d0b59822a257
2014-06-13Rename BluetoothHandsfreeClient to BluetoothHeadsetClientMike Lockwood
This makes our terminology consistent with the existing BluetoothHeadset profile Also updated arguments to Context.bindService() Change-Id: I27cc5a6fde256b1f5dccca53a7a15ec8f58691c2