summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author MichaƂ Narajowski <narajn@google.com> 2023-05-19 21:35:07 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2023-05-19 21:35:07 +0000
commit34fdce41c4afd0b5cb8181fa41d91c4ee463b411 (patch)
treef064f300cf4e54e8fa6e4bed84ec052e180f4cd0
parent31cfd46053ade18e6fb21a1c0722456793fba6f2 (diff)
parente9eb7945485a67fb191805ccf19d5f75313db2ef (diff)
Merge "bt: Fix displaying late bond device name" into udc-dev am: 0c903d88d3 am: dbdfcf7a46 am: e9eb794548
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23348520 Change-Id: I487f427ef1ad4f598a789bb8e85cfa39ce24076c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
index 0db88af92a56..0c1b793102bf 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
@@ -51,6 +51,7 @@ public class CachedBluetoothDeviceManager {
CsipDeviceManager mCsipDeviceManager;
BluetoothDevice mOngoingSetMemberPair;
boolean mIsLateBonding;
+ int mGroupIdOfLateBonding;
public CachedBluetoothDeviceManager(Context context, LocalBluetoothManager localBtManager) {
mContext = context;
@@ -213,6 +214,14 @@ public class CachedBluetoothDeviceManager {
* @return The name, or if unavailable, the address.
*/
public String getName(BluetoothDevice device) {
+ if (isOngoingPairByCsip(device)) {
+ CachedBluetoothDevice firstDevice =
+ mCsipDeviceManager.getFirstMemberDevice(mGroupIdOfLateBonding);
+ if (firstDevice != null && firstDevice.getName() != null) {
+ return firstDevice.getName();
+ }
+ }
+
CachedBluetoothDevice cachedDevice = findDevice(device);
if (cachedDevice != null && cachedDevice.getName() != null) {
return cachedDevice.getName();
@@ -314,6 +323,7 @@ public class CachedBluetoothDeviceManager {
// To clear the SetMemberPair flag when the Bluetooth is turning off.
mOngoingSetMemberPair = null;
mIsLateBonding = false;
+ mGroupIdOfLateBonding = BluetoothCsipSetCoordinator.GROUP_ID_INVALID;
}
}
@@ -426,6 +436,7 @@ public class CachedBluetoothDeviceManager {
return false;
}
+ Log.d(TAG, "isLateBonding: " + mIsLateBonding);
return mIsLateBonding;
}
@@ -444,11 +455,13 @@ public class CachedBluetoothDeviceManager {
Log.d(TAG, "Bond " + device.getAnonymizedAddress() + " groupId=" + groupId + " by CSIP ");
mOngoingSetMemberPair = device;
mIsLateBonding = checkLateBonding(groupId);
+ mGroupIdOfLateBonding = groupId;
syncConfigFromMainDevice(device, groupId);
if (!device.createBond(BluetoothDevice.TRANSPORT_LE)) {
Log.d(TAG, "Bonding could not be started");
mOngoingSetMemberPair = null;
mIsLateBonding = false;
+ mGroupIdOfLateBonding = BluetoothCsipSetCoordinator.GROUP_ID_INVALID;
}
}
@@ -494,6 +507,7 @@ public class CachedBluetoothDeviceManager {
mOngoingSetMemberPair = null;
mIsLateBonding = false;
+ mGroupIdOfLateBonding = BluetoothCsipSetCoordinator.GROUP_ID_INVALID;
if (bondState != BluetoothDevice.BOND_NONE) {
if (findDevice(device) == null) {
final LocalBluetoothProfileManager profileManager = mBtManager.getProfileManager();