[DO NOT MERGE]Revert "DO NOT MERGE: Revert "Merge "Disable PendingIntent background activity launch" into tm-dev am: 05494c71f8""
This reverts commit 3a94cd71da3cde94ff1675a90663115e493aab74.
Reason for revert: <Avoiding mainline rollout regression>
Change-Id: I8ef4faf07b26e185674bc9c907ed70e2e4b89307
bug: 230866011
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index c806c62..638e8ec 100644
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -8348,7 +8348,15 @@
mPendingIntentWakeLock.acquire();
try {
if (DBG) log("Sending " + pendingIntent);
- pendingIntent.send(mContext, 0, intent, this /* onFinished */, null /* Handler */);
+ final BroadcastOptions options = BroadcastOptions.makeBasic();
+ if (SdkLevel.isAtLeastT()) {
+ // Explicitly disallow the receiver from starting activities, to prevent apps from
+ // utilizing the PendingIntent as a backdoor to do this.
+ options.setPendingIntentBackgroundActivityLaunchAllowed(false);
+ }
+ pendingIntent.send(mContext, 0, intent, this /* onFinished */, null /* Handler */,
+ null /* requiredPermission */,
+ SdkLevel.isAtLeastT() ? options.toBundle() : null);
} catch (PendingIntent.CanceledException e) {
if (DBG) log(pendingIntent + " was not sent, it had been canceled.");
mPendingIntentWakeLock.release();