@@ -322,14 +322,18 @@ private void onDeviceFound(final ScanResult bleScanResult) {
322
322
return ;
323
323
}
324
324
325
- BluetoothDeviceView deviceView = new BluetoothDeviceView (context );
326
- deviceView .setDeviceName (formatDeviceName (bleScanResult .getDevice ()));
327
-
328
325
String deviceName = device .getName ();
329
326
if (deviceName == null ) {
330
327
deviceName = BluetoothFactory .convertNoNameToDeviceName (bleScanResult .getScanRecord ().getManufacturerSpecificData ());
328
+ }
329
+ if (deviceName == null ) {
330
+ return ;
331
331
}
332
332
333
+ BluetoothDeviceView deviceView = new BluetoothDeviceView (context );
334
+ deviceView .setDeviceName (formatDeviceName (deviceName , device .getAddress ()));
335
+ deviceView .setAlias (deviceName );
336
+
333
337
BluetoothCommunication btDevice = BluetoothFactory .createDeviceDriver (context , deviceName );
334
338
if (btDevice != null ) {
335
339
Timber .d ("Found supported device %s (driver: %s)" ,
@@ -398,6 +402,7 @@ private class BluetoothDeviceView extends LinearLayout implements View.OnClickLi
398
402
private TextView deviceName ;
399
403
private ImageView deviceIcon ;
400
404
private String deviceAddress ;
405
+ private String deviceAlias ;
401
406
402
407
public BluetoothDeviceView (Context context ) {
403
408
super (context );
@@ -427,6 +432,14 @@ public BluetoothDeviceView(Context context) {
427
432
addView (deviceName );
428
433
}
429
434
435
+ public void setAlias (String alias ) {
436
+ deviceAlias = alias ;
437
+ }
438
+
439
+ public String getAlias () {
440
+ return deviceAlias ;
441
+ }
442
+
430
443
public void setDeviceAddress (String address ) {
431
444
deviceAddress = address ;
432
445
}
@@ -485,10 +498,10 @@ public void onClick(View view) {
485
498
486
499
prefs .edit ()
487
500
.putString (PREFERENCE_KEY_BLUETOOTH_HW_ADDRESS , device .getAddress ())
488
- .putString (PREFERENCE_KEY_BLUETOOTH_DEVICE_NAME , device . getName ())
501
+ .putString (PREFERENCE_KEY_BLUETOOTH_DEVICE_NAME , getAlias ())
489
502
.apply ();
490
503
491
- Timber .d ("Saved Bluetooth device " + device . getName () + " with address " + device .getAddress ());
504
+ Timber .d ("Saved Bluetooth device " + getAlias () + " with address " + device .getAddress ());
492
505
493
506
stopBluetoothDiscovery ();
494
507
0 commit comments