Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[WEEX-566][Android] add jsb version file to make jsb.so can update
Browse files Browse the repository at this point in the history
add jsb version file to make jsb.so can update

Bug: WEEX-566

    [WEEX-566][Android] add jsb version file to make jsb.so can update

    add jsb version file to make jsb.so can update

    Bug: WEEX-566
  • Loading branch information
yayun.dyy committed Aug 16, 2018
1 parent c99066b commit b0845f9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
4 changes: 4 additions & 0 deletions android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public class WXEnvironment {

public static final String CORE_SO_NAME = "weexcore";
public static final String CORE_JSS_SO_NAME = "weexjss";
/**
* this marked jsb.so's version, Change this if we want to update jsb.so
*/
public static final int CORE_JSB_SO_VERSION = 1;

private static String CORE_JSS_SO_PATH = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@
import com.taobao.weex.adapter.IWXUserTrackAdapter;
import com.taobao.weex.common.WXErrorCode;

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -213,8 +218,29 @@ public static void copyStartUpSo() {
} else {
newfile = new File(cacheFile + STARTUPSO);
}
if (newfile.exists()) {
return;

String jsbVersionFile = "jsb.version";

File versionFile = new File(cacheFile,jsbVersionFile);
Closeable r = null;

if(newfile.exists() && versionFile.exists()) {
try {
FileReader fileReader = new FileReader(versionFile);
r = fileReader;
BufferedReader br = new BufferedReader(fileReader);
String s = br.readLine();
if(!TextUtils.isEmpty(s)) {
boolean same = String.valueOf(WXEnvironment.CORE_JSB_SO_VERSION).equals(s.trim());
if(same)
return;
}
} catch (FileNotFoundException e) {
//do nothing and copy so file
} finally {
if (r != null)
r.close();
}
}

String path = "/data/data/" + pkgName + "/lib";
Expand Down Expand Up @@ -242,6 +268,22 @@ public static void copyStartUpSo() {
} else {
WXEnvironment.extractSo();
}

Closeable w = null;
try {
if(!versionFile.exists())
versionFile.createNewFile();
FileWriter fileWriter = new FileWriter(versionFile);
w = fileWriter;
fileWriter.write(String.valueOf(WXEnvironment.CORE_JSB_SO_VERSION));
fileWriter.flush();
} catch (Exception e ) {
// do nothing
} finally {
if(w != null)
w.close();
}

}
} catch (Throwable e) {
e.printStackTrace();
Expand Down

0 comments on commit b0845f9

Please sign in to comment.