This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Handle Flutter assets outside FLX #4343
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6d617bd
Handle Flutter assets outside FLX
szakarias a720c44
comments
szakarias 834b85c
fix bug after rebase
szakarias 2efa7f0
Expect engine to be called with Flutter asset dir
szakarias 7e1815b
Added deprecated attributes and reverted asset path change
szakarias ece8080
parameter name
szakarias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ public class FlutterMain { | |
| private static final String AOT_ISOLATE_SNAPSHOT_INSTR_KEY = "isolate-snapshot-instr"; | ||
| private static final String FLX_KEY = "flx"; | ||
| private static final String SNAPSHOT_BLOB_KEY = "snapshot-blob"; | ||
| private static final String FLUTTER_ASSETS_DIR_KEY = "flutter-assets-dir"; | ||
|
|
||
| // XML Attribute keys supported in AndroidManifest.xml | ||
| public static final String PUBLIC_AOT_AOT_SHARED_LIBRARY_PATH = | ||
|
|
@@ -54,6 +55,8 @@ public class FlutterMain { | |
| FlutterMain.class.getName() + '.' + FLX_KEY; | ||
| public static final String PUBLIC_SNAPSHOT_BLOB_KEY = | ||
| FlutterMain.class.getName() + '.' + SNAPSHOT_BLOB_KEY; | ||
| public static final String PUBLIC_FLUTTER_ASSETS_DIR_KEY = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this was never wired up in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, thanks! |
||
| FlutterMain.class.getName() + '.' + FLUTTER_ASSETS_DIR_KEY; | ||
|
|
||
| // Resource names used for components of the precompiled snapshot. | ||
| private static final String DEFAULT_AOT_SHARED_LIBRARY_PATH= "app.so"; | ||
|
|
@@ -63,6 +66,7 @@ public class FlutterMain { | |
| private static final String DEFAULT_AOT_ISOLATE_SNAPSHOT_INSTR = "isolate_snapshot_instr"; | ||
| private static final String DEFAULT_FLX = "app.flx"; | ||
| private static final String DEFAULT_SNAPSHOT_BLOB = "snapshot_blob.bin"; | ||
| private static final String DEFAULT_FLUTTER_ASSETS_DIR = "flutter_assets"; | ||
|
|
||
| private static final String MANIFEST = "flutter.yaml"; | ||
|
|
||
|
|
@@ -79,6 +83,7 @@ public class FlutterMain { | |
| private static String sAotIsolateSnapshotInstr = DEFAULT_AOT_ISOLATE_SNAPSHOT_INSTR; | ||
| private static String sFlx = DEFAULT_FLX; | ||
| private static String sSnapshotBlob = DEFAULT_SNAPSHOT_BLOB; | ||
| private static String sFlutterAssetsDir = DEFAULT_FLUTTER_ASSETS_DIR; | ||
|
|
||
| private static boolean sInitialized = false; | ||
| private static ResourceExtractor sResourceExtractor; | ||
|
|
@@ -238,7 +243,8 @@ private static void initResources(Context applicationContext) { | |
| new ResourceCleaner(context).start(); | ||
| sResourceExtractor = new ResourceExtractor(context) | ||
| .addResources(SKY_RESOURCES) | ||
| .addResource(sFlx); | ||
| .addResource(sFlx) | ||
| .addResource(sFlutterAssetsDir); | ||
| if (sIsPrecompiledAsSharedLibrary) { | ||
| sResourceExtractor | ||
| .addResource(sAotSharedLibraryPath); | ||
|
|
@@ -290,7 +296,7 @@ public static boolean isRunningPrecompiledCode() { | |
|
|
||
| public static String findAppBundlePath(Context applicationContext) { | ||
| String dataDirectory = PathUtils.getDataDirectory(applicationContext); | ||
| File appBundle = new File(dataDirectory, sFlx); | ||
| File appBundle = new File(dataDirectory, sFlutterAssetsDir); | ||
| return appBundle.exists() ? appBundle.getPath() : null; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we maybe split this up into multiple lines with early returns on failure conditions for readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could probably be split up, but there are no failure conditions as such here. The best we could do would be something like
(I kind of prefer the current version, though, which is copied from engine. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I didn't realize this was copied directly from the engine. Our preferences don't match but I don't have a strong opinion about this. Lets keep it as it.