mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Android: Fix #9697 where we'd hang if we lacked permission and got a filename as a command.
This commit is contained in:
parent
f7184c1753
commit
b1fce1c61a
3 changed files with 35 additions and 11 deletions
|
@ -43,6 +43,7 @@
|
|||
#endif
|
||||
|
||||
#include "base/display.h"
|
||||
#include "base/timeutil.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/NativeApp.h"
|
||||
#include "file/vfs.h"
|
||||
|
@ -394,6 +395,8 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
|||
const char *fileToLog = 0;
|
||||
const char *stateToLoad = 0;
|
||||
|
||||
bool gotBootFilename = false;
|
||||
|
||||
// Parse command line
|
||||
LogTypes::LOG_LEVELS logLevel = LogTypes::LINFO;
|
||||
for (int i = 1; i < argc; i++) {
|
||||
|
@ -435,18 +438,34 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
if (boot_filename.empty()) {
|
||||
ILOG("Boot filename found in args: %s", argv[i]);
|
||||
boot_filename = argv[i];
|
||||
#ifdef _WIN32
|
||||
boot_filename = ReplaceAll(boot_filename, "\\", "/");
|
||||
#endif
|
||||
skipLogo = true;
|
||||
// This parameter should be a boot filename. Only accept it if we
|
||||
// don't already have one.
|
||||
if (!gotBootFilename) {
|
||||
gotBootFilename = true;
|
||||
ILOG("Boot filename found in args: '%s'", argv[i]);
|
||||
|
||||
std::unique_ptr<FileLoader> fileLoader(ConstructFileLoader(boot_filename));
|
||||
if (!fileLoader->Exists()) {
|
||||
fprintf(stderr, "File not found: %s\n", boot_filename.c_str());
|
||||
exit(1);
|
||||
bool okToLoad = 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.");
|
||||
okToLoad = false;
|
||||
} else {
|
||||
ILOG("Storage permission granted.");
|
||||
}
|
||||
}
|
||||
if (okToLoad) {
|
||||
boot_filename = argv[i];
|
||||
#ifdef _WIN32
|
||||
boot_filename = ReplaceAll(boot_filename, "\\", "/");
|
||||
#endif
|
||||
skipLogo = true;
|
||||
|
||||
std::unique_ptr<FileLoader> fileLoader(ConstructFileLoader(boot_filename));
|
||||
if (!fileLoader->Exists()) {
|
||||
fprintf(stderr, "File not found: %s\n", boot_filename.c_str());
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Can only boot one file");
|
||||
|
|
|
@ -600,6 +600,9 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
|
|||
|
||||
setCurrentThreadName("androidInit");
|
||||
|
||||
// Makes sure we get early permission grants.
|
||||
ProcessFrameCommands(env);
|
||||
|
||||
ILOG("NativeApp.init() -- begin");
|
||||
PROFILE_INIT();
|
||||
|
||||
|
|
|
@ -197,6 +197,8 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C
|
|||
// Let's start out granted if it was granted already.
|
||||
if (this.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
NativeApp.sendMessage("permission_granted", "storage");
|
||||
} else {
|
||||
NativeApp.sendMessage("permission_denied", "storage");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue