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