1
1
package com .tns ;
2
2
3
3
import java .io .File ;
4
-
5
4
import org .json .JSONObject ;
6
-
7
5
import android .os .Build ;
8
6
import android .util .Log ;
9
7
10
8
class AppConfig {
11
- private enum KnownKeys {
9
+ protected enum KnownKeys {
12
10
V8FlagsKey ("v8Flags" , "--expose_gc" ),
13
11
CodeCacheKey ("codeCache" , false ),
14
12
HeapSnapshotScriptKey ("heapSnapshotScript" , "" ),
@@ -18,7 +16,7 @@ private enum KnownKeys {
18
16
MemoryCheckInterval ("memoryCheckInterval" , 0 ),
19
17
FreeMemoryRatio ("freeMemoryRatio" , 0.0 ),
20
18
Profiling ("profiling" , "" ),
21
- MarkingMode ("markingMode" , com .tns .MarkingMode .values ()[ 0 ] );
19
+ MarkingMode ("markingMode" , com .tns .MarkingMode .full );
22
20
23
21
private final String name ;
24
22
private final Object defaultValue ;
@@ -52,7 +50,7 @@ public AppConfig(File appDir) {
52
50
try {
53
51
rootObject = FileSystem .readJSONFile (packageInfo );
54
52
if (rootObject != null ) {
55
- if (rootObject .has (KnownKeys .Profiling .name ())) {
53
+ if (rootObject .has (KnownKeys .Profiling .getName ())) {
56
54
String profiling = rootObject .getString (KnownKeys .Profiling .getName ());
57
55
values [KnownKeys .Profiling .ordinal ()] = profiling ;
58
56
}
@@ -92,9 +90,12 @@ public AppConfig(File appDir) {
92
90
}
93
91
if (androidObject .has (KnownKeys .MarkingMode .getName ())) {
94
92
try {
95
- String value = androidObject .getString (KnownKeys .MarkingMode .getName ());
96
- values [KnownKeys .MarkingMode .ordinal ()] = MarkingMode .valueOf (value );
97
- } catch (Throwable e ) {
93
+ String markingModeString = androidObject .getString (KnownKeys .MarkingMode .getName ());
94
+ MarkingMode markingMode = MarkingMode .valueOf (markingModeString );
95
+ values [KnownKeys .MarkingMode .ordinal ()] = markingMode ;
96
+ } catch (Exception e ) {
97
+ e .printStackTrace ();
98
+ Log .v ("JS" , "Failed to parse marking mode. The default " + ((MarkingMode )KnownKeys .MarkingMode .getDefaultValue ()).name () + " will be used." );
98
99
}
99
100
}
100
101
}
@@ -131,5 +132,6 @@ public double getFreeMemoryRatio() {
131
132
public String getProfilingMode () {
132
133
return (String )values [KnownKeys .Profiling .ordinal ()];
133
134
}
135
+
134
136
public MarkingMode getMarkingMode () { return (MarkingMode )values [KnownKeys .MarkingMode .ordinal ()]; }
135
137
}
0 commit comments