@Test public void onDescriptorWrite() { final BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(UUID.randomUUID(), 1, 1); final BluetoothGattDescriptor descriptor = mock(BluetoothGattDescriptor.class); when(descriptor.getCharacteristic()).thenReturn(characteristic); cut.setLoggingEnabled(false); cut.onDescriptorWrite(gatt, descriptor, 1); verifyLogNotCalled(); cut.setLoggingEnabled(true); cut.onDescriptorWrite(gatt, descriptor, 1); verifyLogEngine().log(Mockito.anyString()); }
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { if (loggingEnabled) { final String methodName = "onDescriptorWrite()"; int index = 1; int max = 3; logDeviceInfo(gatt, methodName, index++, max); logGattStatus(status, methodName, index++, max); logger.log(String.format(LOCALE, LOG_TEMPLATE_PREFIX + "Descriptor: %s", SPACE, methodName, index, max, btStringMapper.asString(descriptor))); } }
GattCallbackLogger implements LogControl { public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { if (loggingEnabled) { final String methodName = "onDescriptorWrite()"; int index = 1; int max = 3; logDeviceInfo(gatt, methodName, index++, max); logGattStatus(status, methodName, index++, max); logger.log(String.format(LOCALE, LOG_TEMPLATE_PREFIX + "Descriptor: %s", SPACE, methodName, index, max, btStringMapper.asString(descriptor))); } } }
GattCallbackLogger implements LogControl { public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { if (loggingEnabled) { final String methodName = "onDescriptorWrite()"; int index = 1; int max = 3; logDeviceInfo(gatt, methodName, index++, max); logGattStatus(status, methodName, index++, max); logger.log(String.format(LOCALE, LOG_TEMPLATE_PREFIX + "Descriptor: %s", SPACE, methodName, index, max, btStringMapper.asString(descriptor))); } } GattCallbackLogger(@NonNull final String logTag,
                       @NonNull final ByteFormat byteFormat); @VisibleForTesting  GattCallbackLogger(@NonNull final LogEngine logEngine,
                       @NonNull final ByteFormat byteFormat); }
GattCallbackLogger implements LogControl { public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { if (loggingEnabled) { final String methodName = "onDescriptorWrite()"; int index = 1; int max = 3; logDeviceInfo(gatt, methodName, index++, max); logGattStatus(status, methodName, index++, max); logger.log(String.format(LOCALE, LOG_TEMPLATE_PREFIX + "Descriptor: %s", SPACE, methodName, index, max, btStringMapper.asString(descriptor))); } } GattCallbackLogger(@NonNull final String logTag,
                       @NonNull final ByteFormat byteFormat); @VisibleForTesting  GattCallbackLogger(@NonNull final LogEngine logEngine,
                       @NonNull final ByteFormat byteFormat); void onPhyUpdate(BluetoothGatt gatt,
                            int txPhy,
                            int rxPhy,
                            int status); void onPhyRead(BluetoothGatt gatt,
                          int txPhy,
                          int rxPhy,
                          int status); void onConnectionStateChange(BluetoothGatt gatt,
                                        int status,
                                        int newState); void onServicesDiscovered(BluetoothGatt gatt,
                                     int status); void onCharacteristicRead(BluetoothGatt gatt,
                                     BluetoothGattCharacteristic characteristic,
                                     int status); void onCharacteristicWrite(BluetoothGatt gatt,
                                      BluetoothGattCharacteristic characteristic,
                                      int status); void onCharacteristicChanged(BluetoothGatt gatt,
                                        BluetoothGattCharacteristic characteristic); void onDescriptorRead(BluetoothGatt gatt,
                                 BluetoothGattDescriptor descriptor,
                                 int status); void onDescriptorWrite(BluetoothGatt gatt,
                                  BluetoothGattDescriptor descriptor,
                                  int status); void onReliableWriteCompleted(BluetoothGatt gatt,
                                         int status); void onReadRemoteRssi(BluetoothGatt gatt,
                                 int rssi,
                                 int status); void onMtuChanged(BluetoothGatt gatt,
                             int mtu,
                             int status); @Override boolean isLoggingEnabled(); @Override void setLoggingEnabled(final boolean enabled); }
GattCallbackLogger implements LogControl { public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { if (loggingEnabled) { final String methodName = "onDescriptorWrite()"; int index = 1; int max = 3; logDeviceInfo(gatt, methodName, index++, max); logGattStatus(status, methodName, index++, max); logger.log(String.format(LOCALE, LOG_TEMPLATE_PREFIX + "Descriptor: %s", SPACE, methodName, index, max, btStringMapper.asString(descriptor))); } } GattCallbackLogger(@NonNull final String logTag,
                       @NonNull final ByteFormat byteFormat); @VisibleForTesting  GattCallbackLogger(@NonNull final LogEngine logEngine,
                       @NonNull final ByteFormat byteFormat); void onPhyUpdate(BluetoothGatt gatt,
                            int txPhy,
                            int rxPhy,
                            int status); void onPhyRead(BluetoothGatt gatt,
                          int txPhy,
                          int rxPhy,
                          int status); void onConnectionStateChange(BluetoothGatt gatt,
                                        int status,
                                        int newState); void onServicesDiscovered(BluetoothGatt gatt,
                                     int status); void onCharacteristicRead(BluetoothGatt gatt,
                                     BluetoothGattCharacteristic characteristic,
                                     int status); void onCharacteristicWrite(BluetoothGatt gatt,
                                      BluetoothGattCharacteristic characteristic,
                                      int status); void onCharacteristicChanged(BluetoothGatt gatt,
                                        BluetoothGattCharacteristic characteristic); void onDescriptorRead(BluetoothGatt gatt,
                                 BluetoothGattDescriptor descriptor,
                                 int status); void onDescriptorWrite(BluetoothGatt gatt,
                                  BluetoothGattDescriptor descriptor,
                                  int status); void onReliableWriteCompleted(BluetoothGatt gatt,
                                         int status); void onReadRemoteRssi(BluetoothGatt gatt,
                                 int rssi,
                                 int status); void onMtuChanged(BluetoothGatt gatt,
                             int mtu,
                             int status); @Override boolean isLoggingEnabled(); @Override void setLoggingEnabled(final boolean enabled);  }