summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothSocket.java
AgeCommit message (Collapse)Author
2022-03-07Merge TP1A.220209.001Deyao Ren
Change-Id: Id0e2895d3220831d2c617a243047e8229af8acc9
2022-02-18Clean up logcat messageBrian Orr
Bug: 220185025 Test: Presubmit Change-Id: Id8b5d72b48c027fc014292fd669f64e405afa276 (cherry picked from commit 732b085beff4f62e58ca0f32bf0cb46609b2c5fa)
2022-02-04Merge TP1A.220120.003Haamed Gheibi
Change-Id: I202f5093bbd13b381ea11f969fee6154ba91fa11
2022-01-28Revert the getSocketManager Synchronous callWilliam Escande
Fix: 216736996 Tag: #stability Test: atest 'CtsBluetoothTestCases:android.bluetooth.cts.BasicAdapterTest#test_listenUsingRfcommWithServiceRecord' Test: atest 'CtsBluetoothTestCases:android.bluetooth.cts.LeL2capSocketTest#testOpenInsecureLeL2capServerSocketOnce' Ignore-AOSP-First: No such change on AOSP yet Change-Id: I1242fd01105265949a59deca9bf45e99e2a12a38
2022-01-28Remove allowBlocking from BluetoothManagerServiceWilliam Escande
Since Bluetooth is becoming a mainline module, it can no longer call the allowBlocking hidden api. Instead, corresponding aidl are moved to be oneway and use a synchronous data to handle the return value. also: aosp/1927380 for similar work on all bluetooth profiles BluetoothGatt will be done next Bug: 211851706 Test: build + start bt Tag: #refactor Ignore-AOSP-First: merge conflict resolution Change-Id: I715cc2d8f2ae42be6d1099cd73095d37fa9e30f4
2022-01-26Introduces mechanism for background rfcomm serverstadvana
This change adds a mechanism in the AdapterService which allows it to register RFCOMM listeners requested by a BluetoothAdapter. This is so that applications can request the framework to listen for incoming RFCOMM connections in the background. Apps can request that the bluetooth manager, via a BluetoothAdapter, listen on a specific service record, and then transact incoming socket connections after receiving a notification of availability via a PendingIntent. Tag: #feature Test: Run the CTS Bluetooth Rfcomm Handoff service Test. This requires two devices. Bug: 186494155 Ignore-AOSP-First: Need to commit to downstream first in order to resolve a merge conflict. Change-Id: Ia0c71969e691e6353f22fe3b7dae4a7500230e03
2022-01-25Stop using LocalSocket.createConnectedLocalSocket.Lorenzo Colitti
Use the newly-added module-lib API that constructs a LocalSocket from a FileDescriptor. Test: m Bug: 200200870 Change-Id: I3621c2a6ea9bae6a3e925cf977ebdf914cadd978
2021-11-22BT MAINLINE ParcelFileDescriptor to dup methodWilliam Escande
In order to have Bluetooth a mainline module, we must remove all call to externa hidden API. Tag: #refactor Bug: 200200870 Test: Build Change-Id: I291d670b1dfc3760bedd5f6666ea04883568df69
2021-08-13Register IBluetoothManagerCallback per-process.Jeff Sharkey
As part of introducing AttributionSource across the Bluetooth stack earlier this year, each BluetoothAdapter instance is now associated with a specific AttributionSource, and several instances of shared static code were made BluetoothAdapter-specific so they could be augmented with the relevant AttributionSource. However, processes that create many BluetoothAdapter instances can overload the system, since a IBluetoothManagerCallback was registered for each instance. This change mitigates this by only registering a single IBluetoothManagerCallback for the entire process, and it then reuses the existing sProxyServiceStateCallbacks list for dispatching events to all active adapters within the process. Since it's so late in the release, we keep both mService and sService intact to minimize the size of this CL; future work should refactor to a more robust design, such as Supplier<IBluetooth>. Bug: 195286998, 172022978 Test: atest BluetoothInstrumentationTests Change-Id: I012f3f65e61eaf55e40436486806e56506c928ee (cherry picked from commit f0fa7f9b4aaee876053486d988909df9dc64e990)
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-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-09-14Update language to comply with Android's inclusive language guidanceJeff Sharkey
See https://source.android.com/setup/contribute/respectful-code for reference Test: none Bug: 168334533 Exempt-From-Owner-Approval: docs updates Change-Id: I245b8d9cac722da76ea67983738a3cbb9deb68df
2020-01-09Use 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-09-04Revert "Revert "Remove a misleading "flush" function.""Christian Wailes
This reverts commit 3d30e625e338d452c2a9e91dc2ad477e8500e5eb. Reason for revert: Fixed the test broken by the original commit Bug: 139192244 Bug: 140336855 Test: m -> flash -> boot Test: atest CtsJvmtiAttachingHostTestCases Change-Id: I4c67ad8709652c4710ef24564e0240f74f817f8c
2019-08-31Revert "Remove a misleading "flush" function."Ian Kasprzak
This reverts commit 0388ad1f72c70ca96cabc8b1a4a107877752b187. Reason for revert: Driodcop: aosp-master test-mapping showing multiple failures (b/140336855). Change-Id: If44e273dd111802db8b44db1e5a67a4628c72e3c
2019-08-27Remove a misleading "flush" function.Chris Wailes
This patch removes LocalSocketImpl.flush(). In practice this function was simply a wrapper around `Thread.sleep(10)`. All direct calls to this function have been removed. The `flush()` function is still called on several objects that wrap a SocketOutputStream. This will make booting a device 20ms faster than it currently is. Bug: 139192244 Test: Build -> flash -> boot -> launch app Change-Id: I0a96f4bc72461670370f61e847349f32af5ac774
2019-06-17Document public alternatives to greylisted APIsAndrei Onea
Add known public alternatives or recommendations for greylisted APIs in Bluetooth. Bug: 135171386 Test: m Change-Id: I86e708be37eb7d1b0fafa2d64283b7f81bc02e51
2018-09-13Unhide the LE CoC APIsStanley Tng
Expose the LE Connection-oriented Channels APIs for applications to use. Test: Run the SL4A ACTS test: BleCocTest Bug: 70683224 Change-Id: I68128bc7154966ec065091c973351f8892da9b4d
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-04Add function to change LE Tx Data LengthStanley Tng
As part of new SL4A tests for LE CoC to measure data throughput, this commit adds a function to set the LE Tx Data Length parameter to its maximum. Test: Ran the new ACTS Tests for LE CoC (BleCocTest and BleCoc2ConnTest) Bug: 70683224 Change-Id: Iea93f6cb9f4f7cc484f121afa158d7dae18d1ef1
2018-01-12Added APIs for Connection-oriented channelsStanley Tng
Experimental and hidden APIs are defined for the Connection-oriented Channel (CoC) features. The APIs using PSM are implemented. Test: Can compile Bug: 70683224 Change-Id: Icdb5fa190b0e21881a60437fa48cd575371ee1e4
2017-11-10Move connectSocket into IBluetoothSocketManager (3/3)Jakub Pawlowski
Bug: 68359837 Test: none Merged-In: I1161a5fe74b034fba0112fd3a78bdf1fbace6e12 Change-Id: I1161a5fe74b034fba0112fd3a78bdf1fbace6e12
2017-11-09Move createSocketChannel into IBluetoothSocketManager (3/3)Jakub Pawlowski
Bug: 68359837 Test: none Change-Id: I52b03ff3d637bf661c70279b7ca18b105157f7a2
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-03-31Bluetooth: Add additional BluetoothSocket logging to root cause errorsAjay Panicker
Bug: 34780400 Test: Code still compiles Change-Id: I166842ecc6889f9ea403e7aa3678ed818cd80968
2017-01-06Refactor RFCOMM / BluetoothSocket usage of LocalSocketNeil Fuller
LocalSocket is used by BluetoothSocket. BluetoothSocket passes a pre-created file descriptor to LocalSocket that is then given to the LocalSocketImpl. Commit b08c7bc0bdc48ae95be2697ca27ea89a9dd92c3e broke the behavior. Commit 7a8c36aa4e6a1b5e48f0ee5a787f10bcfece7587 put in a minimal fix. This change tidies up LocalSocket and associated classes and replaces a specialist constructor with a factory method to highlight the special case. While there an unnecessary exception has been removed. Bug: 34111534 Test: Boot device Test: vogar --mode app_process tests/tests/net/src/android/net/cts/LocalSocketTest.java Change-Id: I4ba2f2d9ea361a950ff8bc8d64fc800d998c3210
2016-06-21Merge \\\"Fix links to Bluetooth Guide\\\" am: 6ba39e5642 am: 84abd4a0d6Marie Janssen
am: 1175443e0d Change-Id: I99e17125cf95165b911c6e8f294e2f020d483cb2
2016-06-21Merge \"Fix links to Bluetooth Guide\"Marie Janssen
am: 6ba39e5642 Change-Id: I0f4e84245e05a19403603121a9138c2076ef2282
2016-06-20Fix links to Bluetooth GuideMarie Janssen
Change-Id: I5798c3d71c7cc9c509e0f7b04fa140168b0fdc11
2016-06-18Fix early termination of while loop in BluetoothSocket#writeChristine Hallstrom
While loop exits too early and misses writing remaining bytes. Also restructured the loop itself to be more readable. Change-Id: I71e9b331d20b5ae70175450c3346be43ab56c40c
2015-12-14Frameworks/base: Use Arrays.toStringAndreas Gampe
Fix a couple of cases where Arrays.toString should be used. Bug: 19797138 Change-Id: I905fc79e63face9b26975320a92086c732bf6316
2015-07-14Fix BluetoothSocket file descriptor leakZach Johnson
Sockets accepted on a server socket didn't populate the mPfd field, which is used to close out the java end of the native-and-java communication socket when the overall rfcomm socket is closed. #badnewsbears b/21398841 Change-Id: I3adb0a9965f83d0f3006fa4f79ea4abeab5c9a17
2015-06-09SAP: Make it possible to enforce a 16-digit pin code (4/5)Casper Bonde
This change enable the posibility to enforce using a 16-digit pin or MITM for a RFCOMM or L2CAP connection. This is needed for the SIM access profile. Change-Id: I3205013f9e758c353381442a86845dab467780f8 Signed-off-by: Casper Bonde <c.bonde@samsung.com>
2015-06-03Add support for MITM for BluetoothSockets (1/4)Casper Bonde
This change adds an option to enforce Man-in-the-middle protection for the authentication process. This feature is needed for the Sim Access Profile. Change-Id: Ia3ef0caeb750f88608c9fa6bf6367d1c77de4cf3 Signed-off-by: Casper Bonde <c.bonde@samsung.com>
2015-05-04Add documentation for BluetoothSocket.getConnectionType()Andre Eisenbach
Bug: 20824264 Change-Id: I58aa8f5bbe08ddb252f01f4ad187ae8741963f0b
2015-04-11OBEX Over L2CAP + SDP search API for BT profilesCasper Bonde
- Updated OBEX to support SRM - Added support for OBEX over l2cap and SRM. - Minor bugfixes, and reduce CPU load ALOT - Added support to send responses without body data. - Extend BluetoothSocket to support L2CAP - Added functionality to get the channel number needed to be able to create an SDP record with the channel number. - Added interface to get socket type and max packet sizes. - Added interface to perform SDP search and get the resulting SDP record data. Change-Id: I9d37a00ce73dfffc0e3ce03eab5511ba3a86e5b8
2014-09-03Close the base socket when bindListen failsMatthew Xie
Bug: 10773872 Change-Id: I0a72b2eb65055fa1959070d2dc32d40a573bd6f2
2014-05-17am 3e1bbaf7: am 45734b4a: Merge "Log accept and close debug statements in ↵Joe LaPenna
BluetoothSocket." into klp-modular-dev * commit '3e1bbaf786c12e66624c42c13a58095bc8133117': Log accept and close debug statements in BluetoothSocket.
2014-05-13Log accept and close debug statements in BluetoothSocket.Joe LaPenna
Bug: 14902781 Bug: 14784262 Change-Id: Id0c2cd216244e05c218568427bda863a538b1041
2014-05-06Make sure BluetoothSocket#connect throws on error.Sharvil Nanavati
It sometimes fails silently, resulting in callers using the socket even though it hasn't been initialized. http://b/13909270 Change-Id: Ied08982b51d44c3d2dec72785888ea6c6497a664
2014-01-20bluetoothsocket fd leak, need close the file descriptor after detachFd.Zhihai Xu
Perform ParcelFileDescriptor close after detach to avoid bluetooth socket leaks in strict mode. bug:12647433 Change-Id: I22f422547b2fb33b9bf12065dc689ed7785a7269
2014-01-13NPE in BluetoothSocket.write()Zhihai Xu
If calling connect succeed, we should not see this NPE. An IOException may happen after call BluetoothSocket.connect. If you still call write after the IOException, you will get this NPE. add NPE protection for possible wrong calling sequence from application, To make bluetoothSocket more error-tolerant. bug:12104154 Change-Id: I7fa4e847b500ca9b9d2a43df432f31a1bb016c0a
2014-01-04Merge "NPE in BluetoothSocket.write()"Zhihai Xu
2013-12-17NPE in BluetoothSocket.write()Zhihai Xu
If calling connect succeed, we should not see this NPE. An IOException may happen after call BluetoothSocket.connect. If you still call write after the IOException, you will get this NPE. add NPE protection for possible wrong calling sequence from application, To make bluetoothSocket more error-tolerant. bug:12104154 Change-Id: I7fa4e847b500ca9b9d2a43df432f31a1bb016c0a
2013-11-20Remove unused imports from frameworks/base.John Spurlock
Change-Id: Ia1f99bd2c1105b0b0f70aa614f1f4a67b2840906
2013-10-02Revert "Allow L2CAP sockets"Mike Lockwood
This reverts commit 008ce9e07b5e58c5ab31c5d73ec3d1ad1a6cf605.