Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java +0 −28 Original line number Diff line number Diff line Loading @@ -127,9 +127,6 @@ public class BluetoothEventManager { addHandler(BluetoothDevice.ACTION_ACL_CONNECTED, new AclStateChangedHandler()); addHandler(BluetoothDevice.ACTION_ACL_DISCONNECTED, new AclStateChangedHandler()); addHandler(BluetoothCsipSetCoordinator.ACTION_CSIS_SET_MEMBER_AVAILABLE, new SetMemberAvailableHandler()); registerAdapterIntentReceiver(); } Loading Loading @@ -515,29 +512,4 @@ public class BluetoothEventManager { dispatchAudioModeChanged(); } } private class SetMemberAvailableHandler implements Handler { @Override public void onReceive(Context context, Intent intent, BluetoothDevice device) { final String action = intent.getAction(); if (device == null) { Log.e(TAG, "SetMemberAvailableHandler: device is null"); return; } if (action == null) { Log.e(TAG, "SetMemberAvailableHandler: action is null"); return; } final int groupId = intent.getIntExtra(BluetoothCsipSetCoordinator.EXTRA_CSIS_GROUP_ID, BluetoothCsipSetCoordinator.GROUP_ID_INVALID); if (groupId == BluetoothCsipSetCoordinator.GROUP_ID_INVALID) { Log.e(TAG, "SetMemberAvailableHandler: Invalid group id"); return; } mDeviceManager.onSetMemberAppear(device, groupId); } } } packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java +12 −10 Original line number Diff line number Diff line Loading @@ -340,22 +340,24 @@ public class CachedBluetoothDeviceManager { /** * Called when we found a set member of a group. The function will check the {@code groupId} if * it exists and if there is a ongoing pair, the device would be ignored. * it exists and the bond state of the device is BOND_NOE, and if there isn't any ongoing pair * , and then return {@code true} to pair the device automatically. * * @param device The found device * @param groupId The group id of the found device * * @return {@code true}, if the device should pair automatically; Otherwise, return * {@code false}. */ public synchronized void onSetMemberAppear(BluetoothDevice device, int groupId) { Log.d(TAG, "onSetMemberAppear, groupId: " + groupId + " device: " + device.toString()); if (mOngoingSetMemberPair != null) { Log.d(TAG, "Ongoing set memberPairing in process, drop it!"); return; public synchronized boolean shouldPairByCsip(BluetoothDevice device, int groupId) { if (mOngoingSetMemberPair != null || device.getBondState() != BluetoothDevice.BOND_NONE || !mCsipDeviceManager.isExistedGroupId(groupId)) { return false; } if (mCsipDeviceManager.onSetMemberAppear(device, groupId)) { Log.d(TAG, "Bond " + device.getName() + " by CSIP"); mOngoingSetMemberPair = device; } return true; } /** Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipDeviceManager.java +5 −12 Original line number Diff line number Diff line Loading @@ -240,22 +240,15 @@ public class CsipDeviceManager { } /** * Called when we found a set member of a group. The function will check bond state, and * the {@code groupId} if it exists, and then create the bond. * Check if the {@code groupId} is existed. * * @param device The found device * @param groupId The group id of the found device * @param groupId The group id * * @return {@code true}, if the we create bond with the device. Otherwise, return * {@code false}. * @return {@code true}, if we could find a device with this {@code groupId}; Otherwise, * return {@code false}. */ public boolean onSetMemberAppear(BluetoothDevice device, int groupId) { if (device.getBondState() != BluetoothDevice.BOND_NONE) { return false; } public boolean isExistedGroupId(int groupId) { if (getCachedDevice(groupId) != null) { device.createBond(BluetoothDevice.TRANSPORT_LE); return true; } Loading Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java +0 −28 Original line number Diff line number Diff line Loading @@ -127,9 +127,6 @@ public class BluetoothEventManager { addHandler(BluetoothDevice.ACTION_ACL_CONNECTED, new AclStateChangedHandler()); addHandler(BluetoothDevice.ACTION_ACL_DISCONNECTED, new AclStateChangedHandler()); addHandler(BluetoothCsipSetCoordinator.ACTION_CSIS_SET_MEMBER_AVAILABLE, new SetMemberAvailableHandler()); registerAdapterIntentReceiver(); } Loading Loading @@ -515,29 +512,4 @@ public class BluetoothEventManager { dispatchAudioModeChanged(); } } private class SetMemberAvailableHandler implements Handler { @Override public void onReceive(Context context, Intent intent, BluetoothDevice device) { final String action = intent.getAction(); if (device == null) { Log.e(TAG, "SetMemberAvailableHandler: device is null"); return; } if (action == null) { Log.e(TAG, "SetMemberAvailableHandler: action is null"); return; } final int groupId = intent.getIntExtra(BluetoothCsipSetCoordinator.EXTRA_CSIS_GROUP_ID, BluetoothCsipSetCoordinator.GROUP_ID_INVALID); if (groupId == BluetoothCsipSetCoordinator.GROUP_ID_INVALID) { Log.e(TAG, "SetMemberAvailableHandler: Invalid group id"); return; } mDeviceManager.onSetMemberAppear(device, groupId); } } }
packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java +12 −10 Original line number Diff line number Diff line Loading @@ -340,22 +340,24 @@ public class CachedBluetoothDeviceManager { /** * Called when we found a set member of a group. The function will check the {@code groupId} if * it exists and if there is a ongoing pair, the device would be ignored. * it exists and the bond state of the device is BOND_NOE, and if there isn't any ongoing pair * , and then return {@code true} to pair the device automatically. * * @param device The found device * @param groupId The group id of the found device * * @return {@code true}, if the device should pair automatically; Otherwise, return * {@code false}. */ public synchronized void onSetMemberAppear(BluetoothDevice device, int groupId) { Log.d(TAG, "onSetMemberAppear, groupId: " + groupId + " device: " + device.toString()); if (mOngoingSetMemberPair != null) { Log.d(TAG, "Ongoing set memberPairing in process, drop it!"); return; public synchronized boolean shouldPairByCsip(BluetoothDevice device, int groupId) { if (mOngoingSetMemberPair != null || device.getBondState() != BluetoothDevice.BOND_NONE || !mCsipDeviceManager.isExistedGroupId(groupId)) { return false; } if (mCsipDeviceManager.onSetMemberAppear(device, groupId)) { Log.d(TAG, "Bond " + device.getName() + " by CSIP"); mOngoingSetMemberPair = device; } return true; } /** Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipDeviceManager.java +5 −12 Original line number Diff line number Diff line Loading @@ -240,22 +240,15 @@ public class CsipDeviceManager { } /** * Called when we found a set member of a group. The function will check bond state, and * the {@code groupId} if it exists, and then create the bond. * Check if the {@code groupId} is existed. * * @param device The found device * @param groupId The group id of the found device * @param groupId The group id * * @return {@code true}, if the we create bond with the device. Otherwise, return * {@code false}. * @return {@code true}, if we could find a device with this {@code groupId}; Otherwise, * return {@code false}. */ public boolean onSetMemberAppear(BluetoothDevice device, int groupId) { if (device.getBondState() != BluetoothDevice.BOND_NONE) { return false; } public boolean isExistedGroupId(int groupId) { if (getCachedDevice(groupId) != null) { device.createBond(BluetoothDevice.TRANSPORT_LE); return true; } Loading