@Test public void testOnDisconnected() throws Exception { Field mSocketIoThreadsField = mBluetoothServerThread.getClass() .getDeclaredField("mSocketIoThreads"); mSocketIoThreadsField.setAccessible(true); CopyOnWriteArrayList<BluetoothSocketIoThread> mySocketIoThreads = new CopyOnWriteArrayList<>(); mSocketIoThreadsField.set(mBluetoothServerThread, mySocketIoThreads); mySocketIoThreads.add(mMockBluetoothSocketIoThread); mBluetoothServerThread.onDisconnected("Some reson", mMockBluetoothSocketIoThread); verify(mMockBluetoothSocketIoThread, times(1)).close(true, true); assertThat("The thread is removed from the list of IO threads", mySocketIoThreads.isEmpty(), is(true)); }
@Override public void onDisconnected(String reason, BluetoothSocketIoThread who) { long threadId = who.getId(); boolean threadFound = removeThreadFromList(who, true); if (threadFound) { if (who.getPeerProperties() != null) { Log.e(TAG, "onDisconnected (handshake failed) socket:" + who.getSocket() + ", properties: " + who.getPeerProperties()); } Log.e(TAG, "Handshake failed (thread ID: " + threadId + ")"); } }
BluetoothServerThread extends AbstractBluetoothThread implements BluetoothSocketIoThread.Listener { @Override public void onDisconnected(String reason, BluetoothSocketIoThread who) { long threadId = who.getId(); boolean threadFound = removeThreadFromList(who, true); if (threadFound) { if (who.getPeerProperties() != null) { Log.e(TAG, "onDisconnected (handshake failed) socket:" + who.getSocket() + ", properties: " + who.getPeerProperties()); } Log.e(TAG, "Handshake failed (thread ID: " + threadId + ")"); } } }
BluetoothServerThread extends AbstractBluetoothThread implements BluetoothSocketIoThread.Listener { @Override public void onDisconnected(String reason, BluetoothSocketIoThread who) { long threadId = who.getId(); boolean threadFound = removeThreadFromList(who, true); if (threadFound) { if (who.getPeerProperties() != null) { Log.e(TAG, "onDisconnected (handshake failed) socket:" + who.getSocket() + ", properties: " + who.getPeerProperties()); } Log.e(TAG, "Handshake failed (thread ID: " + threadId + ")"); } } BluetoothServerThread(
            Listener listener, BluetoothAdapter bluetoothAdapter,
            UUID serviceRecordUuid, String myBluetoothName, String myIdentityString); }
BluetoothServerThread extends AbstractBluetoothThread implements BluetoothSocketIoThread.Listener { @Override public void onDisconnected(String reason, BluetoothSocketIoThread who) { long threadId = who.getId(); boolean threadFound = removeThreadFromList(who, true); if (threadFound) { if (who.getPeerProperties() != null) { Log.e(TAG, "onDisconnected (handshake failed) socket:" + who.getSocket() + ", properties: " + who.getPeerProperties()); } Log.e(TAG, "Handshake failed (thread ID: " + threadId + ")"); } } BluetoothServerThread(
            Listener listener, BluetoothAdapter bluetoothAdapter,
            UUID serviceRecordUuid, String myBluetoothName, String myIdentityString); @Override void run(); @Override synchronized void shutdown(); @Override void onBytesRead(byte[] bytes, int size, BluetoothSocketIoThread who); @Override void onBytesWritten(byte[] bytes, int size, BluetoothSocketIoThread who); @Override void onDisconnected(String reason, BluetoothSocketIoThread who); }
BluetoothServerThread extends AbstractBluetoothThread implements BluetoothSocketIoThread.Listener { @Override public void onDisconnected(String reason, BluetoothSocketIoThread who) { long threadId = who.getId(); boolean threadFound = removeThreadFromList(who, true); if (threadFound) { if (who.getPeerProperties() != null) { Log.e(TAG, "onDisconnected (handshake failed) socket:" + who.getSocket() + ", properties: " + who.getPeerProperties()); } Log.e(TAG, "Handshake failed (thread ID: " + threadId + ")"); } } BluetoothServerThread(
            Listener listener, BluetoothAdapter bluetoothAdapter,
            UUID serviceRecordUuid, String myBluetoothName, String myIdentityString); @Override void run(); @Override synchronized void shutdown(); @Override void onBytesRead(byte[] bytes, int size, BluetoothSocketIoThread who); @Override void onBytesWritten(byte[] bytes, int size, BluetoothSocketIoThread who); @Override void onDisconnected(String reason, BluetoothSocketIoThread who);  }