From d975a65f6520aae19299b011cd47289d845f7648 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sun, 14 Oct 2012 19:39:49 -0500 Subject: [PATCH] AndroidGCS: Delete any existing jars before loading to make sure behavior is consistent --- .../openpilot/androidgcs/telemetry/OPTelemetryService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/androidgcs/src/org/openpilot/androidgcs/telemetry/OPTelemetryService.java b/androidgcs/src/org/openpilot/androidgcs/telemetry/OPTelemetryService.java index e3f594a44..c03510a83 100644 --- a/androidgcs/src/org/openpilot/androidgcs/telemetry/OPTelemetryService.java +++ b/androidgcs/src/org/openpilot/androidgcs/telemetry/OPTelemetryService.java @@ -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());