Change lib

This commit is contained in:
khanhduytran0 2020-08-31 11:52:54 +07:00
parent e6ea54740d
commit bf49d40eb7
6 changed files with 35 additions and 71 deletions

View file

@ -3,7 +3,7 @@ package net.kdt.pojavlaunch;
import android.system.*; import android.system.*;
import java.io.*; import java.io.*;
// This clads should be named as 'LoadMe' as original // This class should be named as 'LoadMe' as original
public class BinaryExecutor public class BinaryExecutor
{ {
private BinaryExecutor() {} private BinaryExecutor() {}
@ -18,15 +18,15 @@ public class BinaryExecutor
dlopen(Tools.homeJreDir + "/lib/libawt.so"); dlopen(Tools.homeJreDir + "/lib/libawt.so");
dlopen(Tools.homeJreDir + "/lib/libawt_headless.so"); dlopen(Tools.homeJreDir + "/lib/libawt_headless.so");
} }
public static FileDescriptor redirectStdio() throws ErrnoException { public static void redirectStdio() throws ErrnoException {
File logFile = new File(Tools.MAIN_PATH, "v3log.txt"); File logFile = new File(Tools.MAIN_PATH, "latestlog.txt");
FileDescriptor fd = Os.open(logFile.getAbsolutePath(), OsConstants.O_WRONLY | OsConstants.O_CREAT | OsConstants.O_TRUNC, 0666); FileDescriptor fd = Os.open(logFile.getAbsolutePath(), OsConstants.O_WRONLY | OsConstants.O_CREAT | OsConstants.O_TRUNC, 0666);
Os.dup2(fd, OsConstants.STDERR_FILENO); Os.dup2(fd, OsConstants.STDERR_FILENO);
Os.dup2(fd, OsConstants.STDOUT_FILENO); Os.dup2(fd, OsConstants.STDOUT_FILENO);
return fd; // return fd;
} }
public static native int chdir(String path); public static native int chdir(String path);

View file

