Skip to content

Commit 8b4c1a3

Browse files
committed
Merge branch 'master' into release
2 parents ce5d00f + 3d50b50 commit 8b4c1a3

File tree

19 files changed

+230
-89
lines changed

19 files changed

+230
-89
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
3.0.1
2+
==
3+
4+
## Bug Fixes
5+
6+
- [--debug-brk flag not working (#2741)](https://github.com/NativeScript/nativescript-cli/issues/2741)
7+
8+
3.0.0
9+
==
10+
11+
## What's New
12+
13+
- [Chrome DevTools Network Domain (#715)](https://github.com/NativeScript/android-runtime/issues/715)
14+
- [Chrome DevTools Scope Tab (#713)](https://github.com/NativeScript/android-runtime/issues/713)
15+
- [Enabling java source code or direct dex generation #663)](https://github.com/NativeScript/android-runtime/issues/663)
16+
- [Improve Gradle incremental build (#562)](https://github.com/NativeScript/android-runtime/issues/562)
17+
18+
19+
## Bug Fixes
20+
21+
- [Javascript array not marshalling to Java long[] properly (#696)](https://github.com/NativeScript/android-runtime/issues/696)
22+
123
2.5.0-RC
224
==
325

android-static-binding-generator/project/staticbindinggenerator/src/main/java/org/nativescript/staticbindinggenerator/Generator.java

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,32 +46,31 @@ public Generator(String outputDir, String[] libs, boolean throwOnError) throws I
4646
}
4747

4848

49-
public void writeBindings(String filename) throws IOException {
49+
public void writeBindings(String filename) throws IOException, ClassNotFoundException {
5050
Binding[] bindings = generateBindings(filename);
5151
List<File> writenFiles = new ArrayList<File>();
5252
for (Binding b : bindings) {
53-
if(!writenFiles.contains(b.getFile())) {
53+
if (!writenFiles.contains(b.getFile())) {
5454
writenFiles.add(b.getFile());
5555
try (PrintStream ps = new PrintStream(b.getFile())) {
5656
ps.append(b.getContent());
5757
}
58-
}
59-
else {
58+
} else {
6059
throw new IOException("File already exists. This may lead to undesired behavior.\nPlease change the name of one of the extended classes.\n" + b.getFile());
6160
}
6261
}
6362
}
6463

65-
public Binding[] generateBindings(String filename) throws IOException {
64+
public Binding[] generateBindings(String filename) throws IOException, ClassNotFoundException {
6665
List<DataRow> rows = getRows(filename);
6766

6867
Binding[] generatedFiles = processRows(rows);
6968

7069
return generatedFiles;
7170
}
7271

73-
public Binding generateBinding(DataRow dataRow, HashSet interfaceNames) {
74-
JavaClass clazz = classes.get(dataRow.getBaseClassname());
72+
public Binding generateBinding(DataRow dataRow, HashSet interfaceNames) throws ClassNotFoundException {
73+
JavaClass clazz = getClass(dataRow.getBaseClassname());
7574

7675
boolean hasSpecifiedName = !dataRow.getFilename().isEmpty();
7776
String packageName = hasSpecifiedName ? getBaseDir(dataRow.getFilename()) : (DEFAULT_PACKAGE_NAME + "." + clazz.getPackageName());
@@ -112,7 +111,7 @@ public Binding generateBinding(DataRow dataRow, HashSet interfaceNames) {
112111
return new Binding(new File(baseDir, normalizedName + JAVA_EXT), w.toString(), classname);
113112
}
114113

115-
public Binding generateBinding(DataRow dataRow) {
114+
public Binding generateBinding(DataRow dataRow) throws ClassNotFoundException {
116115
return generateBinding(dataRow, new HashSet());
117116
}
118117

@@ -134,7 +133,7 @@ private List<DataRow> getRows(String filename) throws IOException {
134133
return rows;
135134
}
136135

137-
private Binding[] processRows(List<DataRow> rows) throws IOException {
136+
private Binding[] processRows(List<DataRow> rows) throws IOException, ClassNotFoundException {
138137
ArrayList<Binding> bindings = new ArrayList<>();
139138
HashSet interfaceNames = new HashSet();
140139

@@ -184,11 +183,11 @@ private String getNormalizedName(String filename) {
184183
char c = Character.isJavaIdentifierPart(ch) ? ch : '_';
185184
sb.append(c);
186185
}
187-
String name = sb.toString();
188-
return name;
186+
187+
return sb.toString();
189188
}
190189

191-
private Map<String, List<Method>> getPublicApi(JavaClass clazz) {
190+
private Map<String, List<Method>> getPublicApi(JavaClass clazz) throws ClassNotFoundException {
192191
Map<String, List<Method>> api = new HashMap<String, List<Method>>();
193192
JavaClass currentClass = clazz;
194193
String clazzName = clazz.getClassName();
@@ -240,7 +239,7 @@ private Map<String, List<Method>> getPublicApi(JavaClass clazz) {
240239
break;
241240
} else {
242241
String superClassName = currentClass.getSuperclassName();
243-
currentClass = classes.get(superClassName.replace('$', '.'));
242+
currentClass = getClass(superClassName);
244243
}
245244
}
246245
return api;
@@ -329,7 +328,7 @@ private String getFullMethodSignature(Method m) {
329328
return sig;
330329
}
331330

332-
private void writeBinding(Writer w, DataRow dataRow, JavaClass clazz, String packageName, String name) {
331+
private void writeBinding(Writer w, DataRow dataRow, JavaClass clazz, String packageName, String name) throws ClassNotFoundException {
333332
String[] implInterfaces = dataRow.getInterfaces();
334333
collectImplementedInterfaces(implInterfaces, clazz);
335334

@@ -382,12 +381,12 @@ private void writeBinding(Writer w, DataRow dataRow, JavaClass clazz, String pac
382381
}
383382
}
384383

385-
boolean hasInitMethod2 = isApplicationClass ? false : hasInitMethod;
384+
boolean hasInitMethod2 = !isApplicationClass && hasInitMethod;
386385
writeConstructors(clazz, name, hasInitMethod2, isApplicationClass, w);
387386

388387
if (isInterface) {
389388
Set<String> objectMethods = new HashSet<String>();
390-
for (Method objMethod : classes.get("java.lang.Object").getMethods()) {
389+
for (Method objMethod : getClass("java.lang.Object").getMethods()) {
391390
if (!objMethod.isStatic() && (objMethod.isPublic() || objMethod.isProtected())) {
392391
String sig = getFullMethodSignature(objMethod);
393392
objectMethods.add(sig);
@@ -408,7 +407,7 @@ private void writeBinding(Writer w, DataRow dataRow, JavaClass clazz, String pac
408407
}
409408
while (!interfaceNames.isEmpty()) {
410409
String iname = interfaceNames.pollFirst();
411-
JavaClass iface = classes.get(iname.replace('$', '.'));
410+
JavaClass iface = getClass(iname);
412411
for (String iname2 : iface.getInterfaceNames()) {
413412
interfaceNames.add(iname2.replace('$', '.'));
414413
}
@@ -528,7 +527,6 @@ private void writeMethodSignature(Method m, Writer w) {
528527
private void writeThrowsClause(Method m, Writer w) {
529528
}
530529

531-
532530
private void writeConstructors(JavaClass clazz, String classname, boolean hasInitMethod, boolean isApplicationClass, Writer w) {
533531
boolean isInterface = clazz.isInterface();
534532
if (isInterface) {
@@ -656,7 +654,7 @@ private void writeType(Type t, Writer w) {
656654
w.write(type);
657655
}
658656

659-
private void collectInterfaceMethods(JavaClass clazz, List<Method> methods) {
657+
private void collectInterfaceMethods(JavaClass clazz, List<Method> methods) throws ClassNotFoundException {
660658
JavaClass currentClass = clazz;
661659

662660
while (true) {
@@ -669,7 +667,7 @@ private void collectInterfaceMethods(JavaClass clazz, List<Method> methods) {
669667

670668
while (!queue.isEmpty()) {
671669
String ifaceName = queue.poll();
672-
JavaClass currentInterface = classes.get(ifaceName.replace('$', '.'));
670+
JavaClass currentInterface = getClass(ifaceName);
673671
Method[] ifaceMethods = currentInterface.getMethods();
674672
for (Method m : ifaceMethods) {
675673
methods.add(m);
@@ -683,12 +681,12 @@ private void collectInterfaceMethods(JavaClass clazz, List<Method> methods) {
683681
break;
684682
} else {
685683
String superClassName = currentClass.getSuperclassName();
686-
currentClass = classes.get(superClassName.replace('$', '.'));
684+
currentClass = getClass(superClassName);
687685
}
688686
}
689687
}
690688

691-
private boolean isApplicationClass(JavaClass clazz, Map<String, JavaClass> classes) {
689+
private boolean isApplicationClass(JavaClass clazz, Map<String, JavaClass> classes) throws ClassNotFoundException {
692690
boolean isApplicationClass = false;
693691

694692
String applicationClassname = "android.app.Application";
@@ -707,9 +705,19 @@ private boolean isApplicationClass(JavaClass clazz, Map<String, JavaClass> class
707705
}
708706

709707
String superClassName = currentClass.getSuperclassName();
710-
currentClass = classes.get(superClassName.replace('$', '.'));
708+
currentClass = getClass(superClassName);
711709
}
712710

713711
return isApplicationClass;
714712
}
713+
714+
private JavaClass getClass(String className) throws ClassNotFoundException {
715+
JavaClass clazz = classes.get(className.replace('$', '.'));
716+
717+
if (clazz == null) {
718+
throw new ClassNotFoundException("Class: " + className);
719+
}
720+
721+
return clazz;
722+
}
715723
}

android-static-binding-generator/project/staticbindinggenerator/src/main/java/org/nativescript/staticbindinggenerator/Main.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import java.util.Arrays;
55

66
public class Main {
7-
public static void main(String[] args) throws IOException {
8-
if (args.length < 3) {
9-
throw new IllegalArgumentException("Expects at least three arguments");
10-
}
11-
String inputBindingFilename = args[0];
12-
String outputDir = args[1];
13-
String[] libs = Arrays.copyOfRange(args, 2, args.length);
7+
public static void main(String[] args) throws IOException, ClassNotFoundException {
8+
if (args.length < 3) {
9+
throw new IllegalArgumentException("Expects at least three arguments");
10+
}
11+
String inputBindingFilename = args[0];
12+
String outputDir = args[1];
13+
String[] libs = Arrays.copyOfRange(args, 2, args.length);
1414

15-
new Generator(outputDir, libs).writeBindings(inputBindingFilename);
15+
new Generator(outputDir, libs).writeBindings(inputBindingFilename);
1616
}
1717
}

build-artifacts/project-template-gradle/src/main/java/com/tns/RuntimeHelper.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.content.pm.PackageManager.NameNotFoundException;
77
import android.os.Build;
88
import android.util.Log;
9+
910
import java.io.IOException;
1011

1112
public final class RuntimeHelper {
@@ -28,7 +29,7 @@ private static boolean hasErrorIntent(Application app) {
2829
try {
2930
java.lang.Class ErrReport = java.lang.Class.forName("com.tns.ErrorReport");
3031
java.lang.reflect.Field field = ErrReport.getDeclaredField("ERROR_FILE_NAME");
31-
fileName = (String)field.get(null);
32+
fileName = (String) field.get(null);
3233
} catch (Exception e) {
3334
return false;
3435
}
@@ -97,7 +98,7 @@ public static Runtime initRuntime(Application app) {
9798
logger.write("Extracting snapshot blob");
9899
}
99100

100-
aE.extractAssets(app, "snapshots/" + Build.CPU_ABI, outputDir, extractPolicy);
101+
aE.extractAssets(app, "snapshots/" + Build.CPU_ABI, outputDir, extractPolicy);
101102
}
102103

103104
extractPolicy.setAssetsThumb(app);
@@ -131,17 +132,32 @@ public static Runtime initRuntime(Application app) {
131132
runtime = Runtime.initializeRuntimeWithConfiguration(config);
132133
if (isDebuggable) {
133134
try {
134-
v8Inspector = new AndroidJsV8Inspector(app, logger);
135+
v8Inspector = new AndroidJsV8Inspector(app.getFilesDir().getAbsolutePath(), app.getPackageName());
135136
v8Inspector.start();
136137

137138
// the following snippet is used as means to notify the VSCode extension
138139
// debugger that the debugger agent has started
139-
File debugBreakFile = new File("/data/local/tmp", app.getPackageName() + "-debugger-started");
140+
File debuggerStartedFile = new File("/data/local/tmp", app.getPackageName() + "-debugger-started");
141+
if (debuggerStartedFile.exists() && !debuggerStartedFile.isDirectory() && debuggerStartedFile.length() == 0) {
142+
java.io.FileWriter fileWriter = new java.io.FileWriter(debuggerStartedFile);
143+
fileWriter.write("started");
144+
fileWriter.close();
145+
}
146+
147+
// check if --debug-brk flag has been set. If positive:
148+
// write to the file to invalidate the flag
149+
// inform the v8Inspector to pause the main thread
150+
File debugBreakFile = new File("/data/local/tmp", app.getPackageName() + "-debugbreak");
151+
boolean shouldBreak = false;
140152
if (debugBreakFile.exists() && !debugBreakFile.isDirectory() && debugBreakFile.length() == 0) {
141153
java.io.FileWriter fileWriter = new java.io.FileWriter(debugBreakFile);
142154
fileWriter.write("started");
143155
fileWriter.close();
156+
157+
shouldBreak = true;
144158
}
159+
160+
v8Inspector.waitForDebugger(shouldBreak);
145161
} catch (IOException e) {
146162
e.printStackTrace();
147163
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tns-android",
33
"description": "NativeScript Runtime for Android",
4-
"version": "3.0.0",
4+
"version": "3.1.0",
55
"files": [
66
"**/*"
77
]

0 commit comments

Comments
 (0)