From f0671edfdbf2295b766b26152b84e1cab90c116c Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Fri, 1 Jul 2016 10:19:28 -0700 Subject: [PATCH] workaround adb logcat -T (#4798) --- .../lib/src/android/android_device.dart | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index 508901835c..e020d2f79e 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -640,8 +640,20 @@ class _AdbLogReader extends DeviceLogReader { // Start the adb logcat process. List args = ['logcat', '-v', 'tag']; String lastTimestamp = device.lastLogcatTimestamp; - if (lastTimestamp != null) - args.addAll(['-T', lastTimestamp]); + if (lastTimestamp != null) { + bool supportsLastTimestamp = false; + + // Check to see if this copy of adb supports -T. + try { + // "logcat: invalid option -- T", "Unrecognized Option" + // logcat -g will finish immediately; it will print an error to stdout if -T isn't supported. + String result = runSync(device.adbCommandForDevice(['logcat', '-g', '-T', lastTimestamp])); + supportsLastTimestamp = !result.contains('logcat: invalid option') && !result.contains('Unrecognized Option'); + } catch (_) { } + + if (supportsLastTimestamp) + args.addAll(['-T', lastTimestamp]); + } runCommand(device.adbCommandForDevice(args)).then((Process process) { _process = process; _process.stdout.transform(UTF8.decoder).transform(const LineSplitter()).listen(_onLine);