forked from firka/flutter
Prevent calls to view.uiIsolate.flutterExit on devices which do not support it (#26201)
This commit is contained in:
@@ -184,6 +184,7 @@ abstract class PollingDeviceDiscovery extends DeviceDiscovery {
|
||||
}
|
||||
|
||||
abstract class Device {
|
||||
|
||||
Device(this.id);
|
||||
|
||||
final String id;
|
||||
@@ -276,11 +277,17 @@ abstract class Device {
|
||||
/// Whether this device implements support for hot restart.
|
||||
bool get supportsHotRestart => true;
|
||||
|
||||
/// Whether flutter applications running on this device can be terminated
|
||||
/// from the vmservice.
|
||||
bool get supportsStopApp => true;
|
||||
|
||||
/// Whether the device supports taking screenshots of a running flutter
|
||||
/// application.
|
||||
bool get supportsScreenshot => false;
|
||||
|
||||
/// Stop an app package on the current device.
|
||||
Future<bool> stopApp(ApplicationPackage app);
|
||||
|
||||
bool get supportsScreenshot => false;
|
||||
|
||||
Future<void> takeScreenshot(File outputFile) => Future<void>.error('unimplemented');
|
||||
|
||||
@override
|
||||
|
||||
@@ -150,6 +150,9 @@ class FuchsiaDevice extends Device {
|
||||
@override
|
||||
bool get supportsHotRestart => false;
|
||||
|
||||
@override
|
||||
bool get supportsStopApp => false;
|
||||
|
||||
@override
|
||||
final String name;
|
||||
|
||||
|
||||
@@ -109,6 +109,9 @@ class FlutterDevice {
|
||||
}
|
||||
|
||||
Future<void> stopApps() async {
|
||||
if (!device.supportsStopApp) {
|
||||
return;
|
||||
}
|
||||
final List<FlutterView> flutterViews = views;
|
||||
if (flutterViews == null || flutterViews.isEmpty)
|
||||
return;
|
||||
|
||||
@@ -36,6 +36,15 @@ void main() {
|
||||
expect(names.length, 1);
|
||||
expect(names.first, 'lilia-shore-only-last');
|
||||
});
|
||||
|
||||
test('default capabilities', () async {
|
||||
final FuchsiaDevice device = FuchsiaDevice('123');
|
||||
|
||||
expect(device.supportsHotReload, true);
|
||||
expect(device.supportsHotRestart, false);
|
||||
expect(device.supportsStopApp, false);
|
||||
expect(await device.stopApp(null), false);
|
||||
});
|
||||
});
|
||||
|
||||
group('displays friendly error when', () {
|
||||
|
||||
Reference in New Issue
Block a user