From 79f513a25f224eb0a88712a12cd0184dcb58d8f0 Mon Sep 17 00:00:00 2001 From: khanhduytran0 Date: Tue, 1 Sep 2020 07:58:03 +0700 Subject: [PATCH] Fix error --- .travis.yml | 4 +-- README.md | 3 ++- .../net/kdt/pojavlaunch/BinaryExecutor.java | 26 ++++++++++++++++--- .../kdt/pojavlaunch/InstallModActivity.java | 18 +------------ .../net/kdt/pojavlaunch/MainActivity.java | 23 ++-------------- 5 files changed, 29 insertions(+), 45 deletions(-) diff --git a/.travis.yml b/.travis.yml index 08286c419..2ebd745a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,9 +50,9 @@ deploy: api-key: $GITHUB_API_KEY file: $TRAVIS_BUILD_DIR/app/build/outputs/apk/debug/app-debug.apk skip_cleanup: true - name: PojavLauncher_DevBuild-$TRAVIS_COMMIT + name: PojavLauncher-v3_DevBuild-$TRAVIS_COMMIT body: Automatic build of PojavLauncher from the latest source commit ($TRAVIS_COMMIT) built by Travis CI on $(date +'%F %T %Z'). prerelease: true overwrite: true target_commitish: $TRAVIS_COMMIT - on: [push] +# on: [push] diff --git a/README.md b/README.md index 420124d20..74231ed43 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ A Minecraft: Java Edition launcher for Android based from Boardwalk. Support up- ## Current status - [x] **Removed** ~~BinaryExecutor: execute `java` binary, no `JNIInvocation`.~~ -- [x] JVDroid OpenJDK 11 (32 and 64-bit ARM and x86). Partial, no error `can't lock mutex`, but now exit with none output. +- [x] **Temporary removed** ~~JVDroid OpenJDK 11 (32 and 64-bit ARM and x86). Partial, no error `can't lock mutex`, but now exit with none output.~~ +- [x] OpenJDK 9 Mobile port - [ ] AWT/Swing for mod installer. Will use `Caciocavallo` project. - [ ] OpenGL in OpenJDK environment. Use Boardwalk 2 method or other. - [ ] OpenAL 64-bit version diff --git a/app/src/main/java/net/kdt/pojavlaunch/BinaryExecutor.java b/app/src/main/java/net/kdt/pojavlaunch/BinaryExecutor.java index 76f48df16..dc7c708fa 100644 --- a/app/src/main/java/net/kdt/pojavlaunch/BinaryExecutor.java +++ b/app/src/main/java/net/kdt/pojavlaunch/BinaryExecutor.java @@ -2,6 +2,7 @@ package net.kdt.pojavlaunch; import android.system.*; import java.io.*; +import android.content.*; // This class should be named as 'LoadMe' as original public class BinaryExecutor @@ -29,19 +30,36 @@ public class BinaryExecutor // return fd; } - public static void setJavaEnvironment() { + public static void setJavaEnvironment(Context ctx) throws IOException, ErrnoException { + String libName = System.getProperty("os.arch").contains("64") ? "lib64" : "lib"; + String ldLibraryPath = ( + // To make libjli.so ignore re-execute + Tools.homeJreDir + "/lib/server:" + + + "/system/" + libName + ":" + + "/vendor/" + libName + ":" + + "/vendor/" + libName + "/hw:" + + + ctx.getApplicationInfo().nativeLibraryDir + ":" + + + Tools.homeJreDir + "/lib/jli:" + + Tools.homeJreDir + "/lib" + ); + setEnvironment("JAVA_HOME", Tools.homeJreDir); setEnvironment("HOME", Tools.MAIN_PATH); - setEnvironment("TMPDIR", getCacheDir().getAbsolutePath()); + setEnvironment("TMPDIR", ctx.getCacheDir().getAbsolutePath()); // setEnvironment("LIBGL_MIPMAP", "3"); - setEnvironment("MESA_GLSL_CACHE_DIR", getCacheDir().getAbsolutePath()); + setEnvironment("MESA_GLSL_CACHE_DIR", ctx.getCacheDir().getAbsolutePath()); setEnvironment("LD_LIBRARY_PATH", ldLibraryPath); setEnvironment("PATH", Tools.homeJreDir + "/bin:" + Os.getenv("PATH")); + + setLdLibraryPath(ldLibraryPath); } private static void setEnvironment(String name, String value) throws ErrnoException, IOException { if (MainActivity.LAUNCH_TYPE == MainActivity.LTYPE_PROCESS) { - mLaunchShell.writeToProcess("export " + name + "=" + value); + MainActivity.mLaunchShell.writeToProcess("export " + name + "=" + value); } else { Os.setenv(name, value, true); } diff --git a/app/src/main/java/net/kdt/pojavlaunch/InstallModActivity.java b/app/src/main/java/net/kdt/pojavlaunch/InstallModActivity.java index 3a0335fd4..5dd132911 100644 --- a/app/src/main/java/net/kdt/pojavlaunch/InstallModActivity.java +++ b/app/src/main/java/net/kdt/pojavlaunch/InstallModActivity.java @@ -68,25 +68,9 @@ public class InstallModActivity extends AppCompatActivity javaArgList.add("-Djava.library.path="); javaArgList.add("-jar"); javaArgList.add(modFile.getAbsolutePath()); - - String libName = System.getProperty("os.arch").contains("64") ? "lib64" : "lib"; - String ldLibraryPath = ( - // To make libjli.so ignore re-execute - Tools.homeJreDir + "/lib/server:" + - "/system/" + libName + ":" + - "/vendor/" + libName + ":" + - "/vendor/" + libName + "/hw:" + - - getApplicationInfo().nativeLibraryDir + ":" + - - Tools.homeJreDir + "/lib/jli:" + - Tools.homeJreDir + "/lib" - ); - - BinaryExecutor.setJavaEnvironment(); BinaryExecutor.redirectStdio(); - BinaryExecutor.setLdLibraryPath(ldLibraryPath); + BinaryExecutor.setJavaEnvironment(this); BinaryExecutor.initJavaRuntime(); BinaryExecutor.chdir(Tools.MAIN_PATH); diff --git a/app/src/main/java/net/kdt/pojavlaunch/MainActivity.java b/app/src/main/java/net/kdt/pojavlaunch/MainActivity.java index d78995b8a..493785af6 100644 --- a/app/src/main/java/net/kdt/pojavlaunch/MainActivity.java +++ b/app/src/main/java/net/kdt/pojavlaunch/MainActivity.java @@ -948,7 +948,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener, return args; } - private ShellProcessOperation mLaunchShell; + public static ShellProcessOperation mLaunchShell; private static void startStrace(int pid) throws Exception { String[] straceArgs = new String[] {"/system/bin/strace", @@ -1029,25 +1029,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener, mLaunchShell.initInputStream(this); } - String libName = System.getProperty("os.arch").contains("64") ? "lib64" : "lib"; - String ldLibraryPath = ( - // To make libjli.so ignore re-execute - Tools.homeJreDir + "/lib/server:" + - - "/system/" + libName + ":" + - "/vendor/" + libName + ":" + - "/vendor/" + libName + "/hw:" + - - getApplicationInfo().nativeLibraryDir + ":" + - - Tools.homeJreDir + "/lib/jli:" + - Tools.homeJreDir + "/lib" - - - // "$JAVA_HOME/lib:$JAVA_HOME/lib/jli:$JAVA_HOME/lib/server" - ); - - BinaryExecutor.setJavaEnvironment(); + BinaryExecutor.setJavaEnvironment(this); // can fix java? // setEnvironment("ORIGIN", Tools.homeJreDir + "/lib"); @@ -1094,7 +1076,6 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener, } }, "RuntimeLogThread").start(); - BinaryExecutor.setLdLibraryPath(ldLibraryPath); BinaryExecutor.initJavaRuntime(); BinaryExecutor.chdir(Tools.MAIN_PATH);