From c79de78237dcb922a4deb7e1b9bc58949b746da8 Mon Sep 17 00:00:00 2001 From: duzenko Date: Mon, 15 Jun 2020 19:35:07 +0300 Subject: [PATCH] LG debugging/logcat fixed (#58670) --- .../lib/src/android/android_device.dart | 8 ++++++-- .../general.shard/android/adb_log_reader_test.dart | 14 +++++++++++++- .../android/android_device_start_test.dart | 2 ++ .../general.shard/android/android_device_test.dart | 4 ++-- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index 95c8676fd9..ce53c2ac94 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -1024,7 +1024,11 @@ class AdbLogReader extends DeviceLogReader { }(await device.apiVersion); // Start the adb logcat process and filter the most recent logs since `lastTimestamp`. + // Some devices (notably LG) will only output logcat via shell + // https://github.com/flutter/flutter/issues/51853 final List args = [ + 'shell', + '-x', 'logcat', '-v', 'time', @@ -1034,9 +1038,9 @@ class AdbLogReader extends DeviceLogReader { 'flutter', ] else if (apiVersion != null && apiVersion >= kLollipopVersionCode) ...[ // Otherwise, filter for logs appearing past the present. - // Empty `-T` means the timestamp of the logcat command invocation. + // '-T 0` means the timestamp of the logcat command invocation. '-T', - device.lastLogcatTimestamp ?? '', + if (device.lastLogcatTimestamp != null) '\'${device.lastLogcatTimestamp}\'' else '0', ], ]; final Process process = await processManager.start(device.adbCommandForDevice(args)); diff --git a/packages/flutter_tools/test/general.shard/android/adb_log_reader_test.dart b/packages/flutter_tools/test/general.shard/android/adb_log_reader_test.dart index b1175d82cd..7d3fc87cd5 100644 --- a/packages/flutter_tools/test/general.shard/android/adb_log_reader_test.dart +++ b/packages/flutter_tools/test/general.shard/android/adb_log_reader_test.dart @@ -26,11 +26,13 @@ void main() { 'adb', '-s', '1234', + 'shell', + '-x', 'logcat', '-v', 'time', '-T', - kLastLogcatTimestamp, + '\'$kLastLogcatTimestamp\'', ], ) ]); @@ -49,6 +51,8 @@ void main() { 'adb', '-s', '1234', + 'shell', + '-x', 'logcat', '-v', 'time', @@ -70,6 +74,8 @@ void main() { 'adb', '-s', '1234', + 'shell', + '-x', 'logcat', '-v', 'time', @@ -91,6 +97,8 @@ void main() { 'adb', '-s', '1234', + 'shell', + '-x', 'logcat', '-v', 'time', @@ -115,6 +123,8 @@ void main() { 'adb', '-s', '1234', + 'shell', + '-x', 'logcat', '-v', 'time', @@ -141,6 +151,8 @@ void main() { 'adb', '-s', '1234', + 'shell', + '-x', 'logcat', '-v', 'time', diff --git a/packages/flutter_tools/test/general.shard/android/android_device_start_test.dart b/packages/flutter_tools/test/general.shard/android/android_device_start_test.dart index f940b5a571..81c023192a 100644 --- a/packages/flutter_tools/test/general.shard/android/android_device_start_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_device_start_test.dart @@ -217,6 +217,8 @@ void main() { 'adb', '-s', '1234', + 'shell', + '-x', 'logcat', '-v', 'time', diff --git a/packages/flutter_tools/test/general.shard/android/android_device_test.dart b/packages/flutter_tools/test/general.shard/android/android_device_test.dart index 5770406c91..4d81631d67 100644 --- a/packages/flutter_tools/test/general.shard/android/android_device_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_device_test.dart @@ -370,10 +370,10 @@ flutter: exitCode: 1, ), const FakeCommand( - command: ['adb', '-s', '1234', 'logcat', '-v', 'time', '-s', 'flutter'], + command: ['adb', '-s', '1234', 'shell', '-x', 'logcat', '-v', 'time', '-s', 'flutter'], ), const FakeCommand( - command: ['adb', '-s', '1234', 'logcat', '-v', 'time'], + command: ['adb', '-s', '1234', 'shell', '-x', 'logcat', '-v', 'time'], ) ]) );