diff options
author | Ciesla, Jakub 2 (EXT) <jakub.ciesla@sonymobile.com> | 2015-10-05 13:51:57 +0200 |
---|---|---|
committer | Zoran Jovanovic <zoran.jovanovic@sonymobile.com> | 2015-10-07 18:55:39 +0200 |
commit | 3620a3233ae2fd1fa2fa8dd30266006b243ec188 (patch) | |
tree | 19c84efb07f5945f73732f073d560feae657fb8e /src/com/android | |
parent | 2050f1037683769c60d2065fa5745bf0afc457cd (diff) | |
download | android_packages_apps_PackageInstaller-3620a3233ae2fd1fa2fa8dd30266006b243ec188.tar.gz android_packages_apps_PackageInstaller-3620a3233ae2fd1fa2fa8dd30266006b243ec188.tar.bz2 android_packages_apps_PackageInstaller-3620a3233ae2fd1fa2fa8dd30266006b243ec188.zip |
Fix crash in OnDismiss
Steps to reproduce the crash are as follows:
1. Launch Settings >> Apps
2. Select an app to uninstall
3. Select “uninstall” then confirmation comes up
4. Tap Home key and launch Settings apps again
5. You see app crash notification
This was due to DialogFragment.onDismiss() called after the
underlying activity was stopped and detached.
In other cases (cancel, delete, back key) there is no problem.
For home key scenario it is enough to check, if dialog is
currently added to its activity. Fragment.isAdded() checks
internally, if its activity is not null and if it's added to this
activity.
BUG: https://code.google.com/p/android/issues/detail?id=144163
Change-Id: I3cb75ec392fd68f131ec65e4eafae2351e95ea25
Diffstat (limited to 'src/com/android')
-rwxr-xr-x | src/com/android/packageinstaller/UninstallerActivity.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/com/android/packageinstaller/UninstallerActivity.java b/src/com/android/packageinstaller/UninstallerActivity.java index e277d48f..f1afe424 100755 --- a/src/com/android/packageinstaller/UninstallerActivity.java +++ b/src/com/android/packageinstaller/UninstallerActivity.java @@ -109,7 +109,9 @@ public class UninstallerActivity extends Activity { @Override public void onDismiss(DialogInterface dialog) { super.onDismiss(dialog); - getActivity().finish(); + if (isAdded()) { + getActivity().finish(); + } } } @@ -127,9 +129,11 @@ public class UninstallerActivity extends Activity { @Override public void onDismiss(DialogInterface dialog) { super.onDismiss(dialog); - ((UninstallerActivity) getActivity()).dispatchAborted(); - getActivity().setResult(Activity.RESULT_FIRST_USER); - getActivity().finish(); + if (isAdded()) { + ((UninstallerActivity) getActivity()).dispatchAborted(); + getActivity().setResult(Activity.RESULT_FIRST_USER); + getActivity().finish(); + } } } |