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
07dc2362
Commit
07dc2362
authored
Jun 16, 2019
by
Josh Burton
Committed by
Jonah Williams
Jun 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handles parsing APK manifests with additional namespaces or attributes (#34535)
parent
5f521eea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
3 deletions
+60
-3
application_package.dart
packages/flutter_tools/lib/src/application_package.dart
+4
-3
application_package_test.dart
packages/flutter_tools/test/application_package_test.dart
+56
-0
No files found.
packages/flutter_tools/lib/src/application_package.dart
View file @
07dc2362
...
...
@@ -490,15 +490,16 @@ class ApkManifestData {
final
List
<
String
>
lines
=
data
.
split
(
'
\n
'
);
assert
(
lines
.
length
>
3
);
final
_Element
manifest
=
_Element
.
fromLine
(
lines
[
1
],
null
);
final
int
manifestLine
=
lines
.
indexWhere
((
String
line
)
=>
line
.
contains
(
'E: manifest'
));
final
_Element
manifest
=
_Element
.
fromLine
(
lines
[
manifestLine
],
null
);
_Element
currentElement
=
manifest
;
for
(
String
line
in
lines
.
skip
(
2
))
{
for
(
String
line
in
lines
.
skip
(
manifestLine
))
{
final
String
trimLine
=
line
.
trimLeft
();
final
int
level
=
line
.
length
-
trimLine
.
length
;
// Handle level out
while
(
level
<=
currentElement
.
level
)
{
while
(
currentElement
.
parent
!=
null
&&
level
<=
currentElement
.
level
)
{
currentElement
=
currentElement
.
parent
;
}
...
...
packages/flutter_tools/test/application_package_test.dart
View file @
07dc2362
...
...
@@ -138,12 +138,21 @@ void main() {
expect
(
data
.
packageName
,
'io.flutter.examples.hello_world'
);
expect
(
data
.
launchableActivityName
,
'io.flutter.examples.hello_world.MainActivity2'
);
},
overrides:
noColorTerminalOverride
);
testUsingContext
(
'Parses manifest with an Activity that has no value for its enabled field, action set to android.intent.action.MAIN and category set to android.intent.category.LAUNCHER'
,
()
{
final
ApkManifestData
data
=
ApkManifestData
.
parseFromXmlDump
(
_aaptDataWithDefaultEnabledAndMainLauncherActivity
);
expect
(
data
,
isNotNull
);
expect
(
data
.
packageName
,
'io.flutter.examples.hello_world'
);
expect
(
data
.
launchableActivityName
,
'io.flutter.examples.hello_world.MainActivity2'
);
},
overrides:
noColorTerminalOverride
);
testUsingContext
(
'Parses manifest with a dist namespace'
,
()
{
final
ApkManifestData
data
=
ApkManifestData
.
parseFromXmlDump
(
_aaptDataWithDistNamespace
);
expect
(
data
,
isNotNull
);
expect
(
data
.
packageName
,
'io.flutter.examples.hello_world'
);
expect
(
data
.
launchableActivityName
,
'io.flutter.examples.hello_world.MainActivity'
);
},
overrides:
noColorTerminalOverride
);
testUsingContext
(
'Error when parsing manifest with no Activity that has enabled set to true nor has no value for its enabled field'
,
()
{
final
ApkManifestData
data
=
ApkManifestData
.
parseFromXmlDump
(
_aaptDataWithNoEnabledActivity
);
expect
(
data
,
isNull
);
...
...
@@ -151,6 +160,7 @@ void main() {
expect
(
logger
.
errorText
,
'Error running io.flutter.examples.hello_world. Default activity not found
\n
'
);
},
overrides:
noColorTerminalOverride
);
testUsingContext
(
'Error when parsing manifest with no Activity that has action set to android.intent.action.MAIN'
,
()
{
final
ApkManifestData
data
=
ApkManifestData
.
parseFromXmlDump
(
_aaptDataWithNoMainActivity
);
expect
(
data
,
isNull
);
...
...
@@ -158,6 +168,7 @@ void main() {
expect
(
logger
.
errorText
,
'Error running io.flutter.examples.hello_world. Default activity not found
\n
'
);
},
overrides:
noColorTerminalOverride
);
testUsingContext
(
'Error when parsing manifest with no Activity that has category set to android.intent.category.LAUNCHER'
,
()
{
final
ApkManifestData
data
=
ApkManifestData
.
parseFromXmlDump
(
_aaptDataWithNoLauncherActivity
);
expect
(
data
,
isNull
);
...
...
@@ -174,6 +185,7 @@ void main() {
Platform:
_kNoColorTerminalPlatform
,
OperatingSystemUtils:
()
=>
MockOperatingSystemUtils
(),
};
testUsingContext
(
'Error on non-existing file'
,
()
{
final
PrebuiltIOSApp
iosApp
=
IOSApp
.
fromPrebuiltApp
(
fs
.
file
(
'not_existing.ipa'
));
...
...
@@ -184,6 +196,7 @@ void main() {
'File "not_existing.ipa" does not exist. Use an app bundle or an ipa.
\n
'
,
);
},
overrides:
overrides
);
testUsingContext
(
'Error on non-app-bundle folder'
,
()
{
fs
.
directory
(
'regular_folder'
).
createSync
();
final
PrebuiltIOSApp
iosApp
=
...
...
@@ -193,6 +206,7 @@ void main() {
expect
(
logger
.
errorText
,
'Folder "regular_folder" is not an app bundle.
\n
'
);
},
overrides:
overrides
);
testUsingContext
(
'Error on no info.plist'
,
()
{
fs
.
directory
(
'bundle.app'
).
createSync
();
final
PrebuiltIOSApp
iosApp
=
IOSApp
.
fromPrebuiltApp
(
fs
.
file
(
'bundle.app'
));
...
...
@@ -203,6 +217,7 @@ void main() {
'Invalid prebuilt iOS app. Does not contain Info.plist.
\n
'
,
);
},
overrides:
overrides
);
testUsingContext
(
'Error on bad info.plist'
,
()
{
fs
.
directory
(
'bundle.app'
).
createSync
();
fs
.
file
(
'bundle.app/Info.plist'
).
writeAsStringSync
(
badPlistData
);
...
...
@@ -215,6 +230,7 @@ void main() {
'Invalid prebuilt iOS app. Info.plist does not contain bundle identifier
\n
'
),
);
},
overrides:
overrides
);
testUsingContext
(
'Success with app bundle'
,
()
{
fs
.
directory
(
'bundle.app'
).
createSync
();
fs
.
file
(
'bundle.app/Info.plist'
).
writeAsStringSync
(
plistData
);
...
...
@@ -225,6 +241,7 @@ void main() {
expect
(
iosApp
.
id
,
'fooBundleId'
);
expect
(
iosApp
.
bundleName
,
'bundle.app'
);
},
overrides:
overrides
);
testUsingContext
(
'Bad ipa zip-file, no payload dir'
,
()
{
fs
.
file
(
'app.ipa'
).
createSync
();
when
(
os
.
unzip
(
fs
.
file
(
'app.ipa'
),
any
)).
thenAnswer
((
Invocation
_
)
{
});
...
...
@@ -236,6 +253,7 @@ void main() {
'Invalid prebuilt iOS ipa. Does not contain a "Payload" directory.
\n
'
,
);
},
overrides:
overrides
);
testUsingContext
(
'Bad ipa zip-file, two app bundles'
,
()
{
fs
.
file
(
'app.ipa'
).
createSync
();
when
(
os
.
unzip
(
any
,
any
)).
thenAnswer
((
Invocation
invocation
)
{
...
...
@@ -257,6 +275,7 @@ void main() {
expect
(
logger
.
errorText
,
'Invalid prebuilt iOS ipa. Does not contain a single app bundle.
\n
'
);
},
overrides:
overrides
);
testUsingContext
(
'Success with ipa'
,
()
{
fs
.
file
(
'app.ipa'
).
createSync
();
when
(
os
.
unzip
(
any
,
any
)).
thenAnswer
((
Invocation
invocation
)
{
...
...
@@ -313,6 +332,7 @@ void main() {
Platform:
_kNoColorTerminalPlatform
,
OperatingSystemUtils:
()
=>
MockOperatingSystemUtils
(),
};
testUsingContext
(
'Error on non-existing file'
,
()
{
final
PrebuiltFuchsiaApp
fuchsiaApp
=
FuchsiaApp
.
fromPrebuiltApp
(
fs
.
file
(
'not_existing.far'
));
...
...
@@ -521,6 +541,42 @@ const String _aaptDataWithNoLauncherActivity =
E: action (line=43)
A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")'''
;
const
String
_aaptDataWithDistNamespace
=
'''N: android=http://schemas.android.com/apk/res/android
N: dist=http://schemas.android.com/apk/distribution
E: manifest (line=7)
A: android:versionCode(0x0101021b)=(type 0x10)0x1
A: android:versionName(0x0101021c)="1.0" (Raw: "1.0")
A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1c
A: android:compileSdkVersionCodename(0x01010573)="9" (Raw: "9")
A: package="io.flutter.examples.hello_world" (Raw: "io.flutter.examples.hello_world")
A: platformBuildVersionCode=(type 0x10)0x1
A: platformBuildVersionName=(type 0x4)0x3f800000
E: uses-sdk (line=13)
A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1c
E: dist:module (line=17)
A: dist:instant=(type 0x12)0xffffffff
E: uses-permission (line=24)
A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
E: application (line=32)
A: android:label(0x01010001)="hello_world" (Raw: "hello_world")
A: android:icon(0x01010002)=@0x7f010000
A: android:name(0x01010003)="io.flutter.app.FlutterApplication" (Raw: "io.flutter.app.FlutterApplication")
E: activity (line=36)
A: android:theme(0x01010000)=@0x01030009
A: android:name(0x01010003)="io.flutter.examples.hello_world.MainActivity" (Raw: "io.flutter.examples.hello_world.MainActivity")
A: android:launchMode(0x0101001d)=(type 0x10)0x1
A: android:configChanges(0x0101001f)=(type 0x11)0x400037b4
A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
E: intent-filter (line=43)
E: action (line=44)
A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
E: category (line=46)
A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
'''
;
class
MockIosWorkFlow
extends
Mock
implements
IOSWorkflow
{
@override
...
...
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