Android: Reload the config after getting storage permission, and ask immediately. Should help #10670

This commit is contained in:
Henrik Rydgård committed 2018-03-24 12:52:51 +01:00
1 parent 7761d2366b
commit fb15208777
4 files changed
+27 -27

No files matched your search

+20 -4
View File
@@ -138,6 +138,8 @@ static bool isOuya;
static bool resized = false;
static bool restarting = false;
static bool askedForStoragePermission = false;
struct PendingMessage {
std::string msg;
std::string value;
@@ -369,6 +371,9 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
g_Config.AddSearchPath(user_data_path);
g_Config.AddSearchPath(g_Config.memStickDirectory + "PSP/SYSTEM/");
g_Config.SetDefaultPath(g_Config.memStickDirectory + "PSP/SYSTEM/");
// Note that if we don't have storage permission here, loading the config will
// fail and it will be set to the default. Later, we load again when we get permission.
g_Config.Load();
g_Config.externalDirectory = external_dir;
#endif
@@ -384,6 +389,8 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
File::CreateDir((g_Config.memStickDirectory + "PSP/GAME").c_str());
#endif
const char *fileToLog = 0;
const char *stateToLoad = 0;
@@ -510,6 +517,13 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
else
i18nrepo.LoadIni(g_Config.sLanguageIni, langOverridePath);
if (System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS)) {
if (System_GetPermissionStatus(SYSTEM_PERMISSION_STORAGE) != PERMISSION_STATUS_GRANTED) {
System_AskForPermission(SYSTEM_PERMISSION_STORAGE);
}
}
I18NCategory *des = GetI18NCategory("DesktopUI");
// Note to translators: do not translate this/add this to PPSSPP-lang's files.
// It's intended to be custom for every user.
@@ -925,6 +939,12 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) {
Core_SetPowerSaving(value != "false");
}
if (msg == "permission_granted" && value == "storage") {
// We must have failed to load the config before, so load it now to avoid overwriting the old config
// with a freshly generated one.
ILOG("Reloading config after storage permission grant.");
g_Config.Load();
}
}
void NativeUpdate() {
@@ -1130,10 +1150,6 @@ void NativeShutdown() {
// I think we handle most globals correctly or correct-enough now.
}
void NativePermissionStatus(SystemPermission permission, PermissionStatus status) {
// TODO: Send this through the screen system? Nicer than listening to string messages
}
void PushNewGpsData(float latitude, float longitude, float altitude, float speed, float bearing, long long time) {
GPS::setGpsData(latitude, longitude, altitude, speed, bearing, time);
}