From 1e6925e423bd4978773713eb4e7e095a88590adf Mon Sep 17 00:00:00 2001 From: Ryan Meredith Date: Tue, 16 Jun 2020 11:52:58 -0400 Subject: [PATCH] Android: Disallow multiple launcher activities --- .../dolphinemu/activities/EmulationActivity.java | 16 ++++++++++++++++ .../dolphinemu/fragments/EmulationFragment.java | 1 + 2 files changed, 17 insertions(+) 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 79afa4f81f..0b25387375 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 @@ -73,6 +73,7 @@ public final class EmulationActivity extends AppCompatActivity private boolean mDeviceHasTouchScreen; private boolean mMenuVisible; + private static boolean sIgnoreLaunchRequests = false; private static boolean sIsGameCubeGame; private boolean activityRecreated; @@ -196,6 +197,11 @@ public final class EmulationActivity extends AppCompatActivity public static void launch(FragmentActivity activity, GameFile gameFile) { + if (sIgnoreLaunchRequests) + return; + + sIgnoreLaunchRequests = true; + Intent launcher = new Intent(activity, EmulationActivity.class); launcher.putExtra(EXTRA_SELECTED_GAMES, scanForSecondDisc(gameFile)); @@ -207,6 +213,11 @@ public final class EmulationActivity extends AppCompatActivity public static void launchFile(FragmentActivity activity, String[] filePaths) { + if (sIgnoreLaunchRequests) + return; + + sIgnoreLaunchRequests = true; + Intent launcher = new Intent(activity, EmulationActivity.class); launcher.putExtra(EXTRA_SELECTED_GAMES, filePaths); @@ -237,6 +248,11 @@ public final class EmulationActivity extends AppCompatActivity activity.startActivity(launcher); } + public static void stopIgnoringLaunchRequests() + { + sIgnoreLaunchRequests = false; + } + public static void clearWiimoteNewIniLinkedPreferences(Context context) { SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java index ebb4dd48ef..0315a9e133 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java @@ -411,6 +411,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C Log.debug("[EmulationFragment] Starting emulation thread."); NativeLibrary.Run(mGamePaths); } + EmulationActivity.stopIgnoringLaunchRequests(); }, "NativeEmulation"); emulationThread.start(); }