mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-20 21:40:15 -07:00
[Bug fix] x86: Unable to locate x86 JRE path correctly
This commit is contained in:
parent
9a95ef36eb
commit
233d82cba4
2 changed files with 41 additions and 37 deletions
|
|
@ -908,8 +908,8 @@ public class BaseMainActivity extends LoggableActivity implements OnTouchListene
|
||||||
appendlnToLog("--------- beggining with launcher debug");
|
appendlnToLog("--------- beggining with launcher debug");
|
||||||
checkLWJGL3Installed();
|
checkLWJGL3Installed();
|
||||||
|
|
||||||
Map<String, String> jreReleaseList = readJREReleaseProperties();
|
Map<String, String> jreReleaseList = JREUtils.readJREReleaseProperties();
|
||||||
checkJavaArchitecture(jreReleaseList.get("OS_ARCH"));
|
JREUtils.checkJavaArchitecture(this, jreReleaseList.get("OS_ARCH"));
|
||||||
checkJavaArgsIsLaunchable(jreReleaseList.get("JAVA_VERSION"));
|
checkJavaArgsIsLaunchable(jreReleaseList.get("JAVA_VERSION"));
|
||||||
// appendlnToLog("Info: Custom Java arguments: \"" + LauncherPreferences.PREF_CUSTOM_JAVA_ARGS + "\"");
|
// appendlnToLog("Info: Custom Java arguments: \"" + LauncherPreferences.PREF_CUSTOM_JAVA_ARGS + "\"");
|
||||||
|
|
||||||
|
|
@ -917,34 +917,6 @@ public class BaseMainActivity extends LoggableActivity implements OnTouchListene
|
||||||
Tools.launchMinecraft(this, mProfile, mVersionInfo);
|
Tools.launchMinecraft(this, mProfile, mVersionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> readJREReleaseProperties() throws IOException {
|
|
||||||
Map<String, String> jreReleaseMap = new ArrayMap<>();
|
|
||||||
BufferedReader jreReleaseReader = new BufferedReader(new FileReader(Tools.homeJreDir + "/release"));
|
|
||||||
String currLine;
|
|
||||||
while ((currLine = jreReleaseReader.readLine()) != null) {
|
|
||||||
if (!currLine.isEmpty() || currLine.contains("=")) {
|
|
||||||
String[] keyValue = currLine.split("=");
|
|
||||||
jreReleaseMap.put(keyValue[0], keyValue[1].replace("\"", ""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jreReleaseReader.close();
|
|
||||||
return jreReleaseMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkJavaArchitecture(String jreArch) throws Exception {
|
|
||||||
String[] argName = Tools.currentArch.split("/");
|
|
||||||
appendlnToLog("Architecture: " + Tools.currentArch);
|
|
||||||
if (!(jreArch.contains(argName[0]) || jreArch.contains(argName[1]))) {
|
|
||||||
// x86 check workaround
|
|
||||||
if (jreArch.startsWith("i") && jreArch.endsWith("86") && Tools.currentArch.contains("x86") && !Tools.currentArch.contains("64")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
appendlnToLog("Architecture " + Tools.currentArch + " is incompatible with Java Runtime " + jreArch);
|
|
||||||
throw new RuntimeException(getString(R.string.mcn_check_fail_incompatiblearch, Tools.currentArch, jreArch));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkJavaArgsIsLaunchable(String jreVersion) throws Throwable {
|
private void checkJavaArgsIsLaunchable(String jreVersion) throws Throwable {
|
||||||
appendlnToLog("Info: Custom Java arguments: \"" + LauncherPreferences.PREF_CUSTOM_JAVA_ARGS + "\"");
|
appendlnToLog("Info: Custom Java arguments: \"" + LauncherPreferences.PREF_CUSTOM_JAVA_ARGS + "\"");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,24 @@ public class JREUtils
|
||||||
{
|
{
|
||||||
private JREUtils() {}
|
private JREUtils() {}
|
||||||
|
|
||||||
|
public static String JRE_ARCHITECTURE;
|
||||||
|
|
||||||
public static String LD_LIBRARY_PATH;
|
public static String LD_LIBRARY_PATH;
|
||||||
private static String nativeLibDir;
|
private static String nativeLibDir;
|
||||||
|
|
||||||
|
public static void checkJavaArchitecture(LoggableActivity act, String jreArch) throws Exception {
|
||||||
|
String[] argName = Tools.currentArch.split("/");
|
||||||
|
act.appendlnToLog("Architecture: " + Tools.currentArch);
|
||||||
|
if (!(jreArch.contains(argName[0]) || jreArch.contains(argName[1]))) {
|
||||||
|
// x86 check workaround
|
||||||
|
if (jreArch.startsWith("i") && jreArch.endsWith("86") && Tools.currentArch.contains("x86") && !Tools.currentArch.contains("64")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
act.appendlnToLog("Architecture " + Tools.currentArch + " is incompatible with Java Runtime " + jreArch);
|
||||||
|
throw new RuntimeException(act.getString(R.string.mcn_check_fail_incompatiblearch, Tools.currentArch, jreArch));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String findInLdLibPath(String libName) {
|
public static String findInLdLibPath(String libName) {
|
||||||
for (String libPath : Os.getenv("LD_LIBRARY_PATH").split(":")) {
|
for (String libPath : Os.getenv("LD_LIBRARY_PATH").split(":")) {
|
||||||
|
|
@ -48,6 +64,20 @@ public class JREUtils
|
||||||
dlopen(nativeLibDir + "/libgl04es.so");
|
dlopen(nativeLibDir + "/libgl04es.so");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> readJREReleaseProperties() throws IOException {
|
||||||
|
Map<String, String> jreReleaseMap = new ArrayMap<>();
|
||||||
|
BufferedReader jreReleaseReader = new BufferedReader(new FileReader(Tools.homeJreDir + "/release"));
|
||||||
|
String currLine;
|
||||||
|
while ((currLine = jreReleaseReader.readLine()) != null) {
|
||||||
|
if (!currLine.isEmpty() || currLine.contains("=")) {
|
||||||
|
String[] keyValue = currLine.split("=");
|
||||||
|
jreReleaseMap.put(keyValue[0], keyValue[1].replace("\"", ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jreReleaseReader.close();
|
||||||
|
return jreReleaseMap;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean checkAccessTokenLeak = true;
|
private static boolean checkAccessTokenLeak = true;
|
||||||
public static void redirectAndPrintJRELog(final LoggableActivity act, final String accessToken) {
|
public static void redirectAndPrintJRELog(final LoggableActivity act, final String accessToken) {
|
||||||
|
|
@ -118,15 +148,17 @@ public class JREUtils
|
||||||
Log.i("jrelog-logcat","Logcat thread started");
|
Log.i("jrelog-logcat","Logcat thread started");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void relocateLibPath(Context ctx) {
|
public static void relocateLibPath(Context ctx) throws Exception {
|
||||||
|
if (JRE_ARCHITECTURE == null) {
|
||||||
|
Map<String, String> jreReleaseList = JREUtils.readJREReleaseProperties();
|
||||||
|
JRE_ARCHITECTURE = jreReleaseList.get("OS_ARCH");
|
||||||
|
}
|
||||||
|
|
||||||
nativeLibDir = ctx.getApplicationInfo().nativeLibraryDir;
|
nativeLibDir = ctx.getApplicationInfo().nativeLibraryDir;
|
||||||
|
|
||||||
for (String arch : Tools.currentArch.split("/")) {
|
File f = new File(Tools.homeJreDir, "lib/" + JRE_ARCHITECTURE);
|
||||||
File f = new File(Tools.homeJreDir, "lib/" + arch);
|
if (f.exists() && f.isDirectory()) {
|
||||||
if (f.exists() && f.isDirectory()) {
|
Tools.homeJreLib = "lib/" + JRE_ARCHITECTURE;
|
||||||
Tools.homeJreLib = "lib/" + arch;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String libName = Tools.currentArch.contains("64") ? "lib64" : "lib";
|
String libName = Tools.currentArch.contains("64") ? "lib64" : "lib";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue