validateAdbMessage static method

bool validateAdbMessage(
  1. AdbMessage message
)

Implementation

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