Support brightness override in a11y page #9898
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements the VM service extension integration for overriding brightness in the accessibility controls. It defines the brightnessMode service extension, updates the AccessibilityController to listen to device-side brightness changes, and sends updates back to the VM service when changed via the DevTools UI. Additionally, it adds corresponding analytics constants and comprehensive tests. The reviewer raised a concern regarding potential feedback loops and redundant VM service calls when brightness changes originate from the device itself, suggesting a boolean guard to prevent unnecessary updates.
32aec8c to
cd275cb
Compare
kenzieschmoll
left a comment
There was a problem hiding this comment.
It looks like this PR is missing the UI code to add the dropdown. Can you include that in this PR?
| final state = serviceConnection.serviceManager.serviceExtensionManager | ||
| .getServiceExtensionState(extensions.brightnessMode.extension); | ||
|
|
||
| void updateFromDeviceState(ServiceExtensionState s) { |
There was a problem hiding this comment.
nit: rename s to 'state'.
| if (brightness.value != newBrightness) { | ||
| brightness.value = newBrightness; | ||
| } |
There was a problem hiding this comment.
you can just call brightness.value = newBrightness directly. The value notifier will return early and not notify if the values are the same.
| if (brightness.value != newBrightness) { | |
| brightness.value = newBrightness; | |
| } | |
| brightness.value = newBrightness; |
| /// Service extension description for overriding brightness in accessibility controls. | ||
| final brightnessMode = ServiceExtensionDescription<String>.from( | ||
| extensions.brightnessMode, | ||
| title: 'Override brightness', |
There was a problem hiding this comment.
nit: capital 'B' to match other service extension titles
| title: 'Override brightness', | |
| title: 'Override Brightness', |
| await pumpAccessibilityScreen(tester); | ||
| await tester.pumpAndSettle(); | ||
|
|
||
| expect(controller.brightness.value, BrightnessOverride.system); |
There was a problem hiding this comment.
This test isn't actually testing the accessibility screen UI so it doesn't need to be a widget test. Can you make a new test file accessibility_controller_test.dart that has unit tests to verify this behavior instead?
| final paramValue = switch (value) { | ||
| BrightnessOverride.light => 'Brightness.light', | ||
| BrightnessOverride.dark => 'Brightness.dark', | ||
| BrightnessOverride.system => '', | ||
| }; |
There was a problem hiding this comment.
Consider final paramValue = value.name instead. This will evaluate to "light", "dark", or "system". I think using "system" instead of empty string will be make for a more understandable API.
|
@kenzieschmoll The UI code was merged in #9892, so this PR is just to add functions |
tracking issue: #9893
Screen.Recording.2026-07-16.at.13.41.32.mov
the ext.flutter.brightnessOverride service extension and VM service support to Flutter was added a while ago in PR #59571
Pre-launch Checklist
General checklist
///).Issues checklist
contributions-welcomeorgood-first-issuelabel.contributions-welcomeorgood-first-issuelabel. I understand this means my PR might take longer to be reviewed.Tests checklist
AI-tooling checklist
Feature-change checklist
release-notes-not-requiredlabel or left a comment requesting the label be added.packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md.If you need help, consider asking for help on Discord.