Fix check creator token
1. add creator token when sendIntentSender
2. copy creatorTokenInfo in fillin
3. Toward the end of the ActivityStarter.executeRequest, remove
creatorToken only, not creatorTokenInfo. the collected keys need
to be delievered to the client after the activity is started.
4. in collectExtraIntentKey method, remove the check of !isParceled
because if the intent was an extra (as in nested embedded intents)
this check causes the keys not collected. In the CL for nested intents
I believe we can restore this check.
Bug: 375073264
Test: ExternalSourcesTestAppOpAllowed#allowedSourceTestViaSession
Flag: TEST_ONLY
Change-Id: I5cd41f100619becaf82b392ffca71af5a4925418
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index e8cec70..0675453 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -11672,6 +11672,7 @@
Log.w(TAG, "Failure filling in extras", e);
}
}
+ mCreatorTokenInfo = other.mCreatorTokenInfo;
if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
&& other.mContentUserHint != UserHandle.USER_CURRENT) {
mContentUserHint = other.mContentUserHint;
@@ -12225,6 +12226,13 @@
}
/** @hide */
+ public void removeCreatorToken() {
+ if (mCreatorTokenInfo != null) {
+ mCreatorTokenInfo.mCreatorToken = null;
+ }
+ }
+
+ /** @hide */
public @Nullable IBinder getCreatorToken() {
return mCreatorTokenInfo == null ? null : mCreatorTokenInfo.mCreatorToken;
}
@@ -12251,7 +12259,7 @@
public void collectExtraIntentKeys() {
if (!isPreventIntentRedirectEnabled()) return;
- if (mExtras != null && !mExtras.isParcelled() && !mExtras.isEmpty()) {
+ if (mExtras != null && !mExtras.isEmpty()) {
for (String key : mExtras.keySet()) {
if (mExtras.get(key) instanceof Intent) {
if (mCreatorTokenInfo == null) {
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 6ba8514..b473d88 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -5550,6 +5550,8 @@
if (target instanceof PendingIntentRecord) {
final PendingIntentRecord originalRecord = (PendingIntentRecord) target;
+ addCreatorToken(intent, originalRecord.getPackageName());
+
// In multi-display scenarios, there can be background users who execute the
// PendingIntent. In these scenarios, we don't want to use the foreground user as the
// current user.
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index 2c4179f..e795b7b 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -1275,8 +1275,8 @@
"Creator PermissionPolicyService.checkStartActivity Caused abortion.",
intent, intentCreatorUid, intentCreatorPackage, callingUid, callingPackage);
}
- intent.removeCreatorTokenInfo();
}
+ intent.removeCreatorToken();
// Merge the two options bundles, while realCallerOptions takes precedence.
ActivityOptions checkedOptions = options != null
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 111e74e..25a1ea9 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -1228,7 +1228,6 @@
String callingFeatureId, Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int startFlags, ProfilerInfo profilerInfo,
Bundle bOptions) {
- mAmInternal.addCreatorToken(intent, callingPackage);
return startActivityAsUser(caller, callingPackage, callingFeatureId, intent, resolvedType,
resultTo, resultWho, requestCode, startFlags, profilerInfo, bOptions,
UserHandle.getCallingUserId());