mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #19142 from hrydgard/fix-shortcut-launch
Android: Fix issue where shortcuts wouldn't override the currently running game.
This commit is contained in:
commit
dbcac0e48c
6 changed files with 34 additions and 6 deletions
|
@ -537,6 +537,11 @@ void EmuScreen::sendMessage(UIMessage message, const char *value) {
|
|||
return;
|
||||
}
|
||||
} else if (message == UIMessage::REQUEST_GAME_BOOT) {
|
||||
// TODO: Ignore or not if it's the same game that's already running?
|
||||
if (gamePath_ == Path(value)) {
|
||||
WARN_LOG(LOADER, "Game already running, ignoring");
|
||||
return;
|
||||
}
|
||||
const char *ext = strrchr(value, '.');
|
||||
if (ext != nullptr && !strcmp(ext, ".ppst")) {
|
||||
SaveState::Load(Path(value), -1, &AfterStateBoot);
|
||||
|
|
|
@ -456,7 +456,7 @@ public:
|
|||
// Mark everything requested as done, so
|
||||
std::unique_lock<std::mutex> lock(info_->lock);
|
||||
info_->MarkReadyNoLock(flags_);
|
||||
ERROR_LOG(LOADER, "Failed getting game info.");
|
||||
ERROR_LOG(LOADER, "Failed getting game info for %s", info_->GetFilePath().ToVisualString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,6 +109,10 @@ public:
|
|||
std::string GetTitle();
|
||||
void SetTitle(const std::string &newTitle);
|
||||
|
||||
const Path &GetFilePath() const {
|
||||
return filePath_;
|
||||
}
|
||||
|
||||
bool Ready(GameInfoFlags flags) {
|
||||
std::unique_lock<std::mutex> guard(lock);
|
||||
// Avoid the operator, we want to check all the bits.
|
||||
|
|
|
@ -791,6 +791,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
|
|||
std::vector<std::string> temp;
|
||||
args.push_back(app_name.c_str());
|
||||
if (!shortcut_param.empty()) {
|
||||
EARLY_LOG("NativeInit shortcut param %s", shortcut_param.c_str());
|
||||
parse_args(temp, shortcut_param);
|
||||
for (const auto &arg : temp) {
|
||||
args.push_back(arg.c_str());
|
||||
|
@ -799,7 +800,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
|
|||
|
||||
NativeInit((int)args.size(), &args[0], user_data_path.c_str(), externalStorageDir.c_str(), cacheDir.c_str());
|
||||
|
||||
// In debug mode, don't allow creating software Vulkan devices (reject by VulkaMaybeAvailable).
|
||||
// In debug mode, don't allow creating software Vulkan devices (reject by VulkanMaybeAvailable).
|
||||
// Needed for #16931.
|
||||
#ifdef NDEBUG
|
||||
if (!VulkanMayBeAvailable()) {
|
||||
|
@ -1321,9 +1322,9 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_accelerometer(JNIEnv *,
|
|||
NativeAccelerometer(x, y, z);
|
||||
}
|
||||
|
||||
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendMessageFromJava(JNIEnv *env, jclass, jstring message, jstring param) {
|
||||
std::string msg = GetJavaString(env, message);
|
||||
std::string prm = GetJavaString(env, param);
|
||||
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendMessageFromJava(JNIEnv *env, jclass, jstring jmessage, jstring jparam) {
|
||||
std::string msg = GetJavaString(env, jmessage);
|
||||
std::string prm = GetJavaString(env, jparam);
|
||||
|
||||
// A bit ugly, see InputDeviceState.java.
|
||||
static InputDeviceID nextInputDeviceID = DEVICE_ID_ANY;
|
||||
|
@ -1366,6 +1367,13 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendMessageFromJava(JNI
|
|||
System_PostUIMessage(UIMessage::POWER_SAVING, prm);
|
||||
} else if (msg == "exception") {
|
||||
g_OSD.Show(OSDType::MESSAGE_ERROR, std::string("Java Exception"), prm, 10.0f);
|
||||
} else if (msg == "shortcutParam") {
|
||||
if (prm.empty()) {
|
||||
WARN_LOG(SYSTEM, "shortcutParam empty");
|
||||
return;
|
||||
}
|
||||
INFO_LOG(SYSTEM, "shortcutParam received: %s", prm.c_str());
|
||||
System_PostUIMessage(UIMessage::REQUEST_GAME_BOOT, StripQuotes(prm));
|
||||
} else {
|
||||
ERROR_LOG(SYSTEM, "Got unexpected message from Java, ignoring: %s / %s", msg.c_str(), prm.c_str());
|
||||
}
|
||||
|
|
|
@ -443,6 +443,7 @@ public abstract class NativeActivity extends Activity {
|
|||
String languageRegion = Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry();
|
||||
String shortcut = overrideShortcutParam == null ? shortcutParam : overrideShortcutParam;
|
||||
overrideShortcutParam = null;
|
||||
shortcutParam = null;
|
||||
|
||||
NativeApp.audioConfig(optimalFramesPerBuffer, optimalSampleRate);
|
||||
NativeApp.init(model, deviceType, languageRegion, apkFilePath, dataDir, extStorageDir, externalFilesDir, nativeLibDir, additionalStorageDirs, cacheDir, shortcut, Build.VERSION.SDK_INT, Build.BOARD);
|
||||
|
@ -594,6 +595,7 @@ public abstract class NativeActivity extends Activity {
|
|||
// whether to start at 1x or 2x.
|
||||
sizeManager.updateDisplayMeasurements();
|
||||
|
||||
boolean wasInitialized = initialized;
|
||||
if (!initialized) {
|
||||
Initialize();
|
||||
initialized = true;
|
||||
|
@ -661,6 +663,13 @@ public abstract class NativeActivity extends Activity {
|
|||
Log.i(TAG, "setcontentview after");
|
||||
startRenderLoopThread();
|
||||
}
|
||||
|
||||
if (shortcutParam != null && shortcutParam.length() > 0) {
|
||||
Log.i(TAG, "Got shortcutParam in onCreate on secondary run: " + shortcutParam);
|
||||
// Make sure we only send it once.
|
||||
NativeApp.sendMessageFromJava("shortcutParam", shortcutParam);
|
||||
shortcutParam = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -99,7 +99,9 @@ public class PpssppActivity extends NativeActivity {
|
|||
if (data != null) {
|
||||
String path = data.toString();
|
||||
Log.i(TAG, "Found Shortcut Parameter in data: " + path);
|
||||
super.setShortcutParam("\"" + path.replace("\\", "\\\\").replace("\"", "\\\"") + "\"");
|
||||
String escaped = "\"" + path.replace("\\", "\\\\").replace("\"", "\\\"") + "\"";
|
||||
Log.i(TAG, "Escaped: " + escaped);
|
||||
super.setShortcutParam(escaped);
|
||||
// Toast.makeText(getApplicationContext(), path, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
String param = getIntent().getStringExtra(SHORTCUT_EXTRA_KEY);
|
||||
|
|
Loading…
Add table
Reference in a new issue