diff --git a/packages/flutter_tools/lib/src/android/android_studio.dart b/packages/flutter_tools/lib/src/android/android_studio.dart index acb1e9a036..19370c19b5 100644 --- a/packages/flutter_tools/lib/src/android/android_studio.dart +++ b/packages/flutter_tools/lib/src/android/android_studio.dart @@ -66,28 +66,14 @@ class AndroidStudio implements Comparable { pathsSelectorValue = jvmProperties['idea.paths.selector'] as String; } } - - final int major = version?.major; - final int minor = version?.minor; - String presetPluginsPath; - if (pathsSelectorValue != null) { - if (major >= 4 && minor >= 1) { - presetPluginsPath = globals.fs.path.join( - globals.fsUtils.homeDirPath, - 'Library', - 'Application Support', - 'Google', - pathsSelectorValue, - ); - } else { - presetPluginsPath = globals.fs.path.join( - globals.fsUtils.homeDirPath, - 'Library', - 'Application Support', - pathsSelectorValue, - ); - } - } + final String presetPluginsPath = pathsSelectorValue == null + ? null + : globals.fs.path.join( + globals.fsUtils.homeDirPath, + 'Library', + 'Application Support', + pathsSelectorValue, + ); return AndroidStudio(studioPath, version: version, presetPluginsPath: presetPluginsPath); } @@ -141,23 +127,12 @@ class AndroidStudio implements Comparable { final int major = version?.major; final int minor = version?.minor; if (globals.platform.isMacOS) { - /// plugin path of Android Studio has been changed after version 4.1. - if (major >= 4 && minor >= 1) { - return globals.fs.path.join( - globals.fsUtils.homeDirPath, - 'Library', - 'Application Support', - 'Google', - 'AndroidStudio$major.$minor', - ); - } else { - return globals.fs.path.join( - globals.fsUtils.homeDirPath, - 'Library', - 'Application Support', - 'AndroidStudio$major.$minor', - ); - } + return globals.fs.path.join( + globals.fsUtils.homeDirPath, + 'Library', + 'Application Support', + 'AndroidStudio$major.$minor', + ); } else { return globals.fs.path.join( globals.fsUtils.homeDirPath, diff --git a/packages/flutter_tools/test/general.shard/android/android_studio_test.dart b/packages/flutter_tools/test/general.shard/android/android_studio_test.dart index 0b25590006..7d90aa3610 100644 --- a/packages/flutter_tools/test/general.shard/android/android_studio_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_studio_test.dart @@ -29,19 +29,6 @@ const Map macStudioInfoPlist = { }, }; -const Map macStudioInfoPlist4_1 = { - 'CFBundleGetInfoString': 'Android Studio 4.1, build AI-201.8743.12.41.6858069. Copyright JetBrains s.r.o., (c) 2000-2020', - 'CFBundleShortVersionString': '4.1', - 'CFBundleVersion': 'AI-201.8743.12.41.6858069', - 'JVMOptions': { - 'Properties': { - 'idea.vendor.name' : 'Google', - 'idea.paths.selector': 'AndroidStudio4.1', - 'idea.platform.prefix': 'AndroidStudio', - }, - }, -}; - final Platform linuxPlatform = FakePlatform( operatingSystem: 'linux', environment: {'HOME': homeLinux}, @@ -109,71 +96,6 @@ void main() { ); }); - testUsingContext('Can discover Android Studio >=4.1 location on Mac', () { - final String studioInApplicationPlistFolder = globals.fs.path.join( - '/', - 'Application', - 'Android Studio.app', - 'Contents', - ); - globals.fs.directory(studioInApplicationPlistFolder).createSync(recursive: true); - - final String plistFilePath = globals.fs.path.join(studioInApplicationPlistFolder, 'Info.plist'); - when(plistUtils.parseFile(plistFilePath)).thenReturn(macStudioInfoPlist4_1); - final AndroidStudio studio = AndroidStudio.fromMacOSBundle( - globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path, - ); - - expect(studio, isNotNull); - expect(studio.pluginsPath, equals(globals.fs.path.join( - homeMac, - 'Library', - 'Application Support', - 'Google', - 'AndroidStudio4.1', - ))); - }, overrides: { - FileSystem: () => fileSystem, - FileSystemUtils: () => fsUtils, - ProcessManager: () => FakeProcessManager.any(), - // Custom home paths are not supported on macOS nor Windows yet, - // so we force the platform to fake Linux here. - Platform: () => platform, - PlistParser: () => plistUtils, - }); - - testUsingContext('Can discover Android Studio <4.1 location on Mac', () { - final String studioInApplicationPlistFolder = globals.fs.path.join( - '/', - 'Application', - 'Android Studio.app', - 'Contents', - ); - globals.fs.directory(studioInApplicationPlistFolder).createSync(recursive: true); - - final String plistFilePath = globals.fs.path.join(studioInApplicationPlistFolder, 'Info.plist'); - when(plistUtils.parseFile(plistFilePath)).thenReturn(macStudioInfoPlist); - final AndroidStudio studio = AndroidStudio.fromMacOSBundle( - globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path, - ); - - expect(studio, isNotNull); - expect(studio.pluginsPath, equals(globals.fs.path.join( - homeMac, - 'Library', - 'Application Support', - 'AndroidStudio3.3', - ))); - }, overrides: { - FileSystem: () => fileSystem, - FileSystemUtils: () => fsUtils, - ProcessManager: () => FakeProcessManager.any(), - // Custom home paths are not supported on macOS nor Windows yet, - // so we force the platform to fake Linux here. - Platform: () => platform, - PlistParser: () => plistUtils, - }); - testUsingContext('extracts custom paths for directly downloaded Android Studio on Mac', () { final String studioInApplicationPlistFolder = globals.fs.path.join( '/',