11package com .tns ;
22
33import java .io .File ;
4+
45import org .json .JSONObject ;
56
7+ import android .os .Build ;
8+
69class V8Config
710{
811 private static final String AndroidKey = "android" ;
912 private static final String V8FlagsKey = "v8Flags" ;
1013 private static final String CodeCacheKey = "codeCache" ;
1114 private static final String HeapSnapshotKey = "heapSnapshot" ;
1215 private static final String HeapSnapshotScriptKey = "heapSnapshotScript" ;
16+ private static final String HeapSnapshotBlobKey = "heapSnapshotBlob" ;
17+ private static final String SnapshotFile = "snapshot.blob" ;
1318 private static final String ProfilerOutputDirKey = "profilerOutputDir" ;
1419
1520 public static Object [] fromPackageJSON (File appDir )
@@ -45,9 +50,21 @@ public static Object[] fromPackageJSON(File appDir)
4550 String value = androidObject .getString (HeapSnapshotScriptKey );
4651 result [3 ] = FileSystem .resolveRelativePath (appDir .getPath (), value , appDir + "/app/" );
4752 }
53+ if (androidObject .has (HeapSnapshotBlobKey ))
54+ {
55+ String value = androidObject .getString (HeapSnapshotBlobKey );
56+ String path = FileSystem .resolveRelativePath (appDir .getPath (), value , appDir + "/app/" );
57+ File dir = new File (path );
58+ if (dir .exists () && dir .isDirectory ())
59+ {
60+ // this path is expected to be a directory, containing three sub-directories: armeabi-v7a, x86 and arm64-v8a
61+ path = path + "/" + Build .CPU_ABI + "/" + SnapshotFile ;
62+ result [4 ] = path ;
63+ }
64+ }
4865 if (androidObject .has (ProfilerOutputDirKey ))
4966 {
50- result [4 ] = androidObject .getString (ProfilerOutputDirKey );
67+ result [5 ] = androidObject .getString (ProfilerOutputDirKey );
5168 }
5269 }
5370 }
@@ -70,6 +87,8 @@ private static Object[] makeDefaultOptions()
7087 false ,
7188 // arbitrary script to be included in the snapshot
7289 "" ,
90+ // a binary file containing an already saved snapshot
91+ "" ,
7392 // V8 profiler output directory
7493 ""
7594 };
0 commit comments