validateAdbMessage static method

bool validateAdbMessage(
  1. AdbMessage message
)

Implementation

static bool validateAdbMessage(AdbMessage message) {
  if (message.magic != (~message.command).toUnsigned(message.command.bitLength + 1)) {
    debugPrint('Magic invalid: $message');
    return false;
  }
  if (message.payload != null) {
    bool valid = generatePayloadChecksum(message.payload!) == message.checksum;
    if (!valid) debugPrint('Checksum invalid: $message');
    return valid;
  }
  return true;
}