Skip to content

Commit ad23210

Browse files
author
Matthew Xie
committed
Make public APIs of ACTION_UUID, EXTRA_UUID, getUuids, and fetchUuidsWithSdp
Give APP a way to find out if a service is supported by a remote device bug 5487202 Change-Id: I5a2d050cf24d945e1c9875963c34177ed1ce773a
1 parent 604019c commit ad23210

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

api/current.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4474,10 +4474,12 @@ package android.bluetooth {
44744474
method public android.bluetooth.BluetoothSocket createInsecureRfcommSocketToServiceRecord(java.util.UUID) throws java.io.IOException;
44754475
method public android.bluetooth.BluetoothSocket createRfcommSocketToServiceRecord(java.util.UUID) throws java.io.IOException;
44764476
method public int describeContents();
4477+
method public boolean fetchUuidsWithSdp();
44774478
method public java.lang.String getAddress();
44784479
method public android.bluetooth.BluetoothClass getBluetoothClass();
44794480
method public int getBondState();
44804481
method public java.lang.String getName();
4482+
method public android.os.ParcelUuid[] getUuids();
44814483
method public void writeToParcel(android.os.Parcel, int);
44824484
field public static final java.lang.String ACTION_ACL_CONNECTED = "android.bluetooth.device.action.ACL_CONNECTED";
44834485
field public static final java.lang.String ACTION_ACL_DISCONNECTED = "android.bluetooth.device.action.ACL_DISCONNECTED";
@@ -4486,6 +4488,7 @@ package android.bluetooth {
44864488
field public static final java.lang.String ACTION_CLASS_CHANGED = "android.bluetooth.device.action.CLASS_CHANGED";
44874489
field public static final java.lang.String ACTION_FOUND = "android.bluetooth.device.action.FOUND";
44884490
field public static final java.lang.String ACTION_NAME_CHANGED = "android.bluetooth.device.action.NAME_CHANGED";
4491+
field public static final java.lang.String ACTION_UUID = "android.bluetooth.device.action.UUID";
44894492
field public static final int BOND_BONDED = 12; // 0xc
44904493
field public static final int BOND_BONDING = 11; // 0xb
44914494
field public static final int BOND_NONE = 10; // 0xa
@@ -4497,6 +4500,7 @@ package android.bluetooth {
44974500
field public static final java.lang.String EXTRA_NAME = "android.bluetooth.device.extra.NAME";
44984501
field public static final java.lang.String EXTRA_PREVIOUS_BOND_STATE = "android.bluetooth.device.extra.PREVIOUS_BOND_STATE";
44994502
field public static final java.lang.String EXTRA_RSSI = "android.bluetooth.device.extra.RSSI";
4503+
field public static final java.lang.String EXTRA_UUID = "android.bluetooth.device.extra.UUID";
45004504
}
45014505

45024506
public final class BluetoothHeadset implements android.bluetooth.BluetoothProfile {

core/java/android/bluetooth/BluetoothDevice.java

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,12 @@ public final class BluetoothDevice implements Parcelable {
247247
* has been fetched. This intent is sent only when the UUIDs of the remote
248248
* device are requested to be fetched using Service Discovery Protocol
249249
* <p> Always contains the extra field {@link #EXTRA_DEVICE}
250-
* <p> Always contains the extra filed {@link #EXTRA_UUID}
250+
* <p> Always contains the extra field {@link #EXTRA_UUID}
251251
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
252-
* @hide
253252
*/
254253
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
255254
public static final String ACTION_UUID =
256-
"android.bleutooth.device.action.UUID";
255+
"android.bluetooth.device.action.UUID";
257256

258257
/**
259258
* Broadcast Action: Indicates a failure to retrieve the name of a remote
@@ -451,7 +450,6 @@ public final class BluetoothDevice implements Parcelable {
451450
* Used as an extra field in {@link #ACTION_UUID} intents,
452451
* Contains the {@link android.os.ParcelUuid}s of the remote device which
453452
* is a parcelable version of {@link UUID}.
454-
* @hide
455453
*/
456454
public static final String EXTRA_UUID = "android.bluetooth.device.extra.UUID";
457455

@@ -770,7 +768,18 @@ public boolean setTrust(boolean value) {
770768
return false;
771769
}
772770

773-
/** @hide */
771+
/**
772+
* Returns the supported features (UUIDs) of the remote device.
773+
*
774+
* <p>This method does not start a service discovery procedure to retrieve the UUIDs
775+
* from the remote device. Instead, the local cached copy of the service
776+
* UUIDs are returned.
777+
* <p>Use {@link #fetchUuidsWithSdp} if fresh UUIDs are desired.
778+
* <p>Requires {@link android.Manifest.permission#BLUETOOTH}.
779+
*
780+
* @return the supported features (UUIDs) of the remote device,
781+
* or null on error
782+
*/
774783
public ParcelUuid[] getUuids() {
775784
try {
776785
return sService.getRemoteUuids(mAddress);
@@ -779,18 +788,19 @@ public ParcelUuid[] getUuids() {
779788
}
780789

781790
/**
782-
* Perform a SDP query on the remote device to get the UUIDs
783-
* supported. This API is asynchronous and an Intent is sent,
784-
* with the UUIDs supported by the remote end. If there is an error
785-
* in getting the SDP records or if the process takes a long time,
786-
* an Intent is sent with the UUIDs that is currently present in the
787-
* cache. Clients should use the {@link #getUuids} to get UUIDs
788-
* is SDP is not to be performed.
791+
* Perform a service discovery on the remote device to get the UUIDs supported.
792+
*
793+
* <p>This API is asynchronous and {@link #ACTION_UUID} intent is sent,
794+
* with the UUIDs supported by the remote end. If there is an error
795+
* in getting the SDP records or if the process takes a long time,
796+
* {@link #ACTION_UUID} intent is sent with the UUIDs that is currently
797+
* present in the cache. Clients should use the {@link #getUuids} to get UUIDs
798+
* if service discovery is not to be performed.
799+
* <p>Requires {@link android.Manifest.permission#BLUETOOTH}.
789800
*
790-
* @return False if the sanity check fails, True if the process
801+
* @return False if the sanity check fails, True if the process
791802
* of initiating an ACL connection to the remote device
792803
* was started.
793-
* @hide
794804
*/
795805
public boolean fetchUuidsWithSdp() {
796806
try {

0 commit comments

Comments
 (0)