diff options
author | maxwelb <maxwelb@google.com> | 2017-11-13 18:58:45 -0800 |
---|---|---|
committer | zachh <zachh@google.com> | 2017-11-18 04:22:00 +0000 |
commit | 6d87dbcb3843d6c5adf5f6d82e4fd00cba6dd8e5 (patch) | |
tree | 0dd52d74168530e4f088c354d2ab3db679388f96 | |
parent | 85415fba82acabacef48e3c85355fa18e1f91f19 (diff) |
Fix crash caused by opening dialogs with a dead activity
This CL fixes crashes that are caused by opening the
PhoneDisambiguationDialogFragment after the associated activity is destroyed.
This is done by detecting when the activity is destroyed or finished.
Bug: 69133504
Test: PhoneNumberInteractionTest
PiperOrigin-RevId: 175623483
Change-Id: Ic639e9e9421205edcb5438d594bb144c6b09dd86
-rw-r--r-- | java/com/android/dialer/interactions/PhoneNumberInteraction.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/java/com/android/dialer/interactions/PhoneNumberInteraction.java b/java/com/android/dialer/interactions/PhoneNumberInteraction.java index 15c6ce899..5a6c34607 100644 --- a/java/com/android/dialer/interactions/PhoneNumberInteraction.java +++ b/java/com/android/dialer/interactions/PhoneNumberInteraction.java @@ -82,7 +82,7 @@ import java.util.List; */ public class PhoneNumberInteraction implements OnLoadCompleteListener<Cursor> { - private static final String TAG = PhoneNumberInteraction.class.getSimpleName(); + static final String TAG = PhoneNumberInteraction.class.getSimpleName(); /** The identifier for a permissions request if one is generated. */ public static final int REQUEST_READ_CONTACTS = 1; @@ -356,12 +356,19 @@ public class PhoneNumberInteraction implements OnLoadCompleteListener<Cursor> { } private void showDisambiguationDialog(ArrayList<PhoneItem> phoneList) { + // TODO(a bug): don't leak the activity final Activity activity = (Activity) mContext; + if (activity.isFinishing()) { + LogUtil.i("PhoneNumberInteraction.showDisambiguationDialog", "activity finishing"); + return; + } + if (activity.isDestroyed()) { // Check whether the activity is still running LogUtil.i("PhoneNumberInteraction.showDisambiguationDialog", "activity destroyed"); return; } + try { PhoneDisambiguationDialogFragment.show( activity.getFragmentManager(), |