Unverified Commit 90bc7c64 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] fix calling debugToggleBrightness on release mode (#66401)

ensure that the terminal handler checks if the service protocol is enabled before calling debug toggle brightness. Also removes globals from TerminalHander and test cases.

Fixes #65477
parent a6a8a14d
...@@ -197,55 +197,74 @@ abstract class ResidentWebRunner extends ResidentRunner { ...@@ -197,55 +197,74 @@ abstract class ResidentWebRunner extends ResidentRunner {
} }
@override @override
Future<void> debugDumpApp() async { Future<bool> debugDumpApp() async {
if (!supportsServiceProtocol) {
return false;
}
try { try {
await _vmService await _vmService
?.flutterDebugDumpApp( ?.flutterDebugDumpApp(
isolateId: null, isolateId: null,
); );
} on vmservice.RPCError { } on vmservice.RPCError {
return; // do nothing.
} }
return true;
} }
@override @override
Future<void> debugDumpRenderTree() async { Future<bool> debugDumpRenderTree() async {
if (!supportsServiceProtocol) {
return false;
}
try { try {
await _vmService await _vmService
?.flutterDebugDumpRenderTree( ?.flutterDebugDumpRenderTree(
isolateId: null, isolateId: null,
); );
} on vmservice.RPCError { } on vmservice.RPCError {
return; // do nothing.
} }
return true;
} }
@override @override
Future<void> debugDumpLayerTree() async { Future<bool> debugDumpLayerTree() async {
if (!supportsServiceProtocol) {
return false;
}
try { try {
await _vmService await _vmService
?.flutterDebugDumpLayerTree( ?.flutterDebugDumpLayerTree(
isolateId: null, isolateId: null,
); );
} on vmservice.RPCError { } on vmservice.RPCError {
return; // do nothing.
} }
return true;
} }
@override @override
Future<void> debugDumpSemanticsTreeInTraversalOrder() async { Future<bool> debugDumpSemanticsTreeInTraversalOrder() async {
if (!supportsServiceProtocol) {
return false;
}
try { try {
await _vmService await _vmService
?.flutterDebugDumpSemanticsTreeInTraversalOrder( ?.flutterDebugDumpSemanticsTreeInTraversalOrder(
isolateId: null, isolateId: null,
); );
} on vmservice.RPCError { } on vmservice.RPCError {
return; // do nothing.
} }
return true;
} }
@override @override
Future<void> debugTogglePlatform() async { Future<bool> debugTogglePlatform() async {
if (!supportsServiceProtocol) {
return false;
}
try { try {
final String currentPlatform = await _vmService final String currentPlatform = await _vmService
?.flutterPlatformOverride( ?.flutterPlatformOverride(
...@@ -259,12 +278,16 @@ abstract class ResidentWebRunner extends ResidentRunner { ...@@ -259,12 +278,16 @@ abstract class ResidentWebRunner extends ResidentRunner {
); );
globals.printStatus('Switched operating system to $platform'); globals.printStatus('Switched operating system to $platform');
} on vmservice.RPCError { } on vmservice.RPCError {
return; // do nothing.
} }
return true;
} }
@override @override
Future<void> debugToggleBrightness() async { Future<bool> debugToggleBrightness() async {
if (!supportsServiceProtocol) {
return false;
}
try { try {
final Brightness currentBrightness = await _vmService final Brightness currentBrightness = await _vmService
?.flutterBrightnessOverride( ?.flutterBrightnessOverride(
...@@ -283,8 +306,9 @@ abstract class ResidentWebRunner extends ResidentRunner { ...@@ -283,8 +306,9 @@ abstract class ResidentWebRunner extends ResidentRunner {
); );
globals.logger.printStatus('Changed brightness to $next.'); globals.logger.printStatus('Changed brightness to $next.');
} on vmservice.RPCError { } on vmservice.RPCError {
return; // do nothing.
} }
return true;
} }
@override @override
...@@ -294,87 +318,115 @@ abstract class ResidentWebRunner extends ResidentRunner { ...@@ -294,87 +318,115 @@ abstract class ResidentWebRunner extends ResidentRunner {
} }
@override @override
Future<void> debugDumpSemanticsTreeInInverseHitTestOrder() async { Future<bool> debugDumpSemanticsTreeInInverseHitTestOrder() async {
if (!supportsServiceProtocol) {
return false;
}
try { try {
await _vmService await _vmService
?.flutterDebugDumpSemanticsTreeInInverseHitTestOrder( ?.flutterDebugDumpSemanticsTreeInInverseHitTestOrder(
isolateId: null, isolateId: null,
); );
} on vmservice.RPCError { } on vmservice.RPCError {
return; // do nothing.
} }
return true;
} }
@override @override
Future<void> debugToggleDebugPaintSizeEnabled() async { Future<bool> debugToggleDebugPaintSizeEnabled() async {
if (!supportsServiceProtocol) {
return false;
}
try { try {
await _vmService await _vmService
?.flutterToggleDebugPaintSizeEnabled( ?.flutterToggleDebugPaintSizeEnabled(
isolateId: null, isolateId: null,
); );
} on vmservice.RPCError { } on vmservice.RPCError {
return; // do nothing.
} }
return true;
} }
@override @override
Future<void> debugToggleDebugCheckElevationsEnabled() async { Future<bool> debugToggleDebugCheckElevationsEnabled() async {
if (!supportsServiceProtocol) {
return false;
}
try { try {
await _vmService await _vmService
?.flutterToggleDebugCheckElevationsEnabled( ?.flutterToggleDebugCheckElevationsEnabled(
isolateId: null, isolateId: null,
); );
} on vmservice.RPCError { } on vmservice.RPCError {
return; // do nothing.
} }
return true;
} }
@override @override
Future<void> debugTogglePerformanceOverlayOverride() async { Future<bool> debugTogglePerformanceOverlayOverride() async {
if (!supportsServiceProtocol) {
return false;
}
try { try {
await _vmService await _vmService
?.flutterTogglePerformanceOverlayOverride( ?.flutterTogglePerformanceOverlayOverride(
isolateId: null, isolateId: null,
); );
} on vmservice.RPCError { } on vmservice.RPCError {
return; // do nothing.
} }
return true;
} }
@override @override
Future<void> debugToggleWidgetInspector() async { Future<bool> debugToggleWidgetInspector() async {
if (!supportsServiceProtocol) {
return false;
}
try { try {
await _vmService await _vmService
?.flutterToggleWidgetInspector( ?.flutterToggleWidgetInspector(
isolateId: null, isolateId: null,
); );
} on vmservice.RPCError { } on vmservice.RPCError {
return; // do nothing.
} }
return true;
} }
@override @override
Future<void> debugToggleInvertOversizedImages() async { Future<bool> debugToggleInvertOversizedImages() async {
if (!supportsServiceProtocol) {
return false;
}
try { try {
await _vmService await _vmService
?.flutterToggleInvertOversizedImages( ?.flutterToggleInvertOversizedImages(
isolateId: null, isolateId: null,
); );
} on vmservice.RPCError { } on vmservice.RPCError {
return; // do nothing.
} }
return true;
} }
@override @override
Future<void> debugToggleProfileWidgetBuilds() async { Future<bool> debugToggleProfileWidgetBuilds() async {
if (!supportsServiceProtocol) {
return false;
}
try { try {
await _vmService await _vmService
?.flutterToggleProfileWidgetBuilds( ?.flutterToggleProfileWidgetBuilds(
isolateId: null, isolateId: null,
); );
} on vmservice.RPCError { } on vmservice.RPCError {
return; // do nothing.
} }
return true;
} }
} }
......
...@@ -340,7 +340,12 @@ class AttachCommand extends FlutterCommand { ...@@ -340,7 +340,12 @@ class AttachCommand extends FlutterCommand {
final Completer<void> onAppStart = Completer<void>.sync(); final Completer<void> onAppStart = Completer<void>.sync();
TerminalHandler terminalHandler; TerminalHandler terminalHandler;
unawaited(onAppStart.future.whenComplete(() { unawaited(onAppStart.future.whenComplete(() {
terminalHandler = TerminalHandler(runner) terminalHandler = TerminalHandler(
runner,
logger: globals.logger,
terminal: globals.terminal,
signals: globals.signals,
)
..setupTerminal() ..setupTerminal()
..registerSignalHandlers(); ..registerSignalHandlers();
})); }));
......
...@@ -592,7 +592,12 @@ class RunCommand extends RunCommandBase { ...@@ -592,7 +592,12 @@ class RunCommand extends RunCommandBase {
(_) { (_) {
appStartedTime = globals.systemClock.now(); appStartedTime = globals.systemClock.now();
if (stayResident) { if (stayResident) {
TerminalHandler(runner) TerminalHandler(
runner,
logger: globals.logger,
terminal: globals.terminal,
signals: globals.signals,
)
..setupTerminal() ..setupTerminal()
..registerSignalHandlers(); ..registerSignalHandlers();
} }
......
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