Skip to content

Commit 02c4b35

Browse files
author
Matthew Xie
committed
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
1 parent d72ad2a commit 02c4b35

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/java/android/server/BluetoothEventLoop.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,18 @@ private void onCreatePairedDeviceResult(String address, int result) {
268268
*/
269269
private void onDeviceCreated(String deviceObjectPath) {
270270
String address = mBluetoothService.getAddressFromObjectPath(deviceObjectPath);
271+
if (address == null) {
272+
Log.e(TAG, "onDeviceCreated: device address null!" + " deviceObjectPath: " +
273+
deviceObjectPath);
274+
return;
275+
}
271276
if (!mBluetoothService.isRemoteDeviceInCache(address)) {
272277
// Incoming connection, we haven't seen this device, add to cache.
273278
String[] properties = mBluetoothService.getRemoteDeviceProperties(address);
274279
if (properties != null) {
275280
addDevice(address, properties);
276281
}
277282
}
278-
return;
279283
}
280284

281285
/**

0 commit comments

Comments
 (0)