private boolean isServiceChangedCCCDEnabled() throws DeviceDisconnectedException, DfuException, UploadAbortedException {
  if (!mConnected)   throw new DeviceDisconnectedException("Unable to read Service Changed CCCD: device disconnected");
  if (mAborted)   throw new UploadAbortedException();
  final BluetoothGatt gatt=mGatt;
  final BluetoothGattService genericAttributeService=gatt.getService(GENERIC_ATTRIBUTE_SERVICE_UUID);
  if (genericAttributeService == null)   return false;
  final BluetoothGattCharacteristic serviceChangedCharacteristic=genericAttributeService.getCharacteristic(SERVICE_CHANGED_UUID);
  if (serviceChangedCharacteristic == null)   return false;
  final BluetoothGattDescriptor descriptor=serviceChangedCharacteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG);
  if (descriptor == null)   return false;
  mRequestCompleted=false;
  mError=0;
  logi("Reading Service Changed CCCD value...");
  mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_VERBOSE,"Reading Service Changed CCCD value...");
  mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_DEBUG,"gatt.readDescriptor(" + descriptor.getUuid() + ")");
  gatt.readDescriptor(descriptor);
  try {
synchronized (mLock) {
      while ((!mRequestCompleted && mConnected && mError == 0) || mPaused)       mLock.wait();
    }
  }
 catch (  final InterruptedException e) {
    loge("Sleeping interrupted",e);
  }
  if (mError != 0)   throw new DfuException("Unable to read Service Changed CCCD",mError);
  if (!mConnected)   throw new DeviceDisconnectedException("Unable to read Service Changed CCCD: device disconnected");
  return descriptor.getValue() != null && descriptor.getValue().length == 2 && descriptor.getValue()[0] == BluetoothGattDescriptor.ENABLE_INDICATION_VALUE[0] && descriptor.getValue()[1] == BluetoothGattDescriptor.ENABLE_INDICATION_VALUE[1];
}

private boolean isServiceChangedCCCDEnabled ( ) throws DeviceDisconnectedException , DfuException , UploadAbortedException { if ( ! mConnected ) throw new DeviceDisconnectedException ( "Unable to read Service Changed CCCD: device disconnected" ) ; if ( mAborted ) throw new UploadAbortedException ( ) ; final BluetoothGatt gatt = mGatt ; final BluetoothGattService genericAttributeService = gatt . getService ( GENERIC_ATTRIBUTE_SERVICE_UUID ) ; if ( genericAttributeService == null ) return false ; final BluetoothGattCharacteristic serviceChangedCharacteristic = genericAttributeService . getCharacteristic ( SERVICE_CHANGED_UUID ) ; if ( serviceChangedCharacteristic == null ) return false ; final BluetoothGattDescriptor descriptor = serviceChangedCharacteristic . getDescriptor ( CLIENT_CHARACTERISTIC_CONFIG ) ; if ( descriptor == null ) return false ; mRequestCompleted = false ; mError = 0 ; logi ( "Reading Service Changed CCCD value..." ) ; mService . sendLogBroadcast ( DfuBaseService . LOG_LEVEL_VERBOSE , "Reading Service Changed CCCD value..." ) ; mService . sendLogBroadcast ( DfuBaseService . LOG_LEVEL_DEBUG , "gatt.readDescriptor(" + descriptor . getUuid ( ) + ")" ) ; gatt . readDescriptor ( descriptor ) ; try { synchronized ( mLock ) { while ( ( ! mRequestCompleted && mConnected && mError == 0 ) || mPaused ) mLock . wait ( ) ; } } catch ( final InterruptedException e ) { loge ( "Sleeping interrupted" , e ) ; } if ( mError != 0 ) throw new DfuException ( "Unable to read Service Changed CCCD" , mError ) ; if ( ! mConnected ) throw new DeviceDisconnectedException ( "Unable to read Service Changed CCCD: device disconnected" ) ; return descriptor . getValue ( ) != null && descriptor . getValue ( ) . length == 2 && descriptor . getValue ( ) [ 0 ] == BluetoothGattDescriptor . ENABLE_INDICATION_VALUE [ 0 ] && descriptor . getValue ( ) [ 1 ] == BluetoothGattDescriptor . ENABLE_INDICATION_VALUE [ 1 ] ; }
reads the value of the service changed client characteristic configuration descriptor ( cccd ) .
