From 6e0130351ed38c9cd4e7034812f59714cdd1fd71 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 24 Nov 2019 20:42:21 +0100 Subject: [PATCH] Android: Fix crash on enabling GC adapter We must set Java_GCAdapter.manager before the GC adapter thread (C++) starts. We used to set it at emulation start, which was fine until 9f3f45a made the GC adapter thread start much earlier. --- .../java/org/dolphinemu/dolphinemu/DolphinApplication.java | 6 ++++++ .../dolphinemu/dolphinemu/activities/EmulationActivity.java | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/DolphinApplication.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/DolphinApplication.java index effa7f1744..204c7a7edd 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/DolphinApplication.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/DolphinApplication.java @@ -2,8 +2,11 @@ package org.dolphinemu.dolphinemu; import android.app.Application; import android.content.Context; +import android.hardware.usb.UsbManager; import org.dolphinemu.dolphinemu.utils.DirectoryInitialization; +import org.dolphinemu.dolphinemu.utils.Java_GCAdapter; +import org.dolphinemu.dolphinemu.utils.Java_WiimoteAdapter; import org.dolphinemu.dolphinemu.utils.PermissionsHandler; import org.dolphinemu.dolphinemu.utils.VolleyUtil; @@ -19,6 +22,9 @@ public class DolphinApplication extends Application VolleyUtil.init(getApplicationContext()); System.loadLibrary("main"); + Java_GCAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE); + Java_WiimoteAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE); + if (PermissionsHandler.hasWriteAccess(getApplicationContext())) DirectoryInitialization.start(getApplicationContext()); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java index 68562e9969..8577158706 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java @@ -1,11 +1,9 @@ package org.dolphinemu.dolphinemu.activities; -import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; -import android.hardware.usb.UsbManager; import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; @@ -48,8 +46,6 @@ import org.dolphinemu.dolphinemu.ui.main.MainActivity; import org.dolphinemu.dolphinemu.ui.platform.Platform; import org.dolphinemu.dolphinemu.utils.ControllerMappingHelper; import org.dolphinemu.dolphinemu.utils.FileBrowserHelper; -import org.dolphinemu.dolphinemu.utils.Java_GCAdapter; -import org.dolphinemu.dolphinemu.utils.Java_WiimoteAdapter; import org.dolphinemu.dolphinemu.utils.MotionListener; import org.dolphinemu.dolphinemu.utils.Rumble; import org.dolphinemu.dolphinemu.utils.TvUtil; @@ -304,8 +300,6 @@ public final class EmulationActivity extends AppCompatActivity setTheme(themeId); - Java_GCAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE); - Java_WiimoteAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE); Rumble.initRumble(this); setContentView(R.layout.activity_emulation);