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.
This commit is contained in:
@@ -140,7 +140,12 @@ public class CachedBluetoothDeviceManager {
|
|||||||
*/
|
*/
|
||||||
public String getName(BluetoothDevice device) {
|
public String getName(BluetoothDevice device) {
|
||||||
CachedBluetoothDevice cachedDevice = findDevice(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) {
|
private void dispatchDeviceAdded(CachedBluetoothDevice cachedDevice) {
|
||||||
|
@@ -256,7 +256,10 @@ public class LocalBluetoothManager {
|
|||||||
CachedBluetoothDevice cachedDevice = mCachedDeviceManager.findDevice(device);
|
CachedBluetoothDevice cachedDevice = mCachedDeviceManager.findDevice(device);
|
||||||
String name = null;
|
String name = null;
|
||||||
if (cachedDevice == null) {
|
if (cachedDevice == null) {
|
||||||
|
name = device.getName();
|
||||||
|
if (name == null) {
|
||||||
name = mContext.getString(R.string.bluetooth_remote_device);
|
name = mContext.getString(R.string.bluetooth_remote_device);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
name = cachedDevice.getName();
|
name = cachedDevice.getName();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user