Merge changes I7c3a44cf,Iba8138d8 into udc-dev am: 33b6a6571c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22854606 Change-Id: Ie72200967b1ad47fbfefc747f027cd521ad781f3 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -16,9 +16,11 @@
|
|||||||
|
|
||||||
package com.android.systemui.controls.ui
|
package com.android.systemui.controls.ui
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.app.ActivityOptions
|
import android.app.ActivityOptions
|
||||||
import android.app.ActivityTaskManager
|
import android.app.ActivityTaskManager
|
||||||
import android.app.ActivityTaskManager.INVALID_TASK_ID
|
import android.app.ActivityTaskManager.INVALID_TASK_ID
|
||||||
|
import android.app.ComponentOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
@@ -96,7 +98,9 @@ class DetailDialog(
|
|||||||
activityContext,
|
activityContext,
|
||||||
0 /* enterResId */,
|
0 /* enterResId */,
|
||||||
0 /* exitResId */
|
0 /* exitResId */
|
||||||
)
|
).setPendingIntentBackgroundActivityStartMode(MODE_BACKGROUND_ACTIVITY_START_ALLOWED)
|
||||||
|
options.isPendingIntentBackgroundActivityLaunchAllowedByPermission = true
|
||||||
|
|
||||||
taskView.startActivity(
|
taskView.startActivity(
|
||||||
pendingIntent,
|
pendingIntent,
|
||||||
fillInIntent,
|
fillInIntent,
|
||||||
@@ -214,6 +218,12 @@ class DetailDialog(
|
|||||||
if (!isShowing()) return
|
if (!isShowing()) return
|
||||||
taskView.release()
|
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()
|
super.dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.controls.ui
|
package com.android.systemui.controls.ui
|
||||||
|
|
||||||
|
import android.app.ActivityOptions
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.testing.AndroidTestingRunner
|
import android.testing.AndroidTestingRunner
|
||||||
import android.testing.TestableLooper
|
import android.testing.TestableLooper
|
||||||
@@ -24,7 +25,10 @@ import com.android.systemui.SysuiTestCase
|
|||||||
import com.android.systemui.broadcast.BroadcastSender
|
import com.android.systemui.broadcast.BroadcastSender
|
||||||
import com.android.systemui.plugins.ActivityStarter
|
import com.android.systemui.plugins.ActivityStarter
|
||||||
import com.android.systemui.statusbar.policy.KeyguardStateController
|
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.android.wm.shell.taskview.TaskView
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
@@ -69,6 +73,25 @@ class DetailDialogTest : SysuiTestCase() {
|
|||||||
verify(taskView).startActivity(eq(pendingIntent), any(), any(), any())
|
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 {
|
private fun createDialog(pendingIntent: PendingIntent): DetailDialog {
|
||||||
return DetailDialog(
|
return DetailDialog(
|
||||||
mContext,
|
mContext,
|
||||||
|
|||||||
Reference in New Issue
Block a user