Skip to content

Commit

Permalink
Android: Fix crash on enabling GC adapter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JosJuice committed Nov 27, 2019
1 parent 1550165 commit 6e01303
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

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;

Expand All @@ -19,6 +22,9 @@ public void onCreate()
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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -48,8 +46,6 @@
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;
Expand Down Expand Up @@ -304,8 +300,6 @@ protected void onCreate(Bundle savedInstanceState)

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);
Expand Down

0 comments on commit 6e01303

Please sign in to comment.