Skip to content

[flutter_tools] Migrate AndroidSdk and AndroidStudio away from globals - #193650

Merged
auto-submit[bot] merged 12 commits into
flutter:masterfrom
bkonyi:di/28b-android-sdk-and-studio
Oct 14, 2026
Merged

auto-submit[bot] merged 12 commits into
flutter:masterfrom
bkonyi:di/28b-android-sdk-and-studio

Conversation

@bkonyi

@bkonyi bkonyi commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Migrates AndroidSdk and AndroidStudio away from globals.dart to explicit dependency injection via ToolContext.

Part of #188471

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

Injects Config, FileSystem, FileSystemUtils, Logger, OperatingSystemUtils, Platform, PlistParser, and ProcessManager explicitly into AndroidSdk and AndroidStudio instead of reading ambient globals.
@bkonyi
bkonyi requested a review from a team as a code owner October 1, 2026 15:07
@bkonyi bkonyi added tool Affects the "flutter" command-line tool. See also t: labels. CICD Run CI/CD labels Oct 1, 2026
@bkonyi
bkonyi requested review from gmackall and removed request for a team October 1, 2026 15:07
@github-actions github-actions Bot added the team-android Owned by Android platform team label Oct 1, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors AndroidSdk and AndroidStudio to support dependency injection, removing reliance on global variables and allowing tests to be migrated from testUsingContext to testWithoutContext. The review feedback suggests refactoring the constructors of AndroidSdk and AndroidStudio into factory constructors to avoid redundant instantiations of default dependencies when they are not provided. Additionally, it is recommended to resolve PlistParser once in AndroidStudio._allMacOS and pass it to fromMacOSBundle to prevent multiple instantiations inside the loop.

@bkonyi
bkonyi marked this pull request as draft October 1, 2026 15:23
@flutter-dashboard

Copy link
Copy Markdown

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

bkonyi added 3 commits October 1, 2026 15:28
…dk and AndroidStudio

Uses factory constructors on AndroidSdk and AndroidStudio so default dependencies are resolved once per instantiation, and resolves PlistParser once in AndroidStudio._allMacOS.
…Studio

Allows callers to pass ToolContext rather than individual ToolContext dependencies to AndroidSdk and AndroidStudio constructors and factory methods.
@bkonyi
bkonyi marked this pull request as ready for review October 2, 2026 16:52

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors AndroidSdk and AndroidStudio to use dependency injection via ToolContext instead of relying on legacy globals, and updates associated tests to use fake contexts. The review feedback suggests making fileSystem a required parameter in SDK validation methods to ensure hermeticity, and recommends simplifying several list constructions by removing redundant spread operators and using more idiomatic cascade sorting.

@mboetger
mboetger self-requested a review October 13, 2026 20:48
@camsim99
camsim99 removed the request for review from gmackall October 13, 2026 20:48
mboetger
mboetger previously approved these changes Oct 13, 2026
mboetger
mboetger previously approved these changes Oct 13, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 13, 2026
@auto-submit

auto-submit Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/193650, because Pull request flutter/flutter/193650 is not in a mergeable state.

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 14, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 14, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 14, 2026
Merged via the queue into flutter:master with commit 1d86c47 Oct 14, 2026
34 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 14, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Oct 15, 2026
flutter/flutter@426be96...5c7e45a

2026-10-15 [email protected] [web_paragraph] Honor TextHeightBehavior.leadingDistribution and default to proportional (flutter/flutter#193736)
2026-10-15 [email protected] Roll Skia from 79a00d7c4898 to d131b7789482 (2 revisions) (flutter/flutter#194446)
2026-10-15 [email protected] Roll Dart SDK from b8ffa9233096 to 84686ea04815 (1 revision) (flutter/flutter#194442)
2026-10-15 [email protected] Roll Dart SDK from e81af2dac9d1 to b8ffa9233096 (1 revision) (flutter/flutter#194432)
2026-10-15 [email protected] Roll Skia from ef24b8f87a2a to 79a00d7c4898 (4 revisions) (flutter/flutter#194431)
2026-10-15 [email protected] Roll Skia from 48c51004ee4e to ef24b8f87a2a (1 revision) (flutter/flutter#194427)
2026-10-15 [email protected] Roll Dart SDK from 6b50116630d0 to e81af2dac9d1 (5 revisions) (flutter/flutter#194422)
2026-10-15 [email protected] Roll Skia from b1be97266d3a to 48c51004ee4e (10 revisions) (flutter/flutter#194421)
2026-10-15 [email protected] RawAutocomplete: Fix focusNode listener mismatch in didUpdateWidget/dispose (flutter/flutter#190686)
2026-10-14 [email protected] [flutter_tools] Wait for iOS simulator log stream before launch (flutter/flutter#193142)
2026-10-14 [email protected] Move Material/Cupertino PRs from design triage to framework triage (flutter/flutter#194244)
2026-10-14 [email protected] refactor(flutter_tools): share FlutterCommand options and OptionBundles (flutter/flutter#194356)
2026-10-14 [email protected] Roll pub packages (flutter/flutter#194413)
2026-10-14 [email protected] Add ContextMenuButtonKind (flutter/flutter#193528)
2026-10-14 [email protected] Split SwiftPM plugin into multiple products (flutter/flutter#193521)
2026-10-14 [email protected] Roll Skia from 43d707a3be0e to b1be97266d3a (8 revisions) (flutter/flutter#194392)
2026-10-14 [email protected] Roll pub packages (flutter/flutter#194398)
2026-10-14 [email protected] [flutter_tools] Migrate AndroidSdk and AndroidStudio away from globals (flutter/flutter#193650)
2026-10-14 [email protected] [flutter_tools] Reload widget-preview when data assets change (flutter/flutter#193437)
2026-10-14 [email protected] [flutter tool] suppress sub-tool analytics during first run (flutter/flutter#194320)
2026-10-14 [email protected] Roll Skia from acde3755d2e2 to 43d707a3be0e (1 revision) (flutter/flutter#194385)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
flutter#193650)

Migrates AndroidSdk and AndroidStudio away from globals.dart to explicit
dependency injection via ToolContext.

Part of flutter#188471

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD team-android Owned by Android platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants