@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof RxBleDeviceImpl)) { return false; } RxBleDeviceImpl that = (RxBleDeviceImpl) o; return bluetoothDevice.equals(that.bluetoothDevice); }
/** * Checks the {@link BleProfileService#EXTRA_DEVICE} in the given intent and compares it with the connected BluetoothDevice object. * @param intent intent received via a broadcast from the service * @return true if the data in the intent apply to the connected device, false otherwise */ protected boolean isBroadcastForThisDevice(final Intent intent) { final BluetoothDevice bluetoothDevice = intent.getParcelableExtra(BleProfileService.EXTRA_DEVICE); return mBluetoothDevice != null && mBluetoothDevice.equals(bluetoothDevice); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ConnectionStateEvent that = (ConnectionStateEvent) o; if (state != that.state) return false; if (previousState != that.previousState) return false; return !(bluetoothDevice != null ? !bluetoothDevice.equals(that.bluetoothDevice) : that.bluetoothDevice != null); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; BondStateEvent that = (BondStateEvent) o; if (state != that.state) return false; if (previousState != that.previousState) return false; return !(bluetoothDevice != null ? !bluetoothDevice.equals(that.bluetoothDevice) : that.bluetoothDevice != null); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AclEvent that = (AclEvent) o; if (action != null && !action.equals(that.action)) return false; return !(bluetoothDevice != null ? !bluetoothDevice.equals(that.bluetoothDevice) : that.bluetoothDevice != null); }
private class BluetoothReceiver extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); BluetoothDevice deviceIn = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); if (deviceIn != null) { if (deviceIn.equals(device)) { if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) { int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE); if(bondState == BluetoothDevice.BOND_BONDED){ //now start reading } } } } } }
if (other.mDevice != null) return false; } else if (!mDevice.equals(other.mDevice)) return false; if (mFirstRssi != other.mFirstRssi)
/** * 当前设备与指定设备是否连接 */ public boolean isConnected(BluetoothDevice dev) { boolean connected = (mSocket != null && mSocket.isConnected()); if (dev == null) return connected; return connected && mSocket.getRemoteDevice().equals(dev); }
public void onScanEvent(ScanEvent e) { boolean exists = false; for (int i = 0; i < mValues.size(); i++ ) { ScanEvent tmp = mValues.get(i); if (tmp.getDevice().equals(e.getDevice())) { exists = true; mValues.set(i, e); break; } } if (!exists) { mValues.add(e); } notifyDataSetChanged(); }
if (devices.get(deviceIndex).equals(devices.get(compareIndex))) { isFoundDuplicate = true; break;
void disconnectAll(BluetoothDevice allowedDevice) { for (BluetoothDevice device : mBluetoothManager.getConnectedDevices(BluetoothProfile.GATT)) { if (!device.equals(allowedDevice)) { log(String.format("Disconnecting %s", device)); mGattServer.cancelConnection(device); } } }
/** * Overrides .equals(). * * @param other Another object to compare this PeerNetwork to. */ @Override public boolean equals(Object other) { if (other == null) { return false; } else if (!(other instanceof PeerNetwork)) { return false; } else if (other.getClass() != this.getClass()) { return false; } else if (((PeerNetwork) other).getBluetoothDevice() == null) { return this.getBluetoothDevice() == null; } return ((PeerNetwork) other).getBluetoothDevice().equals(this.getBluetoothDevice()); }
/** * Overrides .equals(). * * @param other Another object to compare this PeerNetwork to. */ @Override public boolean equals(Object other) { if (other == null) { return false; } else if (!(other instanceof PeerNetwork)) { return false; } else if (other.getClass() != this.getClass()) { return false; } else if (((PeerNetwork) other).getBluetoothLEDevice() == null) { return this.getBluetoothLEDevice() == null; } return ((PeerNetwork) other).getBluetoothLEDevice().equals(this.getBluetoothLEDevice()); }
/** * Initiate connection sequence for the specified HID Host. If another device is already * connected, it will be disconnected first. If the parameter is {@code null}, then the service * will only disconnect from the current device. * * @param device New HID Host to connect to. */ @MainThread public void requestConnect(BluetoothDevice device) { synchronized (lock) { waitingForDevice = device; connectedDevice = null; updateDeviceList(); if (device != null && device.equals(connectedDevice)) { for (ProfileListener listener : listeners) { listener.onDeviceStateChanged(device, BluetoothProfile.STATE_CONNECTED); } } } }
Log.d(TAG, "isBonded bondedDevice: " + bondedDevice); if (bondedDevice.equals(device)) { Log.d(TAG, "Found bonded device: " + device); return true;
if (mConnected || !bluetoothEnabled) { final BluetoothDevice currentDevice = mBluetoothDevice; if (bluetoothEnabled && currentDevice != null && currentDevice.equals(device)) { mConnectRequest.notifySuccess(device); } else {
@Override public void onConnectionStateChange(BluetoothDevice device, int status, int newState) { super.onConnectionStateChange(device, status, newState); if (newState == BluetoothGatt.STATE_DISCONNECTED) { log(device + " has disconnected"); if (device.equals(mEddystoneGattService.getConnectedOwner())) { log("Owner disconnected, stopping GATT server"); mEddystoneGattService.onOwnerDisconnected(); close(); } } else if (newState == BluetoothGatt.STATE_CONNECTED) { log(device + " has connected"); if (mEddystoneGattService.getConnectedOwner() != null) { // don't allow a second client to connect at the same time log(device + " tried to connect, but owner is active. Disconnecting."); mGattServer.cancelConnection(device); } } }