mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-14 15:17:02 -04:00
Add launch checks; Fix cursor not working on grab mode
This commit is contained in:
parent
3527d307f7
commit
9f0a79176b
@ -2,12 +2,7 @@
|
||||
* Using libraries:<br>
|
||||
• ClassWrapperMC: A simple wrapper to help launching Minecraft LaunchWrapper on JRE9 and later.<br>
|
||||
• gl4es: OpenGL for OpenGL ES devices by lunixbochs and ptitSeb.<br>
|
||||
• LegacyLauncher: Open source Minecraft LaunchWrapper by Mojang.<br>
|
||||
• OpenJDK JRE 10 for Android by dongfangxunlei.<br>
|
||||
• PRoot special build of Termux to bypass SECCOMP for OpenJDK run in Android 8.<br>
|
||||
• TheQVD XVnc Pro (including Android VNC Viewer).<br>
|
||||
• Some Debian libraries (X11, FreeType...)<br>
|
||||
• Busybox.<br>
|
||||
• Apache Commons Compress.<br>
|
||||
• LWJGL.<br>
|
||||
* License:<br>
|
||||
|
@ -142,7 +142,7 @@ public class InstallModActivity extends LoggableActivity
|
||||
System.out.println(Arrays.toString(javaArgList.toArray(new String[0])));
|
||||
|
||||
//JREUtils.redirectStdio(false);
|
||||
JREUtils.setJavaEnvironment(this);
|
||||
JREUtils.setJavaEnvironment(this, Tools.LAUNCH_TYPE);
|
||||
JREUtils.initJavaRuntime();
|
||||
JREUtils.chdir(Tools.MAIN_PATH);
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class JREUtils
|
||||
Log.i("jrelog-logcat","Logcat thread started");
|
||||
}
|
||||
|
||||
public static void setJavaEnvironment(Context ctx) throws IOException, ErrnoException {
|
||||
public static void setJavaEnvironment(Context ctx, int launchType) throws IOException, ErrnoException {
|
||||
nativeLibDir = ctx.getApplicationInfo().nativeLibraryDir;
|
||||
String libName = System.getProperty("os.arch").contains("64") ? "lib64" : "lib";
|
||||
String ldLibraryPath = (
|
||||
@ -85,17 +85,17 @@ public class JREUtils
|
||||
Tools.homeJreDir + "/lib"
|
||||
);
|
||||
|
||||
setEnvironment("JAVA_HOME", Tools.homeJreDir);
|
||||
setEnvironment("HOME", Tools.MAIN_PATH);
|
||||
setEnvironment("TMPDIR", ctx.getCacheDir().getAbsolutePath());
|
||||
// setEnvironment("LIBGL_MIPMAP", "3");
|
||||
setEnvironment("MESA_GLSL_CACHE_DIR", ctx.getCacheDir().getAbsolutePath());
|
||||
setEnvironment("LD_LIBRARY_PATH", ldLibraryPath);
|
||||
setEnvironment("PATH", Tools.homeJreDir + "/bin:" + Os.getenv("PATH"));
|
||||
setEnvironment(launchType, "JAVA_HOME", Tools.homeJreDir);
|
||||
setEnvironment(launchType, "HOME", Tools.MAIN_PATH);
|
||||
setEnvironment(launchType, "TMPDIR", ctx.getCacheDir().getAbsolutePath());
|
||||
// setEnvironment(launchType, "LIBGL_MIPMAP", "3");
|
||||
setEnvironment(launchType, "MESA_GLSL_CACHE_DIR", ctx.getCacheDir().getAbsolutePath());
|
||||
setEnvironment(launchType, "LD_LIBRARY_PATH", ldLibraryPath);
|
||||
setEnvironment(launchType, "PATH", Tools.homeJreDir + "/bin:" + Os.getenv("PATH"));
|
||||
|
||||
setEnvironment("REGAL_GL_VENDOR", "Android");
|
||||
setEnvironment("REGAL_GL_RENDERER", "Regal");
|
||||
setEnvironment("REGAL_GL_VERSION", "4.5");
|
||||
setEnvironment(launchType, "REGAL_GL_VENDOR", "Android");
|
||||
setEnvironment(launchType, "REGAL_GL_RENDERER", "Regal");
|
||||
setEnvironment(launchType, "REGAL_GL_VERSION", "4.5");
|
||||
// REGAL_GL_EXTENSIONS
|
||||
|
||||
setLdLibraryPath(ldLibraryPath);
|
||||
@ -103,8 +103,8 @@ public class JREUtils
|
||||
// return ldLibraryPath;
|
||||
}
|
||||
|
||||
private static void setEnvironment(String name, String value) throws ErrnoException, IOException {
|
||||
if (Tools.LAUNCH_TYPE == Tools.LTYPE_PROCESS) {
|
||||
private static void setEnvironment(int launchType, String name, String value) throws ErrnoException, IOException {
|
||||
if (launchType == Tools.LTYPE_PROCESS) {
|
||||
Tools.mLaunchShell.writeToProcess("export " + name + "=" + value);
|
||||
} else {
|
||||
Os.setenv(name, value, true);
|
||||
|
@ -26,6 +26,7 @@ import org.lwjgl.glfw.*;
|
||||
import android.app.AlertDialog;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.text.*;
|
||||
//import android.support.v7.view.menu.*;
|
||||
//import net.zhuoweizhang.boardwalk.downloader.*;
|
||||
|
||||
@ -128,7 +129,7 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
File logFile = new File(Tools.MAIN_PATH, "latestlog.txt");
|
||||
if (logFile.exists() && logFile.length() < 2048) {
|
||||
if (logFile.exists() && logFile.length() < 20480) {
|
||||
String errMsg = "Error occurred during initialization of ";
|
||||
try {
|
||||
String logContent = Tools.read(logFile.getAbsolutePath());
|
||||
@ -139,7 +140,7 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
Tools.showError(MCLauncherActivity.this, ex);
|
||||
|
||||
// Do it so dialog will not shown for second time
|
||||
Tools.write(logFile.getAbsolutePath(), logContent.replace(errMsg + "VM", errMsg + " JVM"));
|
||||
Tools.write(logFile.getAbsolutePath(), logContent.replace(errMsg + "VM", errMsg + "JVM"));
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
System.err.println("Could not detect java crash");
|
||||
@ -783,11 +784,11 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
aboutB.setTitle(R.string.mcl_option_about);
|
||||
try
|
||||
{
|
||||
aboutB.setMessage(String.format(Tools.read(getAssets().open("about_en.txt")),
|
||||
aboutB.setMessage(Html.fromHtml(String.format(Tools.read(getAssets().open("about_en.txt")),
|
||||
Tools.APP_NAME,
|
||||
Tools.usingVerName,
|
||||
"3.2.3")
|
||||
);
|
||||
));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import org.lwjgl.glfw.*;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import java.lang.Process;
|
||||
import android.system.*;
|
||||
|
||||
public class MainActivity extends LoggableActivity implements OnTouchListener, OnClickListener
|
||||
{
|
||||
@ -453,6 +454,7 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
|
||||
|
||||
// TODO uncomment after fix wrong trigger
|
||||
// CallbackBridge.putMouseEventWithCoords(rightOverride ? (byte) 1 : (byte) 0, (byte) 0, x, y);
|
||||
CallbackBridge.sendCursorPos(x, y);
|
||||
if (!rightOverride) {
|
||||
CallbackBridge.mouseLeft = false;
|
||||
}
|
||||
@ -956,19 +958,68 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
|
||||
*/
|
||||
|
||||
appendlnToLog("--------- beggining with launcher debug");
|
||||
File lwjgl3dir = new File(Tools.MAIN_PATH, "lwjgl3");
|
||||
if (!lwjgl3dir.exists() || lwjgl3dir.isFile()) {
|
||||
appendlnToLog("Error: LWJGL3 is not installed!");
|
||||
Tools.showError(this, new Throwable("LWJGL3 is not installed!"), true);
|
||||
return;
|
||||
} else {
|
||||
appendlnToLog("Info: LWJGL3 directory size: " + lwjgl3dir.length());
|
||||
}
|
||||
checkLWJGL3Installed();
|
||||
checkJavaArchitecture();
|
||||
checkJavaArgsIsLaunchable();
|
||||
|
||||
JREUtils.redirectAndPrintJRELog(this);
|
||||
Tools.launchMinecraft(this, mProfile, mVersionInfo);
|
||||
}
|
||||
|
||||
private void checkJavaArchitecture() throws Exception {
|
||||
String[] argName = Tools.currentArch.split("/");
|
||||
String releaseContent = Tools.read(Tools.homeJreDir + "/release");
|
||||
int osArchIndex = releaseContent.indexOf("OS_ARCH=\"") + 9;
|
||||
releaseContent = releaseContent.substring(osArchIndex);
|
||||
releaseContent = releaseContent.substring(0, releaseContent.indexOf("\""));
|
||||
if (!(releaseContent.contains(argName[0]) || releaseContent.contains(argName[1]))) {
|
||||
appendlnToLog("Architecture " + Tools.currentArch + " is incompatible with Java Runtime " + releaseContent);
|
||||
throw new RuntimeException(getString(R.string.mcn_check_fail_incompatiblearch, Tools.currentArch, releaseContent));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkJavaArgsIsLaunchable() throws Throwable {
|
||||
appendlnToLog("Info: Custom Java arguments: \"" + LauncherPreferences.PREF_CUSTOM_JAVA_ARGS + "\"");
|
||||
|
||||
// Test java
|
||||
ShellProcessOperation shell = new ShellProcessOperation(new ShellProcessOperation.OnPrintListener(){
|
||||
@Override
|
||||
public void onPrintLine(String text){
|
||||
appendlnToLog("[JRETest] " + text);
|
||||
}
|
||||
});
|
||||
Tools.mLaunchShell = shell;
|
||||
JREUtils.setJavaEnvironment(this, Tools.LTYPE_PROCESS);
|
||||
Tools.mLaunchShell = null;
|
||||
|
||||
List<String> testArgs = new ArrayList<String>();
|
||||
testArgs.add(Tools.homeJreDir + "/bin/java");
|
||||
Tools.getJavaArgs(this, testArgs);
|
||||
testArgs.add("-version");
|
||||
|
||||
shell.writeToProcess("chmod 700 " + Tools.homeJreDir + "/bin/java");
|
||||
shell.writeToProcess("set -e");
|
||||
shell.writeToProcess(testArgs.toArray(new String[0]));
|
||||
|
||||
int exitCode = shell.waitFor();
|
||||
appendlnToLog("Info: java test command exited with " + exitCode);
|
||||
|
||||
if (exitCode != 0) {
|
||||
appendlnToLog("Error: it is failure!");
|
||||
throw new RuntimeException(getString(R.string.mcn_check_fail_java));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkLWJGL3Installed() {
|
||||
File lwjgl3dir = new File(Tools.MAIN_PATH, "lwjgl3");
|
||||
if (!lwjgl3dir.exists() || lwjgl3dir.isFile()) {
|
||||
appendlnToLog("Error: LWJGL3 was not installed!");
|
||||
throw new RuntimeException(getString(R.string.mcn_check_fail_lwjgl));
|
||||
} else {
|
||||
appendlnToLog("Info: LWJGL3 directory: " + lwjgl3dir.list());
|
||||
}
|
||||
}
|
||||
|
||||
public void printStream(InputStream stream) {
|
||||
try {
|
||||
BufferedReader buffStream = new BufferedReader(new InputStreamReader(stream));
|
||||
|
@ -59,6 +59,13 @@ public class PojavApplication extends Application
|
||||
Tools.usingVerName = thisApp.versionName;
|
||||
Tools.usingVerCode = thisApp.versionCode;
|
||||
Tools.datapath = getDir("files", MODE_PRIVATE).getParent();
|
||||
Tools.currentArch = new File(getApplicationInfo().nativeLibraryDir).getName();
|
||||
switch (Tools.currentArch) {
|
||||
case "arm": Tools.currentArch = "arm/aarch32"; break;
|
||||
case "arm64": Tools.currentArch = "arm64/aarch64"; break;
|
||||
case "x86": Tools.currentArch = "x86/i*86"; break;
|
||||
case "x86_64": Tools.currentArch = "x86_64/amd64"; break;
|
||||
}
|
||||
|
||||
LauncherPreferences.DEFAULT_PREF = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
LauncherPreferences.loadPreferences();
|
||||
|
@ -359,7 +359,7 @@ public class PojavLoginActivity extends AppCompatActivity
|
||||
@Override
|
||||
public void run() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(PojavLoginActivity.this);
|
||||
builder.setTitle(getString(R.string.alerttitle_install_jre, System.getProperty("os.arch")));
|
||||
builder.setTitle(getString(R.string.alerttitle_install_jre, Tools.currentArch));
|
||||
builder.setCancelable(false);
|
||||
|
||||
final AlertDialog dialog = builder.create();
|
||||
|
@ -34,6 +34,7 @@ public final class Tools
|
||||
public static String mhomeUrl = "https://pojavlauncherteam.github.io/PojavLauncher"; // "http://kdtjavacraft.eu5.net";
|
||||
public static String datapath = "/data/data/net.kdt.pojavlaunch";
|
||||
public static String worksDir = datapath + "/app_working_dir";
|
||||
public static String currentArch;
|
||||
|
||||
// New since 3.0.0
|
||||
public static String homeJreDir = datapath + "/jre_runtime";
|
||||
@ -122,7 +123,7 @@ public final class Tools
|
||||
// can fix java?
|
||||
// setEnvironment("ORIGIN", Tools.homeJreDir + "/lib");
|
||||
|
||||
JREUtils.setJavaEnvironment(ctx);
|
||||
JREUtils.setJavaEnvironment(ctx, Tools.LAUNCH_TYPE);
|
||||
|
||||
if (LAUNCH_TYPE == LTYPE_PROCESS) {
|
||||
mLaunchShell.writeToProcess("cd $HOME");
|
||||
|
@ -151,6 +151,9 @@
|
||||
<string name="mcn_exit_crash">Game Crash detected! Click OK to exit.</string>
|
||||
<string name="mcn_exit_errcrash">Unable to locate crash! You may ignore this.</string>
|
||||
<string name="mcn_exit_confirm">Are you sure want to force close?</string>
|
||||
<string name="mcn_check_fail_lwjgl">LWJGL3 was not installed!</string>
|
||||
<string name="mcn_check_fail_incompatiblearch">Architecture %s is incompatible with Java Runtime %s.</string>
|
||||
<string name="mcn_check_fail_java">Could not start test Java VM. Check %s for more info.</string>
|
||||
|
||||
<!-- MainActivity: Control buttons -->
|
||||
<string name="controls">Controls</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user