@@ -54,8 +54,19 @@ public void initRuntime() {
5454
5555 DefaultExtractPolicy extractPolicy = new DefaultExtractPolicy (logger );
5656 boolean skipAssetExtraction = Util .runPlugin (logger , app );
57+
58+ String appName = app .getPackageName ();
59+ File rootDir = new File (app .getApplicationInfo ().dataDir );
60+ File appDir = app .getFilesDir ();
61+
62+ try {
63+ appDir = appDir .getCanonicalFile ();
64+ } catch (IOException e1 ) {
65+ }
66+
67+ Object [] v8Config = V8Config .fromPackageJSON (appDir );
68+
5769 if (!skipAssetExtraction ) {
58- long startTime = System .currentTimeMillis ();
5970 AssetExtractor aE = new AssetExtractor (null , logger );
6071
6172 String outputDir = app .getFilesDir ().getPath () + File .separator ;
@@ -64,25 +75,15 @@ public void initRuntime() {
6475 aE .extractAssets (app , "internal" , outputDir , extractPolicy );
6576 aE .extractAssets (app , "metadata" , outputDir , extractPolicy );
6677
67- // if(true) {
68- // aE.extractAssets(app, "snapshots/" + Build.CPU_ABI + "/snapshot.blob", outputDir, extractPolicy);
69- // }
78+ boolean shouldExtractSnapshots = !v8Config [3 ].toString ().isEmpty ();
79+ if (shouldExtractSnapshots ) {
80+ System .out .println ("EXTRACTING A SNAPSHOT!" );
81+ aE .extractAssets (app , "snapshots/" + Build .CPU_ABI + "/snapshot.blob" , outputDir , extractPolicy );
82+ }
7083
7184 extractPolicy .setAssetsThumb (app );
72-
73- long endTime = System .currentTimeMillis ();
74- System .out .println ("Total execution time: " + (endTime - startTime ) + "ms" );
7585 }
76-
77- String appName = app .getPackageName ();
78- File rootDir = new File (app .getApplicationInfo ().dataDir );
79- File appDir = app .getFilesDir ();
80-
81- try {
82- appDir = appDir .getCanonicalFile ();
83- } catch (IOException e1 ) {
84- }
85-
86+
8687 ClassLoader classLoader = app .getClassLoader ();
8788 File dexDir = new File (rootDir , "code_cache/secondary-dexes" );
8889 String dexThumb = null ;
@@ -95,7 +96,7 @@ public void initRuntime() {
9596 }
9697 ThreadScheduler workThreadScheduler = new WorkThreadScheduler (new Handler (Looper .getMainLooper ()));
9798 Configuration config = new Configuration (workThreadScheduler , logger , debugger , appName , null , rootDir ,
98- appDir , classLoader , dexDir , dexThumb );
99+ appDir , classLoader , dexDir , dexThumb , v8Config );
99100 Runtime runtime = new Runtime (config );
100101
101102 exHandler .setRuntime (runtime );
0 commit comments