mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 08:35:37 -04:00
[Mod installer] Bug fix: thread never attached
This commit is contained in:
parent
292fe4bca5
commit
c5f753d040
@ -1,40 +0,0 @@
|
|||||||
package net.kdt.pojavlaunch;
|
|
||||||
|
|
||||||
import android.support.annotation.*;
|
|
||||||
|
|
||||||
public abstract class AsyncThread<Params, Progress, Result> extends Thread
|
|
||||||
{
|
|
||||||
private boolean isCancelled = true;
|
|
||||||
|
|
||||||
@WorkerThread
|
|
||||||
protected abstract Result doInBackground(Params... params);
|
|
||||||
|
|
||||||
@MainThread
|
|
||||||
protected void onPreExecute() {}
|
|
||||||
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"})
|
|
||||||
@MainThread
|
|
||||||
protected void onPostExecute(Result result) {}
|
|
||||||
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"})
|
|
||||||
@MainThread
|
|
||||||
protected void onProgressUpdate(Progress... values) {}
|
|
||||||
|
|
||||||
@SuppressWarnings({"UnusedParameters"})
|
|
||||||
@MainThread
|
|
||||||
protected void onCancelled(Result result) {
|
|
||||||
onCancelled();
|
|
||||||
}
|
|
||||||
|
|
||||||
@MainThread
|
|
||||||
protected void onCancelled() {}
|
|
||||||
|
|
||||||
public final boolean isCancelled() {
|
|
||||||
return isCancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean cancel() {
|
|
||||||
super.stop();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -70,13 +70,21 @@ public class InstallModActivity extends LoggableActivity {
|
|||||||
|
|
||||||
// final Surface surface = new Surface(tex);
|
// final Surface surface = new Surface(tex);
|
||||||
new Thread(new Runnable(){
|
new Thread(new Runnable(){
|
||||||
|
private boolean attached = false;
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (IS_JRE_RUNNING) {
|
try {
|
||||||
Canvas canvas = mTextureView.lockCanvas();
|
while (IS_JRE_RUNNING) {
|
||||||
JREUtils.renderAWTScreenFrame(canvas, w, h);
|
if (!attached) {
|
||||||
mTextureView.unlockCanvasAndPost(canvas);
|
attached = CallbackBridge.nativeAttachThreadToOther(true, MainActivity.isInputStackCall);
|
||||||
}
|
Thread.sleep(100);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Canvas canvas = mTextureView.lockCanvas();
|
||||||
|
JREUtils.renderAWTScreenFrame(canvas, w, h);
|
||||||
|
mTextureView.unlockCanvasAndPost(canvas);
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {}
|
||||||
}
|
}
|
||||||
}, "AWTSurfaceUpdater").start();
|
}, "AWTSurfaceUpdater").start();
|
||||||
|
|
||||||
|
@ -28,7 +28,12 @@ public class CallbackBridge {
|
|||||||
sendMouseKeycode(button, 0, state == 1);
|
sendMouseKeycode(button, 0, state == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean attached;
|
||||||
public static void sendCursorPos(int x, int y) {
|
public static void sendCursorPos(int x, int y) {
|
||||||
|
if (!attached) {
|
||||||
|
attached = CallbackBridge.nativeAttachThreadToOther(true, MainActivity.isInputStackCall);
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG_STRING.append("CursorPos=" + x + ", " + y + "\n");
|
DEBUG_STRING.append("CursorPos=" + x + ", " + y + "\n");
|
||||||
mouseX = x;
|
mouseX = x;
|
||||||
mouseY = y;
|
mouseY = y;
|
||||||
@ -119,7 +124,7 @@ public class CallbackBridge {
|
|||||||
private static native void nativeSendData(boolean isAndroid, int type, String data);
|
private static native void nativeSendData(boolean isAndroid, int type, String data);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static native void nativeAttachThreadToOther(boolean isAndroid, boolean isUsePushPoll);
|
public static native boolean nativeAttachThreadToOther(boolean isAndroid, boolean isUsePushPoll);
|
||||||
private static native boolean nativeSendChar(int codepoint);
|
private static native boolean nativeSendChar(int codepoint);
|
||||||
// GLFW: GLFWCharModsCallback deprecated, but is Minecraft still use?
|
// GLFW: GLFWCharModsCallback deprecated, but is Minecraft still use?
|
||||||
private static native boolean nativeSendCharMods(int codepoint, int mods);
|
private static native boolean nativeSendCharMods(int codepoint, int mods);
|
||||||
@ -135,7 +140,6 @@ public class CallbackBridge {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("pojavexec");
|
System.loadLibrary("pojavexec");
|
||||||
CallbackBridge.nativeAttachThreadToOther(true, MainActivity.isInputStackCall);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +81,9 @@ void attachThread(bool isAndroid, JNIEnv** secondJNIEnvPtr) {
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
LOGD("Debug: Attaching %s thread to %s, javavm.isNull=%d\n", isAndroid ? "Android" : "JRE", isAndroid ? "JRE" : "Android", (isAndroid ? runtimeJavaVMPtr : dalvikJavaVMPtr) == NULL);
|
LOGD("Debug: Attaching %s thread to %s, javavm.isNull=%d\n", isAndroid ? "Android" : "JRE", isAndroid ? "JRE" : "Android", (isAndroid ? runtimeJavaVMPtr : dalvikJavaVMPtr) == NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (*secondJNIEnvPtr != NULL) return;
|
||||||
|
|
||||||
if (isAndroid && runtimeJavaVMPtr) {
|
if (isAndroid && runtimeJavaVMPtr) {
|
||||||
(*runtimeJavaVMPtr)->AttachCurrentThread(runtimeJavaVMPtr, secondJNIEnvPtr, NULL);
|
(*runtimeJavaVMPtr)->AttachCurrentThread(runtimeJavaVMPtr, secondJNIEnvPtr, NULL);
|
||||||
} else if (!isAndroid && dalvikJavaVMPtr) {
|
} else if (!isAndroid && dalvikJavaVMPtr) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user