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
c08a3c7a
Unverified
Commit
c08a3c7a
authored
Aug 07, 2019
by
Emmanuel Garcia
Committed by
GitHub
Aug 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add metadata to indicate if the host app contains a Flutter module (#37731)
parent
36b8725a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
13 deletions
+102
-13
module_test.dart
dev/devicelab/bin/tasks/module_test.dart
+76
-4
apk_utils.dart
dev/devicelab/lib/framework/apk_utils.dart
+19
-8
AndroidManifest.xml.tmpl
...id/library/Flutter.tmpl/src/main/AndroidManifest.xml.tmpl
+7
-1
No files found.
dev/devicelab/bin/tasks/module_test.dart
View file @
c08a3c7a
...
...
@@ -5,6 +5,7 @@
import
'dart:async'
;
import
'dart:io'
;
import
'package:flutter_devicelab/framework/apk_utils.dart'
;
import
'package:flutter_devicelab/framework/framework.dart'
;
import
'package:flutter_devicelab/framework/utils.dart'
;
import
'package:path/path.dart'
as
path
;
...
...
@@ -156,6 +157,8 @@ Future<void> main() async {
final
File
analyticsOutputFile
=
File
(
path
.
join
(
tempDir
.
path
,
'analytics.log'
));
section
(
'Build debug host APK'
);
await
inDirectory
(
hostApp
,
()
async
{
if
(!
Platform
.
isWindows
)
{
await
exec
(
'chmod'
,
<
String
>[
'+x'
,
'gradlew'
]);
...
...
@@ -169,7 +172,9 @@ Future<void> main() async {
);
});
final
bool
existingAppBuilt
=
exists
(
File
(
path
.
join
(
section
(
'Check debug APK exists'
);
final
String
debugHostApk
=
path
.
join
(
hostApp
.
path
,
'app'
,
'build'
,
...
...
@@ -177,9 +182,29 @@ Future<void> main() async {
'apk'
,
'debug'
,
'app-debug.apk'
,
)));
if
(!
existingAppBuilt
)
{
return
TaskResult
.
failure
(
'Failed to build existing app .apk'
);
);
if
(!
exists
(
File
(
debugHostApk
)))
{
return
TaskResult
.
failure
(
'Failed to build debug host APK'
);
}
section
(
'Check files in debug APK'
);
checkItContains
<
String
>(<
String
>[
'AndroidManifest.xml'
,
'assets/flutter_assets/isolate_snapshot_data'
,
'assets/flutter_assets/kernel_blob.bin'
,
'assets/flutter_assets/vm_snapshot_data'
,
],
await
getFilesInApk
(
debugHostApk
));
section
(
'Check debug AndroidManifest.xml'
);
final
String
androidManifestDebug
=
await
getAndroidManifest
(
debugHostApk
);
if
(!
androidManifestDebug
.
contains
(
'''
<meta-data
android:name="flutterProjectType"
android:value="module" />'''
)
)
{
return
TaskResult
.
failure
(
'Debug host APK doesn
\'
t contain metadata: flutterProjectType = module '
);
}
final
String
analyticsOutput
=
analyticsOutputFile
.
readAsStringSync
();
...
...
@@ -193,7 +218,54 @@ Future<void> main() async {
);
}
section
(
'Build release host APK'
);
await
inDirectory
(
hostApp
,
()
async
{
await
exec
(
gradlewExecutable
,
<
String
>[
'app:assembleRelease'
],
environment:
<
String
,
String
>{
'JAVA_HOME'
:
javaHome
,
'FLUTTER_ANALYTICS_LOG_FILE'
:
analyticsOutputFile
.
path
,
},
);
});
final
String
releaseHostApk
=
path
.
join
(
hostApp
.
path
,
'app'
,
'build'
,
'outputs'
,
'apk'
,
'release'
,
'app-release-unsigned.apk'
,
);
if
(!
exists
(
File
(
releaseHostApk
)))
{
return
TaskResult
.
failure
(
'Failed to build release host APK'
);
}
section
(
'Check files in release APK'
);
checkItContains
<
String
>(<
String
>[
'AndroidManifest.xml'
,
'lib/arm64-v8a/libapp.so'
,
'lib/arm64-v8a/libflutter.so'
,
'lib/armeabi-v7a/libapp.so'
,
'lib/armeabi-v7a/libflutter.so'
,
],
await
getFilesInApk
(
releaseHostApk
));
section
(
'Check release AndroidManifest.xml'
);
final
String
androidManifestRelease
=
await
getAndroidManifest
(
debugHostApk
);
if
(!
androidManifestRelease
.
contains
(
'''
<meta-data
android:name="flutterProjectType"
android:value="module" />'''
)
)
{
return
TaskResult
.
failure
(
'Release host APK doesn
\'
t contain metadata: flutterProjectType = module '
);
}
return
TaskResult
.
success
(
null
);
}
on
TaskResult
catch
(
taskResult
)
{
return
taskResult
;
}
catch
(
e
)
{
return
TaskResult
.
failure
(
e
.
toString
());
}
finally
{
...
...
dev/devicelab/lib/framework/apk_utils.dart
View file @
c08a3c7a
...
...
@@ -89,6 +89,16 @@ bool hasMultipleOccurrences(String text, Pattern pattern) {
return
text
.
indexOf
(
pattern
)
!=
text
.
lastIndexOf
(
pattern
);
}
/// The Android home directory.
String
get
_androidHome
{
final
String
androidHome
=
Platform
.
environment
[
'ANDROID_HOME'
]
??
Platform
.
environment
[
'ANDROID_SDK_ROOT'
];
if
(
androidHome
==
null
||
androidHome
.
isEmpty
)
{
throw
Exception
(
'Unset env flag: `ANDROID_HOME` or `ANDROID_SDK_ROOT`.'
);
}
return
androidHome
;
}
/// Utility class to analyze the content inside an APK using dexdump,
/// which is provided by the Android SDK.
/// https://android.googlesource.com/platform/art/+/master/dexdump/dexdump.cc
...
...
@@ -117,18 +127,12 @@ class ApkExtractor {
/// Returns the full path to the [dexdump] tool.
Future
<
String
>
_findDexDump
()
async
{
final
String
androidHome
=
Platform
.
environment
[
'ANDROID_HOME'
]
??
Platform
.
environment
[
'ANDROID_SDK_ROOT'
];
if
(
androidHome
==
null
||
androidHome
.
isEmpty
)
{
throw
Exception
(
'Unset env flag: `ANDROID_HOME` or `ANDROID_SDK_ROOT`.'
);
}
String
dexdumps
;
if
(
Platform
.
isWindows
)
{
dexdumps
=
await
eval
(
'dir'
,
<
String
>[
'/s/b'
,
'dexdump.exe'
],
workingDirectory:
androidHome
);
workingDirectory:
_
androidHome
);
}
else
{
dexdumps
=
await
eval
(
'find'
,
<
String
>[
androidHome
,
'-name'
,
'dexdump'
]);
dexdumps
=
await
eval
(
'find'
,
<
String
>[
_
androidHome
,
'-name'
,
'dexdump'
]);
}
if
(
dexdumps
.
isEmpty
)
{
throw
Exception
(
'Couldn
\'
t find a dexdump executable.'
);
...
...
@@ -165,6 +169,13 @@ class ApkExtractor {
}
}
/// Gets the content of the `AndroidManifest.xml`.
Future
<
String
>
getAndroidManifest
(
String
apk
)
{
final
String
apkAnalyzer
=
path
.
join
(
_androidHome
,
'tools'
,
'bin'
,
'apkanalyzer'
);
return
eval
(
apkAnalyzer
,
<
String
>[
'manifest'
,
'print'
,
apk
],
workingDirectory:
_androidHome
);
}
/// Checks that the classes are contained in the APK, throws otherwise.
Future
<
void
>
checkApkContainsClasses
(
File
apk
,
List
<
String
>
classes
)
async
{
final
ApkExtractor
extractor
=
ApkExtractor
(
apk
);
...
...
packages/flutter_tools/templates/module/android/library/Flutter.tmpl/src/main/AndroidManifest.xml.tmpl
View file @
c08a3c7a
<!-- Generated file. Do not edit. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="{{androidIdentifier}}">
package="{{androidIdentifier}}"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET"/>
<application tools:node="merge">
<meta-data
android:name="flutterProjectType"
android:value="module" />
</application>
</manifest>
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