Merge branch 'fix-554' into 'master'

Work around dead activity issue in AppDetails

It seems like install() sometimes runs when the AppDetails activity is
finished or finishing. This results in the windows (dialogs) failing to
show, and a BadTokenException to fire:

    android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@d6e3570 is not valid; is your activity running?

This seems to be the culprit:

    at org.fdroid.fdroid.AppDetails.install(AppDetails.java:840)
    at org.fdroid.fdroid.AppDetails$AppDetailsListFragment.install(AppDetails.java:1657)
    at org.fdroid.fdroid.AppDetails$AppDetailsListFragment.onListItemClick(AppDetails.java:1721)

Apparently, you can check whether an activity/context is being finished:

https://stackoverflow.com/questions/7811993/error-binderproxy45d459c0-is-not-valid-is-your-activity-running

I cannot reproduce this issue, thus can't say whether this fixes it or
not. Either way, it can't hurt to try. This can be reverted if we see
ACRA reports of this in the future, and the issue reopened.

Fixes #565.

See merge request !204
This commit is contained in:
Peter Serwylo 2016-02-13 21:49:22 +00:00
commit 88b4e1ff31

View File

@ -798,6 +798,10 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
// Install the version of this app denoted by 'app.curApk'. // Install the version of this app denoted by 'app.curApk'.
@Override @Override
public void install(final Apk apk) { public void install(final Apk apk) {
if (isFinishing()) {
return;
}
// Ignore call if another download is running. // Ignore call if another download is running.
if (downloadHandler != null && !downloadHandler.isComplete()) if (downloadHandler != null && !downloadHandler.isComplete())
return; return;