From 5e2bc90dafeef0e48b8282eb3a5bf1f68696350d Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Thu, 3 Dec 2015 14:44:59 -0800 Subject: [PATCH] Make it possible to specify the saved path for trace --stop @chinmaygarde --- packages/flutter_tools/lib/src/commands/trace.dart | 3 ++- packages/flutter_tools/lib/src/device.dart | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/trace.dart b/packages/flutter_tools/lib/src/commands/trace.dart index 26db7a9649c..04f006ad3f1 100644 --- a/packages/flutter_tools/lib/src/commands/trace.dart +++ b/packages/flutter_tools/lib/src/commands/trace.dart @@ -20,6 +20,7 @@ class TraceCommand extends FlutterCommand { TraceCommand() { argParser.addFlag('start', negatable: false, help: 'Start tracing.'); argParser.addFlag('stop', negatable: false, help: 'Stop tracing.'); + argParser.addOption('out', help: 'Specify the path of the saved trace file.'); argParser.addOption('duration', defaultsTo: '10', abbr: 'd', help: 'Duration in seconds to trace.'); } @@ -52,7 +53,7 @@ class TraceCommand extends FlutterCommand { } void _stopTracing(AndroidDevice android, AndroidApk androidApp) { - String tracePath = android.stopTracing(androidApp); + String tracePath = android.stopTracing(androidApp, outPath: argResults['out']); if (tracePath == null) { logging.warning('No trace file saved.'); } else { diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart index f31ca64deec..81d8d7ae90b 100644 --- a/packages/flutter_tools/lib/src/device.dart +++ b/packages/flutter_tools/lib/src/device.dart @@ -853,7 +853,7 @@ class AndroidDevice extends Device { ])); } - String stopTracing(AndroidApk apk) { + String stopTracing(AndroidApk apk, { String outPath: null }) { clearLogs(); runCheckedSync(adbCommandForDevice([ 'shell', @@ -878,11 +878,12 @@ class AndroidDevice extends Device { } if (tracePath != null) { + String localPath = (outPath != null) ? outPath : path.basename(tracePath); runCheckedSync(adbCommandForDevice(['root'])); runSync(adbCommandForDevice(['shell', 'run-as', apk.id, 'chmod', '777', tracePath])); - runCheckedSync(adbCommandForDevice(['pull', tracePath])); + runCheckedSync(adbCommandForDevice(['pull', tracePath, localPath])); runSync(adbCommandForDevice(['shell', 'rm', tracePath])); - return path.basename(tracePath); + return localPath; } logging.warning('No trace file detected. ' 'Did you remember to start the trace before stopping it?');