Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
d7228752
Unverified
Commit
d7228752
authored
Aug 18, 2021
by
Taha Tesser
Committed by
GitHub
Aug 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[tools] Fix Android Studio duplicate detection (#88384)
parent
061dff8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
70 deletions
+46
-70
android_studio.dart
packages/flutter_tools/lib/src/android/android_studio.dart
+8
-12
android_studio_test.dart
...tools/test/general.shard/android/android_studio_test.dart
+38
-58
No files found.
packages/flutter_tools/lib/src/android/android_studio.dart
View file @
d7228752
...
...
@@ -40,17 +40,13 @@ class AndroidStudio implements Comparable<AndroidStudio> {
_init
(
version:
version
);
}
factory
AndroidStudio
.
fromMacOSBundle
(
String
bundlePath
)
{
String
studioPath
=
globals
.
fs
.
path
.
join
(
bundlePath
,
'Contents'
);
String
plistFile
=
globals
.
fs
.
path
.
join
(
studioPath
,
'Info.plist'
);
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.
final
String
?
jetBrainsToolboxAppBundlePath
=
plistValues
[
'JetBrainsToolboxApp'
]
as
String
?;
if
(
jetBrainsToolboxAppBundlePath
!=
null
)
{
studioPath
=
globals
.
fs
.
path
.
join
(
jetBrainsToolboxAppBundlePath
,
'Contents'
);
plistFile
=
globals
.
fs
.
path
.
join
(
studioPath
,
'Info.plist'
);
plistValues
=
globals
.
plistParser
.
parseFile
(
plistFile
);
static
AndroidStudio
?
fromMacOSBundle
(
String
bundlePath
)
{
final
String
studioPath
=
globals
.
fs
.
path
.
join
(
bundlePath
,
'Contents'
);
final
String
plistFile
=
globals
.
fs
.
path
.
join
(
studioPath
,
'Info.plist'
);
final
Map
<
String
,
dynamic
>
plistValues
=
globals
.
plistParser
.
parseFile
(
plistFile
);
// If we've found a JetBrainsToolbox wrapper, ignore it.
if
(
plistValues
.
containsKey
(
'JetBrainsToolboxApp'
))
{
return
null
;
}
final
String
versionString
=
plistValues
[
PlistParser
.
kCFBundleShortVersionStringKey
]
as
String
;
...
...
@@ -317,7 +313,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
}
return
candidatePaths
.
map
<
AndroidStudio
>((
FileSystemEntity
e
)
=>
AndroidStudio
.
fromMacOSBundle
(
e
.
path
))
.
map
<
AndroidStudio
?
>((
FileSystemEntity
e
)
=>
AndroidStudio
.
fromMacOSBundle
(
e
.
path
))
.
whereType
<
AndroidStudio
>()
.
toList
();
}
...
...
packages/flutter_tools/test/general.shard/android/android_studio_test.dart
View file @
d7228752
...
...
@@ -157,6 +157,7 @@ void main() {
Platform:
()
=>
platform
,
PlistParser:
()
=>
plistUtils
,
});
testUsingContext
(
'Can discover Android Studio >=2020.3 location on Mac'
,
()
{
final
String
studioInApplicationPlistFolder
=
globals
.
fs
.
path
.
join
(
'/'
,
...
...
@@ -222,6 +223,43 @@ void main() {
PlistParser:
()
=>
plistUtils
,
});
testUsingContext
(
'Does not discover Android Studio with JetBrainsToolboxApp wrapper'
,
()
{
final
String
applicationPlistFolder
=
globals
.
fs
.
path
.
join
(
'/'
,
'Applications'
,
'Android Studio.app'
,
'Contents'
,
);
globals
.
fs
.
directory
(
applicationPlistFolder
).
createSync
(
recursive:
true
);
final
String
applicationsPlistFilePath
=
globals
.
fs
.
path
.
join
(
applicationPlistFolder
,
'Info.plist'
);
const
Map
<
String
,
dynamic
>
jetbrainsInfoPlist
=
<
String
,
dynamic
>{
'JetBrainsToolboxApp'
:
'ignored'
,
};
plistUtils
.
fileContents
[
applicationsPlistFilePath
]
=
jetbrainsInfoPlist
;
final
String
homeDirectoryPlistFolder
=
globals
.
fs
.
path
.
join
(
globals
.
fsUtils
.
homeDirPath
,
'Applications'
,
'Android Studio.app'
,
'Contents'
,
);
globals
.
fs
.
directory
(
homeDirectoryPlistFolder
).
createSync
(
recursive:
true
);
final
String
homeDirectoryPlistFilePath
=
globals
.
fs
.
path
.
join
(
homeDirectoryPlistFolder
,
'Info.plist'
);
plistUtils
.
fileContents
[
homeDirectoryPlistFilePath
]
=
macStudioInfoPlist2020_3
;
expect
(
AndroidStudio
.
allInstalled
().
length
,
1
);
},
overrides:
<
Type
,
Generator
>{
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 installation from Spotlight query'
,
()
{
// One in expected location.
final
String
studioInApplication
=
fileSystem
.
path
.
join
(
...
...
@@ -370,64 +408,6 @@ void main() {
Platform:
()
=>
platform
,
PlistParser:
()
=>
plistUtils
,
});
testUsingContext
(
'extracts custom paths for Android Studio downloaded by JetBrainsToolbox on Mac'
,
()
{
final
String
jetbrainsStudioInApplicationPlistFolder
=
globals
.
fs
.
path
.
join
(
homeMac
,
'Application'
,
'JetBrains Toolbox'
,
'Android Studio.app'
,
'Contents'
,
);
globals
.
fs
.
directory
(
jetbrainsStudioInApplicationPlistFolder
).
createSync
(
recursive:
true
);
const
Map
<
String
,
dynamic
>
jetbrainsInfoPlist
=
<
String
,
dynamic
>{
'CFBundleLongVersionString'
:
'3.3'
,
'CFBundleShortVersionString'
:
'3.3'
,
'CFBundleVersion'
:
'3.3'
,
'JetBrainsToolboxApp'
:
'
$homeMac
/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/183.5256920/Android Studio 3.3.app'
,
};
final
String
jetbrainsPlistFilePath
=
globals
.
fs
.
path
.
join
(
jetbrainsStudioInApplicationPlistFolder
,
'Info.plist'
,
);
plistUtils
.
fileContents
[
jetbrainsPlistFilePath
]
=
jetbrainsInfoPlist
;
final
String
studioInApplicationPlistFolder
=
globals
.
fs
.
path
.
join
(
globals
.
fs
.
path
.
join
(
homeMac
,
'Library'
,
'Application Support'
),
'JetBrains'
,
'Toolbox'
,
'apps'
,
'AndroidStudio'
,
'ch-0'
,
'183.5256920'
,
globals
.
fs
.
path
.
join
(
'Android Studio 3.3.app'
,
'Contents'
),
);
globals
.
fs
.
directory
(
studioInApplicationPlistFolder
).
createSync
(
recursive:
true
);
final
String
studioPlistFilePath
=
globals
.
fs
.
path
.
join
(
studioInApplicationPlistFolder
,
'Info.plist'
,
);
plistUtils
.
fileContents
[
studioPlistFilePath
]
=
macStudioInfoPlist
;
final
AndroidStudio
studio
=
AndroidStudio
.
fromMacOSBundle
(
globals
.
fs
.
directory
(
jetbrainsStudioInApplicationPlistFolder
)?.
parent
?.
path
,
);
expect
(
studio
,
isNotNull
);
expect
(
studio
.
pluginsPath
,
equals
(
globals
.
fs
.
path
.
join
(
homeMac
,
'Library'
,
'Application Support'
,
'AndroidStudio3.3'
,
)));
},
overrides:
<
Type
,
Generator
>{
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
,
});
});
FileSystem
windowsFileSystem
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment