aboutsummaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothSocket.java
Commit message (Collapse)AuthorAgeFilesLines
* Add more log for Bluetooth socketUgo Yu2023-02-151-2/+3
| | | | | | | | | | | | | - Enable framework logs - Add Bluetooth socket event log into dumpsys Bug: 263323082 Bug: 248162762 Test: atest BluetoothInstrumentationTests Change-Id: I0cbb18f1c221eaa7353b3867629affc09f1eb0a8 (cherry picked from commit 63c3fa677e15f1224e43dda1aee9d0d262aaab69) (cherry picked from commit b6dc15a708a03a5095523161911fc6a4f68772d9) Merged-In: I0cbb18f1c221eaa7353b3867629affc09f1eb0a8
* Follow error prone recommendationWilliam Escande2022-10-171-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ``` ObexServerSockets.java:228: warning: BluetoothSocket is final and does not override Object.toString Log.d(mTag, "onConnect() socket: " + conSocket); ^ BluetoothPbapService.java:767: warning: BluetoothSocket is final and does not override Object.toString + " socket=" + socket); ^ AvrcpCoverArtService.java:256: warning: BluetoothSocket is final and does not override Object.toString debug("onConnect() - device=" + device + ", socket=" + socket); ^ PbapClientConnectionHandler.java:377: warning: BluetoothSocket is final and does not override Object.toString Log.d(TAG, "Closing socket" + mSocket); ^ [...] (see https://errorprone.info/bugpattern/ObjectToString) ``` Bug: 236759221 Test: m RUN_ERROR_PRONE=true Bluetooth Ignore-AOSP-First: Cherry-pick of aosp/2133706 to solve merge conflict Merged-In: I6a49a8ef8c6b380547cbb817468fa33bf89347a3 Change-Id: I6a49a8ef8c6b380547cbb817468fa33bf89347a3 (cherry picked from commit 6134f7c0682cbf72a4caeeb2bdc9661aeab9b9f3)
* Clean up logcat messageBrian Orr2022-02-171-1/+1
| | | | | | Bug: 220185025 Test: Presubmit Change-Id: Id8b5d72b48c027fc014292fd669f64e405afa276
* Remove allowBlocking from BluetoothManagerServiceWilliam Escande2022-02-011-8/+16
| | | | | | | | | | | | | | | 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 Change-Id: I715cc2d8f2ae42be6d1099cd73095d37fa9e30f4 Merged-In: I715cc2d8f2ae42be6d1099cd73095d37fa9e30f4
* Introduces mechanism for background rfcomm serverstadvana2022-01-271-0/+32
| | | | | | | | | | | | | | | | | | | | | | 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 Merged-In: Ia0c71969e691e6353f22fe3b7dae4a7500230e03
* Stop using LocalSocket.createConnectedLocalSocket.Lorenzo Colitti2022-01-251-3/+3
| | | | | | | | | Use the newly-added module-lib API that constructs a LocalSocket from a FileDescriptor. Test: m Bug: 200200870 Change-Id: I3621c2a6ea9bae6a3e925cf977ebdf914cadd978
* BT MAINLINE ParcelFileDescriptor to dup methodWilliam Escande2021-11-221-2/+1
| | | | | | | | | | 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
* Register IBluetoothManagerCallback per-process.Jeff Sharkey2021-08-131-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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)
* More Bluetooth API annotation updates.Jeff Sharkey2021-04-161-1/+12
| | | | | | | | | | | | | | | | | | 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
* Update Bluetooth API annotations.Jeff Sharkey2021-04-141-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-291-1/+2
| | | | | | | | | | | | | | | | | | | 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
* Revert "Add maxTargetSdk restriction to unused APIs."Hongwei Wang2020-10-281-2/+1
| | | | | | | | | 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
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-271-1/+2
| | | | | | | | | | 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
* Update language to comply with Android's inclusive language guidanceJeff Sharkey2020-09-141-4/+7
| | | | | | | | | See https://source.android.com/setup/contribute/respectful-code for reference Test: none Bug: 168334533 Exempt-From-Owner-Approval: docs updates Change-Id: I245b8d9cac722da76ea67983738a3cbb9deb68df
* Use new UnsupportedAppUsage annotation.Artur Satayev2020-01-091-1/+1
| | | | | | | | | 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
* Revert "Revert "Remove a misleading "flush" function.""Christian Wailes2019-09-041-14/+0
| | | | | | | | | | | | | | 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
* Revert "Remove a misleading "flush" function."Ian Kasprzak2019-08-311-0/+14
| | | | | | | | This reverts commit 0388ad1f72c70ca96cabc8b1a4a107877752b187. Reason for revert: Driodcop: aosp-master test-mapping showing multiple failures (b/140336855). Change-Id: If44e273dd111802db8b44db1e5a67a4628c72e3c
* Remove a misleading "flush" function.Chris Wailes2019-08-271-14/+0
| | | | | | | | | | | | | 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
* Document public alternatives to greylisted APIsAndrei Onea2019-06-171-1/+1
| | | | | | | | | Add known public alternatives or recommendations for greylisted APIs in Bluetooth. Bug: 135171386 Test: m Change-Id: I86e708be37eb7d1b0fafa2d64283b7f81bc02e51
* Unhide the LE CoC APIsStanley Tng2018-09-131-0/+4
| | | | | | | | Expose the LE Connection-oriented Channels APIs for applications to use. Test: Run the SL4A ACTS test: BleCocTest Bug: 70683224 Change-Id: I68128bc7154966ec065091c973351f8892da9b4d
* Add @UnsupportedAppUsage annotationsMathew Inwood2018-08-011-0/+6
| | | | | | | | | | | | | | | | | | 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
* Add function to change LE Tx Data LengthStanley Tng2018-02-041-0/+29
| | | | | | | | | | 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
* Added APIs for Connection-oriented channelsStanley Tng2018-01-121-4/+15
| | | | | | | | | 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
* Move connectSocket into IBluetoothSocketManager (3/3)Jakub Pawlowski2017-11-101-1/+1
| | | | | | | Bug: 68359837 Test: none Merged-In: I1161a5fe74b034fba0112fd3a78bdf1fbace6e12 Change-Id: I1161a5fe74b034fba0112fd3a78bdf1fbace6e12
* Move createSocketChannel into IBluetoothSocketManager (3/3)Jakub Pawlowski2017-11-091-1/+1
| | | | | | Bug: 68359837 Test: none Change-Id: I52b03ff3d637bf661c70279b7ca18b105157f7a2
* Fix checkstyle errors (2/2)Jack He2017-08-241-18/+15
| | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Fix checkstyle errors (1/2)Jack He2017-08-241-133/+175
| | | | | | | | * Automatic style corrections through IDE Bug: 63596319 Test: make checkbuild, no manual changes, no functional changes Change-Id: I2397d55abc34c9b7a9b748bec6137778df3421a7
* Bluetooth: Add additional BluetoothSocket logging to root cause errorsAjay Panicker2017-03-311-5/+8
| | | | | | Bug: 34780400 Test: Code still compiles Change-Id: I166842ecc6889f9ea403e7aa3678ed818cd80968
* Refactor RFCOMM / BluetoothSocket usage of LocalSocketNeil Fuller2017-01-061-5/+5
| | | | | | | | | | | | | | | | | | | | 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
* Merge \\\"Fix links to Bluetooth Guide\\\" am: 6ba39e5642 am: 84abd4a0d6Marie Janssen2016-06-211-1/+1
|\ | | | | | | | | | | am: 1175443e0d Change-Id: I99e17125cf95165b911c6e8f294e2f020d483cb2
| * Merge \"Fix links to Bluetooth Guide\"Marie Janssen2016-06-211-1/+1
| |\ | | | | | | | | | | | | | | | am: 6ba39e5642 Change-Id: I0f4e84245e05a19403603121a9138c2076ef2282
| | * Fix links to Bluetooth GuideMarie Janssen2016-06-201-1/+1
| | | | | | | | | | | | Change-Id: I5798c3d71c7cc9c509e0f7b04fa140168b0fdc11
* | | Fix early termination of while loop in BluetoothSocket#writeChristine Hallstrom2016-06-181-12/+9
|/ / | | | | | | | | | | | | While loop exits too early and misses writing remaining bytes. Also restructured the loop itself to be more readable. Change-Id: I71e9b331d20b5ae70175450c3346be43ab56c40c
* / Frameworks/base: Use Arrays.toStringAndreas Gampe2015-12-141-2/+3
|/ | | | | | | Fix a couple of cases where Arrays.toString should be used. Bug: 19797138 Change-Id: I905fc79e63face9b26975320a92086c732bf6316
* Fix BluetoothSocket file descriptor leakZach Johnson2015-07-141-0/+2
| | | | | | | | | | | 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
* SAP: Make it possible to enforce a 16-digit pin code (4/5)Casper Bonde2015-06-091-3/+11
| | | | | | | | | | 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>
* Add support for MITM for BluetoothSockets (1/4)Casper Bonde2015-06-031-2/+26
| | | | | | | | | 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>
* Add documentation for BluetoothSocket.getConnectionType()Andre Eisenbach2015-05-041-3/+7
| | | | | Bug: 20824264 Change-Id: I58aa8f5bbe08ddb252f01f4ad187ae8741963f0b
* OBEX Over L2CAP + SDP search API for BT profilesCasper Bonde2015-04-111-24/+173
| | | | | | | | | | | | | | | - 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
* Close the base socket when bindListen failsMatthew Xie2014-09-031-0/+8
| | | | Bug: 10773872 Change-Id: I0a72b2eb65055fa1959070d2dc32d40a573bd6f2
* am 3e1bbaf7: am 45734b4a: Merge "Log accept and close debug statements in ↵Joe LaPenna2014-05-171-11/+11
|\ | | | | | | | | | | | | BluetoothSocket." into klp-modular-dev * commit '3e1bbaf786c12e66624c42c13a58095bc8133117': Log accept and close debug statements in BluetoothSocket.
| * Log accept and close debug statements in BluetoothSocket.Joe LaPenna2014-05-131-11/+11
| | | | | | | | | | | | | | Bug: 14902781 Bug: 14784262 Change-Id: Id0c2cd216244e05c218568427bda863a538b1041
| * NPE in BluetoothSocket.write()Zhihai Xu2014-01-131-13/+14
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | Make sure BluetoothSocket#connect throws on error.Sharvil Nanavati2014-05-061-0/+1
| | | | | | | | | | | | | | | | | | It sometimes fails silently, resulting in callers using the socket even though it hasn't been initialized. http://b/13909270 Change-Id: Ied08982b51d44c3d2dec72785888ea6c6497a664
* | bluetoothsocket fd leak, need close the file descriptor after detachFd.Zhihai Xu2014-01-201-2/+4
| | | | | | | | | | | | | | | | Perform ParcelFileDescriptor close after detach to avoid bluetooth socket leaks in strict mode. bug:12647433 Change-Id: I22f422547b2fb33b9bf12065dc689ed7785a7269
* | Merge "NPE in BluetoothSocket.write()"Zhihai Xu2014-01-041-13/+14
|\ \
| * | NPE in BluetoothSocket.write()Zhihai Xu2013-12-171-13/+14
| |/ | | | | | | | | | | | | | | | | | | | | | | 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
* / Remove unused imports from frameworks/base.John Spurlock2013-11-201-5/+0
|/ | | | Change-Id: Ia1f99bd2c1105b0b0f70aa614f1f4a67b2840906
* Revert "Allow L2CAP sockets"Mike Lockwood2013-10-021-3/+1
| | | | This reverts commit 008ce9e07b5e58c5ab31c5d73ec3d1ad1a6cf605.
* Allow L2CAP socketsDmitry Grinberg2013-09-061-1/+3
| | | | Change-Id: Icb498e6c0430789b6168bec3beb1d4650e4f1238