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

* [android] fix on android 4.0.* platform cannot startup multiprocess #803

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified android/sdk/libs/armeabi/libweexjsb.so
Binary file not shown.
Binary file modified android/sdk/libs/armeabi/libweexjsc.so
Binary file not shown.
Binary file modified android/sdk/libs/armeabi/libweexjss.so
Binary file not shown.
Binary file added android/sdk/libs/armeabi/libweexjst.so
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class WXBridge implements IWXBridge {
*
* @param framework assets/main.js
*/
public native int initFramework(String framework, WXParams params, String cacheDir, boolean onSdcard);
public native int initFramework(String framework, WXParams params, String cacheDir, boolean pieSupport);


/**
Expand Down Expand Up @@ -78,9 +78,9 @@ class WXBridge implements IWXBridge {
public native void takeHeapSnapshot(String filename);


public int initFrameworkEnv(String framework, WXParams params, String cacheDir, boolean onSdcard){
public int initFrameworkEnv(String framework, WXParams params, String cacheDir, boolean pieSupport){
if (MULTIPROCESS) {
return initFramework(framework, params, cacheDir, onSdcard);
return initFramework(framework, params, cacheDir, pieSupport);
} else {
return initFramework(framework, params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Looper;
Expand Down Expand Up @@ -1571,27 +1572,22 @@ private void initFramework(String framework) {

long start = System.currentTimeMillis();
String crashFile = "";
boolean installOnSdcard = false;
try {
crashFile = WXEnvironment.getApplication().getApplicationContext().getCacheDir().getPath();
} catch (Exception e) {
e.printStackTrace();
}

boolean pieSupport = true;
try {
PackageManager pm = WXEnvironment.getApplication().getApplicationContext().getPackageManager();
String pkgName = WXEnvironment.getApplication().getPackageName();
ApplicationInfo appInfo = pm.getApplicationInfo(pkgName, 0);
if ((appInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
// App on sdcard
installOnSdcard = true;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
pieSupport = false;
}
} catch (Exception e) {
e.printStackTrace();
}

WXLogUtils.d("[WXBridgeManager] initFrameworkEnv crashFile:" + crashFile + " pieSupport:" + pieSupport);
// extends initFramework
if (mWXBridge.initFrameworkEnv(framework, assembleDefaultOptions(), crashFile, installOnSdcard) == INIT_FRAMEWORK_OK) {
if (mWXBridge.initFrameworkEnv(framework, assembleDefaultOptions(), crashFile, pieSupport) == INIT_FRAMEWORK_OK) {
WXEnvironment.sJSLibInitTime = System.currentTimeMillis() - start;
WXLogUtils.renderPerformanceLog("initFramework", WXEnvironment.sJSLibInitTime);
WXEnvironment.sSDKInitTime = System.currentTimeMillis() - WXEnvironment.sSDKInitStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public interface IWXBridge extends IWXObject {
* @param framework assets/main.js
* @return
*/
int initFrameworkEnv(String framework, WXParams params, String cacheDir, boolean onSdcard);
int initFrameworkEnv(String framework, WXParams params, String cacheDir, boolean pieSupport);

/**
* execute javascript function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class WXSoInstallMgrSdk {
private final static String X86 = "x86";
private final static String MIPS = "mips";
private final static String STARTUPSO = "/libweexjsb.so";
private final static String STARTUPSOANDROID15 = "/libweexjst.so";

private final static int ARMEABI_Size = 3583820;
private final static int X86_Size = 4340864;
Expand Down Expand Up @@ -192,20 +193,35 @@ public static void copyStartUpSo() {
// }
// } catch (Throwable e) {
// }

if (installOnSdcard) {

String cacheFile = WXEnvironment.getApplication().getApplicationContext().getCacheDir().getPath();
File newfile = new File(cacheFile + STARTUPSO);
// if android api < 16 copy libweexjst.so else copy libweexjsb.so
boolean pieSupport = true;
File newfile;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
pieSupport = false;
newfile = new File(cacheFile + STARTUPSOANDROID15);
} else {
newfile = new File(cacheFile + STARTUPSO);
}
if (newfile.exists()) {
return;
}

String path = "/data/data/" + pkgName + "/lib";;
String path = "/data/data/" + pkgName + "/lib";
if (cacheFile != null && cacheFile.indexOf("/cache") > 0) {
path = cacheFile.replace("/cache", "/lib");
}

String soName = path + STARTUPSO;
String soName;
if (pieSupport) {
soName = path + STARTUPSO;
} else {
soName = path + STARTUPSOANDROID15;
}

File oldfile = new File(soName);
if (oldfile.exists()) {
//获得原文件流
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public int initFramework(String scriptsFramework,WXParams params) {
}

@Override
public int initFrameworkEnv(String scriptsFramework,WXParams params, String cacheDir, boolean onSdcard) {
public int initFrameworkEnv(String scriptsFramework,WXParams params, String cacheDir, boolean pieSupport) {
if (!mInit) {
return -1;
}
Expand Down