Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0bec859f authored by Hyundo Moon's avatar Hyundo Moon Committed by Gerrit Code Review
Browse files

Merge "Rename CachedBluetoothDevice.setMemberDevice to addMemberDevice"

parents 65e07d31 5c811c4d
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -1351,7 +1351,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
    /**
     * Store the member devices that are in the same coordinated set.
     */
    public void setMemberDevice(CachedBluetoothDevice memberDevice) {
    public void addMemberDevice(CachedBluetoothDevice memberDevice) {
        mMemberDevices.add(memberDevice);
    }

@@ -1368,24 +1368,24 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
     * device and member devices.
     *
     * @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,
            CachedBluetoothDevice newMainDevie) {
            CachedBluetoothDevice newMainDevice) {
        // Backup from main device
        final BluetoothDevice tmpDevice = mDevice;
        final short tmpRssi = mRssi;
        final boolean tmpJustDiscovered = mJustDiscovered;
        // Set main device from sub device
        mDevice = newMainDevie.mDevice;
        mRssi = newMainDevie.mRssi;
        mJustDiscovered = newMainDevie.mJustDiscovered;
        setMemberDevice(prevMainDevice);
        mMemberDevices.remove(newMainDevie);
        mDevice = newMainDevice.mDevice;
        mRssi = newMainDevice.mRssi;
        mJustDiscovered = newMainDevice.mJustDiscovered;
        addMemberDevice(prevMainDevice);
        mMemberDevices.remove(newMainDevice);
        // Set sub device from backup
        newMainDevie.mDevice = tmpDevice;
        newMainDevie.mRssi = tmpRssi;
        newMainDevie.mJustDiscovered = tmpJustDiscovered;
        newMainDevice.mDevice = tmpDevice;
        newMainDevice.mRssi = tmpRssi;
        newMainDevice.mJustDiscovered = tmpJustDiscovered;
        fetchActiveDevices();
    }

+2 −2
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ public class CsipDeviceManager {
            // Once there is other devices with the same groupId, to add new device as member
            // devices.
            if (CsipDevice != null) {
                CsipDevice.setMemberDevice(newDevice);
                CsipDevice.addMemberDevice(newDevice);
                newDevice.setName(CsipDevice.getName());
                return true;
            }
@@ -148,7 +148,7 @@ public class CsipDeviceManager {
            log("onGroupIdChanged: removed from UI device =" + cachedDevice
                    + ", with groupId=" + groupId + " firstMatchedIndex=" + firstMatchedIndex);

            mainDevice.setMemberDevice(cachedDevice);
            mainDevice.addMemberDevice(cachedDevice);
            mCachedDevices.remove(i);
            mBtManager.getEventManager().dispatchDeviceRemoved(cachedDevice);
            break;
+4 −5
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

@RunWith(RobolectricTestRunner.class)
@@ -503,8 +502,8 @@ public class CachedBluetoothDeviceManagerTest {
        CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mDevice1);
        CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mDevice2);
        CachedBluetoothDevice cachedDevice3 = mCachedDeviceManager.addDevice(mDevice3);
        cachedDevice1.setMemberDevice(cachedDevice2);
        cachedDevice1.setMemberDevice(cachedDevice3);
        cachedDevice1.addMemberDevice(cachedDevice2);
        cachedDevice1.addMemberDevice(cachedDevice3);

        assertThat(cachedDevice1.getMemberDevice()).contains(cachedDevice2);
        assertThat(cachedDevice1.getMemberDevice()).contains(cachedDevice3);
@@ -524,7 +523,7 @@ public class CachedBluetoothDeviceManagerTest {
        CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mDevice2);
        cachedDevice1.setGroupId(1);
        cachedDevice2.setGroupId(1);
        cachedDevice1.setMemberDevice(cachedDevice2);
        cachedDevice1.addMemberDevice(cachedDevice2);

        // Call onDeviceUnpaired for the one in mCachedDevices.
        mCachedDeviceManager.onDeviceUnpaired(cachedDevice1);
@@ -541,7 +540,7 @@ public class CachedBluetoothDeviceManagerTest {
        CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mDevice2);
        cachedDevice1.setGroupId(1);
        cachedDevice2.setGroupId(1);
        cachedDevice1.setMemberDevice(cachedDevice2);
        cachedDevice1.addMemberDevice(cachedDevice2);

        // Call onDeviceUnpaired for the one in mCachedDevices.
        mCachedDeviceManager.onDeviceUnpaired(cachedDevice2);