1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

AndroidGCS: Delete any existing jars before loading to make sure behavior is consistent

This commit is contained in:
James Cotton 2012-10-14 19:39:49 -05:00
parent 7eac1e2245
commit d975a65f65

View File

@ -294,6 +294,7 @@ public class OPTelemetryService extends Service {
numRead = inputStream.read(buffer);
}
}
private void copyAssets(String JAR_DIR, String JAR_NAME)
{
File jarsDir = getDir(JAR_DIR, MODE_WORLD_READABLE);
@ -364,6 +365,10 @@ public class OPTelemetryService extends Service {
final String JAR_DIR = "jars";
final String DEX_DIR = "optimized_dex";
File jarsDir = getDir(JAR_DIR, MODE_WORLD_READABLE);
if (jarsDir.exists())
deleteDirectoryContents(jarsDir);
copyAssets(JAR_DIR, jar);
Log.d(TAG, "Starting dex loader");
@ -373,7 +378,6 @@ public class OPTelemetryService extends Service {
if (dexDir.exists())
deleteDirectoryContents(dexDir);
File jarsDir = getDir(JAR_DIR, MODE_WORLD_READABLE);
String classpath = new File(jarsDir, jar).getAbsolutePath();
DexClassLoader loader = new DexClassLoader(classpath, dexDir.getAbsolutePath(), null, getClassLoader());