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
c6359dc9
Unverified
Commit
c6359dc9
authored
Jun 04, 2021
by
Jenn Magder
Committed by
GitHub
Jun 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove globals from android application_package (#83852)
parent
02b21e5f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
28 deletions
+33
-28
application_package.dart
...es/flutter_tools/lib/src/android/application_package.dart
+28
-27
flutter_application_package.dart
...es/flutter_tools/lib/src/flutter_application_package.dart
+1
-0
application_package_test.dart
...er_tools/test/general.shard/application_package_test.dart
+4
-1
No files found.
packages/flutter_tools/lib/src/android/application_package.dart
View file @
c6359dc9
...
...
@@ -18,7 +18,6 @@ import '../base/logger.dart';
import
'../base/process.dart'
;
import
'../base/user_messages.dart'
;
import
'../build_info.dart'
;
import
'../globals_null_migrated.dart'
as
globals
;
import
'../project.dart'
;
import
'android_sdk.dart'
;
import
'gradle.dart'
;
...
...
@@ -42,6 +41,7 @@ class AndroidApk extends ApplicationPackage {
@required
ProcessManager
processManager
,
@required
UserMessages
userMessages
,
@required
Logger
logger
,
@required
ProcessUtils
processUtils
,
})
{
final
String
aaptPath
=
androidSdk
?.
latestVersion
?.
aaptPath
;
if
(
aaptPath
==
null
||
!
processManager
.
canRun
(
aaptPath
))
{
...
...
@@ -51,7 +51,7 @@ class AndroidApk extends ApplicationPackage {
String
apptStdout
;
try
{
apptStdout
=
globals
.
processUtils
.
runSync
(
apptStdout
=
processUtils
.
runSync
(
<
String
>[
aaptPath
,
'dump'
,
...
...
@@ -62,7 +62,7 @@ class AndroidApk extends ApplicationPackage {
throwOnError:
true
,
).
stdout
.
trim
();
}
on
ProcessException
catch
(
error
)
{
globals
.
printError
(
'Failed to extract manifest from APK:
$error
.'
);
logger
.
printError
(
'Failed to extract manifest from APK:
$error
.'
);
return
null
;
}
...
...
@@ -117,6 +117,7 @@ class AndroidApk extends ApplicationPackage {
processManager:
processManager
,
logger:
logger
,
userMessages:
userMessages
,
processUtils:
processUtils
,
);
}
// The .apk hasn't been built yet, so we work with what we have. The run
...
...
@@ -209,24 +210,24 @@ class AndroidApk extends ApplicationPackage {
String
get
name
=>
file
.
basename
;
}
abstract
class
_Entry
{
const
_Entry
(
this
.
parent
,
this
.
level
);
class
_Entry
{
_Element
parent
;
int
level
;
final
_Element
parent
;
final
int
level
;
}
class
_Element
extends
_Entry
{
_Element
.
fromLine
(
String
line
,
_Element
parent
)
{
_Element
.
_
(
this
.
name
,
_Element
parent
,
int
level
)
:
super
(
parent
,
level
);
factory
_Element
.
fromLine
(
String
line
,
_Element
parent
)
{
// E: application (line=29)
final
List
<
String
>
parts
=
line
.
trimLeft
().
split
(
' '
);
name
=
parts
[
1
];
level
=
line
.
length
-
line
.
trimLeft
().
length
;
this
.
parent
=
parent
;
children
=
<
_Entry
>[];
return
_Element
.
_
(
parts
[
1
],
parent
,
line
.
length
-
line
.
trimLeft
().
length
);
}
List
<
_Entry
>
children
;
String
name
;
final
List
<
_Entry
>
children
=
<
_Entry
>[]
;
final
String
name
;
void
addChild
(
_Entry
child
)
{
children
.
add
(
child
);
...
...
@@ -252,20 +253,17 @@ class _Element extends _Entry {
}
class
_Attribute
extends
_Entry
{
_Attribute
.
fromLine
(
String
line
,
_Element
parent
)
{
const
_Attribute
.
_
(
this
.
key
,
this
.
value
,
_Element
parent
,
int
level
)
:
super
(
parent
,
level
);
factory
_Attribute
.
fromLine
(
String
line
,
_Element
parent
)
{
// A: android:label(0x01010001)="hello_world" (Raw: "hello_world")
const
String
attributePrefix
=
'A: '
;
final
List
<
String
>
keyVal
=
line
.
substring
(
line
.
indexOf
(
attributePrefix
)
+
attributePrefix
.
length
)
.
split
(
'='
);
key
=
keyVal
[
0
];
value
=
keyVal
[
1
];
level
=
line
.
length
-
line
.
trimLeft
().
length
;
this
.
parent
=
parent
;
final
List
<
String
>
keyVal
=
line
.
substring
(
line
.
indexOf
(
attributePrefix
)
+
attributePrefix
.
length
).
split
(
'='
);
return
_Attribute
.
_
(
keyVal
[
0
],
keyVal
[
1
],
parent
,
line
.
length
-
line
.
trimLeft
().
length
);
}
String
key
;
String
value
;
final
String
key
;
final
String
value
;
}
class
ApkManifestData
{
...
...
@@ -388,10 +386,13 @@ class ApkManifestData {
return
null
;
}
final
Map
<
String
,
Map
<
String
,
String
>>
map
=
<
String
,
Map
<
String
,
String
>>{};
map
[
'package'
]
=
<
String
,
String
>{
'name'
:
packageName
};
map
[
'version-code'
]
=
<
String
,
String
>{
'name'
:
versionCode
.
toString
()};
map
[
'launchable-activity'
]
=
<
String
,
String
>{
'name'
:
activityName
};
final
Map
<
String
,
Map
<
String
,
String
>>
map
=
<
String
,
Map
<
String
,
String
>>{
if
(
packageName
!=
null
)
'package'
:
<
String
,
String
>{
'name'
:
packageName
},
'version-code'
:
<
String
,
String
>{
'name'
:
versionCode
.
toString
()},
if
(
activityName
!=
null
)
'launchable-activity'
:
<
String
,
String
>{
'name'
:
activityName
},
};
return
ApkManifestData
.
_
(
map
);
}
...
...
packages/flutter_tools/lib/src/flutter_application_package.dart
View file @
c6359dc9
...
...
@@ -77,6 +77,7 @@ class FlutterApplicationPackageFactory extends ApplicationPackageFactory {
logger:
_logger
,
androidSdk:
_androidSdk
,
userMessages:
_userMessages
,
processUtils:
_processUtils
,
);
case
TargetPlatform
.
ios
:
return
applicationBinary
==
null
...
...
packages/flutter_tools/test/general.shard/application_package_test.dart
View file @
c6359dc9
...
...
@@ -12,6 +12,7 @@ import 'package:flutter_tools/src/application_package.dart';
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/base/process.dart'
;
import
'package:flutter_tools/src/base/user_messages.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
...
...
@@ -122,12 +123,14 @@ void main() {
testWithoutContext
(
'returns null when failed to extract manifest'
,
()
async
{
final
AndroidSdkVersion
sdkVersion
=
FakeAndroidSdkVersion
();
sdk
.
latestVersion
=
sdkVersion
;
final
Logger
logger
=
BufferLogger
.
test
();
final
AndroidApk
androidApk
=
AndroidApk
.
fromApk
(
null
,
processManager:
fakeProcessManager
,
logger:
BufferLogger
.
test
()
,
logger:
logger
,
userMessages:
UserMessages
(),
androidSdk:
sdk
,
processUtils:
ProcessUtils
(
processManager:
fakeProcessManager
,
logger:
logger
),
);
expect
(
androidApk
,
isNull
);
...
...
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