Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Always run HandleInit logic on app start #6275

Merged
merged 3 commits into from
Dec 28, 2017

Conversation

JosJuice
Copy link
Member

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?

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.
Copy link
Contributor

@mahdihijazi mahdihijazi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree with these changes, I totally missed the case if the app is killed completely . Everything looks fine.

@leoetlino leoetlino merged commit 257da99 into dolphin-emu:master Dec 28, 2017
@JosJuice JosJuice deleted the android-reliable-init branch December 28, 2017 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants