Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java +14 −0 Original line number Original line Diff line number Diff line Loading @@ -51,6 +51,7 @@ public class CachedBluetoothDeviceManager { CsipDeviceManager mCsipDeviceManager; CsipDeviceManager mCsipDeviceManager; BluetoothDevice mOngoingSetMemberPair; BluetoothDevice mOngoingSetMemberPair; boolean mIsLateBonding; boolean mIsLateBonding; int mGroupIdOfLateBonding; public CachedBluetoothDeviceManager(Context context, LocalBluetoothManager localBtManager) { public CachedBluetoothDeviceManager(Context context, LocalBluetoothManager localBtManager) { mContext = context; mContext = context; Loading Loading @@ -213,6 +214,14 @@ public class CachedBluetoothDeviceManager { * @return The name, or if unavailable, the address. * @return The name, or if unavailable, the address. */ */ public String getName(BluetoothDevice device) { 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); CachedBluetoothDevice cachedDevice = findDevice(device); if (cachedDevice != null && cachedDevice.getName() != null) { if (cachedDevice != null && cachedDevice.getName() != null) { return cachedDevice.getName(); return cachedDevice.getName(); Loading Loading @@ -314,6 +323,7 @@ public class CachedBluetoothDeviceManager { // To clear the SetMemberPair flag when the Bluetooth is turning off. // To clear the SetMemberPair flag when the Bluetooth is turning off. mOngoingSetMemberPair = null; mOngoingSetMemberPair = null; mIsLateBonding = false; mIsLateBonding = false; mGroupIdOfLateBonding = BluetoothCsipSetCoordinator.GROUP_ID_INVALID; } } } } Loading Loading @@ -426,6 +436,7 @@ public class CachedBluetoothDeviceManager { return false; return false; } } Log.d(TAG, "isLateBonding: " + mIsLateBonding); return mIsLateBonding; return mIsLateBonding; } } Loading @@ -444,11 +455,13 @@ public class CachedBluetoothDeviceManager { Log.d(TAG, "Bond " + device.getAnonymizedAddress() + " groupId=" + groupId + " by CSIP "); Log.d(TAG, "Bond " + device.getAnonymizedAddress() + " groupId=" + groupId + " by CSIP "); mOngoingSetMemberPair = device; mOngoingSetMemberPair = device; mIsLateBonding = checkLateBonding(groupId); mIsLateBonding = checkLateBonding(groupId); mGroupIdOfLateBonding = groupId; syncConfigFromMainDevice(device, groupId); syncConfigFromMainDevice(device, groupId); if (!device.createBond(BluetoothDevice.TRANSPORT_LE)) { if (!device.createBond(BluetoothDevice.TRANSPORT_LE)) { Log.d(TAG, "Bonding could not be started"); Log.d(TAG, "Bonding could not be started"); mOngoingSetMemberPair = null; mOngoingSetMemberPair = null; mIsLateBonding = false; mIsLateBonding = false; mGroupIdOfLateBonding = BluetoothCsipSetCoordinator.GROUP_ID_INVALID; } } } } Loading Loading @@ -494,6 +507,7 @@ public class CachedBluetoothDeviceManager { mOngoingSetMemberPair = null; mOngoingSetMemberPair = null; mIsLateBonding = false; mIsLateBonding = false; mGroupIdOfLateBonding = BluetoothCsipSetCoordinator.GROUP_ID_INVALID; if (bondState != BluetoothDevice.BOND_NONE) { if (bondState != BluetoothDevice.BOND_NONE) { if (findDevice(device) == null) { if (findDevice(device) == null) { final LocalBluetoothProfileManager profileManager = mBtManager.getProfileManager(); final LocalBluetoothProfileManager profileManager = mBtManager.getProfileManager(); Loading Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java +14 −0 Original line number Original line Diff line number Diff line Loading @@ -51,6 +51,7 @@ public class CachedBluetoothDeviceManager { CsipDeviceManager mCsipDeviceManager; CsipDeviceManager mCsipDeviceManager; BluetoothDevice mOngoingSetMemberPair; BluetoothDevice mOngoingSetMemberPair; boolean mIsLateBonding; boolean mIsLateBonding; int mGroupIdOfLateBonding; public CachedBluetoothDeviceManager(Context context, LocalBluetoothManager localBtManager) { public CachedBluetoothDeviceManager(Context context, LocalBluetoothManager localBtManager) { mContext = context; mContext = context; Loading Loading @@ -213,6 +214,14 @@ public class CachedBluetoothDeviceManager { * @return The name, or if unavailable, the address. * @return The name, or if unavailable, the address. */ */ public String getName(BluetoothDevice device) { 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); CachedBluetoothDevice cachedDevice = findDevice(device); if (cachedDevice != null && cachedDevice.getName() != null) { if (cachedDevice != null && cachedDevice.getName() != null) { return cachedDevice.getName(); return cachedDevice.getName(); Loading Loading @@ -314,6 +323,7 @@ public class CachedBluetoothDeviceManager { // To clear the SetMemberPair flag when the Bluetooth is turning off. // To clear the SetMemberPair flag when the Bluetooth is turning off. mOngoingSetMemberPair = null; mOngoingSetMemberPair = null; mIsLateBonding = false; mIsLateBonding = false; mGroupIdOfLateBonding = BluetoothCsipSetCoordinator.GROUP_ID_INVALID; } } } } Loading Loading @@ -426,6 +436,7 @@ public class CachedBluetoothDeviceManager { return false; return false; } } Log.d(TAG, "isLateBonding: " + mIsLateBonding); return mIsLateBonding; return mIsLateBonding; } } Loading @@ -444,11 +455,13 @@ public class CachedBluetoothDeviceManager { Log.d(TAG, "Bond " + device.getAnonymizedAddress() + " groupId=" + groupId + " by CSIP "); Log.d(TAG, "Bond " + device.getAnonymizedAddress() + " groupId=" + groupId + " by CSIP "); mOngoingSetMemberPair = device; mOngoingSetMemberPair = device; mIsLateBonding = checkLateBonding(groupId); mIsLateBonding = checkLateBonding(groupId); mGroupIdOfLateBonding = groupId; syncConfigFromMainDevice(device, groupId); syncConfigFromMainDevice(device, groupId); if (!device.createBond(BluetoothDevice.TRANSPORT_LE)) { if (!device.createBond(BluetoothDevice.TRANSPORT_LE)) { Log.d(TAG, "Bonding could not be started"); Log.d(TAG, "Bonding could not be started"); mOngoingSetMemberPair = null; mOngoingSetMemberPair = null; mIsLateBonding = false; mIsLateBonding = false; mGroupIdOfLateBonding = BluetoothCsipSetCoordinator.GROUP_ID_INVALID; } } } } Loading Loading @@ -494,6 +507,7 @@ public class CachedBluetoothDeviceManager { mOngoingSetMemberPair = null; mOngoingSetMemberPair = null; mIsLateBonding = false; mIsLateBonding = false; mGroupIdOfLateBonding = BluetoothCsipSetCoordinator.GROUP_ID_INVALID; if (bondState != BluetoothDevice.BOND_NONE) { if (bondState != BluetoothDevice.BOND_NONE) { if (findDevice(device) == null) { if (findDevice(device) == null) { final LocalBluetoothProfileManager profileManager = mBtManager.getProfileManager(); final LocalBluetoothProfileManager profileManager = mBtManager.getProfileManager(); Loading