@nativescript/android 8.8.0-alpha.11 → 8.8.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/framework/app/build.gradle +10 -4
  2. package/framework/app/libs/runtime-libs/nativescript-optimized-with-inspector.aar +0 -0
  3. package/framework/app/libs/runtime-libs/nativescript-optimized.aar +0 -0
  4. package/framework/app/libs/runtime-libs/nativescript-regular.aar +0 -0
  5. package/framework/app/src/main/assets/internal/ts_helpers.js +3 -1
  6. package/framework/build-tools/android-metadata-generator.jar +0 -0
  7. package/framework/build-tools/dts-generator.jar +0 -0
  8. package/framework/build-tools/jsparser/js_parser.js +1 -1
  9. package/framework/build-tools/static-binding-generator.jar +0 -0
  10. package/framework/settings.gradle +7 -0
  11. package/package.json +1 -1
  12. package/framework/app/src/debug/java/com/tns/ErrorReport.java +0 -512
  13. package/framework/app/src/debug/java/com/tns/ErrorReportActivity.java +0 -52
  14. package/framework/app/src/debug/java/com/tns/NativeScriptSyncService.java +0 -346
  15. package/framework/app/src/debug/java/com/tns/NativeScriptSyncServiceSocketImpl.java +0 -448
  16. package/framework/app/src/debug/res/layout/error_activity.xml +0 -62
  17. package/framework/app/src/debug/res/layout/exception_tab.xml +0 -71
  18. package/framework/app/src/debug/res/layout/logcat_tab.xml +0 -71
  19. package/framework/app/src/main/java/com/tns/AndroidJsV8Inspector.java +0 -361
  20. package/framework/app/src/main/java/com/tns/DefaultExtractPolicy.java +0 -151
  21. package/framework/app/src/main/java/com/tns/EqualityComparator.java +0 -7
  22. package/framework/app/src/main/java/com/tns/LogcatLogger.java +0 -45
  23. package/framework/app/src/main/java/com/tns/NativeScriptUncaughtExceptionHandler.java +0 -72
  24. package/framework/app/src/main/java/com/tns/RuntimeHelper.java +0 -343
  25. package/framework/app/src/main/java/com/tns/Util.java +0 -105
  26. package/framework/app/src/main/java/com/tns/internal/AppBuilderCallback.java +0 -21
  27. package/framework/app/src/main/java/com/tns/internal/Plugin.java +0 -5
