mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-18 09:07:48 -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);
|
||||
new Thread(new Runnable(){
|
||||
private boolean attached = false;
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
while (IS_JRE_RUNNING) {
|
||||
if (!attached) {
|
||||
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();
|
||||
|
||||
|
@ -28,7 +28,12 @@ public class CallbackBridge {
|
||||
sendMouseKeycode(button, 0, state == 1);
|
||||
}
|
||||
|
||||
private static boolean attached;
|
||||
public static void sendCursorPos(int x, int y) {
|
||||
if (!attached) {
|
||||
attached = CallbackBridge.nativeAttachThreadToOther(true, MainActivity.isInputStackCall);
|
||||
}
|
||||
|
||||
DEBUG_STRING.append("CursorPos=" + x + ", " + y + "\n");
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
@ -119,7 +124,7 @@ public class CallbackBridge {
|
||||
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);
|
||||
// GLFW: GLFWCharModsCallback deprecated, but is Minecraft still use?
|
||||
private static native boolean nativeSendCharMods(int codepoint, int mods);
|
||||
@ -135,7 +140,6 @@ public class CallbackBridge {
|
||||
|
||||
static {
|
||||
System.loadLibrary("pojavexec");
|
||||
CallbackBridge.nativeAttachThreadToOther(true, MainActivity.isInputStackCall);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,9 @@ void attachThread(bool isAndroid, JNIEnv** secondJNIEnvPtr) {
|
||||
#ifdef DEBUG
|
||||
LOGD("Debug: Attaching %s thread to %s, javavm.isNull=%d\n", isAndroid ? "Android" : "JRE", isAndroid ? "JRE" : "Android", (isAndroid ? runtimeJavaVMPtr : dalvikJavaVMPtr) == NULL);
|
||||
#endif
|
||||
|
||||
if (*secondJNIEnvPtr != NULL) return;
|
||||
|
||||
if (isAndroid && runtimeJavaVMPtr) {
|
||||
(*runtimeJavaVMPtr)->AttachCurrentThread(runtimeJavaVMPtr, secondJNIEnvPtr, NULL);
|
||||
} else if (!isAndroid && dalvikJavaVMPtr) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user