Android: Enforce that there's never more than one instance of PpssppActivity, listen to onNewIntent.

Fixes shortcut-launch in-game. Although need to add some better handling
for the paused case.
This commit is contained in:
Henrik Rydgård
2025-05-21 18:07:46 +02:00
parent 53f8c32309
commit 9cf5d1bc25
4 changed files with 31 additions and 13 deletions
+2 -1
View File
@@ -756,7 +756,8 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
} else if (gotoDeveloperTools) {
g_screenManager->switchScreen(new MainScreen());
g_screenManager->push(new DeveloperToolsScreen(Path()));
} else if (skipLogo) {
} else if (skipLogo && !boot_filename.empty()) {
INFO_LOG(Log::System, "Launching EmuScreen with boot filename '%s'", boot_filename.c_str());
g_screenManager->switchScreen(new EmuScreen(boot_filename));
} else {
g_screenManager->switchScreen(new LogoScreen(AfterLogoScreen::DEFAULT));
+1
View File
@@ -53,6 +53,7 @@
android:name=".PpssppActivity"
android:configChanges="locale|keyboard|keyboardHidden|navigation|uiMode"
android:theme="@style/ppsspp_style"
android:launchMode="singleInstance"
android:exported="true">
<!-- android:screenOrientation="landscape" -->
<intent-filter>
@@ -977,7 +977,7 @@ public abstract class NativeActivity extends Activity {
buffer += input.getDebugString();
}
if (buffer.isEmpty()) {
buffer = "(no devices)";
return "(no devices)";
}
return buffer;
} else {
@@ -85,30 +85,46 @@ public class PpssppActivity extends NativeActivity {
// In case app launched from homescreen shortcut, get shortcut parameter
// using Intent extra string. Intent extra will be null if launch normal
// (from app drawer or file explorer).
Intent intent = getIntent();
String param = parseIntent(getIntent());
if (param != null) {
Log.i(TAG, "Found Shortcut Parameter in data, passing on: " + param);
super.setShortcutParam(param);
}
super.onCreate(savedInstanceState);
}
private static String parseIntent(Intent intent) {
// String action = intent.getAction();
Uri data = intent.getData();
if (data != null) {
String path = data.toString();
Log.i(TAG, "Found Shortcut Parameter in data: " + path);
String escaped = "\"" + path.replace("\\", "\\\\").replace("\"", "\\\"") + "\"";
Log.i(TAG, "Escaped: " + escaped);
super.setShortcutParam(escaped);
// Do some unescaping. Not really sure why needed.
return "\"" + path.replace("\\", "\\\\").replace("\"", "\\\"") + "\"";
// Toast.makeText(getApplicationContext(), path, Toast.LENGTH_SHORT).show();
} else {
String param = getIntent().getStringExtra(SHORTCUT_EXTRA_KEY);
String args = getIntent().getStringExtra(ARGS_EXTRA_KEY);
String param = intent.getStringExtra(SHORTCUT_EXTRA_KEY);
String args = intent.getStringExtra(ARGS_EXTRA_KEY);
if (param != null) {
Log.i(TAG, "Found Shortcut Parameter in extra-data: " + param);
super.setShortcutParam("\"" + param.replace("\\", "\\\\").replace("\"", "\\\"") + "\"");
return "\"" + param.replace("\\", "\\\\").replace("\"", "\\\"") + "\"";
} else if (args != null) {
Log.i(TAG, "Found args parameter in extra-data: " + args);
super.setShortcutParam(args);
return args;
} else {
super.setShortcutParam("");
return null;
}
}
super.onCreate(savedInstanceState);
}
@Override
public void onNewIntent(Intent intent) {
String value = parseIntent(intent);
if (value != null) {
// TODO: Actually send a command to the native code to launch the new game.
Log.i(TAG, "NEW INTENT AT RUNTIME: " + value);
Log.i(TAG, "Posting a 'shortcutParam' message to the C++ code.");
NativeApp.sendMessageFromJava("shortcutParam", value);
}
}
// called by the C++ code through JNI. Dispatch anything we can't directly handle