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

Commit e8d1338a authored by Nan Wu's avatar Nan Wu
Browse files

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
parent f96d78f4
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -11672,6 +11672,7 @@ public class Intent implements Parcelable, Cloneable {
                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;
@@ -12224,6 +12225,13 @@ public class Intent implements Parcelable, Cloneable {
        mCreatorTokenInfo = null;
    }
    /** @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 class Intent implements Parcelable, Cloneable {
    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) {
+2 −0
Original line number Diff line number Diff line
@@ -5550,6 +5550,8 @@ public class ActivityManagerService extends IActivityManager.Stub
        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.
+1 −1
Original line number Diff line number Diff line
@@ -1275,8 +1275,8 @@ class ActivityStarter {
                        "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
+0 −1
Original line number Diff line number Diff line
@@ -1228,7 +1228,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            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());