Merge "Make BluetoothUuid constants and some functions System Apis" am: f6ea5afa58 am: f9f689020c
am: 7232ba49c8
Change-Id: Ief860164e931a234ccc82417f645cee0d0be6235
This commit is contained in:
@@ -1434,6 +1434,37 @@ package android.bluetooth {
|
||||
field @Deprecated public static final int PRIORITY_ON = 100; // 0x64
|
||||
}
|
||||
|
||||
public final class BluetoothUuid {
|
||||
method public static boolean containsAnyUuid(@Nullable android.os.ParcelUuid[], @Nullable android.os.ParcelUuid[]);
|
||||
method @NonNull public static android.os.ParcelUuid parseUuidFrom(@Nullable byte[]);
|
||||
field @NonNull public static final android.os.ParcelUuid A2DP_SINK;
|
||||
field @NonNull public static final android.os.ParcelUuid A2DP_SOURCE;
|
||||
field @NonNull public static final android.os.ParcelUuid ADV_AUDIO_DIST;
|
||||
field @NonNull public static final android.os.ParcelUuid AVRCP_CONTROLLER;
|
||||
field @NonNull public static final android.os.ParcelUuid AVRCP_TARGET;
|
||||
field @NonNull public static final android.os.ParcelUuid BASE_UUID;
|
||||
field @NonNull public static final android.os.ParcelUuid BNEP;
|
||||
field @NonNull public static final android.os.ParcelUuid HEARING_AID;
|
||||
field @NonNull public static final android.os.ParcelUuid HFP;
|
||||
field @NonNull public static final android.os.ParcelUuid HFP_AG;
|
||||
field @NonNull public static final android.os.ParcelUuid HID;
|
||||
field @NonNull public static final android.os.ParcelUuid HOGP;
|
||||
field @NonNull public static final android.os.ParcelUuid HSP;
|
||||
field @NonNull public static final android.os.ParcelUuid HSP_AG;
|
||||
field @NonNull public static final android.os.ParcelUuid MAP;
|
||||
field @NonNull public static final android.os.ParcelUuid MAS;
|
||||
field @NonNull public static final android.os.ParcelUuid MNS;
|
||||
field @NonNull public static final android.os.ParcelUuid NAP;
|
||||
field @NonNull public static final android.os.ParcelUuid OBEX_OBJECT_PUSH;
|
||||
field @NonNull public static final android.os.ParcelUuid PANU;
|
||||
field @NonNull public static final android.os.ParcelUuid PBAP_PCE;
|
||||
field @NonNull public static final android.os.ParcelUuid PBAP_PSE;
|
||||
field @NonNull public static final android.os.ParcelUuid SAP;
|
||||
field public static final int UUID_BYTES_128_BIT = 16; // 0x10
|
||||
field public static final int UUID_BYTES_16_BIT = 2; // 0x2
|
||||
field public static final int UUID_BYTES_32_BIT = 4; // 0x4
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.bluetooth.le {
|
||||
|
||||
@@ -610,7 +610,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
|
||||
if (uuids == null) return false;
|
||||
|
||||
for (ParcelUuid uuid : uuids) {
|
||||
if (BluetoothUuid.isAvrcpTarget(uuid)) {
|
||||
if (uuid.equals(BluetoothUuid.AVRCP_TARGET)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
|
||||
package android.bluetooth;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.UnsupportedAppUsage;
|
||||
import android.os.Build;
|
||||
import android.os.ParcelUuid;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -31,6 +33,7 @@ import java.util.UUID;
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public final class BluetoothUuid {
|
||||
|
||||
/* See Bluetooth Assigned Numbers document - SDP section, to get the values of UUIDs
|
||||
@@ -39,167 +42,157 @@ public final class BluetoothUuid {
|
||||
* The following 128 bit values are calculated as:
|
||||
* uuid * 2^96 + BASE_UUID
|
||||
*/
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
public static final ParcelUuid AudioSink =
|
||||
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid A2DP_SINK =
|
||||
ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB");
|
||||
public static final ParcelUuid AudioSource =
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid A2DP_SOURCE =
|
||||
ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
public static final ParcelUuid AdvAudioDist =
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid ADV_AUDIO_DIST =
|
||||
ParcelUuid.fromString("0000110D-0000-1000-8000-00805F9B34FB");
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid HSP =
|
||||
ParcelUuid.fromString("00001108-0000-1000-8000-00805F9B34FB");
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid HSP_AG =
|
||||
ParcelUuid.fromString("00001112-0000-1000-8000-00805F9B34FB");
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
public static final ParcelUuid Handsfree =
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid HFP =
|
||||
ParcelUuid.fromString("0000111E-0000-1000-8000-00805F9B34FB");
|
||||
public static final ParcelUuid Handsfree_AG =
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid HFP_AG =
|
||||
ParcelUuid.fromString("0000111F-0000-1000-8000-00805F9B34FB");
|
||||
public static final ParcelUuid AvrcpController =
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid AVRCP_CONTROLLER =
|
||||
ParcelUuid.fromString("0000110E-0000-1000-8000-00805F9B34FB");
|
||||
public static final ParcelUuid AvrcpTarget =
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid AVRCP_TARGET =
|
||||
ParcelUuid.fromString("0000110C-0000-1000-8000-00805F9B34FB");
|
||||
@UnsupportedAppUsage
|
||||
public static final ParcelUuid ObexObjectPush =
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid OBEX_OBJECT_PUSH =
|
||||
ParcelUuid.fromString("00001105-0000-1000-8000-00805f9b34fb");
|
||||
public static final ParcelUuid Hid =
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid HID =
|
||||
ParcelUuid.fromString("00001124-0000-1000-8000-00805f9b34fb");
|
||||
@UnsupportedAppUsage
|
||||
public static final ParcelUuid Hogp =
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid HOGP =
|
||||
ParcelUuid.fromString("00001812-0000-1000-8000-00805f9b34fb");
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid PANU =
|
||||
ParcelUuid.fromString("00001115-0000-1000-8000-00805F9B34FB");
|
||||
@UnsupportedAppUsage
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid NAP =
|
||||
ParcelUuid.fromString("00001116-0000-1000-8000-00805F9B34FB");
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid BNEP =
|
||||
ParcelUuid.fromString("0000000f-0000-1000-8000-00805F9B34FB");
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid PBAP_PCE =
|
||||
ParcelUuid.fromString("0000112e-0000-1000-8000-00805F9B34FB");
|
||||
@UnsupportedAppUsage
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid PBAP_PSE =
|
||||
ParcelUuid.fromString("0000112f-0000-1000-8000-00805F9B34FB");
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid MAP =
|
||||
ParcelUuid.fromString("00001134-0000-1000-8000-00805F9B34FB");
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid MNS =
|
||||
ParcelUuid.fromString("00001133-0000-1000-8000-00805F9B34FB");
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid MAS =
|
||||
ParcelUuid.fromString("00001132-0000-1000-8000-00805F9B34FB");
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid SAP =
|
||||
ParcelUuid.fromString("0000112D-0000-1000-8000-00805F9B34FB");
|
||||
public static final ParcelUuid HearingAid =
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid HEARING_AID =
|
||||
ParcelUuid.fromString("0000FDF0-0000-1000-8000-00805f9b34fb");
|
||||
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static final ParcelUuid BASE_UUID =
|
||||
ParcelUuid.fromString("00000000-0000-1000-8000-00805F9B34FB");
|
||||
|
||||
/** Length of bytes for 16 bit UUID */
|
||||
public static final int UUID_BYTES_16_BIT = 2;
|
||||
/** Length of bytes for 32 bit UUID */
|
||||
public static final int UUID_BYTES_32_BIT = 4;
|
||||
/** Length of bytes for 128 bit UUID */
|
||||
public static final int UUID_BYTES_128_BIT = 16;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public static final ParcelUuid[] RESERVED_UUIDS = {
|
||||
AudioSink, AudioSource, AdvAudioDist, HSP, Handsfree, AvrcpController, AvrcpTarget,
|
||||
ObexObjectPush, PANU, NAP, MAP, MNS, MAS, SAP};
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public static boolean isAudioSource(ParcelUuid uuid) {
|
||||
return uuid.equals(AudioSource);
|
||||
}
|
||||
|
||||
public static boolean isAudioSink(ParcelUuid uuid) {
|
||||
return uuid.equals(AudioSink);
|
||||
}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public static boolean isAdvAudioDist(ParcelUuid uuid) {
|
||||
return uuid.equals(AdvAudioDist);
|
||||
}
|
||||
|
||||
public static boolean isHandsfree(ParcelUuid uuid) {
|
||||
return uuid.equals(Handsfree);
|
||||
}
|
||||
|
||||
public static boolean isHeadset(ParcelUuid uuid) {
|
||||
return uuid.equals(HSP);
|
||||
}
|
||||
|
||||
public static boolean isAvrcpController(ParcelUuid uuid) {
|
||||
return uuid.equals(AvrcpController);
|
||||
}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public static boolean isAvrcpTarget(ParcelUuid uuid) {
|
||||
return uuid.equals(AvrcpTarget);
|
||||
}
|
||||
|
||||
public static boolean isInputDevice(ParcelUuid uuid) {
|
||||
return uuid.equals(Hid);
|
||||
}
|
||||
|
||||
public static boolean isPanu(ParcelUuid uuid) {
|
||||
return uuid.equals(PANU);
|
||||
}
|
||||
|
||||
public static boolean isNap(ParcelUuid uuid) {
|
||||
return uuid.equals(NAP);
|
||||
}
|
||||
|
||||
public static boolean isBnep(ParcelUuid uuid) {
|
||||
return uuid.equals(BNEP);
|
||||
}
|
||||
|
||||
public static boolean isMap(ParcelUuid uuid) {
|
||||
return uuid.equals(MAP);
|
||||
}
|
||||
|
||||
public static boolean isMns(ParcelUuid uuid) {
|
||||
return uuid.equals(MNS);
|
||||
}
|
||||
|
||||
public static boolean isMas(ParcelUuid uuid) {
|
||||
return uuid.equals(MAS);
|
||||
}
|
||||
|
||||
public static boolean isSap(ParcelUuid uuid) {
|
||||
return uuid.equals(SAP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if ParcelUuid is present in uuidArray
|
||||
* Length of bytes for 16 bit UUID
|
||||
*
|
||||
* @param uuidArray - Array of ParcelUuids
|
||||
* @param uuid
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public static boolean isUuidPresent(ParcelUuid[] uuidArray, ParcelUuid uuid) {
|
||||
if ((uuidArray == null || uuidArray.length == 0) && uuid == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (uuidArray == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ParcelUuid element : uuidArray) {
|
||||
if (element.equals(uuid)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@SystemApi
|
||||
public static final int UUID_BYTES_16_BIT = 2;
|
||||
/**
|
||||
* Length of bytes for 32 bit UUID
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final int UUID_BYTES_32_BIT = 4;
|
||||
/**
|
||||
* Length of bytes for 128 bit UUID
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final int UUID_BYTES_128_BIT = 16;
|
||||
|
||||
/**
|
||||
* Returns true if there any common ParcelUuids in uuidA and uuidB.
|
||||
*
|
||||
* @param uuidA - List of ParcelUuids
|
||||
* @param uuidB - List of ParcelUuids
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public static boolean containsAnyUuid(ParcelUuid[] uuidA, ParcelUuid[] uuidB) {
|
||||
@SystemApi
|
||||
public static boolean containsAnyUuid(@Nullable ParcelUuid[] uuidA,
|
||||
@Nullable ParcelUuid[] uuidB) {
|
||||
if (uuidA == null && uuidB == null) return true;
|
||||
|
||||
if (uuidA == null) {
|
||||
@@ -217,29 +210,6 @@ public final class BluetoothUuid {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if all the ParcelUuids in ParcelUuidB are present in
|
||||
* ParcelUuidA
|
||||
*
|
||||
* @param uuidA - Array of ParcelUuidsA
|
||||
* @param uuidB - Array of ParcelUuidsB
|
||||
*/
|
||||
public static boolean containsAllUuids(ParcelUuid[] uuidA, ParcelUuid[] uuidB) {
|
||||
if (uuidA == null && uuidB == null) return true;
|
||||
|
||||
if (uuidA == null) {
|
||||
return uuidB.length == 0;
|
||||
}
|
||||
|
||||
if (uuidB == null) return true;
|
||||
|
||||
HashSet<ParcelUuid> uuidSet = new HashSet<ParcelUuid>(Arrays.asList(uuidA));
|
||||
for (ParcelUuid uuid : uuidB) {
|
||||
if (!uuidSet.contains(uuid)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the Service Identifier or the actual uuid from the Parcel Uuid.
|
||||
* For example, if 0000110B-0000-1000-8000-00805F9B34FB is the parcel Uuid,
|
||||
@@ -248,7 +218,7 @@ public final class BluetoothUuid {
|
||||
* @param parcelUuid
|
||||
* @return the service identifier.
|
||||
*/
|
||||
public static int getServiceIdentifierFromParcelUuid(ParcelUuid parcelUuid) {
|
||||
private static int getServiceIdentifierFromParcelUuid(ParcelUuid parcelUuid) {
|
||||
UUID uuid = parcelUuid.getUuid();
|
||||
long value = (uuid.getMostSignificantBits() & 0xFFFFFFFF00000000L) >>> 32;
|
||||
return (int) value;
|
||||
@@ -262,8 +232,12 @@ public final class BluetoothUuid {
|
||||
* @param uuidBytes Byte representation of uuid.
|
||||
* @return {@link ParcelUuid} parsed from bytes.
|
||||
* @throws IllegalArgumentException If the {@code uuidBytes} cannot be parsed.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static ParcelUuid parseUuidFrom(byte[] uuidBytes) {
|
||||
@NonNull
|
||||
@SystemApi
|
||||
public static ParcelUuid parseUuidFrom(@Nullable byte[] uuidBytes) {
|
||||
if (uuidBytes == null) {
|
||||
throw new IllegalArgumentException("uuidBytes cannot be null");
|
||||
}
|
||||
@@ -305,6 +279,8 @@ public final class BluetoothUuid {
|
||||
* @param uuid uuid to parse.
|
||||
* @return shortest representation of {@code uuid} as bytes.
|
||||
* @throws IllegalArgumentException If the {@code uuid} is null.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static byte[] uuidToBytes(ParcelUuid uuid) {
|
||||
if (uuid == null) {
|
||||
@@ -345,6 +321,8 @@ public final class BluetoothUuid {
|
||||
*
|
||||
* @param parcelUuid
|
||||
* @return true if the parcelUuid can be converted to 16 bit uuid, false otherwise.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public static boolean is16BitUuid(ParcelUuid parcelUuid) {
|
||||
@@ -361,6 +339,8 @@ public final class BluetoothUuid {
|
||||
*
|
||||
* @param parcelUuid
|
||||
* @return true if the parcelUuid can be converted to 32 bit uuid, false otherwise.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public static boolean is32BitUuid(ParcelUuid parcelUuid) {
|
||||
@@ -373,4 +353,6 @@ public final class BluetoothUuid {
|
||||
}
|
||||
return ((uuid.getMostSignificantBits() & 0xFFFFFFFFL) == 0x1000L);
|
||||
}
|
||||
|
||||
private BluetoothUuid() {}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ public class A2dpProfile implements LocalBluetoothProfile {
|
||||
private final CachedBluetoothDeviceManager mDeviceManager;
|
||||
|
||||
static final ParcelUuid[] SINK_UUIDS = {
|
||||
BluetoothUuid.AudioSink,
|
||||
BluetoothUuid.AdvAudioDist,
|
||||
BluetoothUuid.A2DP_SINK,
|
||||
BluetoothUuid.ADV_AUDIO_DIST,
|
||||
};
|
||||
|
||||
static final String NAME = "A2DP";
|
||||
|
||||
@@ -40,8 +40,8 @@ final class A2dpSinkProfile implements LocalBluetoothProfile {
|
||||
private final CachedBluetoothDeviceManager mDeviceManager;
|
||||
|
||||
static final ParcelUuid[] SRC_UUIDS = {
|
||||
BluetoothUuid.AudioSource,
|
||||
BluetoothUuid.AdvAudioDist,
|
||||
BluetoothUuid.A2DP_SOURCE,
|
||||
BluetoothUuid.ADV_AUDIO_DIST,
|
||||
};
|
||||
|
||||
static final String NAME = "A2DPSink";
|
||||
|
||||
@@ -22,6 +22,8 @@ import android.bluetooth.BluetoothUuid;
|
||||
import android.os.ParcelUuid;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
|
||||
/**
|
||||
* BluetoothDeviceFilter contains a static method that returns a
|
||||
* Filter object that returns whether or not the BluetoothDevice
|
||||
@@ -130,7 +132,7 @@ public final class BluetoothDeviceFilter {
|
||||
@Override
|
||||
boolean matches(ParcelUuid[] uuids, BluetoothClass btClass) {
|
||||
if (uuids != null) {
|
||||
if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.ObexObjectPush)) {
|
||||
if (ArrayUtils.contains(uuids, BluetoothUuid.OBEX_OBJECT_PUSH)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -144,7 +146,7 @@ public final class BluetoothDeviceFilter {
|
||||
@Override
|
||||
boolean matches(ParcelUuid[] uuids, BluetoothClass btClass) {
|
||||
if (uuids != null) {
|
||||
if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.PANU)) {
|
||||
if (ArrayUtils.contains(uuids, BluetoothUuid.PANU)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -158,7 +160,7 @@ public final class BluetoothDeviceFilter {
|
||||
@Override
|
||||
boolean matches(ParcelUuid[] uuids, BluetoothClass btClass) {
|
||||
if (uuids != null) {
|
||||
if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.NAP)) {
|
||||
if (ArrayUtils.contains(uuids, BluetoothUuid.NAP)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.settingslib.R;
|
||||
import com.android.settingslib.Utils;
|
||||
|
||||
@@ -685,9 +686,9 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
||||
ParcelUuid[] uuids = mDevice.getUuids();
|
||||
|
||||
long timeout = MAX_UUID_DELAY_FOR_AUTO_CONNECT;
|
||||
if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Hogp)) {
|
||||
if (ArrayUtils.contains(uuids, BluetoothUuid.HOGP)) {
|
||||
timeout = MAX_HOGP_DELAY_FOR_AUTO_CONNECT;
|
||||
} else if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.HearingAid)) {
|
||||
} else if (ArrayUtils.contains(uuids, BluetoothUuid.HEARING_AID)) {
|
||||
timeout = MAX_HEARING_AIDS_DELAY_FOR_AUTO_CONNECT;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class HeadsetProfile implements LocalBluetoothProfile {
|
||||
|
||||
static final ParcelUuid[] UUIDS = {
|
||||
BluetoothUuid.HSP,
|
||||
BluetoothUuid.Handsfree,
|
||||
BluetoothUuid.HFP,
|
||||
};
|
||||
|
||||
static final String NAME = "HEADSET";
|
||||
|
||||
@@ -44,7 +44,7 @@ final class HfpClientProfile implements LocalBluetoothProfile {
|
||||
|
||||
static final ParcelUuid[] SRC_UUIDS = {
|
||||
BluetoothUuid.HSP_AG,
|
||||
BluetoothUuid.Handsfree_AG,
|
||||
BluetoothUuid.HFP_AG,
|
||||
};
|
||||
|
||||
static final String NAME = "HEADSET_CLIENT";
|
||||
|
||||
@@ -30,8 +30,8 @@ import android.bluetooth.BluetoothMapClient;
|
||||
import android.bluetooth.BluetoothPan;
|
||||
import android.bluetooth.BluetoothPbap;
|
||||
import android.bluetooth.BluetoothPbapClient;
|
||||
import android.bluetooth.BluetoothSap;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.bluetooth.BluetoothSap;
|
||||
import android.bluetooth.BluetoothUuid;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -40,6 +40,7 @@ import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.internal.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -471,43 +472,40 @@ public class LocalBluetoothProfileManager {
|
||||
}
|
||||
|
||||
if (mHeadsetProfile != null) {
|
||||
if ((BluetoothUuid.isUuidPresent(localUuids, BluetoothUuid.HSP_AG) &&
|
||||
BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.HSP)) ||
|
||||
(BluetoothUuid.isUuidPresent(localUuids, BluetoothUuid.Handsfree_AG) &&
|
||||
BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Handsfree))) {
|
||||
if ((ArrayUtils.contains(localUuids, BluetoothUuid.HSP_AG)
|
||||
&& ArrayUtils.contains(uuids, BluetoothUuid.HSP))
|
||||
|| (ArrayUtils.contains(localUuids, BluetoothUuid.HFP_AG)
|
||||
&& ArrayUtils.contains(uuids, BluetoothUuid.HFP))) {
|
||||
profiles.add(mHeadsetProfile);
|
||||
removedProfiles.remove(mHeadsetProfile);
|
||||
}
|
||||
}
|
||||
|
||||
if ((mHfpClientProfile != null) &&
|
||||
BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Handsfree_AG) &&
|
||||
BluetoothUuid.isUuidPresent(localUuids, BluetoothUuid.Handsfree)) {
|
||||
ArrayUtils.contains(uuids, BluetoothUuid.HFP_AG)
|
||||
&& ArrayUtils.contains(localUuids, BluetoothUuid.HFP)) {
|
||||
profiles.add(mHfpClientProfile);
|
||||
removedProfiles.remove(mHfpClientProfile);
|
||||
}
|
||||
|
||||
if (BluetoothUuid.containsAnyUuid(uuids, A2dpProfile.SINK_UUIDS) &&
|
||||
mA2dpProfile != null) {
|
||||
if (BluetoothUuid.containsAnyUuid(uuids, A2dpProfile.SINK_UUIDS) && mA2dpProfile != null) {
|
||||
profiles.add(mA2dpProfile);
|
||||
removedProfiles.remove(mA2dpProfile);
|
||||
}
|
||||
|
||||
if (BluetoothUuid.containsAnyUuid(uuids, A2dpSinkProfile.SRC_UUIDS) &&
|
||||
mA2dpSinkProfile != null) {
|
||||
if (BluetoothUuid.containsAnyUuid(uuids, A2dpSinkProfile.SRC_UUIDS)
|
||||
&& mA2dpSinkProfile != null) {
|
||||
profiles.add(mA2dpSinkProfile);
|
||||
removedProfiles.remove(mA2dpSinkProfile);
|
||||
}
|
||||
|
||||
if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.ObexObjectPush) &&
|
||||
mOppProfile != null) {
|
||||
if (ArrayUtils.contains(uuids, BluetoothUuid.OBEX_OBJECT_PUSH) && mOppProfile != null) {
|
||||
profiles.add(mOppProfile);
|
||||
removedProfiles.remove(mOppProfile);
|
||||
}
|
||||
|
||||
if ((BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Hid) ||
|
||||
BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Hogp)) &&
|
||||
mHidProfile != null) {
|
||||
if ((ArrayUtils.contains(uuids, BluetoothUuid.HID)
|
||||
|| ArrayUtils.contains(uuids, BluetoothUuid.HOGP)) && mHidProfile != null) {
|
||||
profiles.add(mHidProfile);
|
||||
removedProfiles.remove(mHidProfile);
|
||||
}
|
||||
@@ -520,8 +518,8 @@ public class LocalBluetoothProfileManager {
|
||||
|
||||
if(isPanNapConnected)
|
||||
if(DEBUG) Log.d(TAG, "Valid PAN-NAP connection exists.");
|
||||
if ((BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.NAP) &&
|
||||
mPanProfile != null) || isPanNapConnected) {
|
||||
if ((ArrayUtils.contains(uuids, BluetoothUuid.NAP) && mPanProfile != null)
|
||||
|| isPanNapConnected) {
|
||||
profiles.add(mPanProfile);
|
||||
removedProfiles.remove(mPanProfile);
|
||||
}
|
||||
@@ -545,20 +543,18 @@ public class LocalBluetoothProfileManager {
|
||||
removedProfiles.remove(mMapClientProfile);
|
||||
}
|
||||
|
||||
if ((mPbapClientProfile != null) &&
|
||||
BluetoothUuid.isUuidPresent(localUuids, BluetoothUuid.PBAP_PCE) &&
|
||||
BluetoothUuid.containsAnyUuid(uuids, PbapClientProfile.SRC_UUIDS)) {
|
||||
if ((mPbapClientProfile != null) && ArrayUtils.contains(localUuids, BluetoothUuid.PBAP_PCE)
|
||||
&& BluetoothUuid.containsAnyUuid(uuids, PbapClientProfile.SRC_UUIDS)) {
|
||||
profiles.add(mPbapClientProfile);
|
||||
removedProfiles.remove(mPbapClientProfile);
|
||||
}
|
||||
|
||||
if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.HearingAid) &&
|
||||
mHearingAidProfile != null) {
|
||||
if (ArrayUtils.contains(uuids, BluetoothUuid.HEARING_AID) && mHearingAidProfile != null) {
|
||||
profiles.add(mHearingAidProfile);
|
||||
removedProfiles.remove(mHearingAidProfile);
|
||||
}
|
||||
|
||||
if (mSapProfile != null && BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.SAP)) {
|
||||
if (mSapProfile != null && ArrayUtils.contains(uuids, BluetoothUuid.SAP)) {
|
||||
profiles.add(mSapProfile);
|
||||
removedProfiles.remove(mSapProfile);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class PbapServerProfile implements LocalBluetoothProfile {
|
||||
// The UUIDs indicate that remote device might access pbap server
|
||||
static final ParcelUuid[] PBAB_CLIENT_UUIDS = {
|
||||
BluetoothUuid.HSP,
|
||||
BluetoothUuid.Handsfree,
|
||||
BluetoothUuid.HFP,
|
||||
BluetoothUuid.PBAP_PCE
|
||||
};
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ public class LocalBluetoothProfileManagerTest {
|
||||
mShadowBluetoothAdapter.setSupportedProfiles(generateList(
|
||||
new int[] {BluetoothProfile.HID_HOST}));
|
||||
mProfileManager.updateLocalProfiles();
|
||||
ParcelUuid[] uuids = new ParcelUuid[]{BluetoothUuid.Hid};
|
||||
ParcelUuid[] uuids = new ParcelUuid[]{BluetoothUuid.HID};
|
||||
ParcelUuid[] localUuids = new ParcelUuid[]{};
|
||||
List<LocalBluetoothProfile> profiles = new ArrayList<>();
|
||||
List<LocalBluetoothProfile> removedProfiles = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user