From 3eb43fe7a4a508e8cd476525fd68ec8d900f06b8 Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Tue, 15 Sep 2009 14:07:22 -0700 Subject: [PATCH] Show name for incoming pairing requests. Settings apps invalidates its cache whenever a new scan is started. When there is a new incoming pairing request, we will not get a DeviceFound signal, because its not due to a inquiry scan. Thus when the pairing request is displayed, the settings app doesn't have it in cache and hence will just display the address. Make it query the framework when it doesn't have the name. --- .../settings/bluetooth/CachedBluetoothDeviceManager.java | 7 ++++++- .../android/settings/bluetooth/LocalBluetoothManager.java | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java index 7052bfb6ed2..046cd7693f7 100644 --- a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java @@ -140,7 +140,12 @@ public class CachedBluetoothDeviceManager { */ public String getName(BluetoothDevice device) { CachedBluetoothDevice cachedDevice = findDevice(device); - return cachedDevice != null ? cachedDevice.getName() : device.getAddress(); + if (cachedDevice != null) return cachedDevice.getName(); + + String name = device.getName(); + if (name != null) return name; + + return device.getAddress(); } private void dispatchDeviceAdded(CachedBluetoothDevice cachedDevice) { diff --git a/src/com/android/settings/bluetooth/LocalBluetoothManager.java b/src/com/android/settings/bluetooth/LocalBluetoothManager.java index 501f767f67e..70375821126 100644 --- a/src/com/android/settings/bluetooth/LocalBluetoothManager.java +++ b/src/com/android/settings/bluetooth/LocalBluetoothManager.java @@ -256,7 +256,10 @@ public class LocalBluetoothManager { CachedBluetoothDevice cachedDevice = mCachedDeviceManager.findDevice(device); String name = null; if (cachedDevice == null) { - name = mContext.getString(R.string.bluetooth_remote_device); + name = device.getName(); + if (name == null) { + name = mContext.getString(R.string.bluetooth_remote_device); + } } else { name = cachedDevice.getName(); }