From 1b2049eff4a9ebbee6c2905208e4ffb274567b18 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Thu, 20 Oct 2016 12:37:04 -0700 Subject: [PATCH] Fix app refresh on Android in no-hot-reload mode (#6435) Also remove the obsolete "flutter refresh" command --- packages/flutter_tools/lib/executable.dart | 2 - .../lib/src/android/android_device.dart | 9 +- .../lib/src/commands/refresh.dart | 83 ------------------- 3 files changed, 8 insertions(+), 86 deletions(-) delete mode 100644 packages/flutter_tools/lib/src/commands/refresh.dart diff --git a/packages/flutter_tools/lib/executable.dart b/packages/flutter_tools/lib/executable.dart index dea394aa24..d8a3b5c20f 100644 --- a/packages/flutter_tools/lib/executable.dart +++ b/packages/flutter_tools/lib/executable.dart @@ -28,7 +28,6 @@ import 'src/commands/logs.dart'; import 'src/commands/setup.dart'; import 'src/commands/packages.dart'; import 'src/commands/precache.dart'; -import 'src/commands/refresh.dart'; import 'src/commands/run.dart'; import 'src/commands/run_mojo.dart'; import 'src/commands/screenshot.dart'; @@ -73,7 +72,6 @@ Future main(List args) async { ..addCommand(new LogsCommand()) ..addCommand(new PackagesCommand()) ..addCommand(new PrecacheCommand()) - ..addCommand(new RefreshCommand()) ..addCommand(new RunCommand(verboseHelp: verboseHelp)) ..addCommand(new RunMojoCommand(hidden: !verboseHelp)) ..addCommand(new ScreenshotCommand()) diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index 0234e07a34..2cff7b3ae4 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -13,9 +13,11 @@ import '../application_package.dart'; import '../base/os.dart'; import '../base/process.dart'; import '../build_info.dart'; +import '../dart/package_map.dart'; import '../device.dart'; import '../flx.dart' as flx; import '../globals.dart'; +import '../toolchain.dart'; import '../vmservice.dart'; import '../protocol_discovery.dart'; import 'adb.dart'; @@ -461,7 +463,12 @@ class AndroidDevice extends Device { try { String snapshotPath = path.join(tempDir.path, 'snapshot_blob.bin'); - int result = await flx.createSnapshot(mainPath: mainPath, snapshotPath: snapshotPath); + int result = await flx.createSnapshot( + snapshotterPath: tools.getHostToolPath(HostTool.SkySnapshot), + mainPath: mainPath, + snapshotPath: snapshotPath, + packages: path.absolute(PackageMap.globalPackagesPath), + ); if (result != 0) { printError('Failed to run the Flutter compiler; exit code: $result'); diff --git a/packages/flutter_tools/lib/src/commands/refresh.dart b/packages/flutter_tools/lib/src/commands/refresh.dart deleted file mode 100644 index d0df1115a3..0000000000 --- a/packages/flutter_tools/lib/src/commands/refresh.dart +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:async'; -import 'dart:io'; - -import 'package:flutter_tools/src/device.dart'; -import 'package:path/path.dart' as path; - -import '../android/android_device.dart'; -import '../application_package.dart'; -import '../cache.dart'; -import '../flx.dart'; -import '../globals.dart'; -import '../runner/flutter_command.dart'; - -class RefreshCommand extends FlutterCommand { - @override - final String name = 'refresh'; - - @override - final String description = 'Build and deploy the Dart code in a Flutter app (Android only).'; - - RefreshCommand() { - usesTargetOption(); - - argParser.addOption('activity', - help: 'The Android activity that will be told to reload the Flutter code.' - ); - } - - Device device; - - @override - Future verifyThenRunCommand() async { - if (!commandValidator()) - return 1; - device = await findTargetDevice(androidOnly: true); - if (device == null) - return 1; - return super.verifyThenRunCommand(); - } - - @override - Future runCommand() async { - Directory tempDir = await Directory.systemTemp.createTemp('flutter_tools'); - try { - String snapshotPath = path.join(tempDir.path, 'snapshot_blob.bin'); - int result = await createSnapshot(mainPath: targetFile, snapshotPath: snapshotPath); - - if (result != 0) { - printError('Failed to run the Flutter compiler. Exit code: $result'); - return result; - } - - Cache.releaseLockEarly(); - - String activity = argResults['activity']; - if (activity == null) { - AndroidApk apk = applicationPackages.getPackageForPlatform(device.platform); - if (apk != null) { - activity = apk.launchActivity; - } else { - printError('Unable to find the activity to be refreshed.'); - return 1; - } - } - - AndroidDevice androidDevice = device; - - bool success = await androidDevice.refreshSnapshot(activity, snapshotPath); - if (!success) { - printError('Error refreshing snapshot on $device.'); - return 1; - } - - return 0; - } finally { - tempDir.deleteSync(recursive: true); - } - } -}