diff --git a/src/com/android/settings/bluetooth/BluetoothEventManager.java b/src/com/android/settings/bluetooth/BluetoothEventManager.java index 0eead8567b5..bf7606ea2c7 100755 --- a/src/com/android/settings/bluetooth/BluetoothEventManager.java +++ b/src/com/android/settings/bluetooth/BluetoothEventManager.java @@ -206,7 +206,7 @@ final class BluetoothEventManager { } cachedDevice.setRssi(rssi); cachedDevice.setBtClass(btClass); - cachedDevice.setName(name); + cachedDevice.setNewName(name); cachedDevice.setVisible(true); } } diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index 3b64ade0b97..c19f754a611 100755 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -387,15 +387,26 @@ final class CachedBluetoothDevice implements Comparable { 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); - } + mName = name; + mDevice.setAlias(name); dispatchAttributesChanged(); } }