Merge "csip: Expose an extra data with intent and store in CachedBluetoothDevice" into stage-aosp-master
This commit is contained in:
@@ -9076,6 +9076,7 @@ package android.bluetooth {
|
|||||||
field public static final String EXTRA_BOND_STATE = "android.bluetooth.device.extra.BOND_STATE";
|
field public static final String EXTRA_BOND_STATE = "android.bluetooth.device.extra.BOND_STATE";
|
||||||
field public static final String EXTRA_CLASS = "android.bluetooth.device.extra.CLASS";
|
field public static final String EXTRA_CLASS = "android.bluetooth.device.extra.CLASS";
|
||||||
field public static final String EXTRA_DEVICE = "android.bluetooth.device.extra.DEVICE";
|
field public static final String EXTRA_DEVICE = "android.bluetooth.device.extra.DEVICE";
|
||||||
|
field public static final String EXTRA_IS_COORDINATED_SET_MEMBER = "android.bluetooth.extra.IS_COORDINATED_SET_MEMBER";
|
||||||
field public static final String EXTRA_NAME = "android.bluetooth.device.extra.NAME";
|
field public static final String EXTRA_NAME = "android.bluetooth.device.extra.NAME";
|
||||||
field public static final String EXTRA_PAIRING_KEY = "android.bluetooth.device.extra.PAIRING_KEY";
|
field public static final String EXTRA_PAIRING_KEY = "android.bluetooth.device.extra.PAIRING_KEY";
|
||||||
field public static final String EXTRA_PAIRING_VARIANT = "android.bluetooth.device.extra.PAIRING_VARIANT";
|
field public static final String EXTRA_PAIRING_VARIANT = "android.bluetooth.device.extra.PAIRING_VARIANT";
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
|
|||||||
* <p>Sent when a remote device is found during discovery.
|
* <p>Sent when a remote device is found during discovery.
|
||||||
* <p>Always contains the extra fields {@link #EXTRA_DEVICE} and {@link
|
* <p>Always contains the extra fields {@link #EXTRA_DEVICE} and {@link
|
||||||
* #EXTRA_CLASS}. Can contain the extra fields {@link #EXTRA_NAME} and/or
|
* #EXTRA_CLASS}. Can contain the extra fields {@link #EXTRA_NAME} and/or
|
||||||
* {@link #EXTRA_RSSI} if they are available.
|
* {@link #EXTRA_RSSI} and/or {@link #EXTRA_IS_COORDINATED_SET_MEMBER} if they are available.
|
||||||
*/
|
*/
|
||||||
// TODO: Change API to not broadcast RSSI if not available (incoming connection)
|
// TODO: Change API to not broadcast RSSI if not available (incoming connection)
|
||||||
@RequiresLegacyBluetoothPermission
|
@RequiresLegacyBluetoothPermission
|
||||||
@@ -278,6 +278,15 @@ public final class BluetoothDevice implements Parcelable, Attributable {
|
|||||||
*/
|
*/
|
||||||
public static final String EXTRA_RSSI = "android.bluetooth.device.extra.RSSI";
|
public static final String EXTRA_RSSI = "android.bluetooth.device.extra.RSSI";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used as an bool extra field in {@link #ACTION_FOUND} intents.
|
||||||
|
* It contains the information if device is discovered as member of a coordinated set or not.
|
||||||
|
* Pairing with device that belongs to a set would trigger pairing with the rest of set members.
|
||||||
|
* See Bluetooth CSIP specification for more details.
|
||||||
|
*/
|
||||||
|
public static final String EXTRA_IS_COORDINATED_SET_MEMBER =
|
||||||
|
"android.bluetooth.extra.IS_COORDINATED_SET_MEMBER";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used as a Parcelable {@link BluetoothClass} extra field in {@link
|
* Used as a Parcelable {@link BluetoothClass} extra field in {@link
|
||||||
* #ACTION_FOUND} and {@link #ACTION_CLASS_CHANGED} intents.
|
* #ACTION_FOUND} and {@link #ACTION_CLASS_CHANGED} intents.
|
||||||
|
|||||||
@@ -294,6 +294,8 @@ public class BluetoothEventManager {
|
|||||||
BluetoothDevice device) {
|
BluetoothDevice device) {
|
||||||
short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, Short.MIN_VALUE);
|
short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, Short.MIN_VALUE);
|
||||||
String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
|
String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
|
||||||
|
final boolean isCoordinatedSetMember =
|
||||||
|
intent.getBooleanExtra(BluetoothDevice.EXTRA_IS_COORDINATED_SET_MEMBER, false);
|
||||||
// TODO Pick up UUID. They should be available for 2.1 devices.
|
// TODO Pick up UUID. They should be available for 2.1 devices.
|
||||||
// Skip for now, there's a bluez problem and we are not getting uuids even for 2.1.
|
// Skip for now, there's a bluez problem and we are not getting uuids even for 2.1.
|
||||||
CachedBluetoothDevice cachedDevice = mDeviceManager.findDevice(device);
|
CachedBluetoothDevice cachedDevice = mDeviceManager.findDevice(device);
|
||||||
@@ -308,6 +310,7 @@ public class BluetoothEventManager {
|
|||||||
}
|
}
|
||||||
cachedDevice.setRssi(rssi);
|
cachedDevice.setRssi(rssi);
|
||||||
cachedDevice.setJustDiscovered(true);
|
cachedDevice.setJustDiscovered(true);
|
||||||
|
cachedDevice.setIsCoordinatedSetMember(isCoordinatedSetMember);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
|||||||
|
|
||||||
boolean mJustDiscovered;
|
boolean mJustDiscovered;
|
||||||
|
|
||||||
|
boolean mIsCoordinatedSetMember = false;
|
||||||
|
|
||||||
private final Collection<Callback> mCallbacks = new CopyOnWriteArrayList<>();
|
private final Collection<Callback> mCallbacks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -320,6 +322,24 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
|||||||
return mHiSyncId != BluetoothHearingAid.HI_SYNC_ID_INVALID;
|
return mHiSyncId != BluetoothHearingAid.HI_SYNC_ID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark the discovered device as member of coordinated set.
|
||||||
|
*
|
||||||
|
* @param isCoordinatedSetMember {@code true}, if the device is a member of a coordinated set.
|
||||||
|
*/
|
||||||
|
public void setIsCoordinatedSetMember(boolean isCoordinatedSetMember) {
|
||||||
|
mIsCoordinatedSetMember = isCoordinatedSetMember;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the device is a CSIP member device.
|
||||||
|
*
|
||||||
|
* @return {@code true}, if this device supports CSIP, otherwise returns {@code false}.
|
||||||
|
*/
|
||||||
|
public boolean isCoordinatedSetMemberDevice() {
|
||||||
|
return mIsCoordinatedSetMember;
|
||||||
|
}
|
||||||
|
|
||||||
void onBondingDockConnect() {
|
void onBondingDockConnect() {
|
||||||
// Attempt to connect if UUIDs are available. Otherwise,
|
// Attempt to connect if UUIDs are available. Otherwise,
|
||||||
// we will connect when the ACTION_UUID intent arrives.
|
// we will connect when the ACTION_UUID intent arrives.
|
||||||
|
|||||||
Reference in New Issue
Block a user