Merge pull request #8860 from Ebola16/Emu

Android: Disallow multiple launcher activities
This commit is contained in:
Tilka 2020-06-16 19:38:55 +01:00 committed by GitHub
commit a2b7627d66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -73,6 +73,7 @@ public final class EmulationActivity extends AppCompatActivity
private boolean mDeviceHasTouchScreen; private boolean mDeviceHasTouchScreen;
private boolean mMenuVisible; private boolean mMenuVisible;
private static boolean sIgnoreLaunchRequests = false;
private static boolean sIsGameCubeGame; private static boolean sIsGameCubeGame;
private boolean activityRecreated; private boolean activityRecreated;
@ -196,6 +197,11 @@ public final class EmulationActivity extends AppCompatActivity
public static void launch(FragmentActivity activity, GameFile gameFile) public static void launch(FragmentActivity activity, GameFile gameFile)
{ {
if (sIgnoreLaunchRequests)
return;
sIgnoreLaunchRequests = true;
Intent launcher = new Intent(activity, EmulationActivity.class); Intent launcher = new Intent(activity, EmulationActivity.class);
launcher.putExtra(EXTRA_SELECTED_GAMES, scanForSecondDisc(gameFile)); 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) public static void launchFile(FragmentActivity activity, String[] filePaths)
{ {
if (sIgnoreLaunchRequests)
return;
sIgnoreLaunchRequests = true;
Intent launcher = new Intent(activity, EmulationActivity.class); Intent launcher = new Intent(activity, EmulationActivity.class);
launcher.putExtra(EXTRA_SELECTED_GAMES, filePaths); launcher.putExtra(EXTRA_SELECTED_GAMES, filePaths);
@ -237,6 +248,11 @@ public final class EmulationActivity extends AppCompatActivity
activity.startActivity(launcher); activity.startActivity(launcher);
} }
public static void stopIgnoringLaunchRequests()
{
sIgnoreLaunchRequests = false;
}
public static void clearWiimoteNewIniLinkedPreferences(Context context) public static void clearWiimoteNewIniLinkedPreferences(Context context)
{ {
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit(); SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();

View File

@ -411,6 +411,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
Log.debug("[EmulationFragment] Starting emulation thread."); Log.debug("[EmulationFragment] Starting emulation thread.");
NativeLibrary.Run(mGamePaths); NativeLibrary.Run(mGamePaths);
} }
EmulationActivity.stopIgnoringLaunchRequests();
}, "NativeEmulation"); }, "NativeEmulation");
emulationThread.start(); emulationThread.start();
} }