From 56e15541106a28a1cf03088a6cef7dab9dc3a8c3 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Tue, 23 Dec 2014 11:30:31 -0800 Subject: Fix for clear call log dialog not being dismissed This CL fixes a bug that could result in the progress dialog that appears when clearing call logs to never be dismissed. The cause of this bug is a race condition that causes the original dialog fragment to be detached from the parent activity before the progress dialog is dismissed. If that happens, the progress dialog is never dismissed and stays on screen forever. This CL fixes this by assigning the activity to the dialog explicitly and retrieving it when trying to dismiss it. Bug: 18836384 Change-Id: I5f8941e13dc7eb962b23e828cf47bc64f2b1a2aa --- src/com/android/dialer/calllog/ClearCallLogDialog.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/com/android/dialer/calllog/ClearCallLogDialog.java b/src/com/android/dialer/calllog/ClearCallLogDialog.java index f4c75d10d..bef5010ec 100644 --- a/src/com/android/dialer/calllog/ClearCallLogDialog.java +++ b/src/com/android/dialer/calllog/ClearCallLogDialog.java @@ -16,6 +16,7 @@ package com.android.dialer.calllog; +import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; @@ -56,6 +57,7 @@ public class ClearCallLogDialog extends DialogFragment { final ProgressDialog progressDialog = ProgressDialog.show(getActivity(), getString(R.string.clearCallLogProgress_title), "", true, false); + progressDialog.setOwnerActivity(getActivity()); final AsyncTask task = new AsyncTask() { @Override protected Void doInBackground(Void... params) { @@ -67,7 +69,9 @@ public class ClearCallLogDialog extends DialogFragment { } @Override protected void onPostExecute(Void result) { - if (getActivity() == null || getActivity().isDestroyed()) { + final Activity activity = progressDialog.getOwnerActivity(); + + if (activity == null || activity.isDestroyed() || activity.isFinishing()) { return; } -- cgit v1.2.3