Skip to content

Commit

Permalink
Signal Handler Funnies
Browse files Browse the repository at this point in the history
  • Loading branch information
CADIndie committed Dec 2, 2024
1 parent 1b9dada commit 307b13e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/oracle/dalvik/VMLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public final class VMLauncher {
private VMLauncher() {
}
public static native int launchJVM(String[] args);
public static native int launchJVM(String[] args, boolean usePojavSigHandler);

static {
System.loadLibrary("jrelauncher");
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/pojlib/UnityPlayerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;

Expand Down Expand Up @@ -93,6 +95,17 @@ protected String updateUnityCommandLineArguments(String cmdLine)

mUnityPlayer = new UnityPlayer(this, this);
setContentView(mUnityPlayer);
mUnityPlayer.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
@Override
public void onChildViewAdded(View parent, View child) {
System.out.println("Child added: " + child.toString());
}

@Override
public void onChildViewRemoved(View parent, View child) {
System.out.println("Child removed: " + child.toString());
}
});
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mUnityPlayer.requestFocus();

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/pojlib/util/JREUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,12 @@ public static int launchJavaVM(final Activity activity, final List<String> JVMAr
chdir(instance.gameDir);
userArgs.add(0,"java"); //argv[0] is the program name according to C standard.

int exitCode = VMLauncher.launchJVM(userArgs.toArray(new String[0]));
boolean usePojavSigHandler = true;
if (Build.MANUFACTURER.equalsIgnoreCase("Oculus") || Build.MANUFACTURER.equalsIgnoreCase("Meta")) {
usePojavSigHandler = false;
}

int exitCode = VMLauncher.launchJVM(userArgs.toArray(new String[0]), usePojavSigHandler);
Logger.getInstance().appendToLog("Java Exit code: " + exitCode);
return exitCode;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/jni/jre_launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static jint launchJVM(int margc, char** margv) {
* Method: launchJVM
* Signature: ([Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_com_oracle_dalvik_VMLauncher_launchJVM(JNIEnv *env, jclass clazz, jobjectArray argsArray) {
JNIEXPORT jint JNICALL Java_com_oracle_dalvik_VMLauncher_launchJVM(JNIEnv *env, jclass clazz, jobjectArray argsArray, jboolean usePojavSigHandler) {
#ifdef TRY_SIG2JVM
void* libjsig = dlopen("libjsig.so", RTLD_LAZY | RTLD_GLOBAL);
if (NULL == libjsig) {
Expand All @@ -147,6 +147,7 @@ JNIEXPORT jint JNICALL Java_com_oracle_dalvik_VMLauncher_launchJVM(JNIEnv *env,
catcher.sa_sigaction = android_sigaction;
catcher.sa_flags = SA_SIGINFO|SA_RESTART;
// SA_RESETHAND;

#define CATCHSIG(X) sigaction_p(X, &catcher, &old_sa[X])
CATCHSIG(SIGILL);
CATCHSIG(SIGABRT);
Expand Down

0 comments on commit 307b13e

Please sign in to comment.