diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index b7ced1147c4..a1522984c0d 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -648,23 +648,6 @@ class FlutterDevice { } } -// Issue: https://github.com/flutter/flutter/issues/33050 -// Matches the following patterns: -// HttpException: Connection closed before full header was received, uri = * -// HttpException: , uri = * -final RegExp kAndroidQHttpConnectionClosedExp = RegExp(r'^HttpException\:.+\, uri \=.+$'); - -/// Returns `true` if any of the devices is running Android Q. -Future hasDeviceRunningAndroidQ(List flutterDevices) async { - for (final FlutterDevice flutterDevice in flutterDevices) { - final String sdkNameAndVersion = await flutterDevice.device.sdkNameAndVersion; - if (sdkNameAndVersion != null && sdkNameAndVersion.startsWith('Android 10')) { - return true; - } - } - return false; -} - // Shared code between different resident application runners. abstract class ResidentRunner { ResidentRunner( diff --git a/packages/flutter_tools/lib/src/run_cold.dart b/packages/flutter_tools/lib/src/run_cold.dart index 81d7fb91284..d2da2b91605 100644 --- a/packages/flutter_tools/lib/src/run_cold.dart +++ b/packages/flutter_tools/lib/src/run_cold.dart @@ -134,13 +134,6 @@ class ColdRunner extends ResidentRunner { ); } on Exception catch (error) { globals.printError('Error connecting to the service protocol: $error'); - // https://github.com/flutter/flutter/issues/33050 - // TODO(blasten): Remove this check once https://issuetracker.google.com/issues/132325318 has been fixed. - if (await hasDeviceRunningAndroidQ(flutterDevices) && - error.toString().contains(kAndroidQHttpConnectionClosedExp)) { - globals.printStatus('🔨 If you are using an emulator running Android Q Beta, consider using an emulator running API level 29 or lower.'); - globals.printStatus('Learn more about the status of this issue on https://issuetracker.google.com/issues/132325318'); - } return 2; } for (final FlutterDevice device in flutterDevices) { diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart index 8b1d768722f..4150ddf638f 100644 --- a/packages/flutter_tools/lib/src/run_hot.dart +++ b/packages/flutter_tools/lib/src/run_hot.dart @@ -233,20 +233,6 @@ class HotRunner extends ResidentRunner { rethrow; } globals.printError('Error connecting to the service protocol: $error'); - // https://github.com/flutter/flutter/issues/33050 - // TODO(blasten): Remove this check once - // https://issuetracker.google.com/issues/132325318 has been fixed. - if (await hasDeviceRunningAndroidQ(flutterDevices) && - error.toString().contains(kAndroidQHttpConnectionClosedExp)) { - globals.printStatus( - '🔨 If you are using an emulator running Android Q Beta, ' - 'consider using an emulator running API level 29 or lower.', - ); - globals.printStatus( - 'Learn more about the status of this issue on ' - 'https://issuetracker.google.com/issues/132325318.', - ); - } return 2; } diff --git a/packages/flutter_tools/test/general.shard/cold_test.dart b/packages/flutter_tools/test/general.shard/cold_test.dart index c7e9b2807aa..83b3d74e6c9 100644 --- a/packages/flutter_tools/test/general.shard/cold_test.dart +++ b/packages/flutter_tools/test/general.shard/cold_test.dart @@ -6,9 +6,6 @@ import 'dart:async'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/logger.dart'; -import 'package:flutter_tools/src/base/platform.dart'; -import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/device.dart'; @@ -23,75 +20,28 @@ import '../src/context.dart'; import '../src/mocks.dart'; void main() { - group('cold attach', () { - MockResidentCompiler residentCompiler; - BufferLogger mockLogger; + testUsingContext('Exits with code 2 when when HttpException is thrown ' + 'during VM service connection', () async { + final MockResidentCompiler residentCompiler = MockResidentCompiler(); + final MockDevice mockDevice = MockDevice(); + when(mockDevice.supportsHotReload).thenReturn(true); + when(mockDevice.supportsHotRestart).thenReturn(false); + when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester); + when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation _) async => 'Android 10'); - setUp(() { - mockLogger = BufferLogger( - terminal: AnsiTerminal( - stdio: null, - platform: const LocalPlatform(), - ), - outputPreferences: OutputPreferences.test(), - ); - residentCompiler = MockResidentCompiler(); - }); + final List devices = [ + TestFlutterDevice( + device: mockDevice, + generator: residentCompiler, + exception: const HttpException('Connection closed before full header was received, ' + 'uri = http://127.0.0.1:63394/5ZmLv8A59xY=/ws'), + ), + ]; - testUsingContext('Prints message when HttpException is thrown - 1', () async { - final MockDevice mockDevice = MockDevice(); - when(mockDevice.supportsHotReload).thenReturn(true); - when(mockDevice.supportsHotRestart).thenReturn(false); - when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester); - when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation _) async => 'Android 10'); - - final List devices = [ - TestFlutterDevice( - device: mockDevice, - generator: residentCompiler, - exception: const HttpException('Connection closed before full header was received, ' - 'uri = http://127.0.0.1:63394/5ZmLv8A59xY=/ws'), - ), - ]; - - final int exitCode = await ColdRunner(devices, - debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), - ).attach(); - expect(exitCode, 2); - expect(mockLogger.statusText, contains('If you are using an emulator running Android Q Beta, ' - 'consider using an emulator running API level 29 or lower.')); - expect(mockLogger.statusText, contains('Learn more about the status of this issue on ' - 'https://issuetracker.google.com/issues/132325318')); - }, overrides: { - Logger: () => mockLogger, - }); - - testUsingContext('Prints message when HttpException is thrown - 2', () async { - final MockDevice mockDevice = MockDevice(); - when(mockDevice.supportsHotReload).thenReturn(true); - when(mockDevice.supportsHotRestart).thenReturn(false); - when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester); - when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation _) async => 'Android 10'); - - final List devices = [ - TestFlutterDevice( - device: mockDevice, - generator: residentCompiler, - exception: const HttpException(', uri = http://127.0.0.1:63394/5ZmLv8A59xY=/ws'), - ), - ]; - - final int exitCode = await ColdRunner(devices, - debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), - ).attach(); - expect(exitCode, 2); - expect(mockLogger.statusText, contains('If you are using an emulator running Android Q Beta, ' - 'consider using an emulator running API level 29 or lower.')); - expect(mockLogger.statusText, contains('Learn more about the status of this issue on ' - 'https://issuetracker.google.com/issues/132325318')); - }, overrides: { - Logger: () => mockLogger, - }); + final int exitCode = await ColdRunner(devices, + debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), + ).attach(); + expect(exitCode, 2); }); group('cleanupAtFinish()', () { diff --git a/packages/flutter_tools/test/general.shard/hot_test.dart b/packages/flutter_tools/test/general.shard/hot_test.dart index 09909434876..48de79b31ea 100644 --- a/packages/flutter_tools/test/general.shard/hot_test.dart +++ b/packages/flutter_tools/test/general.shard/hot_test.dart @@ -415,15 +415,15 @@ void main() { }); group('hot attach', () { - MockResidentCompiler residentCompiler = MockResidentCompiler(); MockLocalEngineArtifacts mockArtifacts; setUp(() { - residentCompiler = MockResidentCompiler(); mockArtifacts = MockLocalEngineArtifacts(); }); - testUsingContext('Prints message when HttpException is thrown - 1', () async { + testUsingContext('Exits with code 2 when when HttpException is thrown ' + 'during VM service connection', () async { + final MockResidentCompiler residentCompiler = MockResidentCompiler(); final MockDevice mockDevice = MockDevice(); when(mockDevice.supportsHotReload).thenReturn(true); when(mockDevice.supportsHotRestart).thenReturn(false); @@ -443,38 +443,6 @@ void main() { debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), ).attach(); expect(exitCode, 2); - expect(testLogger.statusText, contains('If you are using an emulator running Android Q Beta, ' - 'consider using an emulator running API level 29 or lower.')); - expect(testLogger.statusText, contains('Learn more about the status of this issue on ' - 'https://issuetracker.google.com/issues/132325318')); - }, overrides: { - Artifacts: () => mockArtifacts, - HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true), - }); - - testUsingContext('Prints message when HttpException is thrown - 2', () async { - final MockDevice mockDevice = MockDevice(); - when(mockDevice.supportsHotReload).thenReturn(true); - when(mockDevice.supportsHotRestart).thenReturn(false); - when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester); - when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation _) async => 'Android 10'); - - final List devices = [ - TestFlutterDevice( - device: mockDevice, - generator: residentCompiler, - exception: const HttpException(', uri = http://127.0.0.1:63394/5ZmLv8A59xY=/ws'), - ), - ]; - - final int exitCode = await HotRunner(devices, - debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), - ).attach(); - expect(exitCode, 2); - expect(testLogger.statusText, contains('If you are using an emulator running Android Q Beta, ' - 'consider using an emulator running API level 29 or lower.')); - expect(testLogger.statusText, contains('Learn more about the status of this issue on ' - 'https://issuetracker.google.com/issues/132325318')); }, overrides: { Artifacts: () => mockArtifacts, HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),