classifyAndroidInputTap function

NativeTapResult? classifyAndroidInputTap({
  1. required int exitCode,
  2. required String stdout,
  3. required String stderr,
})

Classifies the output of adb shell input tap. Returns null when the tap went through.

adb often exits 0 even when input threw, so the output is checked regardless of the exit code: SecurityException / INJECT_EVENTS means the OS blocked injection; any other Exception is a failure.

Implementation

NativeTapResult? classifyAndroidInputTap({required int exitCode, required String stdout, required String stderr}) {
  final output = [stdout.trim(), stderr.trim()].where((s) => s.isNotEmpty).join('\n');
  if (output.contains('INJECT_EVENTS') || output.contains('SecurityException')) {
    return NativeTapInputInjectionBlocked(output);
  }
  if (exitCode != 0) {
    return NativeTapAdbFailed(output.isNotEmpty ? output : 'adb exited with code $exitCode');
  }
  if (output.contains('Exception')) return NativeTapAdbFailed(output);
  return null;
}