Don't dismiss DetailDialog if activity is finishing

If the task is released when the containing activity is finishing, do
not dismiss the dialog. It will be dismissed by itself. See b/248562161.

Test: dialog is dismissed
Fixes: 210990128
Change-Id: I7c3a44cff6e0dab7f23205a8d454a293800af3b3
This commit is contained in:
Fabián Kozynski
2023-04-24 16:35:17 -04:00
parent dd623d85a9
commit 9db0ca4e84

View File

@@ -16,6 +16,7 @@
package com.android.systemui.controls.ui
import android.app.Activity
import android.app.ActivityOptions
import android.app.ActivityTaskManager
import android.app.ActivityTaskManager.INVALID_TASK_ID
@@ -217,6 +218,12 @@ class DetailDialog(
if (!isShowing()) return
taskView.release()
val isActivityFinishing =
(activityContext as? Activity)?.let { it.isFinishing || it.isDestroyed }
if (isActivityFinishing == true) {
// Don't dismiss the dialog if the activity is finishing, it will get removed
return
}
super.dismiss()
}
}