Skip to content

[tools] Fix Android Studio duplicate detection - #88384

Merged
fluttergithubbot merged 4 commits into
flutter:masterfrom
TahaTesser:duplicate_as_fix
Aug 18, 2021
Merged

fluttergithubbot merged 4 commits into
flutter:masterfrom
TahaTesser:duplicate_as_fix

Conversation

@TahaTesser

@TahaTesser TahaTesser commented Aug 17, 2021 •

Copy link
Copy Markdown
Contributor

Fixes #86291

Made the changes suggested in #86291 (comment)

For the test, I've removed extracts custom paths for Android Studio downloaded by JetBrainsToolbox on Mac, since we are not extracting the path this way and this fails due to changes made in android_studio.dart
and added my own test for duplicate detection

If we provide
plistUtils.fileContents[applicationsPlistFilePath] = macStudioInfoPlist2020_3;
Result

Expected: <1>
Actual: <2>

if we provide plist with JetBrainsToolboxApp key

const Map<String, dynamic> jetbrainsInfoPlist = <String, dynamic>{
        'JetBrainsToolboxApp': 'ignored',
};
plistUtils.fileContents[applicationsPlistFilePath] = jetbrainsInfoPlist;

Result
expect(AndroidStudio.allInstalled().length, 1);
Test passes

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 feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 17, 2021
@TahaTesser
TahaTesser requested a review from jmagman August 17, 2021 22:12
@google-cla google-cla Bot added the cla: yes label Aug 17, 2021

@jmagman jmagman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM with minor nits.

final String plistFile = globals.fs.path.join(studioPath, 'Info.plist');
final Map<String, dynamic> plistValues = globals.plistParser.parseFile(plistFile);
// As AndroidStudio managed by JetBrainsToolbox could have a wrapper pointing to the real Android Studio.
// Check if we've found a JetBrainsToolbox wrapper and deal with it properly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Update the comment too. Maybe "If we've found a JetBrainsToolbox wrapper, ignore it."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done


final String applicationsPlistFilePath = globals.fs.path.join(applicationPlistFolder, 'Info.plist');
const Map<String, dynamic> jetbrainsInfoPlist = <String, dynamic>{
'JetBrainsToolboxApp': '$homeMac/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7583922/Android Studio.app',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You don't need to get so complicated since the value is ignored, it's just checking that the key exists.

Suggested change
'JetBrainsToolboxApp': '$homeMac/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7583922/Android Studio.app',
'JetBrainsToolboxApp': 'ignored',

or

Suggested change
'JetBrainsToolboxApp': '$homeMac/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7583922/Android Studio.app',
'JetBrainsToolboxApp': 'bogus',

The simpler the case is, the easier it is to see what it's testing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

originally wanted to leave this as empty string '' but ignored is perfect here

@jmagman jmagman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks for digging into this!

@TahaTesser

Copy link
Copy Markdown
Contributor Author

@jmagman
This was a great experience, thanks for your time

@fluttergithubbot

Copy link
Copy Markdown
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite Mac build_tests_3_4 has failed. Please fix the issues identified (or deflake) before re-applying this label.
  • The status or check suite Mac tool_integration_tests_4_4 has failed. Please fix the issues identified (or deflake) before re-applying this label.

@fluttergithubbot
fluttergithubbot merged commit d722875 into flutter:master Aug 18, 2021
@TahaTesser
TahaTesser deleted the duplicate_as_fix branch August 18, 2021 10:02
blasten pushed a commit to blasten/flutter that referenced this pull request Aug 19, 2021
@stlr00

stlr00 commented Oct 20, 2021 •

Copy link
Copy Markdown

@TahaTesser When it wiil be at stable?

@jmagman

jmagman commented Oct 20, 2021

Copy link
Copy Markdown
Member

This change is available in 2.6.0-0.0.pre.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[tools] flutter doctor reports Android Studio twice when installed from JetBrains Toolbox

5 participants