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

Commit ac2afd4e authored by Jack He's avatar Jack He Committed by android-build-merger
Browse files

Merge "CachedBluetoothDevice: Rename mVisible to mJustDiscovered" into oc-mr1-dev

am: cb065bc3

Change-Id: I089e0f69629666d21bc401c2191341a71d7c3172
parents 2fd6220a cb065bc3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ public class BluetoothEventManager {
            cachedDevice.setRssi(rssi);
            cachedDevice.setBtClass(btClass);
            cachedDevice.setNewName(name);
            cachedDevice.setVisible(true);
            cachedDevice.setJustDiscovered(true);
        }
    }

@@ -352,7 +352,7 @@ public class BluetoothEventManager {
                if (device != null && device.getBondState() == BluetoothDevice.BOND_NONE) {
                    CachedBluetoothDevice cachedDevice = mDeviceManager.findDevice(device);
                    if (cachedDevice != null) {
                        cachedDevice.setVisible(false);
                        cachedDevice.setJustDiscovered(false);
                    }
                }
            }
+6 −11
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
    // Device supports PANU but not NAP: remove PanProfile after device disconnects from NAP
    private boolean mLocalNapRoleConnected;

    private boolean mVisible;
    private boolean mJustDiscovered;

    private int mMessageRejectionCount;

@@ -360,7 +360,6 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
        migrateMessagePermissionChoice();
        fetchMessageRejectionCount();

        mVisible = false;
        dispatchAttributesChanged();
    }

@@ -431,13 +430,9 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
        dispatchAttributesChanged();
    }

    public boolean isVisible() {
        return mVisible;
    }

    public void setVisible(boolean visible) {
        if (mVisible != visible) {
            mVisible = visible;
    public void setJustDiscovered(boolean justDiscovered) {
        if (mJustDiscovered != justDiscovered) {
            mJustDiscovered = justDiscovered;
            dispatchAttributesChanged();
        }
    }
@@ -661,8 +656,8 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
            (getBondState() == BluetoothDevice.BOND_BONDED ? 1 : 0);
        if (comparison != 0) return comparison;

        // Visible above not visible
        comparison = (another.mVisible ? 1 : 0) - (mVisible ? 1 : 0);
        // Just discovered above discovered in the past
        comparison = (another.mJustDiscovered ? 1 : 0) - (mJustDiscovered ? 1 : 0);
        if (comparison != 0) return comparison;

        // Stronger signal above weaker signal
+3 −3
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public class CachedBluetoothDeviceManager {
    }

    public static boolean onDeviceDisappeared(CachedBluetoothDevice cachedDevice) {
        cachedDevice.setVisible(false);
        cachedDevice.setJustDiscovered(false);
        return cachedDevice.getBondState() == BluetoothDevice.BOND_NONE;
    }

@@ -131,7 +131,7 @@ public class CachedBluetoothDeviceManager {
        // Iterate in reverse order since devices may be removed.
        for (int i = mCachedDevices.size() - 1; i >= 0; i--) {
            CachedBluetoothDevice cachedDevice = mCachedDevices.get(i);
            cachedDevice.setVisible(false);
            cachedDevice.setJustDiscovered(false);
        }
    }

@@ -156,7 +156,7 @@ public class CachedBluetoothDeviceManager {
            for (int i = mCachedDevices.size() - 1; i >= 0; i--) {
                CachedBluetoothDevice cachedDevice = mCachedDevices.get(i);
                if (cachedDevice.getBondState() != BluetoothDevice.BOND_BONDED) {
                    cachedDevice.setVisible(false);
                    cachedDevice.setJustDiscovered(false);
                    mCachedDevices.remove(i);
                } else {
                    // For bonded devices, we need to clear the connection status so that