YorkShen commented on a change in pull request #2712: Update for libweexjsb path
URL: https://github.com/apache/incubator-weex/pull/2712#discussion_r303874244
 
 

 ##########
 File path: 
android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java
 ##########
 @@ -208,110 +211,83 @@ public static boolean initSo(String libName, int 
version, IWXUserTrackAdapter ut
     return InitSuc;
   }
 
+  private static File _desSoCopyFile(String soName) {
+    String cpuType = _cpuType();
+    String copyPath = WXEnvironment.copySoDesDir();
+    if (TextUtils.isEmpty(copyPath)) {
+      return null;
+    }
+    File desDir = new File(copyPath, soName + "/" + cpuType);
+    return desDir;
+  }
+
   /**
    * copyStartUpSo
    */
   public static void copyStartUpSo() {
     try {
-      boolean installOnSdcard = true;
-      String pkgName = WXEnvironment.getApplication().getPackageName();
-      // cp weexjsb any way
-//      try {
-//        PackageManager pm = 
WXEnvironment.getApplication().getApplicationContext().getPackageManager();
-//        ApplicationInfo appInfo = pm.getApplicationInfo(pkgName, 0);
-//        if ((appInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
-//          // App on sdcard
-//          installOnSdcard = true;
-//        }
-//      } catch (Throwable e) {
-//      }
+      // copy libjsb.so to cache/weex/jsb/cputype
 
-      if (installOnSdcard) {
-
-        String cacheFile = 
WXEnvironment.getApplication().getApplicationContext().getCacheDir().getPath();
-        // if android api < 16 copy libweexjst.so else copy libweexjsb.so
-        boolean pieSupport = true;
-        File newfile;
-        String startSoName = WXEnvironment.CORE_JSB_SO_NAME;
-        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
-          pieSupport = false;
-          newfile = new File(cacheFile + STARTUPSOANDROID15);
-          startSoName = WXEnvironment.CORE_JST_SO_NAME;
-        } else {
-          newfile = new File(cacheFile + STARTUPSO);
-        }
-
-        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";
-        if (cacheFile != null && cacheFile.indexOf("/cache") > 0) {
-          path = cacheFile.replace("/cache", "/lib");
-        }
-
-        String soName;
-        if (pieSupport) {
-          soName = path + STARTUPSO;
-        } else {
-          soName = path + STARTUPSOANDROID15;
-        }
+      String pkgName = WXEnvironment.getApplication().getPackageName();
+      String cacheFile = 
WXEnvironment.getApplication().getApplicationContext().getCacheDir().getPath();
 
-        File oldfile = new File(soName);
+      // cp weexjsb any way
+      // if android api < 16 copy libweexjst.so else copy libweexjsb.so
+      boolean pieSupport = true;
+      File newfile;
+      String startSoName = WXEnvironment.CORE_JSB_SO_NAME;
+      String startSoPath = STARTUPSO;
+      if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
+        pieSupport = false;
+        startSoName = WXEnvironment.CORE_JST_SO_NAME;
+        startSoPath = STARTUPSOANDROID15;
+      }
 
+      final File copyPath = _desSoCopyFile(startSoName);
+      if(!copyPath.exists()) {
+        copyPath.mkdirs();
+      }
+      newfile = new File(copyPath + startSoPath);
 
 Review comment:
   Use `new File(copyPath, startSoPath)` instead

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


With regards,
Apache Git Services

Reply via email to