YorkShen closed pull request #1437: [WEEX-566][Android] add jsb version file to 
make jsb.so can update
URL: https://github.com/apache/incubator-weex/pull/1437
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 b98c17daa6..3d4be0139e 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 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();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to