Loading packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt +11 −1 Original line number Diff line number Diff line Loading @@ -16,9 +16,11 @@ 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 import android.app.ComponentOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED import android.app.Dialog import android.app.PendingIntent import android.content.ComponentName Loading Loading @@ -96,7 +98,9 @@ class DetailDialog( activityContext, 0 /* enterResId */, 0 /* exitResId */ ) ).setPendingIntentBackgroundActivityStartMode(MODE_BACKGROUND_ACTIVITY_START_ALLOWED) options.isPendingIntentBackgroundActivityLaunchAllowedByPermission = true taskView.startActivity( pendingIntent, fillInIntent, Loading Loading @@ -214,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() } } packages/SystemUI/tests/src/com/android/systemui/controls/ui/DetailDialogTest.kt +23 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.controls.ui import android.app.ActivityOptions import android.app.PendingIntent import android.testing.AndroidTestingRunner import android.testing.TestableLooper Loading @@ -24,7 +25,10 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.broadcast.BroadcastSender import com.android.systemui.plugins.ActivityStarter import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.mockito.argumentCaptor import com.android.systemui.util.mockito.capture import com.android.wm.shell.taskview.TaskView import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading Loading @@ -69,6 +73,25 @@ class DetailDialogTest : SysuiTestCase() { verify(taskView).startActivity(eq(pendingIntent), any(), any(), any()) } @Test fun testActivityOptionsAllowBal() { // GIVEN the dialog is created with a PendingIntent val dialog = createDialog(pendingIntent) // WHEN the TaskView is initialized dialog.stateCallback.onInitialized() val optionsCaptor = argumentCaptor<ActivityOptions>() // THEN the ActivityOptions have the correct flags verify(taskView).startActivity(any(), any(), capture(optionsCaptor), any()) assertThat(optionsCaptor.value.pendingIntentBackgroundActivityStartMode) .isEqualTo(ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED) assertThat(optionsCaptor.value.isPendingIntentBackgroundActivityLaunchAllowedByPermission) .isTrue() } private fun createDialog(pendingIntent: PendingIntent): DetailDialog { return DetailDialog( mContext, Loading Loading
packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt +11 −1 Original line number Diff line number Diff line Loading @@ -16,9 +16,11 @@ 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 import android.app.ComponentOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED import android.app.Dialog import android.app.PendingIntent import android.content.ComponentName Loading Loading @@ -96,7 +98,9 @@ class DetailDialog( activityContext, 0 /* enterResId */, 0 /* exitResId */ ) ).setPendingIntentBackgroundActivityStartMode(MODE_BACKGROUND_ACTIVITY_START_ALLOWED) options.isPendingIntentBackgroundActivityLaunchAllowedByPermission = true taskView.startActivity( pendingIntent, fillInIntent, Loading Loading @@ -214,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() } }
packages/SystemUI/tests/src/com/android/systemui/controls/ui/DetailDialogTest.kt +23 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.controls.ui import android.app.ActivityOptions import android.app.PendingIntent import android.testing.AndroidTestingRunner import android.testing.TestableLooper Loading @@ -24,7 +25,10 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.broadcast.BroadcastSender import com.android.systemui.plugins.ActivityStarter import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.mockito.argumentCaptor import com.android.systemui.util.mockito.capture import com.android.wm.shell.taskview.TaskView import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading Loading @@ -69,6 +73,25 @@ class DetailDialogTest : SysuiTestCase() { verify(taskView).startActivity(eq(pendingIntent), any(), any(), any()) } @Test fun testActivityOptionsAllowBal() { // GIVEN the dialog is created with a PendingIntent val dialog = createDialog(pendingIntent) // WHEN the TaskView is initialized dialog.stateCallback.onInitialized() val optionsCaptor = argumentCaptor<ActivityOptions>() // THEN the ActivityOptions have the correct flags verify(taskView).startActivity(any(), any(), capture(optionsCaptor), any()) assertThat(optionsCaptor.value.pendingIntentBackgroundActivityStartMode) .isEqualTo(ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED) assertThat(optionsCaptor.value.isPendingIntentBackgroundActivityLaunchAllowedByPermission) .isTrue() } private fun createDialog(pendingIntent: PendingIntent): DetailDialog { return DetailDialog( mContext, Loading