@ -110,6 +110,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
private Button[] controlButtons; private Button[] controlButtons;
private File logFile;
private PrintStream logStream; private PrintStream logStream;
/* /*
@ -155,7 +156,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
setContentView(R.layout.main); setContentView(R.layout.main);
try { try {
File logFile = new File(Tools.MAIN_PATH, "latestlog.txt"); logFile = new File(Tools.MAIN_PATH, "latestlog.txt");
logFile.delete(); logFile.delete();
logFile.createNewFile(); logFile.createNewFile();
logStream = new PrintStream(logFile.getAbsolutePath()); logStream = new PrintStream(logFile.getAbsolutePath());
@ -175,52 +176,6 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
} }
}); });
ExitManager.setExitTrappedListener(new ExitManager.ExitTrappedListener(){
@Override
public void onExitTrapped()
{
logStream.close();
runOnUiThread(new Runnable(){
@Override
public void run() {
isExited = true;
AlertDialog.Builder d = new AlertDialog.Builder(MainActivity.this);
d.setTitle(R.string.mcn_exit_title);
try {
File crashLog = Tools.lastFileModified(Tools.crashPath);
if(crashLog != null && Tools.read(crashLog.getAbsolutePath()).startsWith("---- Minecraft Crash Report ----")){
d.setMessage(R.string.mcn_exit_crash);
} else {
fullyExit();
return;
}
} catch (Throwable th) {
d.setMessage(getStr(R.string.mcn_exit_errcrash) + "\n" + Log.getStackTraceString(th));
}
d.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2)
{
fullyExit();
}
});
d.setCancelable(false);
d.show();
}
});
}
});
try {
ExitManager.disableSystemExit();
} catch (Throwable th) {
Log.w(Tools.APP_NAME, "Could not disable System.exit() method!", th);
}
mProfile = PojavProfile.getCurrentProfileContent(this); mProfile = PojavProfile.getCurrentProfileContent(this);
mVersionInfo = Tools.getVersionInfo(mProfile.getVersion()); mVersionInfo = Tools.getVersionInfo(mProfile.getVersion());
@ -334,18 +289,14 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
ControlButton[] specialButtons = ControlButton.getSpecialButtons(); ControlButton[] specialButtons = ControlButton.getSpecialButtons();
specialButtons[0].specialButtonListener = new View.OnClickListener(){ specialButtons[0].specialButtonListener = new View.OnClickListener(){
@Override @Override
public void onClick(View p1) public void onClick(View view) {
{
showKeyboard(); showKeyboard();
} }
}; };
specialButtons[1].specialButtonListener = new View.OnClickListener(){ specialButtons[1].specialButtonListener = new View.OnClickListener(){
@Override @Override
public void onClick(View view) public void onClick(View view) {
{
MainActivity.this.onClick(toggleControlButton); MainActivity.this.onClick(toggleControlButton);
} }
}; };
@ -884,11 +835,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
} }
public static void fullyExit() { public static void fullyExit() {
if (!ExitManager.isExiting()) { System.exit(0);
ExitManager.enableSystemExit();
System.exit(0);
}
ExitManager.stopExitLoop();
} }
public void forceUserHome(String s) throws Exception { public void forceUserHome(String s) throws Exception {
@ -1029,16 +976,11 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
// javaArgList.add("-Xms512m"); // javaArgList.add("-Xms512m");
javaArgList.add("-Xmx512m"); javaArgList.add("-Xmx512m");
/*
javaArgList.add("-Djava.library.path=" +
// TODO lwjgl2 vs lwjgl3 native path
getApplicationInfo().nativeLibraryDir
);
*/
javaArgList.add("-Djava.home=" + Tools.homeJreDir); javaArgList.add("-Djava.home=" + Tools.homeJreDir);
javaArgList.add("-Dos.name=Linux"); javaArgList.add("-Dos.name=Linux");
// javaArgList.add("-Dorg.lwjgl.libname=liblwjgl3.so");
// javaArgList.add("-Dorg.lwjgl.system.jemalloc.libname=libjemalloc.so"); // javaArgList.add("-Dorg.lwjgl.system.jemalloc.libname=libjemalloc.so");
javaArgList.add("-Dorg.lwjgl.opengl.libname=libgl04es.so"); javaArgList.add("-Dorg.lwjgl.opengl.libname=libgl04es.so");
// javaArgList.add("-Dorg.lwjgl.opengl.libname=libRegal.so"); // javaArgList.add("-Dorg.lwjgl.opengl.libname=libRegal.so");
@ -1052,6 +994,8 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
javaArgList.add("-Dglfwstub.windowWidth=" + AndroidDisplay.windowWidth); javaArgList.add("-Dglfwstub.windowWidth=" + AndroidDisplay.windowWidth);
javaArgList.add("-Dglfwstub.windowHeight=" + AndroidDisplay.windowHeight); javaArgList.add("-Dglfwstub.windowHeight=" + AndroidDisplay.windowHeight);
javaArgList.add("-Dglfwstub.initEgl=false");
if (mVersionInfo.arguments != null) { if (mVersionInfo.arguments != null) {
// Minecraft 1.13+ // Minecraft 1.13+
@ -1130,8 +1074,21 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
Tools.showError(this, new ErrnoException("java", exitCode), false); Tools.showError(this, new ErrnoException("java", exitCode), false);
} }
} else { // Type Invocation } else { // Type Invocation
final FileDescriptor logFile = BinaryExecutor.redirectStdio(); // Is it need?
/*
Os.dup2(FileDescriptor.err, OsConstants.STDERR_FILENO);
Os.dup2(FileDescriptor.out, OsConstants.STDOUT_FILENO);
*/
BinaryExecutor.redirectStdio();
// DEPRECATED constructor (String) api 29
FileObserver fobs = new FileObserver(logFile.getAbsolutePath(), FileObserver.MODIFY){
@Override
public void onEvent(int event, String str) {
}
};
fobs.startWatching();
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {

View file

@ -84,6 +84,7 @@ public final class Tools
String[] classpath = generateLibClasspath(info); String[] classpath = generateLibClasspath(info);
// Debug: LWJGL 3 override // Debug: LWJGL 3 override
File lwjgl2Folder = new File(Tools.MAIN_PATH, "lwjgl2");
File lwjgl3Folder = new File(Tools.MAIN_PATH, "lwjgl3"); File lwjgl3Folder = new File(Tools.MAIN_PATH, "lwjgl3");
if (info.arguments != null && lwjgl3Folder.exists()) { if (info.arguments != null && lwjgl3Folder.exists()) {
for (File file: lwjgl3Folder.listFiles()) { for (File file: lwjgl3Folder.listFiles()) {
@ -91,6 +92,12 @@ public final class Tools
libStr.append(file.getAbsolutePath() + ":"); libStr.append(file.getAbsolutePath() + ":");
} }
} }
} else if (lwjgl2Folder.exists()) {
for (File file: lwjgl2Folder.listFiles()) {
if (file.getName().endsWith(".jar")) {
libStr.append(file.getAbsolutePath() + ":");
}
}
} }
if (isClientFirst) { if (isClientFirst) {