Merge "Rename CachedBluetoothDevice.setMemberDevice to addMemberDevice"

This commit is contained in:
Hyundo Moon
2022-05-04 10:14:20 +00:00
committed by Gerrit Code Review
3 changed files with 17 additions and 18 deletions

View File

@@ -1351,7 +1351,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
/** /**
* Store the member devices that are in the same coordinated set. * Store the member devices that are in the same coordinated set.
*/ */
public void setMemberDevice(CachedBluetoothDevice memberDevice) { public void addMemberDevice(CachedBluetoothDevice memberDevice) {
mMemberDevices.add(memberDevice); mMemberDevices.add(memberDevice);
} }
@@ -1368,24 +1368,24 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
* device and member devices. * device and member devices.
* *
* @param prevMainDevice the previous Main device, it will be added into the member device set. * @param prevMainDevice the previous Main device, it will be added into the member device set.
* @param newMainDevie the new Main device, it will be removed from the member device set. * @param newMainDevice the new Main device, it will be removed from the member device set.
*/ */
public void switchMemberDeviceContent(CachedBluetoothDevice prevMainDevice, public void switchMemberDeviceContent(CachedBluetoothDevice prevMainDevice,
CachedBluetoothDevice newMainDevie) { CachedBluetoothDevice newMainDevice) {
// Backup from main device // Backup from main device
final BluetoothDevice tmpDevice = mDevice; final BluetoothDevice tmpDevice = mDevice;
final short tmpRssi = mRssi; final short tmpRssi = mRssi;
final boolean tmpJustDiscovered = mJustDiscovered; final boolean tmpJustDiscovered = mJustDiscovered;
// Set main device from sub device // Set main device from sub device
mDevice = newMainDevie.mDevice; mDevice = newMainDevice.mDevice;
mRssi = newMainDevie.mRssi; mRssi = newMainDevice.mRssi;
mJustDiscovered = newMainDevie.mJustDiscovered; mJustDiscovered = newMainDevice.mJustDiscovered;
setMemberDevice(prevMainDevice); addMemberDevice(prevMainDevice);
mMemberDevices.remove(newMainDevie); mMemberDevices.remove(newMainDevice);
// Set sub device from backup // Set sub device from backup
newMainDevie.mDevice = tmpDevice; newMainDevice.mDevice = tmpDevice;
newMainDevie.mRssi = tmpRssi; newMainDevice.mRssi = tmpRssi;
newMainDevie.mJustDiscovered = tmpJustDiscovered; newMainDevice.mJustDiscovered = tmpJustDiscovered;
fetchActiveDevices(); fetchActiveDevices();
} }

View File

@@ -85,7 +85,7 @@ public class CsipDeviceManager {
// Once there is other devices with the same groupId, to add new device as member // Once there is other devices with the same groupId, to add new device as member
// devices. // devices.
if (CsipDevice != null) { if (CsipDevice != null) {
CsipDevice.setMemberDevice(newDevice); CsipDevice.addMemberDevice(newDevice);
newDevice.setName(CsipDevice.getName()); newDevice.setName(CsipDevice.getName());
return true; return true;
} }
@@ -148,7 +148,7 @@ public class CsipDeviceManager {
log("onGroupIdChanged: removed from UI device =" + cachedDevice log("onGroupIdChanged: removed from UI device =" + cachedDevice
+ ", with groupId=" + groupId + " firstMatchedIndex=" + firstMatchedIndex); + ", with groupId=" + groupId + " firstMatchedIndex=" + firstMatchedIndex);
mainDevice.setMemberDevice(cachedDevice); mainDevice.addMemberDevice(cachedDevice);
mCachedDevices.remove(i); mCachedDevices.remove(i);
mBtManager.getEventManager().dispatchDeviceRemoved(cachedDevice); mBtManager.getEventManager().dispatchDeviceRemoved(cachedDevice);
break; break;

View File

@@ -40,7 +40,6 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
@@ -503,8 +502,8 @@ public class CachedBluetoothDeviceManagerTest {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mDevice1); CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mDevice1);
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mDevice2); CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mDevice2);
CachedBluetoothDevice cachedDevice3 = mCachedDeviceManager.addDevice(mDevice3); CachedBluetoothDevice cachedDevice3 = mCachedDeviceManager.addDevice(mDevice3);
cachedDevice1.setMemberDevice(cachedDevice2); cachedDevice1.addMemberDevice(cachedDevice2);
cachedDevice1.setMemberDevice(cachedDevice3); cachedDevice1.addMemberDevice(cachedDevice3);
assertThat(cachedDevice1.getMemberDevice()).contains(cachedDevice2); assertThat(cachedDevice1.getMemberDevice()).contains(cachedDevice2);
assertThat(cachedDevice1.getMemberDevice()).contains(cachedDevice3); assertThat(cachedDevice1.getMemberDevice()).contains(cachedDevice3);
@@ -524,7 +523,7 @@ public class CachedBluetoothDeviceManagerTest {
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mDevice2); CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mDevice2);
cachedDevice1.setGroupId(1); cachedDevice1.setGroupId(1);
cachedDevice2.setGroupId(1); cachedDevice2.setGroupId(1);
cachedDevice1.setMemberDevice(cachedDevice2); cachedDevice1.addMemberDevice(cachedDevice2);
// Call onDeviceUnpaired for the one in mCachedDevices. // Call onDeviceUnpaired for the one in mCachedDevices.
mCachedDeviceManager.onDeviceUnpaired(cachedDevice1); mCachedDeviceManager.onDeviceUnpaired(cachedDevice1);
@@ -541,7 +540,7 @@ public class CachedBluetoothDeviceManagerTest {
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mDevice2); CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mDevice2);
cachedDevice1.setGroupId(1); cachedDevice1.setGroupId(1);
cachedDevice2.setGroupId(1); cachedDevice2.setGroupId(1);
cachedDevice1.setMemberDevice(cachedDevice2); cachedDevice1.addMemberDevice(cachedDevice2);
// Call onDeviceUnpaired for the one in mCachedDevices. // Call onDeviceUnpaired for the one in mCachedDevices.
mCachedDeviceManager.onDeviceUnpaired(cachedDevice2); mCachedDeviceManager.onDeviceUnpaired(cachedDevice2);