Merge changes I7c3a44cf,Iba8138d8 into udc-dev
* changes: Don't dismiss DetailDialog if activity is finishing Add flags for background launch.
This commit is contained in:
committed by
Android (Google) Code Review
commit
33b6a6571c
@@ -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
|
||||
@@ -96,7 +98,9 @@ class DetailDialog(
|
||||
activityContext,
|
||||
0 /* enterResId */,
|
||||
0 /* exitResId */
|
||||
)
|
||||
).setPendingIntentBackgroundActivityStartMode(MODE_BACKGROUND_ACTIVITY_START_ALLOWED)
|
||||
options.isPendingIntentBackgroundActivityLaunchAllowedByPermission = true
|
||||
|
||||
taskView.startActivity(
|
||||
pendingIntent,
|
||||
fillInIntent,
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user