Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions src/src/com/tns/JsDebugger.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class JsDebugger

private static final int INVALID_PORT = -1;

private String baseDebugFilesDir;

private static final String portEnvInputFile = "envDebug.in";

private static final String portEnvOutputFile = "envDebug.out";
Expand All @@ -64,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;
Expand Down Expand Up @@ -313,17 +316,23 @@ 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);

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);
File envOutFile = new File(baseDir, portEnvOutputFile);
File envOutFile = new File(baseDebugFilesDir, portEnvOutputFile);
OutputStreamWriter w = null;
try
{
Expand Down Expand Up @@ -353,7 +362,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)
{
Expand All @@ -368,11 +380,14 @@ int getDebuggerPortFromEnvironment()
}
}

File envInFile = new File(baseDir, portEnvInputFile);
File envInFile = new File(baseDebugFilesDir, portEnvInputFile);

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)
{
Expand Down Expand Up @@ -436,7 +451,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;
}
Expand Down Expand Up @@ -558,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)
{
Expand All @@ -571,8 +589,7 @@ public static boolean shouldDebugBreak(Context context)
return false;
}

File baseDir = context.getExternalFilesDir(null);
File debugBreakFile = new File(baseDir, DEBUG_BREAK_FILENAME);
File debugBreakFile = new File(baseDebugFilesDir, DEBUG_BREAK_FILENAME);
if (debugBreakFile.exists())
{
debugBreakFile.delete();
Expand Down