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

Commit 2f837509 authored by Matthew Xie's avatar Matthew Xie
Browse files

Do not overwrite alias with device name

Bug: 17287682
Change-Id: Iea29e85125ae4720fd99f893f516c301b7aed7c6
parent 0a11f605
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -206,7 +206,7 @@ final class BluetoothEventManager {
            }
            cachedDevice.setRssi(rssi);
            cachedDevice.setBtClass(btClass);
            cachedDevice.setName(name);
            cachedDevice.setNewName(name);
            cachedDevice.setVisible(true);
        }
    }
+18 −7
Original line number Diff line number Diff line
@@ -387,15 +387,26 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
        return mName;
    }

    /**
     * Populate name from BluetoothDevice.ACTION_FOUND intent
     */
    void setNewName(String name) {
        if (mName == null) {
            mName = name;
            if (mName == null || TextUtils.isEmpty(mName)) {
                mName = mDevice.getAddress();
            }
            dispatchAttributesChanged();
        }
    }

    /**
     * user changes the device name
     */
    void setName(String name) {
        if (!mName.equals(name)) {
            if (TextUtils.isEmpty(name)) {
                // TODO: use friendly name for unknown device (bug 1181856)
                mName = mDevice.getAddress();
            } else {
            mName = name;
            mDevice.setAlias(name);
            }
            dispatchAttributesChanged();
        }
    }