/** * Attempts to get the name of a remote device, otherwise returns the address. * * @param device The remote device. * @return The name, or if unavailable, the address. */ public String getName(BluetoothDevice device) { CachedBluetoothDevice cachedDevice = findDevice(device); if (cachedDevice != null) { return cachedDevice.getName(); } String name = device.getAliasName(); if (name != null) { return name; } return device.getAddress(); }
synchronized boolean hasOtherConnectedDevices(BluetoothDevice dock) { Collection<CachedBluetoothDevice> cachedDevices = mDeviceManager.getCachedDevicesCopy(); Set<BluetoothDevice> btDevices = mLocalAdapter.getBondedDevices(); if (btDevices == null || cachedDevices == null || btDevices.isEmpty()) { return false; } if (DEBUG) { Log.d(TAG, "btDevices = " + btDevices.size()); Log.d(TAG, "cachedDeviceUIs = " + cachedDevices.size()); } for (CachedBluetoothDevice deviceUI : cachedDevices) { BluetoothDevice btDevice = deviceUI.getDevice(); if (!btDevice.equals(dock) && btDevices.contains(btDevice) && deviceUI.isConnected()) { if (DEBUG) Log.d(TAG, "connected deviceUI = " + deviceUI.getName()); return true; } } return false; }