Browse Source

Android: Update engine version code

pull/6/head
Hussein Kasem 4 years ago
parent
commit
4c1b935803
No known key found for this signature in database GPG Key ID: 9E61B9BC790E6B02
  1. 23
      android/src/foundation/pEp/jniadapter/AndroidHelper.java

23
android/src/foundation/pEp/jniadapter/AndroidHelper.java

@ -30,7 +30,8 @@ public class AndroidHelper {
private static File tmpDir; private static File tmpDir;
// TODO : Increment when needed. // TODO : Increment when needed.
public static int ENGINE_VERSION_CODE = 5115; // TODO : Check if this version tracking is really needed and Automatize it
public static String ENGINE_VERSION_CODE = "Release_2.1.27";
private static File shareDir; private static File shareDir;
@ -45,7 +46,7 @@ public class AndroidHelper {
// Add GnuPG's bin to PATH // Add GnuPG's bin to PATH
binDir = new File(optDir, "bin"); binDir = new File(optDir, "bin");
setenv("PATH", System.getenv("PATH") + ":" + setenv("PATH", System.getenv("PATH") + ":" +
binDir.getAbsolutePath(), true); binDir.getAbsolutePath(), true);
tmpDir = new File(c.getCacheDir(), "tmp"); tmpDir = new File(c.getCacheDir(), "tmp");
@ -62,11 +63,11 @@ public class AndroidHelper {
} }
libDir = new File(optDir, "lib"); libDir = new File(optDir, "lib");
setenv("LD_LIBRARY_PATH", appLibDir + ":" + setenv("LD_LIBRARY_PATH", appLibDir + ":" +
libDir.getAbsolutePath() + ":" + libDir.getAbsolutePath() + ":" +
System.getenv("LD_LIBRARY_PATH"), true); System.getenv("LD_LIBRARY_PATH"), true);
// Set HOME environment variable pointing to // Set HOME environment variable pointing to
// something like "/data/data/app.package.name/home" // something like "/data/data/app.package.name/home"
// pEpEngine use it to find management DB and gpg home // pEpEngine use it to find management DB and gpg home
homeDir = c.getDir("home", Context.MODE_PRIVATE); homeDir = c.getDir("home", Context.MODE_PRIVATE);
@ -206,8 +207,8 @@ public class AndroidHelper {
try { try {
InputStream inputStream = assetManager.open(assetPath); InputStream inputStream = assetManager.open(assetPath);
String targetFileName = String targetFileName =
new File(targetDir, new File(targetDir,
new File(assetPath).getName()).getAbsolutePath(); new File(assetPath).getName()).getAbsolutePath();
OutputStream outputStream = new FileOutputStream(targetFileName); OutputStream outputStream = new FileOutputStream(targetFileName);
IOUtils.copy(inputStream, outputStream); IOUtils.copy(inputStream, outputStream);
@ -219,12 +220,12 @@ public class AndroidHelper {
} }
} }
private static int getInstalledVersion() { private static String getInstalledVersion() {
int versionCode = -1; String versionCode = "";
if (versionFile.exists()){ if (versionFile.exists()){
try { try {
Scanner scan = new Scanner(versionFile); Scanner scan = new Scanner(versionFile);
versionCode = Integer.parseInt(scan.next()); versionCode = scan.next();
scan.close(); scan.close();
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, "getInstalledVersion: " + e.getMessage()); Log.e(TAG, "getInstalledVersion: " + e.getMessage());
@ -237,7 +238,7 @@ public class AndroidHelper {
try { try {
FileOutputStream fileOutputStream = new FileOutputStream(versionFile); FileOutputStream fileOutputStream = new FileOutputStream(versionFile);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream);
outputStreamWriter.write(String.valueOf(ENGINE_VERSION_CODE) + "\n"); outputStreamWriter.write(ENGINE_VERSION_CODE + "\n");
outputStreamWriter.close(); outputStreamWriter.close();
fileOutputStream.close(); fileOutputStream.close();
} catch (Exception e) { } catch (Exception e) {
@ -246,7 +247,7 @@ public class AndroidHelper {
} }
public static boolean needNewAssets() { public static boolean needNewAssets() {
return ENGINE_VERSION_CODE != getInstalledVersion(); return !getInstalledVersion().equals(ENGINE_VERSION_CODE);
} }
// TODO: replace with native impl, less prone to failure. // TODO: replace with native impl, less prone to failure.

Loading…
Cancel
Save