summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author William Loh <wloh@google.com> 2024-05-23 14:20:01 -0700
committer William Loh <wloh@google.com> 2024-05-24 23:48:27 +0000
commit51208e1ca9f065d8ee79d27cd8c3a6903baa889c (patch)
tree9c1f9319fefa4ee082440e570725a975d7fecff9
parent2dc7b8b3d0ff0c4a23d7e72b34b70c1bcca4f164 (diff)
Opt in to BAL for Instant Apps
Explicityly opt in to background activity launch when creating PendingIntent in InstantAppNotifier and IntentSender in InstantAppResolver. Bug: 328262639 Test: manual Flag: EXEMPT bugfix Change-Id: I0d0eaebb20af0767b78f41354577428dda926a20
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/InstantAppNotifier.java6
-rw-r--r--services/core/java/com/android/server/pm/InstantAppResolver.java8
2 files changed, 11 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/InstantAppNotifier.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/InstantAppNotifier.java
index 5bbd77ee6dd9..60d846ebacac 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/InstantAppNotifier.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/InstantAppNotifier.java
@@ -23,6 +23,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
+import android.app.ActivityOptions;
import android.app.ActivityTaskManager;
import android.app.ActivityTaskManager.RootTaskInfo;
import android.app.AppGlobals;
@@ -271,13 +272,16 @@ public class InstantAppNotifier
.addFlags(Intent.FLAG_IGNORE_EPHEMERAL)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ ActivityOptions options = ActivityOptions.makeBasic()
+ .setPendingIntentCreatorBackgroundActivityStartMode(
+ ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
PendingIntent pendingIntent =
PendingIntent.getActivityAsUser(
mContext,
0 /* requestCode */,
browserIntent,
PendingIntent.FLAG_IMMUTABLE /* flags */,
- null,
+ options.toBundle(),
user);
ComponentName aiaComponent = null;
try {
diff --git a/services/core/java/com/android/server/pm/InstantAppResolver.java b/services/core/java/com/android/server/pm/InstantAppResolver.java
index 92d6a826b5f5..42efd6e60fc0 100644
--- a/services/core/java/com/android/server/pm/InstantAppResolver.java
+++ b/services/core/java/com/android/server/pm/InstantAppResolver.java
@@ -28,6 +28,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
+import android.app.ActivityOptions;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
@@ -296,6 +297,9 @@ public abstract class InstantAppResolver {
if (needsPhaseTwo) {
intent.setAction(Intent.ACTION_RESOLVE_INSTANT_APP_PACKAGE);
} else {
+ ActivityOptions options = ActivityOptions.makeBasic()
+ .setPendingIntentCreatorBackgroundActivityStartMode(
+ ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
// We have all of the data we need; just start the installer without a second phase
if (failureIntent != null || installFailureActivity != null) {
// Intent that is launched if the package couldn't be installed for any reason.
@@ -322,7 +326,7 @@ public abstract class InstantAppResolver {
PendingIntent.FLAG_CANCEL_CURRENT
| PendingIntent.FLAG_ONE_SHOT
| PendingIntent.FLAG_IMMUTABLE,
- null /*bOptions*/, userId);
+ options.toBundle(), userId);
IntentSender failureSender = new IntentSender(failureIntentTarget);
// TODO(b/72700831): remove populating old extra
intent.putExtra(Intent.EXTRA_INSTANT_APP_FAILURE, failureSender);
@@ -342,7 +346,7 @@ public abstract class InstantAppResolver {
new String[] { resolvedType },
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT
| PendingIntent.FLAG_IMMUTABLE,
- null /*bOptions*/, userId);
+ options.toBundle(), userId);
IntentSender successSender = new IntentSender(successIntentTarget);
intent.putExtra(Intent.EXTRA_INSTANT_APP_SUCCESS, successSender);
} catch (RemoteException ignore) { /* ignore; same process */ }