Unverified Commit 5555725f authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tool] Fix 'q' for Fuchsia profile/debug mode (#33846)

parent 9114f445
......@@ -863,7 +863,7 @@ class AppInstance {
return runner.restart(fullRestart: fullRestart, pauseAfterRestart: pauseAfterRestart, reason: reason);
}
Future<void> stop() => runner.stop();
Future<void> stop() => runner.exit();
Future<void> detach() => runner.detach();
void closeLogger() {
......
......@@ -307,7 +307,7 @@ abstract class Device {
/// Whether flutter applications running on this device can be terminated
/// from the vmservice.
bool get supportsStopApp => true;
bool get supportsFlutterExit => true;
/// Whether the device supports taking screenshots of a running flutter
/// application.
......
......@@ -184,7 +184,7 @@ class FuchsiaDevice extends Device {
bool get supportsHotRestart => false;
@override
bool get supportsStopApp => false;
bool get supportsFlutterExit => false;
@override
final String name;
......
......@@ -11,7 +11,7 @@ import 'artifacts.dart';
import 'asset.dart';
import 'base/common.dart';
import 'base/file_system.dart';
import 'base/io.dart';
import 'base/io.dart' as io;
import 'base/logger.dart';
import 'base/terminal.dart';
import 'base/utils.dart';
......@@ -166,8 +166,9 @@ class FlutterDevice {
await service.getVM();
}
Future<void> stopApps() async {
if (!device.supportsStopApp) {
Future<void> exitApps() async {
if (!device.supportsFlutterExit) {
await device.stopApp(package);
return;
}
final List<FlutterView> flutterViews = views;
......@@ -530,7 +531,7 @@ abstract class ResidentRunner {
final bool stayResident;
final bool ipv6;
final Completer<int> _finished = Completer<int>();
bool _stopped = false;
bool _exited = false;
String _packagesFilePath;
String get packagesFilePath => _packagesFilePath;
String _projectRootPath;
......@@ -582,18 +583,18 @@ abstract class ResidentRunner {
throw '${fullRestart ? 'Restart' : 'Reload'} is not supported in $mode mode';
}
Future<void> stop() async {
_stopped = true;
Future<void> exit() async {
_exited = true;
if (saveCompilationTrace)
await _debugSaveCompilationTrace();
await stopEchoingDeviceLog();
await preStop();
await stopApp();
await preExit();
await exitApp();
}
Future<void> detach() async {
await stopEchoingDeviceLog();
await preStop();
await preExit();
appFinished();
}
......@@ -743,29 +744,29 @@ abstract class ResidentRunner {
void registerSignalHandlers() {
assert(stayResident);
ProcessSignal.SIGINT.watch().listen(_cleanUpAndExit);
ProcessSignal.SIGTERM.watch().listen(_cleanUpAndExit);
io.ProcessSignal.SIGINT.watch().listen(_cleanUpAndExit);
io.ProcessSignal.SIGTERM.watch().listen(_cleanUpAndExit);
if (!supportsServiceProtocol || !supportsRestart)
return;
ProcessSignal.SIGUSR1.watch().listen(_handleSignal);
ProcessSignal.SIGUSR2.watch().listen(_handleSignal);
io.ProcessSignal.SIGUSR1.watch().listen(_handleSignal);
io.ProcessSignal.SIGUSR2.watch().listen(_handleSignal);
}
Future<void> _cleanUpAndExit(ProcessSignal signal) async {
Future<void> _cleanUpAndExit(io.ProcessSignal signal) async {
_resetTerminal();
await cleanupAfterSignal();
exit(0);
io.exit(0);
}
bool _processingUserRequest = false;
Future<void> _handleSignal(ProcessSignal signal) async {
Future<void> _handleSignal(io.ProcessSignal signal) async {
if (_processingUserRequest) {
printTrace('Ignoring signal: "$signal" because we are busy.');
return;
}
_processingUserRequest = true;
final bool fullRestart = signal == ProcessSignal.SIGUSR2;
final bool fullRestart = signal == io.ProcessSignal.SIGUSR2;
try {
await restart(fullRestart: fullRestart);
......@@ -903,7 +904,7 @@ abstract class ResidentRunner {
}
} else if (lower == 'q') {
// exit
await stop();
await exit();
return true;
} else if (lower == 'd') {
await detach();
......@@ -937,7 +938,7 @@ abstract class ResidentRunner {
}
void _serviceDisconnected() {
if (_stopped) {
if (_exited) {
// User requested the application exit.
return;
}
......@@ -980,12 +981,12 @@ abstract class ResidentRunner {
return exitCode;
}
Future<void> preStop() async { }
Future<void> preExit() async { }
Future<void> stopApp() async {
Future<void> exitApp() async {
final List<Future<void>> futures = <Future<void>>[];
for (FlutterDevice device in flutterDevices)
futures.add(device.stopApps());
futures.add(device.exitApps());
await Future.wait(futures);
appFinished();
}
......
......@@ -160,10 +160,8 @@ class ColdRunner extends ResidentRunner {
await stopEchoingDeviceLog();
if (_didAttach) {
appFinished();
} else {
await stopApp();
}
await stopApp();
await exitApp();
}
@override
......@@ -207,7 +205,7 @@ class ColdRunner extends ResidentRunner {
}
@override
Future<void> preStop() async {
Future<void> preExit() async {
for (FlutterDevice device in flutterDevices) {
// If we're running in release mode, stop the app using the device logic.
if (device.vmServices == null || device.vmServices.isEmpty)
......
......@@ -218,7 +218,7 @@ class HotRunner extends ResidentRunner {
printStatus('Benchmark completed. Exiting application.');
await _cleanupDevFS();
await stopEchoingDeviceLog();
await stopApp();
await exitApp();
}
final File benchmarkOutput = fs.file('hot_benchmark.json');
benchmarkOutput.writeAsStringSync(toPrettyJson(benchmarkData));
......@@ -922,12 +922,12 @@ class HotRunner extends ResidentRunner {
if (_didAttach) {
appFinished();
} else {
await stopApp();
await exitApp();
}
}
@override
Future<void> preStop() async {
Future<void> preExit() async {
await _cleanupDevFS();
await hotRunnerConfig.runPreShutdownOperations();
}
......
......@@ -49,7 +49,7 @@ class WebDevice extends Device {
bool get supportsStartPaused => true;
@override
bool get supportsStopApp => true;
bool get supportsFlutterExit => true;
@override
bool get supportsScreenshot => false;
......
......@@ -72,7 +72,7 @@ void main() {
expect(device.supportsHotReload, true);
expect(device.supportsHotRestart, false);
expect(device.supportsStopApp, false);
expect(device.supportsFlutterExit, false);
expect(device.isSupportedForProject(FlutterProject.current()), true);
}, overrides: <Type, Generator>{
FileSystem: () => memoryFileSystem,
......
......@@ -232,7 +232,7 @@ void main() {
final MockDevice mockDevice = MockDevice();
when(mockDevice.supportsHotReload).thenReturn(true);
when(mockDevice.supportsHotRestart).thenReturn(true);
when(mockDevice.supportsStopApp).thenReturn(false);
when(mockDevice.supportsFlutterExit).thenReturn(false);
final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug),
];
......@@ -247,11 +247,11 @@ void main() {
final MockDevice mockDevice = MockDevice();
when(mockDevice.supportsHotReload).thenReturn(true);
when(mockDevice.supportsHotRestart).thenReturn(true);
when(mockDevice.supportsStopApp).thenReturn(false);
when(mockDevice.supportsFlutterExit).thenReturn(false);
final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug),
];
await HotRunner(devices).preStop();
await HotRunner(devices).preExit();
expect(shutdownTestingConfig.shutdownHookCalled, true);
}, overrides: <Type, Generator>{
Artifacts: () => mockArtifacts,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment