summaryrefslogtreecommitdiff
path: root/core/java/android/bluetooth
diff options
context:
space:
mode:
authorAlice Kuo <aliceypkuo@google.com>2021-08-13 00:17:17 +0800
committerAlice Kuo <aliceypkuo@google.com>2021-08-20 16:26:24 +0000
commit21ff734712d7a9de84103af0e5daa4e487418a01 (patch)
treebcd05d748c26e77e2f523d3c84d6d3cb722949ea /core/java/android/bluetooth
parentb2cb2c799468a9bb4a79a801a7a98953122826ac (diff)
Add a system api to fetch uuids by the specific transport
The functionality is similar with fetchUuidsWithSdp which uses TRANSPORT_AUTO. Bt stack depends on the devie type and address type to do sdp or gatt service discovery. Add an api to specific the transport. It would be fexible to handle the dual mode device. Ignore-AOSP-First: avoid merge conflict Tag: #feature Bug: 194447999 Test: atest BluetoothInstrumentationTests Test: Take two headphone to test the dual mode behavior Change-Id: I32c8dde68969e0bdc42e4e898c43a4f2c1d3379a Merged-In: I32c8dde68969e0bdc42e4e898c43a4f2c1d3379a
Diffstat (limited to 'core/java/android/bluetooth')
-rw-r--r--core/java/android/bluetooth/BluetoothDevice.java30
1 files changed, 29 insertions, 1 deletions
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java
index f68a8b28e9df..12211485cc07 100644
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -1791,13 +1791,41 @@ public final class BluetoothDevice implements Parcelable, Attributable {
@RequiresBluetoothConnectPermission
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
public boolean fetchUuidsWithSdp() {
+ return fetchUuidsWithSdp(TRANSPORT_AUTO);
+ }
+
+ /**
+ * Perform a service discovery on the remote device to get the UUIDs supported with the
+ * specific transport.
+ *
+ * <p>This API is asynchronous and {@link #ACTION_UUID} intent is sent,
+ * with the UUIDs supported by the remote end. If there is an error
+ * in getting the SDP or GATT records or if the process takes a long time, or the device
+ * is bonding and we have its UUIDs cached, {@link #ACTION_UUID} intent is sent with the
+ * UUIDs that is currently present in the cache. Clients should use the {@link #getUuids}
+ * to get UUIDs if service discovery is not to be performed. If there is an ongoing bonding
+ * process, service discovery or device inquiry, the request will be queued.
+ *
+ * @param transport - provide type of transport (e.g. LE or Classic).
+ * @return False if the check fails, True if the process of initiating an ACL connection
+ * to the remote device was started or cached UUIDs will be broadcast with the specific
+ * transport.
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.BLUETOOTH_CONNECT,
+ android.Manifest.permission.BLUETOOTH_PRIVILEGED,
+ })
+ public boolean fetchUuidsWithSdp(@Transport int transport) {
final IBluetooth service = sService;
if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot fetchUuidsWithSdp");
return false;
}
try {
- return service.fetchRemoteUuidsWithAttribution(this, mAttributionSource);
+ return service.fetchRemoteUuidsWithAttribution(this, transport, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, "", e);
}