Add flags for background launch.

With BAL restrictions, these flags are needed to be able to launch the
TaskView.

Test: manual, using test app
Test: atest DetailDialogTest
Fixes: 276785257
Change-Id: Iba8138d83e8053ee60343ae64cba47b27b5f5fd9
This commit is contained in:
Fabián Kozynski
2023-04-24 15:14:33 -04:00
parent 01b56bb057
commit dd623d85a9
2 changed files with 27 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ package com.android.systemui.controls.ui
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
@@ -96,7 +97,9 @@ class DetailDialog(
activityContext,
0 /* enterResId */,
0 /* exitResId */
)
).setPendingIntentBackgroundActivityStartMode(MODE_BACKGROUND_ACTIVITY_START_ALLOWED)
options.isPendingIntentBackgroundActivityLaunchAllowedByPermission = true
taskView.startActivity(
pendingIntent,
fillInIntent,

View File

@@ -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
@@ -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
@@ -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,