Check null of address in onDeviceCreated

address can be null that returned from getAddressFromObjectPath.
If it is null case, donot continue  call getRemoteDeviceProperties.
Otherwise it causes null pointer exception and crash the system.
Bug 6338780

Change-Id: Ib190342032ab2ad11c49f44fa6d4b2509a861514
This commit is contained in:
Matthew Xie
2012-05-01 17:15:10 -07:00
parent d72ad2ac88
commit 02c4b353f7

View File

@@ -268,6 +268,11 @@ class BluetoothEventLoop {
*/
private void onDeviceCreated(String deviceObjectPath) {
String address = mBluetoothService.getAddressFromObjectPath(deviceObjectPath);
if (address == null) {
Log.e(TAG, "onDeviceCreated: device address null!" + " deviceObjectPath: " +
deviceObjectPath);
return;
}
if (!mBluetoothService.isRemoteDeviceInCache(address)) {
// Incoming connection, we haven't seen this device, add to cache.
String[] properties = mBluetoothService.getRemoteDeviceProperties(address);
@@ -275,7 +280,6 @@ class BluetoothEventLoop {
addDevice(address, properties);
}
}
return;
}
/**