Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f3f617c4 authored by Kai Li's avatar Kai Li
Browse files

Use ActivityOptions for ambient cue pending intent start

This fixes the "BAL blocked" error when we try to start an activity from an ambient cue.

Change-Id: Ice52b86c91083e0bc53df0fe1a795efc9ee99225
Bug: 403422950
Flag: com.android.systemui.enable_underlay
Test: atest AmbientCueRepositoryTest
parent a1e4d8d6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -245,7 +245,7 @@ class AmbientCueRepositoryTest : SysuiTestCase() {
            val action: ActionModel = actions!!.first()
            action.onPerformAction()
            runCurrent()
            verify(pendingIntent).send()
            verify(pendingIntent).send(any<Bundle>())
        }

    @Test
+16 −1
Original line number Diff line number Diff line
@@ -16,7 +16,10 @@

package com.android.systemui.ambientcue.data.repository

import android.app.ActivityOptions
import android.app.ActivityTaskManager
import android.app.BroadcastOptions
import android.app.PendingIntent
import android.app.assist.ActivityId
import android.app.smartspace.SmartspaceConfig
import android.app.smartspace.SmartspaceManager
@@ -148,7 +151,19 @@ constructor(
                                                activityId.taskId,
                                            )
                                        } else if (pendingIntent != null) {
                                            pendingIntent.send()
                                            val options = BroadcastOptions.makeBasic()
                                            options.isInteractive = true
                                            options.pendingIntentBackgroundActivityStartMode =
                                                ActivityOptions
                                                    .MODE_BACKGROUND_ACTIVITY_START_ALLOWED
                                            try {
                                                pendingIntent.send(options.toBundle())
                                            } catch (e: PendingIntent.CanceledException) {
                                                Log.e(
                                                    TAG,
                                                    "pending intent of $pendingIntent was canceled",
                                                )
                                            }
                                        } else if (intent != null) {
                                            activityStarter.startActivity(intent, false)
                                        }