Skip to content

Commit 09d2e2c

Browse files
committed
Merge branch 'QuestCraft-6.0.0' into QuestCraft-6.0.1
2 parents aa8baa2 + a74bb86 commit 09d2e2c

11 files changed

Lines changed: 59 additions & 30 deletions

File tree

0 Bytes
Binary file not shown.

src/main/assets/lwjgl/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1738988056798
1+
1752546870116

src/main/java/pojlib/API.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,21 +172,29 @@ public static MinecraftInstances.Instance createNewInstance(Activity activity, M
172172
*
173173
* @param instance The instance to update
174174
*/
175-
public static void prelaunch(Activity activity, MinecraftInstances instances, MinecraftInstances.Instance instance) {
175+
public static boolean prelaunch(Activity activity, MinecraftInstances instances, MinecraftInstances.Instance instance) {
176176
gameReady = false;
177177
instance.updateMods(instances);
178178
if (hasConnection(activity)) {
179179
try {
180-
JREUtils.prelaunchCheck(activity, instance);
181-
} catch (IOException | ExecutionException | InterruptedException e) {
180+
if(!JREUtils.prelaunchCheck(activity, instance)) {
181+
Logger.getInstance().appendToLog("JVM is not properly installed despite retry!");
182+
return false;
183+
}
184+
} catch (Throwable e) {
182185
Logger.getInstance().appendToLog("WARN! Instance launch failed!" + e);
183186
}
184187
} else {
185-
Logger.getInstance().appendToLog("Skipping prelaunch check due to no wifi connection!");
188+
Logger.getInstance().appendToLog("Skipping most prelaunch checks due to no WiFi connection.");
189+
if(!JREUtils.initJavaRuntime()) {
190+
Logger.getInstance().appendToLog("JVM is not properly installed! Please connect to WiFi to install it!");
191+
return false;
192+
}
186193
}
187194
DownloadManager.reset();
188195

189196
MinecraftInstances.CheckVivecraftConfig(instance);
197+
return true;
190198
}
191199

192200
/**

src/main/java/pojlib/util/JREUtils.java

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.Arrays;
2525
import java.util.List;
2626
import java.util.Map;
27-
import java.util.concurrent.ExecutionException;
2827

2928
import pojlib.API;
3029

@@ -78,11 +77,8 @@ public static ArrayList<File> locateLibs(File path) {
7877
return returnValue;
7978
}
8079

81-
public static void initJavaRuntime() {
82-
dlopen(findInLdLibPath("libjli.so"));
83-
if(!dlopen("libjvm.so")){
84-
dlopen(jvmLibraryPath+"/libjvm.so");
85-
}
80+
public static boolean initJavaRuntime() {
81+
dlopen(findInLdLibPath("server/libjvm.so"));
8682
dlopen(findInLdLibPath("libverify.so"));
8783
dlopen(findInLdLibPath("libjava.so"));
8884
dlopen(findInLdLibPath("libnet.so"));
@@ -91,9 +87,15 @@ public static void initJavaRuntime() {
9187
dlopen(findInLdLibPath("libawt_headless.so"));
9288
dlopen(findInLdLibPath("libfreetype.so"));
9389
dlopen(findInLdLibPath("libfontmanager.so"));
94-
for(File f : locateLibs(new File(runtimeDir + "/lib"))) {
95-
dlopen(f.getAbsolutePath());
90+
dlopen(findInLdLibPath("libjli.so"));
91+
92+
String dlerr = dlerror();
93+
if(dlerr.contains(runtimeDir)) {
94+
Logger.getInstance().appendToLog("ERROR! Could not dlopen libraries! " + dlerr);
95+
return false;
9696
}
97+
98+
return true;
9799
}
98100

99101
public static void redirectAndPrintJRELog() {
@@ -154,11 +156,15 @@ public static void setJavaEnvironment(Activity activity, MinecraftInstances.Inst
154156
//envMap.put("APP_HOME", Constants.USER_HOME);
155157
envMap.put("TMPDIR", activity.getCacheDir().getAbsolutePath());
156158
envMap.put("VR_MODEL", API.model);
157-
envMap.put("POJLIB_RENDERER", "LightThinWrapper");
159+
envMap.put("POJLIB_RENDERER", "MobileGLUES");
160+
envMap.put("MG_DIR_PATH", activity.getFilesDir() + "/mg");
158161

159162
envMap.put("LD_LIBRARY_PATH", LD_LIBRARY_PATH);
160163
envMap.put("PATH", activity.getFilesDir() + "/runtimes/JRE/bin:" + Os.getenv("PATH"));
161164

165+
File mg = new File(activity.getFilesDir() + "/mg");
166+
mg.mkdirs();
167+
162168
File customEnvFile = new File(Constants.USER_HOME, "custom_env.txt");
163169
if (customEnvFile.exists() && customEnvFile.isFile()) {
164170
BufferedReader reader = new BufferedReader(new FileReader(customEnvFile));
@@ -184,18 +190,21 @@ public static void setJavaEnvironment(Activity activity, MinecraftInstances.Inst
184190
}
185191

186192
// Called before game launch to ensure all files are present and correct
187-
public static void prelaunchCheck(Activity activity, MinecraftInstances.Instance instance) throws IOException, ExecutionException, InterruptedException {
193+
public static boolean prelaunchCheck(Activity activity, MinecraftInstances.Instance instance) throws Throwable {
194+
runtimeDir = activity.getFilesDir() + "/runtimes/JRE";
195+
JREUtils.relocateLibPath(activity);
196+
setJavaEnvironment(activity, instance);
197+
188198
UnityPlayerActivity.installLWJGL(activity);
189199
Installer.installJVM(activity);
190200
Installer.installClient(MinecraftMeta.getVersionInfo(instance.versionName), Constants.USER_HOME).get();
191201
Installer.installLibraries(MinecraftMeta.getVersionInfo(instance.versionName), Constants.USER_HOME).get();
192202
Installer.installAssets(MinecraftMeta.getVersionInfo(instance.versionName), Constants.USER_HOME).get();
203+
204+
return initJavaRuntime();
193205
}
194206

195207
public static int launchJavaVM(final Activity activity, final List<String> JVMArgs, MinecraftInstances.Instance instance) throws Throwable {
196-
JREUtils.relocateLibPath(activity);
197-
setJavaEnvironment(activity, instance);
198-
199208
final String graphicsLib = loadGraphicsLibrary();
200209
List<String> userArgs = getJavaArgs(activity, instance);
201210

@@ -209,12 +218,10 @@ public static int launchJavaVM(final Activity activity, final List<String> JVMAr
209218
ActivityManager.MemoryInfo ami = new ActivityManager.MemoryInfo();
210219
manager.getMemoryInfo(ami);
211220
long availMem = (ami.availMem-ami.threshold)/(1024*1024);
212-
availMem *= 0.8; // Lossy, but should work...
213221
long allocatedRam = Math.max(availMem, 1536);
214222

215223
Logger.getInstance().appendToLog("QuestCraft: Setting JVM memory to " + allocatedRam + "MB");
216224

217-
218225
userArgs.add("-Xms" + 1024 + "M");
219226
userArgs.add("-Xmx" + allocatedRam + "M");
220227
}
@@ -242,9 +249,6 @@ public static int launchJavaVM(final Activity activity, final List<String> JVMAr
242249
userArgs.addAll(JVMArgs);
243250
System.out.println(JVMArgs);
244251

245-
runtimeDir = activity.getFilesDir() + "/runtimes/JRE";
246-
247-
initJavaRuntime();
248252
chdir(instance.gameDir);
249253
userArgs.add(0,"java"); //argv[0] is the program name according to C standard.
250254

@@ -366,7 +370,7 @@ public static ArrayList<String> parseJavaArguments(String args){
366370
* @return The name of the loaded library
367371
*/
368372
public static String loadGraphicsLibrary(){
369-
return "libltw.so";
373+
return "libmobileglues.so";
370374
}
371375

372376
public static native long getEGLContextPtr();
@@ -375,6 +379,7 @@ public static String loadGraphicsLibrary(){
375379
public static native int chdir(String path);
376380
public static native void logToLogger(final Logger logger);
377381
public static native boolean dlopen(String libPath);
382+
public static native String dlerror();
378383
public static native void setLdLibraryPath(String ldLibraryPath);
379384

380385
static {

src/main/jni/egl_bridge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void pojavTerminate() {
6767
}
6868

6969
void dlsym_egl() {
70-
void* handle = dlopen("libltw.so", RTLD_NOW);
70+
void* handle = dlopen("libmobileglues.so", RTLD_NOW);
7171
eglGetProcAddress_p = (eglGetProcAddress_t*) dlsym(handle, "eglGetProcAddress");
7272
eglGetDisplay_p = (eglGetDisplay_t*) eglGetProcAddress_p("eglGetDisplay");
7373
eglInitialize_p = (eglInitialize_t*) eglGetProcAddress_p("eglInitialize");

src/main/jni/jre_launcher.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "utils.h"
3737

3838
// Uncomment to try redirect signal handling to JVM
39-
#define TRY_SIG2JVM
39+
// #define TRY_SIG2JVM
4040

4141
#define FULL_VERSION "1.8.0-internal"
4242
#define DOT_VERSION "1.8"
@@ -121,7 +121,7 @@ static jint launchJVM(int margc, char** margv) {
121121
*/
122122
JNIEXPORT jint JNICALL Java_com_oracle_dalvik_VMLauncher_launchJVM(JNIEnv *env, jclass clazz, jobjectArray argsArray) {
123123
#ifdef TRY_SIG2JVM
124-
void* libjvm = dlopen("libjvm.so", RTLD_LAZY | RTLD_GLOBAL);
124+
void* libjvm = dlopen("libjvm.so", RTLD_NOLOAD);
125125
if (NULL == libjvm) {
126126
LOGE("JVM lib = NULL: %s", dlerror());
127127
return -1;

src/main/jni/utils.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ JNIEXPORT jboolean JNICALL Java_pojlib_util_JREUtils_dlopen(JNIEnv *env, jclass
9191
return handle != NULL;
9292
}
9393

94+
JNIEXPORT jstring JNICALL Java_pojlib_util_JREUtils_dlerror(JNIEnv *env, jclass clazz) {
95+
char* err = dlerror();
96+
if(err == NULL) {
97+
return NULL;
98+
}
99+
jstring dstStr = (*env)->NewStringUTF(env, err);
100+
101+
return dstStr;
102+
}
103+
94104
JNIEXPORT jint JNICALL Java_pojlib_util_JREUtils_chdir(JNIEnv *env, jclass clazz, jstring nameStr) {
95105
const char *name = (*env)->GetStringUTFChars(env, nameStr, NULL);
96106
int retval = chdir(name);

src/main/jniLibs/arm64-v8a/libltw.so

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:2d5786d88e9bb9078c73c1b71ea2de57ef61931c0db5455c1688776dcec44cbd
3+
size 8442096
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:f0e9c155c6002b19fd546e6ed3dfc8ff709b5c7e866bf1795cbdcc58a9d383ec
3+
size 1565080

0 commit comments

Comments
 (0)