mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-26 00:45:49 +00:00
Android: Fix initial start from shortcut.
Fixes #10855. We have to wait for the permission request to complete.
This commit is contained in:
parent
0d677fff87
commit
895de164ed
@ -131,6 +131,34 @@ EmuScreen::EmuScreen(const std::string &filename)
|
||||
OnDevMenu.Handle(this, &EmuScreen::OnDevTools);
|
||||
}
|
||||
|
||||
bool EmuScreen::bootAllowStorage(const std::string &filename) {
|
||||
// No permissions needed. The easy life.
|
||||
if (filename.find("http://") == 0 || filename.find("https://") == 0)
|
||||
return true;
|
||||
if (!System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS))
|
||||
return true;
|
||||
|
||||
PermissionStatus status = System_GetPermissionStatus(SYSTEM_PERMISSION_STORAGE);
|
||||
switch (status) {
|
||||
case PERMISSION_STATUS_UNKNOWN:
|
||||
System_AskForPermission(SYSTEM_PERMISSION_STORAGE);
|
||||
return false;
|
||||
|
||||
case PERMISSION_STATUS_DENIED:
|
||||
stopRender_ = true;
|
||||
screenManager()->switchScreen(new MainScreen());
|
||||
System_SendMessage("event", "failstartgame");
|
||||
return false;
|
||||
|
||||
case PERMISSION_STATUS_PENDING:
|
||||
// Keep waiting.
|
||||
return false;
|
||||
|
||||
case PERMISSION_STATUS_GRANTED:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void EmuScreen::bootGame(const std::string &filename) {
|
||||
if (PSP_IsIniting()) {
|
||||
std::string error_string;
|
||||
@ -150,6 +178,10 @@ void EmuScreen::bootGame(const std::string &filename) {
|
||||
|
||||
SetBackgroundAudioGame("");
|
||||
|
||||
// Check permission status first, in case we came from a shortcut.
|
||||
if (!bootAllowStorage(filename))
|
||||
return;
|
||||
|
||||
//pre-emptive loading of game specific config if possible, to get all the settings
|
||||
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(nullptr, filename, 0);
|
||||
if (info && !info->id.empty()) {
|
||||
|
@ -54,6 +54,7 @@ protected:
|
||||
|
||||
private:
|
||||
void bootGame(const std::string &filename);
|
||||
bool bootAllowStorage(const std::string &filename);
|
||||
void bootComplete();
|
||||
void renderUI();
|
||||
void processAxis(const AxisInput &axis, int direction);
|
||||
|
@ -444,11 +444,16 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
ILOG("Boot filename found in args: '%s'", argv[i]);
|
||||
|
||||
bool okToLoad = true;
|
||||
bool okToCheck = true;
|
||||
if (System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS)) {
|
||||
PermissionStatus status = System_GetPermissionStatus(SYSTEM_PERMISSION_STORAGE);
|
||||
if (status != PERMISSION_STATUS_GRANTED) {
|
||||
ELOG("Storage permission not granted. Launching without argument.");
|
||||
if (status == PERMISSION_STATUS_DENIED) {
|
||||
ELOG("Storage permission denied. Launching without argument.");
|
||||
okToLoad = false;
|
||||
okToCheck = false;
|
||||
} else if (status != PERMISSION_STATUS_GRANTED) {
|
||||
ELOG("Storage permission not granted. Launching without argument check.");
|
||||
okToCheck = false;
|
||||
} else {
|
||||
ILOG("Storage permission granted.");
|
||||
}
|
||||
@ -459,7 +464,8 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
boot_filename = ReplaceAll(boot_filename, "\\", "/");
|
||||
#endif
|
||||
skipLogo = true;
|
||||
|
||||
}
|
||||
if (okToLoad && okToCheck) {
|
||||
std::unique_ptr<FileLoader> fileLoader(ConstructFileLoader(boot_filename));
|
||||
if (!fileLoader->Exists()) {
|
||||
fprintf(stderr, "File not found: %s\n", boot_filename.c_str());
|
||||
|
Loading…
x
Reference in New Issue
Block a user