Bluetooth: Only show devices when their names are resolved
* Add a developer menu option to allow name-less devices to be shown when a Bluetooth developer needs it, but hide it for non-developer users. * Set BluetoothDevicePreference to invisible when CachedBluetoothDevice does not have a name besides MAC address and the above developer option is false. * This affects BluetoothPairingDetail and DevicePickerFragment, but does not affect BluetoothSettings. BluetoothSettings will show all paired devices regardless whether an user friendly name exists. Bug: 34685932 Test: pair Bluetooth device, send file over Bluetooth, unit tests Change-Id: Idd7ad4b1671dfdcf3204efb50eddb6dae1065aa5
This commit is contained in:
@@ -54,16 +54,17 @@ public final class BluetoothDevicePreference extends GearPreference implements
|
||||
private final UserManager mUserManager;
|
||||
|
||||
private AlertDialog mDisconnectDialog;
|
||||
|
||||
private String contentDescription = null;
|
||||
|
||||
private DeviceListPreferenceFragment mDeviceListPreferenceFragment;
|
||||
/* Talk-back descriptions for various BT icons */
|
||||
Resources mResources;
|
||||
|
||||
public BluetoothDevicePreference(Context context, CachedBluetoothDevice cachedDevice) {
|
||||
public BluetoothDevicePreference(Context context, CachedBluetoothDevice cachedDevice,
|
||||
DeviceListPreferenceFragment deviceListPreferenceFragment) {
|
||||
super(context, null);
|
||||
mResources = getContext().getResources();
|
||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
mDeviceListPreferenceFragment = deviceListPreferenceFragment;
|
||||
|
||||
if (sDimAlpha == Integer.MIN_VALUE) {
|
||||
TypedValue outValue = new TypedValue();
|
||||
@@ -131,6 +132,11 @@ public final class BluetoothDevicePreference extends GearPreference implements
|
||||
// Used to gray out the item
|
||||
setEnabled(!mCachedDevice.isBusy());
|
||||
|
||||
// Device is only visible in the UI if it has a valid name besides MAC address or when user
|
||||
// allows showing devices without user-friendly name in developer settings
|
||||
setVisible(mDeviceListPreferenceFragment.shouldShowDevicesWithoutNames()
|
||||
|| mCachedDevice.hasHumanReadableName());
|
||||
|
||||
// This could affect ordering, so notify that
|
||||
notifyHierarchyChanged();
|
||||
}
|
||||
|
Reference in New Issue
Block a user