From ff68ab87ccbbb2b9bea436738d2fb90fdc388d23 Mon Sep 17 00:00:00 2001 From: blagoev Date: Mon, 8 Jun 2015 23:26:20 +0300 Subject: [PATCH 1/3] fix debug-brk command for CLI to use proper internal files dir instead of sdcard location which may not be present --- src/src/com/tns/JsDebugger.java | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/src/com/tns/JsDebugger.java b/src/src/com/tns/JsDebugger.java index d05be4fda..f76bb6009 100644 --- a/src/src/com/tns/JsDebugger.java +++ b/src/src/com/tns/JsDebugger.java @@ -318,11 +318,16 @@ int getDebuggerPortFromEnvironment() boolean shouldEnableDebuggingFlag = shouldEnableDebugging(context); - if (Platform.IsLogEnabled) Log.d(Platform.DEFAULT_LOG_TAG, "getDebuggerPortFromEnvironment:: shouldEnableDebuggingFlag=" + shouldEnableDebuggingFlag); + if (Platform.IsLogEnabled) + { + Log.d(Platform.DEFAULT_LOG_TAG, "getDebuggerPortFromEnvironment:: shouldEnableDebuggingFlag=" + shouldEnableDebuggingFlag); + } if (shouldEnableDebuggingFlag) { - File baseDir = context.getExternalFilesDir(null); + String appRoot = context.getFilesDir().getPath() + File.separator; + File baseDir = new File(appRoot); + File envOutFile = new File(baseDir, portEnvOutputFile); OutputStreamWriter w = null; try @@ -353,7 +358,10 @@ int getDebuggerPortFromEnvironment() boolean shouldDebugBreakFlag = shouldDebugBreak(context); - if (Platform.IsLogEnabled) Log.d(Platform.DEFAULT_LOG_TAG, "shouldDebugBreakFlag=" + shouldDebugBreakFlag); + if (Platform.IsLogEnabled) + { + Log.d(Platform.DEFAULT_LOG_TAG, "shouldDebugBreakFlag=" + shouldDebugBreakFlag); + } if (shouldDebugBreakFlag) { @@ -372,7 +380,10 @@ int getDebuggerPortFromEnvironment() boolean envInFileFlag = envInFile.exists(); - if (Platform.IsLogEnabled) Log.d(Platform.DEFAULT_LOG_TAG, "envInFileFlag=" + envInFileFlag); + if (Platform.IsLogEnabled) + { + Log.d(Platform.DEFAULT_LOG_TAG, "envInFileFlag=" + envInFileFlag); + } if (envInFileFlag) { @@ -436,7 +447,10 @@ int getDebuggerPortFromEnvironment() } } - Log.d(Platform.DEFAULT_LOG_TAG, "port=" + port); + if (Platform.IsLogEnabled) + { + Log.d(Platform.DEFAULT_LOG_TAG, "Debug port=" + port); + } return port; } @@ -571,8 +585,8 @@ public static boolean shouldDebugBreak(Context context) return false; } - File baseDir = context.getExternalFilesDir(null); - File debugBreakFile = new File(baseDir, DEBUG_BREAK_FILENAME); + String appRoot = context.getFilesDir().getPath() + File.separator; + File debugBreakFile = new File(appRoot, DEBUG_BREAK_FILENAME); if (debugBreakFile.exists()) { debugBreakFile.delete(); From 235cce8716f88acaedab1e5a504b02e03a140ae9 Mon Sep 17 00:00:00 2001 From: blagoev Date: Tue, 9 Jun 2015 12:21:50 +0300 Subject: [PATCH 2/3] use /data/local/tmp for debug files --- src/src/com/tns/JsDebugger.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/src/com/tns/JsDebugger.java b/src/src/com/tns/JsDebugger.java index f76bb6009..327fc4eba 100644 --- a/src/src/com/tns/JsDebugger.java +++ b/src/src/com/tns/JsDebugger.java @@ -46,6 +46,8 @@ public class JsDebugger private static final int INVALID_PORT = -1; + private static final String BASE_DEBUG_FILES_DIR = "/data/local/tmp/"; + private static final String portEnvInputFile = "envDebug.in"; private static final String portEnvOutputFile = "envDebug.out"; @@ -325,10 +327,10 @@ int getDebuggerPortFromEnvironment() if (shouldEnableDebuggingFlag) { - String appRoot = context.getFilesDir().getPath() + File.separator; - File baseDir = new File(appRoot); + //String appRoot = context.getFilesDir().getPath() + File.separator; + File baseDir = new File(BASE_DEBUG_FILES_DIR); - File envOutFile = new File(baseDir, portEnvOutputFile); + File envOutFile = new File(baseDir, context.getPackageName() + "-" + portEnvOutputFile); OutputStreamWriter w = null; try { @@ -376,7 +378,7 @@ int getDebuggerPortFromEnvironment() } } - File envInFile = new File(baseDir, portEnvInputFile); + File envInFile = new File(baseDir, context.getPackageName() + "-" + portEnvInputFile); boolean envInFileFlag = envInFile.exists(); @@ -585,8 +587,7 @@ public static boolean shouldDebugBreak(Context context) return false; } - String appRoot = context.getFilesDir().getPath() + File.separator; - File debugBreakFile = new File(appRoot, DEBUG_BREAK_FILENAME); + File debugBreakFile = new File(BASE_DEBUG_FILES_DIR, context.getPackageName() + "-" + DEBUG_BREAK_FILENAME); if (debugBreakFile.exists()) { debugBreakFile.delete(); From 074258c6362be2dcc60d503d7d225eb99bab0d9e Mon Sep 17 00:00:00 2001 From: blagoev Date: Tue, 9 Jun 2015 13:40:41 +0300 Subject: [PATCH 3/3] move debug files to internal storage --- src/src/com/tns/JsDebugger.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/src/com/tns/JsDebugger.java b/src/src/com/tns/JsDebugger.java index 327fc4eba..45d8b5b8d 100644 --- a/src/src/com/tns/JsDebugger.java +++ b/src/src/com/tns/JsDebugger.java @@ -46,7 +46,7 @@ public class JsDebugger private static final int INVALID_PORT = -1; - private static final String BASE_DEBUG_FILES_DIR = "/data/local/tmp/"; + private String baseDebugFilesDir; private static final String portEnvInputFile = "envDebug.in"; @@ -66,6 +66,7 @@ private static void enqueueMessage(String message) public JsDebugger(Context context) { this.context = context; + baseDebugFilesDir = context.getFilesDir().getPath() + File.separator; } private static ServerSocket serverSocket; @@ -315,8 +316,12 @@ public void run() int getDebuggerPortFromEnvironment() { - if (Platform.IsLogEnabled) Log.d(Platform.DEFAULT_LOG_TAG, "getDebuggerPortFromEnvironment"); - int port = INVALID_PORT; + if (Platform.IsLogEnabled) + { + Log.d(Platform.DEFAULT_LOG_TAG, "getDebuggerPortFromEnvironment"); + } + + int port = INVALID_PORT; boolean shouldEnableDebuggingFlag = shouldEnableDebugging(context); @@ -327,10 +332,7 @@ int getDebuggerPortFromEnvironment() if (shouldEnableDebuggingFlag) { - //String appRoot = context.getFilesDir().getPath() + File.separator; - File baseDir = new File(BASE_DEBUG_FILES_DIR); - - File envOutFile = new File(baseDir, context.getPackageName() + "-" + portEnvOutputFile); + File envOutFile = new File(baseDebugFilesDir, portEnvOutputFile); OutputStreamWriter w = null; try { @@ -378,7 +380,7 @@ int getDebuggerPortFromEnvironment() } } - File envInFile = new File(baseDir, context.getPackageName() + "-" + portEnvInputFile); + File envInFile = new File(baseDebugFilesDir, portEnvInputFile); boolean envInFileFlag = envInFile.exists(); @@ -574,7 +576,7 @@ public static boolean shouldEnableDebugging(Context context) public static Boolean shouldDebugBreakFlag = null; - public static boolean shouldDebugBreak(Context context) + public boolean shouldDebugBreak(Context context) { if (shouldDebugBreakFlag != null) { @@ -587,7 +589,7 @@ public static boolean shouldDebugBreak(Context context) return false; } - File debugBreakFile = new File(BASE_DEBUG_FILES_DIR, context.getPackageName() + "-" + DEBUG_BREAK_FILENAME); + File debugBreakFile = new File(baseDebugFilesDir, DEBUG_BREAK_FILENAME); if (debugBreakFile.exists()) { debugBreakFile.delete();