Opt in systemui for BAL

We see some calls from android.uid.systemui being blocked in our logs. Unfortunately we cannot exactly identify the source of these calls, but in a manual review we identified some invocations that may be affected. To avoid activities being blocked and functionality regression, this change will revert those code paths back to T behavior by opting into allowing the launch if the PI sender (systemUI) is in the foreground. Maybe not all these changes are required, but any missed change might cause functionality to break, while extra changes have no functional impact.

The change is relatively safe since it won't block anything, only allow the launch, as it was allowed by default in T.

Change-Id: Ide20c906e9852ac49abbc8af8570313a8f5f965e
Test: compile + presubmit
Bug: 284486752
This commit is contained in:
Achim Thesmann
2023-06-24 00:30:03 +00:00
parent e5cd5624dd
commit 17f7c255e9
11 changed files with 41 additions and 7 deletions

View File

@@ -1253,6 +1253,9 @@ class MediaDataManager(
return try {
val options = BroadcastOptions.makeBasic()
options.setInteractive(true)
options.setPendingIntentBackgroundActivityStartMode(
BroadcastOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED
)
intent.send(options.toBundle())
true
} catch (e: PendingIntent.CanceledException) {

View File

@@ -23,6 +23,7 @@ import static com.android.systemui.media.controls.models.recommendation.Smartspa
import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.animation.AnimatorSet;
import android.app.ActivityOptions;
import android.app.BroadcastOptions;
import android.app.PendingIntent;
import android.app.WallpaperColors;
@@ -535,7 +536,10 @@ public class MediaControlPanel {
mLockscreenUserManager.getCurrentUserId());
if (showOverLockscreen) {
try {
clickIntent.send();
ActivityOptions opts = ActivityOptions.makeBasic();
opts.setPendingIntentBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
clickIntent.send(opts.toBundle());
} catch (PendingIntent.CanceledException e) {
Log.e(TAG, "Pending intent for " + key + " was cancelled");
}
@@ -684,6 +688,8 @@ public class MediaControlPanel {
try {
BroadcastOptions options = BroadcastOptions.makeBasic();
options.setInteractive(true);
options.setPendingIntentBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
deviceIntent.send(options.toBundle());
} catch (PendingIntent.CanceledException e) {
Log.e(TAG, "Device pending intent was canceled");

View File

@@ -71,6 +71,8 @@ public class ActionProxyReceiver extends BroadcastReceiver {
ActivityOptions opts = ActivityOptions.makeBasic();
opts.setDisallowEnterPictureInPictureWhileLaunching(
intent.getBooleanExtra(EXTRA_DISALLOW_ENTER_PIP, false));
opts.setPendingIntentBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
try {
actionIntent.send(context, 0, null, null, null, null, opts.toBundle());
if (intent.getBooleanExtra(ScreenshotController.EXTRA_OVERRIDE_TRANSITION, false)) {

View File

@@ -99,6 +99,8 @@ public class OverlayActionChip extends FrameLayout {
try {
BroadcastOptions options = BroadcastOptions.makeBasic();
options.setInteractive(true);
options.setPendingIntentBackgroundActivityStartMode(
BroadcastOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
intent.send(options.toBundle());
finisher.run();
} catch (PendingIntent.CanceledException e) {

View File

@@ -55,7 +55,8 @@ public class SmartActionsReceiver extends BroadcastReceiver {
Log.d(TAG, "Executing smart action [" + actionType + "]:" + pendingIntent.getIntent());
}
ActivityOptions opts = ActivityOptions.makeBasic();
opts.setPendingIntentBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
try {
pendingIntent.send(context, 0, fillIn, null, null, null, opts.toBundle());
} catch (PendingIntent.CanceledException e) {

View File

@@ -19,6 +19,7 @@ import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER
import static com.android.systemui.DejankUtils.whitelistIpcs;
import android.app.ActivityOptions;
import android.app.KeyguardManager;
import android.app.Notification;
import android.app.admin.DevicePolicyManager;
@@ -158,7 +159,11 @@ public class NotificationLockscreenUserManagerImpl implements
final String notificationKey = intent.getStringExtra(Intent.EXTRA_INDEX);
if (intentSender != null) {
try {
mContext.startIntentSender(intentSender, null, 0, 0, 0);
ActivityOptions options = ActivityOptions.makeBasic();
options.setPendingIntentBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
mContext.startIntentSender(intentSender, null, 0, 0, 0,
options.toBundle());
} catch (IntentSender.SendIntentException e) {
/* ignore */
}

View File

@@ -42,6 +42,7 @@ import static com.android.systemui.statusbar.phone.BarTransitions.TransitionMode
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityOptions;
import android.app.IWallpaperManager;
import android.app.KeyguardManager;
import android.app.Notification;
@@ -1773,7 +1774,10 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
EventLog.writeEvent(EventLogTags.SYSUI_HEADS_UP_ESCALATION,
sbn.getKey());
wakeUpForFullScreenIntent();
notification.fullScreenIntent.send();
ActivityOptions opts = ActivityOptions.makeBasic();
opts.setPendingIntentBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
notification.fullScreenIntent.send(opts.toBundle());
entry.notifyFullScreenIntentLaunched();
} catch (PendingIntent.CanceledException e) {
}

View File

@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.policy
import android.app.ActivityOptions
import android.app.Notification
import android.app.PendingIntent
import android.app.RemoteInput
@@ -275,7 +276,10 @@ class RemoteInputViewControllerImpl @Inject constructor(
entry.sbn.instanceId)
try {
pendingIntent.send(view.context, 0, intent)
val options = ActivityOptions.makeBasic()
options.setPendingIntentBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED)
pendingIntent.send(view.context, 0, intent, null, null, null, options.toBundle())
} catch (e: PendingIntent.CanceledException) {
Log.i(TAG, "Unable to send remote input result", e)
uiEventLogger.logWithInstanceId(

View File

@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.policy
import android.app.ActivityOptions
import android.app.Notification
import android.app.Notification.Action.SEMANTIC_ACTION_MARK_CONVERSATION_AS_PRIORITY
import android.app.PendingIntent
@@ -491,7 +492,11 @@ class SmartReplyInflaterImpl @Inject constructor(
entry.setHasSentReply()
try {
val intent = createRemoteInputIntent(smartReplies, choice)
smartReplies.pendingIntent.send(context, 0, intent)
val opts = ActivityOptions.makeBasic()
opts.setPendingIntentBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED)
smartReplies.pendingIntent.send(context, 0, intent, /* onFinished */null,
/* handler */ null, /* requiredPermission */ null, opts.toBundle())
} catch (e: PendingIntent.CanceledException) {
Log.w(TAG, "Unable to send smart reply", e)
}

View File

@@ -103,6 +103,8 @@ public class TvNotificationAdapter extends RecyclerView.Adapter<RecyclerView.Vie
if (mPendingIntent != null) {
BroadcastOptions options = BroadcastOptions.makeBasic();
options.setInteractive(true);
options.setPendingIntentBackgroundActivityStartMode(
BroadcastOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
mPendingIntent.send(options.toBundle());
}
} catch (PendingIntent.CanceledException e) {

View File

@@ -1793,7 +1793,7 @@ public class MediaControlPanelTest : SysuiTestCase() {
// THEN it sends the PendingIntent without dismissing keyguard first,
// and does not use the Intent directly (see b/271845008)
captor.value.onClick(viewHolder.player)
verify(pendingIntent).send()
verify(pendingIntent).send(any(Bundle::class.java))
verify(pendingIntent, never()).getIntent()
verify(activityStarter, never()).postStartActivityDismissingKeyguard(eq(clickIntent), any())
}