Android: Always run HandleInit logic on app start #6275
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: By "HandleInit" in this commit message, I mean the code that is in HandleInit in master except the part that launches EmulationActivity. In other words, I mean the call to SetUserDirectory and the call to DirectoryInitializationService.startService. Couldn't think of something more accurate to call that than "HandleInit"...
In master, HandleInit only runs when the main activity is launched. This is a problem if the app ends up being launched in some other way, such as resuming EmulationActivity after the app has been killed in order to reclaim memory. It's important that we run HandleInit, because otherwise the native code won't know where the User and Sys folders are.
In order to implement this, I'm dropping the ability to set a custom User folder in an intent. I don't think anyone is using that anyway. It's not impossible to support it, but I can't see a way to support it that doesn't involve something ugly like having code for calling HandleInit in every activity (or at least MainActivity + TvMainActivity + EmulationActivity, with more activities potentially needing it in the future if we expand the usage of native code for e.g. settings). If we want to support setting a custom user directory, we should consider another way to do it, such as a setting that's stored in getFilesDir() or getExternalStorageDirectory(). Intents are intended to control the behavior of a specific activity, not the whole app.
@mahdihijazi Any opinion?