diff --git a/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java b/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java index 9f53b6bad4..037f3347d1 100644 --- a/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java +++ b/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java @@ -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; diff --git a/android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java b/android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java index 09c50773fc..02efe7b6b7 100644 --- a/android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java +++ b/android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java @@ -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; @@ -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"; @@ -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();