@@ -1,346 +0,0 @@
1
- package com.tns;
2
-
3
- import java.io.Closeable;
4
- import java.io.DataInputStream;
5
- import java.io.File;
6
- import java.io.FileFilter;
7
- import java.io.FileInputStream;
8
- import java.io.FileNotFoundException;
9
- import java.io.FileOutputStream;
10
- import java.io.IOException;
11
- import java.io.InputStream;
12
- import java.io.OutputStream;
13
-
14
- import android.content.Context;
15
- import android.content.pm.ApplicationInfo;
16
- import android.content.pm.PackageManager.NameNotFoundException;
17
- import android.net.LocalServerSocket;
18
- import android.net.LocalSocket;
19
- import android.util.Log;
20
-
21
- public class NativeScriptSyncService {
22
- private static String SYNC_ROOT_SOURCE_DIR = "/data/local/tmp/";
23
- private static final String SYNC_SOURCE_DIR = "/sync/";
24
- private static final String FULL_SYNC_SOURCE_DIR = "/fullsync/";
25
- private static final String REMOVED_SYNC_SOURCE_DIR = "/removedsync/";
26
-
27
- private final Runtime runtime;
28
- private static Logger logger;
29
- private final Context context;
30
-
31
- private final String syncPath;
32
- private final String fullSyncPath;
33
- private final String removedSyncPath;
34
- private final File fullSyncDir;
35
- private final File syncDir;
36
- private final File removedSyncDir;
37
-
38
- private LocalServerSocketThread localServerThread;
39
- private Thread localServerJavaThread;
40
-
41
- public NativeScriptSyncService(Runtime runtime, Logger logger, Context context) {
42
- this.runtime = runtime;
43
- NativeScriptSyncService.logger = logger;
44
- this.context = context;
45
-
46
- syncPath = SYNC_ROOT_SOURCE_DIR + context.getPackageName() + SYNC_SOURCE_DIR;
47
- fullSyncPath = SYNC_ROOT_SOURCE_DIR + context.getPackageName() + FULL_SYNC_SOURCE_DIR;
48
- removedSyncPath = SYNC_ROOT_SOURCE_DIR + context.getPackageName() + REMOVED_SYNC_SOURCE_DIR;
49
- fullSyncDir = new File(fullSyncPath);
50
- syncDir = new File(syncPath);
51
- removedSyncDir = new File(removedSyncPath);
52
- }
53
-
54
- public void sync() {
55
- if (logger != null && logger.isEnabled()) {
56
- logger.write("Sync is enabled:");
57
- logger.write("Sync path : " + syncPath);
58
- logger.write("Full sync path : " + fullSyncPath);
59
- logger.write("Removed files sync path: " + removedSyncPath);
60
- }
61
-
62
- if (fullSyncDir.exists()) {
63
- executeFullSync(context, fullSyncDir);
64
- return;
65
- }
66
-
67
- if (syncDir.exists()) {
68
- executePartialSync(context, syncDir);
69
- }
70
-
71
- if (removedSyncDir.exists()) {
72
- executeRemovedSync(context, removedSyncDir);
73
- }
74
- }
75
-
76
- private class LocalServerSocketThread implements Runnable {
77
- private volatile boolean running;
78
- private final String name;
79
-
80
- private ListenerWorker commThread;
81
- private LocalServerSocket serverSocket;
82
-
83
- public LocalServerSocketThread(String name) {
84
- this.name = name;
85
- this.running = false;
86
- }
87
-
88
- public void stop() {
89
- this.running = false;
90
- try {
91
- serverSocket.close();
92
- } catch (IOException e) {
93
- if (com.tns.Runtime.isDebuggable()) {
94
- e.printStackTrace();
95
- }
96
- }
97
- }
98
-
99
- public void run() {
100
- running = true;
101
- try {
102
- serverSocket = new LocalServerSocket(this.name);
103
- while (running) {
104
- LocalSocket socket = serverSocket.accept();
105
- commThread = new ListenerWorker(socket);
106
- new Thread(commThread).start();
107
- }
108
- } catch (IOException e) {
109
- if (com.tns.Runtime.isDebuggable()) {
110
- e.printStackTrace();
111
- }
112
- }
113
- }
114
- }
115
-
116
- private class ListenerWorker implements Runnable {
117
- private final DataInputStream input;
118
- private Closeable socket;
119
- private OutputStream output;
120
-
121
- public ListenerWorker(LocalSocket socket) throws IOException {
122
- this.socket = socket;
123
- input = new DataInputStream(socket.getInputStream());
124
- output = socket.getOutputStream();
125
- }
126
-
127
- public void run() {
128
- try {
129
- int length = input.readInt();
130
- input.readFully(new byte[length]); // ignore the payload
131
- executePartialSync(context, syncDir);
132
- executeRemovedSync(context, removedSyncDir);
133
-
134
- runtime.runScript(new File(NativeScriptSyncService.this.context.getFilesDir(), "internal/livesync.js"));
135
- try {
136
- output.write(1);
137
- } catch (IOException e) {
138
- if (com.tns.Runtime.isDebuggable()) {
139
- e.printStackTrace();
140
- }
141
- }
142
- socket.close();
143
- } catch (IOException e) {
144
- if (com.tns.Runtime.isDebuggable()) {
145
- e.printStackTrace();
146
- }
147
- }
148
- }
149
- }
150
-
151
- public void startServer() {
152
- localServerThread = new LocalServerSocketThread(context.getPackageName() + "-livesync");
153
- localServerJavaThread = new Thread(localServerThread);
154
- localServerJavaThread.start();
155
- }
156
-
157
- public static boolean isSyncEnabled(Context context) {
158
- int flags;
159
- boolean shouldExecuteSync = false;
160
- try {
161
- flags = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.flags;
162
- shouldExecuteSync = ((flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0);
163
- } catch (NameNotFoundException e) {
164
- if (com.tns.Runtime.isDebuggable()) {
165
- e.printStackTrace();
166
- }
167
- return false;
168
- }
169
-
170
- return shouldExecuteSync;
171
- }
172
-
173
- final FileFilter deletingFilesFilter = new FileFilter() {
174
- @Override
175
- public boolean accept(File pathname) {
176
- if (pathname.isDirectory()) {
177
- return true;
178
- }
179
-
180
- boolean success = pathname.delete();
181
- if (!success) {
182
- logger.write("Syncing: file not deleted: " + pathname.getAbsolutePath().toString());
183
- }
184
- return false;
185
- }
186
- };
187
-
188
- private void deleteDir(File directory) {
189
- File[] subDirectories = directory.listFiles(deletingFilesFilter);
190
- if (subDirectories != null) {
191
- for (int i = 0; i < subDirectories.length; i++) {
192
- File subDir = subDirectories[i];
193
- deleteDir(subDir);
194
- }
195
- }
196
-
197
- boolean success = directory.delete();
198
- if (!success && directory.exists()) {
199
- logger.write("Syncing: directory not deleted: " + directory.getAbsolutePath().toString());
200
- }
201
- }
202
-
203
- private void moveFiles(File sourceDir, String sourceRootAbsolutePath, String targetRootAbsolutePath) {
204
- File[] files = sourceDir.listFiles();
205
-
206
- if (files != null) {
207
- if (logger.isEnabled()) {
208
- logger.write("Syncing total number of fiiles: " + files.length);
209
- }
210
-
211
- for (int i = 0; i < files.length; i++) {
212
- File file = files[i];
213
- if (file.isFile()) {
214
- if (logger.isEnabled()) {
215
- logger.write("Syncing: " + file.getAbsolutePath().toString());
216
- }
217
-
218
- String targetFilePath = file.getAbsolutePath().replace(sourceRootAbsolutePath, targetRootAbsolutePath);
219
- File targetFileDir = new File(targetFilePath);
220
-
221
- File targetParent = targetFileDir.getParentFile();
222
- if (targetParent != null) {
223
- targetParent.mkdirs();
224
- }
225
-
226
- boolean success = copyFile(file.getAbsolutePath(), targetFilePath);
227
- if (!success) {
228
- logger.write("Sync failed: " + file.getAbsolutePath().toString());
229
- }
230
- } else {
231
- moveFiles(file, sourceRootAbsolutePath, targetRootAbsolutePath);
232
- }
233
- }
234
- } else {
235
- if (logger.isEnabled()) {
236
- logger.write("Can't move files. Source is empty.");
237
- }
238
- }
239
- }
240
-
241
- // this removes only the app directory from the device to preserve
242
- // any existing files in /files directory on the device
243
- private void executeFullSync(Context context, final File sourceDir) {
244
- String appPath = context.getFilesDir().getAbsolutePath() + "/app";
245
- final File appDir = new File(appPath);
246
-
247
- if (appDir.exists()) {
248
- deleteDir(appDir);
249
- moveFiles(sourceDir, sourceDir.getAbsolutePath(), appDir.getAbsolutePath());
250
- }
251
- }
252
-
253
- private void executePartialSync(Context context, File sourceDir) {
254
- String appPath = context.getFilesDir().getAbsolutePath() + "/app";
255
- final File appDir = new File(appPath);
256
-
257
- if (!appDir.exists()) {
258
- Log.e("TNS", "Application dir does not exists. Partial Sync failed. appDir: " + appPath);
259
- return;
260
- }
261
-
262
- if (logger.isEnabled()) {
263
- logger.write("Syncing sourceDir " + sourceDir.getAbsolutePath() + " with " + appDir.getAbsolutePath());
264
- }
265
-
266
- moveFiles(sourceDir, sourceDir.getAbsolutePath(), appDir.getAbsolutePath());
267
- }
268
-
269
- private void deleteRemovedFiles(File sourceDir, String sourceRootAbsolutePath, String targetRootAbsolutePath) {
270
- if (!sourceDir.exists()) {
271
- if (logger.isEnabled()) {
272
- logger.write("Directory does not exist: " + sourceDir.getAbsolutePath());
273
- }
274
- }
275
-
276
- File[] files = sourceDir.listFiles();
277
-
278
- if (files != null) {
279
- for (int i = 0; i < files.length; i++) {
280
- File file = files[i];
281
- String targetFilePath = file.getAbsolutePath().replace(sourceRootAbsolutePath, targetRootAbsolutePath);
282
- File targetFile = new File(targetFilePath);
283
- if (file.isFile()) {
284
- if (logger.isEnabled()) {
285
- logger.write("Syncing removed file: " + file.getAbsolutePath().toString());
286
- }
287
-
288
- targetFile.delete();
289
- } else {
290
- deleteRemovedFiles(file, sourceRootAbsolutePath, targetRootAbsolutePath);
291
-
292
- // this is done so empty folders, if any, are deleted after we're don deleting files.
293
- if (targetFile.listFiles().length == 0) {
294
- targetFile.delete();
295
- }
296
- }
297
- }
298
- }
299
- }
300
-
301
- private void executeRemovedSync(final Context context, final File sourceDir) {
302
- String appPath = context.getFilesDir().getAbsolutePath() + "/app";
303
- deleteRemovedFiles(sourceDir, sourceDir.getAbsolutePath(), appPath);
304
- }
305
-
306
- private boolean copyFile(String sourceFile, String destinationFile) {
307
- FileInputStream fis = null;
308
- FileOutputStream fos = null;
309
-
310
- try {
311
- fis = new FileInputStream(sourceFile);
312
- fos = new FileOutputStream(destinationFile, false);
313
-
314
- byte[] buffer = new byte[4096];
315
- int read = 0;
316
-
317
- while ((read = fis.read(buffer)) != -1) {
318
- fos.write(buffer, 0, read);
319
- }
320
- } catch (FileNotFoundException e) {
321
- logger.write("Error copying file " + sourceFile);
322
- if (com.tns.Runtime.isDebuggable()) {
323
- e.printStackTrace();
324
- }
325
- return false;
326
- } catch (IOException e) {
327
- logger.write("Error copying file " + sourceFile);
328
- if (com.tns.Runtime.isDebuggable()) {
329
- e.printStackTrace();
330
- }
331
- return false;
332
- } finally {
333
- try {
334
- if (fis != null) {
335
- fis.close();
336
- }
337
- if (fos != null) {
338
- fos.close();
339
- }
340
- } catch (IOException e) {
341
- }
342
- }
343
-
344
- return true;
345
- }
346
- }