mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 14:51:51 -04:00
Changes
This commit is contained in:
parent
96686fb8e4
commit
965b9ff10e
@ -3,7 +3,22 @@ package net.kdt.pojavlaunch;
|
||||
// This class load and execute PIE binary using dlopen and dlsym("main")
|
||||
public class BinaryExecutor
|
||||
{
|
||||
public static native int executeBinary(String ldLibraryPath, String[] args);
|
||||
public static void initJavaRuntime() {
|
||||
dlopen(Tools.homeJreDir + "/lib/jli/libjli.so");
|
||||
dlopen(Tools.homeJreDir + "/lib/server/libjvm.so");
|
||||
dlopen(Tools.homeJreDir + "/lib/libverify.so");
|
||||
dlopen(Tools.homeJreDir + "/lib/libjava.so");
|
||||
dlopen(Tools.homeJreDir + "/lib/libnet.so");
|
||||
dlopen(Tools.homeJreDir + "/lib/libnio.so");
|
||||
dlopen(Tools.homeJreDir + "/lib/libawt.so");
|
||||
dlopen(Tools.homeJreDir + "/lib/libawt_headless.so");
|
||||
|
||||
chdir(Tools.MAIN_PATH);
|
||||
}
|
||||
|
||||
public static native int chdir(String path);
|
||||
public static native boolean dlopen(String libPath);
|
||||
public static native int executeBinary(String[] args);
|
||||
|
||||
static {
|
||||
System.loadLibrary("binexecutor");
|
||||
|
@ -203,7 +203,6 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
|
||||
setTitle("Minecraft " + mProfile.getVersion());
|
||||
|
||||
initEnvs();
|
||||
//System.loadLibrary("gl4es");
|
||||
/*
|
||||
if (mVersionInfo.arguments != null) {
|
||||
@ -882,21 +881,6 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
}
|
||||
}
|
||||
|
||||
public void initEnvs() {
|
||||
try {
|
||||
// Os.setenv("LIBGL_MIPMAP", "3", true);
|
||||
|
||||
System.out.println("ldlib before = " + System.getenv("LD_LIBRARY_PATH"));
|
||||
|
||||
Os.setenv("JAVA_HOME", Tools.homeJreDir, true);
|
||||
Os.setenv("LIBGL_MIPMAP", "3", true);
|
||||
|
||||
System.out.println("ldlib after = " + System.getenv("LD_LIBRARY_PATH"));
|
||||
} catch (Exception e) {
|
||||
Tools.showError(MainActivity.this, e, true);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPointerCaptureSupported() {
|
||||
return Build.VERSION.SDK_INT >= 26;
|
||||
}
|
||||
@ -999,10 +983,27 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
Os.dup2(fd, OsConstants.STDOUT_FILENO);
|
||||
}
|
||||
|
||||
public void initEnvs() {
|
||||
try {
|
||||
// Os.setenv("LIBGL_MIPMAP", "3", true);
|
||||
|
||||
System.out.println("ldlib before = " + System.getenv("LD_LIBRARY_PATH"));
|
||||
|
||||
Os.setenv("HOME", Tools.MAIN_PATH, true);
|
||||
Os.setenv("JAVA_HOME", Tools.homeJreDir, true);
|
||||
Os.setenv("LIBGL_MIPMAP", "3", true);
|
||||
|
||||
System.out.println("ldlib after = " + System.getenv("LD_LIBRARY_PATH"));
|
||||
} catch (Exception e) {
|
||||
Tools.showError(MainActivity.this, e, true);
|
||||
}
|
||||
}
|
||||
|
||||
public static String launchClassPath;
|
||||
public static String launchLibrarySearchPath;
|
||||
private void runCraft() throws Throwable
|
||||
{
|
||||
private void runCraft() throws Throwable {
|
||||
initEnvs();
|
||||
|
||||
String[] launchArgs = getMCArgs();
|
||||
|
||||
// Setup OptiFine
|
||||
@ -1023,12 +1024,25 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
System.out.println();
|
||||
|
||||
redirectStdio();
|
||||
BinaryExecutor.initJavaRuntime();
|
||||
|
||||
BinaryExecutor.dlopen(Tools.homeJreDir + "/bin/java");
|
||||
|
||||
List<String> javaArgList = new ArrayList<String>();
|
||||
javaArgList.add(Tools.homeJreDir + "/bin/java");
|
||||
// javaArgList.add("-Xms512m");
|
||||
javaArgList.add("-Xmx512m");
|
||||
|
||||
String libPath = "lib" + (Build.CPU_ABI.contains("64") ? "64" : "");
|
||||
javaArgList.add("-Djava.library.path=" +
|
||||
"/system/" + libPath + ":" +
|
||||
"/vendor/" + libPath + ":" +
|
||||
"/vendor/" + libPath + "/hw:" +
|
||||
// TODO lwjgl2 vs lwjgl3 native path
|
||||
getApplicationInfo().nativeLibraryDir
|
||||
);
|
||||
|
||||
javaArgList.add("-Djava.home=" + Tools.homeJreDir);
|
||||
javaArgList.add("-Duser.home=" + Tools.MAIN_PATH);
|
||||
|
||||
// javaArgList.add("-Dorg.lwjgl.system.jemalloc.libname=libjemalloc.so");
|
||||
@ -1044,22 +1058,21 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
javaArgList.add(mVersionInfo.mainClass);
|
||||
javaArgList.addAll(Arrays.asList(launchArgs));
|
||||
|
||||
try {
|
||||
String libPath = "lib" + (Build.CPU_ABI.contains("64") ? "64" : "");
|
||||
BinaryExecutor.executeBinary(
|
||||
"/system/" + libPath + ":" +
|
||||
"/vendor/" + libPath + ":" +
|
||||
"/vendor/" + libPath + "/hw:" +
|
||||
getApplicationInfo().nativeLibraryDir + ":" +
|
||||
Tools.homeJreDir + "/lib:" +
|
||||
Tools.homeJreDir + "/lib/jli:" +
|
||||
Tools.homeJreDir + "/lib/server",
|
||||
/*
|
||||
ShellProcessOperation sp = new ShellProcessOperation(new ShellProcessOperation.OnPrintListener(){
|
||||
|
||||
javaArgList.toArray(new String[0])
|
||||
);
|
||||
} catch (Throwable th) {
|
||||
Tools.showError(this, th, true);
|
||||
@Override
|
||||
public void onPrintLine(String text) {
|
||||
appendlnToLog(text, false);
|
||||
}
|
||||
});
|
||||
sp.initInputStream(this);
|
||||
sp.writeToProcess("export LD_LIBRARY_PATH=" + Tools.homeJreDir + "/lib/jli:" + Tools.homeJreDir + "/lib/server:" + Tools.homeJreDir + "/lib");
|
||||
sp.writeToProcess(javaArgList.toArray(new String[0]));
|
||||
*/
|
||||
|
||||
BinaryExecutor.executeBinary(javaArgList.toArray(new String[0]));
|
||||
|
||||
/*
|
||||
"-Dorg.apache.logging.log4j.level=INFO",
|
||||
"-Dorg.apache.logging.log4j.simplelog.level=INFO",
|
||||
|
@ -20,6 +20,12 @@ public class ShellProcessOperation
|
||||
); //"/system/bin/sh -c \"" + command + "\"");
|
||||
}
|
||||
|
||||
public void writeToProcess(String[] cmdArr) throws IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String cmd : cmdArr) {sb.append(cmd + " ");}
|
||||
writeToProcess(sb.toString());
|
||||
}
|
||||
|
||||
public void writeToProcess(String cmd) throws IOException {
|
||||
DataOutputStream os = new DataOutputStream(process.getOutputStream());
|
||||
os.writeBytes(cmd + "\n");
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user