@Test public void testGetBluetoothMacAddressFromSocket() throws Exception { String macAddress = "0A:1B:2C:3D:4E:5F"; when(mMockBluetoothDevice.getAddress()).thenReturn(macAddress); assertThat("The BT MAC the peer from the given BT socket instance is proper", BluetoothUtils.getBluetoothMacAddressFromSocket(mMockBluetoothSocket), is(macAddress)); assertThat("The BT MAC the peer from the given BT socket instance is null if not accessible", BluetoothUtils.getBluetoothMacAddressFromSocket(null), is(nullValue())); when(mMockBluetoothSocket.getRemoteDevice()).thenReturn(null); assertThat("The BT MAC the peer from the given BT socket instance is null if not accessible", BluetoothUtils.getBluetoothMacAddressFromSocket(null), is(nullValue())); }
public static String getBluetoothMacAddressFromSocket(final BluetoothSocket bluetoothSocket) { String bluetoothMacAddress = null; if (bluetoothSocket != null && bluetoothSocket.getRemoteDevice() != null) { bluetoothMacAddress = bluetoothSocket.getRemoteDevice().getAddress(); } else { Log.e(TAG, "getBluetoothMacAddressFromSocket: Either the socket or its remote device is null"); } return bluetoothMacAddress; }
BluetoothUtils { public static String getBluetoothMacAddressFromSocket(final BluetoothSocket bluetoothSocket) { String bluetoothMacAddress = null; if (bluetoothSocket != null && bluetoothSocket.getRemoteDevice() != null) { bluetoothMacAddress = bluetoothSocket.getRemoteDevice().getAddress(); } else { Log.e(TAG, "getBluetoothMacAddressFromSocket: Either the socket or its remote device is null"); } return bluetoothMacAddress; } }
BluetoothUtils { public static String getBluetoothMacAddressFromSocket(final BluetoothSocket bluetoothSocket) { String bluetoothMacAddress = null; if (bluetoothSocket != null && bluetoothSocket.getRemoteDevice() != null) { bluetoothMacAddress = bluetoothSocket.getRemoteDevice().getAddress(); } else { Log.e(TAG, "getBluetoothMacAddressFromSocket: Either the socket or its remote device is null"); } return bluetoothMacAddress; }  }
BluetoothUtils { public static String getBluetoothMacAddressFromSocket(final BluetoothSocket bluetoothSocket) { String bluetoothMacAddress = null; if (bluetoothSocket != null && bluetoothSocket.getRemoteDevice() != null) { bluetoothMacAddress = bluetoothSocket.getRemoteDevice().getAddress(); } else { Log.e(TAG, "getBluetoothMacAddressFromSocket: Either the socket or its remote device is null"); } return bluetoothMacAddress; }  static boolean isBluetoothMacAddressUnknown(String bluetoothMacAddress); static boolean isValidBluetoothMacAddress(String bluetoothMacAddress); static String getBluetoothMacAddressFromSocket(final BluetoothSocket bluetoothSocket); static PeerProperties validateReceivedHandshakeMessage(
            byte[] handshakeMessage, int handshakeMessageLength, BluetoothSocket bluetoothSocketOfSender); static int getPreviouslyUsedAlternativeChannelOrPort(); static void setNextAlternativeChannelOrPort(int channelOrPort); static BluetoothSocket createBluetoothSocketToServiceRecord(
            BluetoothDevice bluetoothDevice, UUID serviceRecordUuid, int channelOrPort, boolean secure); static BluetoothSocket createBluetoothSocketToServiceRecordWithNextPort(
            BluetoothDevice bluetoothDevice, UUID serviceRecordUuid, boolean secure); static BluetoothSocket createBluetoothSocket(
            BluetoothSocket originalBluetoothSocket, int channelOrPort, boolean secure); static BluetoothSocket createBluetoothSocketWithNextChannel(
            BluetoothSocket originalBluetoothSocket, boolean secure); }
BluetoothUtils { public static String getBluetoothMacAddressFromSocket(final BluetoothSocket bluetoothSocket) { String bluetoothMacAddress = null; if (bluetoothSocket != null && bluetoothSocket.getRemoteDevice() != null) { bluetoothMacAddress = bluetoothSocket.getRemoteDevice().getAddress(); } else { Log.e(TAG, "getBluetoothMacAddressFromSocket: Either the socket or its remote device is null"); } return bluetoothMacAddress; }  static boolean isBluetoothMacAddressUnknown(String bluetoothMacAddress); static boolean isValidBluetoothMacAddress(String bluetoothMacAddress); static String getBluetoothMacAddressFromSocket(final BluetoothSocket bluetoothSocket); static PeerProperties validateReceivedHandshakeMessage(
            byte[] handshakeMessage, int handshakeMessageLength, BluetoothSocket bluetoothSocketOfSender); static int getPreviouslyUsedAlternativeChannelOrPort(); static void setNextAlternativeChannelOrPort(int channelOrPort); static BluetoothSocket createBluetoothSocketToServiceRecord(
            BluetoothDevice bluetoothDevice, UUID serviceRecordUuid, int channelOrPort, boolean secure); static BluetoothSocket createBluetoothSocketToServiceRecordWithNextPort(
            BluetoothDevice bluetoothDevice, UUID serviceRecordUuid, boolean secure); static BluetoothSocket createBluetoothSocket(
            BluetoothSocket originalBluetoothSocket, int channelOrPort, boolean secure); static BluetoothSocket createBluetoothSocketWithNextChannel(
            BluetoothSocket originalBluetoothSocket, boolean secure); static final String BLUETOOTH_ADDRESS_SEPARATOR; static final int BLUETOOTH_ADDRESS_BYTE_COUNT; static final int BLUETOOTH_MAC_ADDRESS_STRING_LENGTH_MIN; static final int BLUETOOTH_MAC_ADDRESS_STRING_LENGTH_MAX; static final String SIMPLE_HANDSHAKE_MESSAGE_AS_STRING; static final byte[] SIMPLE_HANDSHAKE_MESSAGE_AS_BYTE_ARRAY; }