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

Commit 0bbd1f57 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Only allow using PendingRemAnimRegistry on top launched activity" into pi-dev

parents 4019c394 6fa41c3e
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -350,7 +350,8 @@ public class ActivityStartController {
                                "FLAG_CANT_SAVE_STATE not supported here");
                                "FLAG_CANT_SAVE_STATE not supported here");
                    }
                    }


                    final SafeActivityOptions checkedOptions = i == intents.length - 1
                    final boolean top = i == intents.length - 1;
                    final SafeActivityOptions checkedOptions = top
                            ? options
                            ? options
                            : null;
                            : null;
                    final int res = obtainStarter(intent, reason)
                    final int res = obtainStarter(intent, reason)
@@ -367,6 +368,10 @@ public class ActivityStartController {
                            .setActivityOptions(checkedOptions)
                            .setActivityOptions(checkedOptions)
                            .setComponentSpecified(componentSpecified)
                            .setComponentSpecified(componentSpecified)
                            .setOutActivity(outActivity)
                            .setOutActivity(outActivity)

                            // Top activity decides on animation being run, so we allow only for the
                            // top one as otherwise an activity below might consume it.
                            .setAllowPendingRemoteAnimationRegistryLookup(top /* allowLookup*/)
                            .execute();
                            .execute();


                    if (res < 0) {
                    if (res < 0) {
+31 −9
Original line number Original line Diff line number Diff line
@@ -313,6 +313,12 @@ class ActivityStarter {
        int userId;
        int userId;
        WaitResult waitResult;
        WaitResult waitResult;


        /**
         * If set to {@code true}, allows this activity start to look into
         * {@link PendingRemoteAnimationRegistry}
         */
        boolean allowPendingRemoteAnimationRegistryLookup;

        /**
        /**
         * Indicates that we should wait for the result of the start request. This flag is set when
         * Indicates that we should wait for the result of the start request. This flag is set when
         * {@link ActivityStarter#setMayWait(int)} is called.
         * {@link ActivityStarter#setMayWait(int)} is called.
@@ -360,6 +366,7 @@ class ActivityStarter {
            waitResult = null;
            waitResult = null;
            mayWait = false;
            mayWait = false;
            avoidMoveToFront = false;
            avoidMoveToFront = false;
            allowPendingRemoteAnimationRegistryLookup = true;
        }
        }


        /**
        /**
@@ -395,6 +402,8 @@ class ActivityStarter {
            waitResult = request.waitResult;
            waitResult = request.waitResult;
            mayWait = request.mayWait;
            mayWait = request.mayWait;
            avoidMoveToFront = request.avoidMoveToFront;
            avoidMoveToFront = request.avoidMoveToFront;
            allowPendingRemoteAnimationRegistryLookup
                    = request.allowPendingRemoteAnimationRegistryLookup;
        }
        }
    }
    }


@@ -477,7 +486,8 @@ class ActivityStarter {
                        mRequest.resultWho, mRequest.requestCode, mRequest.startFlags,
                        mRequest.resultWho, mRequest.requestCode, mRequest.startFlags,
                        mRequest.profilerInfo, mRequest.waitResult, mRequest.globalConfig,
                        mRequest.profilerInfo, mRequest.waitResult, mRequest.globalConfig,
                        mRequest.activityOptions, mRequest.ignoreTargetSecurity, mRequest.userId,
                        mRequest.activityOptions, mRequest.ignoreTargetSecurity, mRequest.userId,
                        mRequest.inTask, mRequest.reason);
                        mRequest.inTask, mRequest.reason,
                        mRequest.allowPendingRemoteAnimationRegistryLookup);
            } else {
            } else {
                return startActivity(mRequest.caller, mRequest.intent, mRequest.ephemeralIntent,
                return startActivity(mRequest.caller, mRequest.intent, mRequest.ephemeralIntent,
                        mRequest.resolvedType, mRequest.activityInfo, mRequest.resolveInfo,
                        mRequest.resolvedType, mRequest.activityInfo, mRequest.resolveInfo,
@@ -486,7 +496,8 @@ class ActivityStarter {
                        mRequest.callingUid, mRequest.callingPackage, mRequest.realCallingPid,
                        mRequest.callingUid, mRequest.callingPackage, mRequest.realCallingPid,
                        mRequest.realCallingUid, mRequest.startFlags, mRequest.activityOptions,
                        mRequest.realCallingUid, mRequest.startFlags, mRequest.activityOptions,
                        mRequest.ignoreTargetSecurity, mRequest.componentSpecified,
                        mRequest.ignoreTargetSecurity, mRequest.componentSpecified,
                        mRequest.outActivity, mRequest.inTask, mRequest.reason);
                        mRequest.outActivity, mRequest.inTask, mRequest.reason,
                        mRequest.allowPendingRemoteAnimationRegistryLookup);
            }
            }
        } finally {
        } finally {
            onExecutionComplete();
            onExecutionComplete();
@@ -517,7 +528,8 @@ class ActivityStarter {
            IBinder resultTo, String resultWho, int requestCode, int callingPid, int callingUid,
            IBinder resultTo, String resultWho, int requestCode, int callingPid, int callingUid,
            String callingPackage, int realCallingPid, int realCallingUid, int startFlags,
            String callingPackage, int realCallingPid, int realCallingUid, int startFlags,
            SafeActivityOptions options, boolean ignoreTargetSecurity, boolean componentSpecified,
            SafeActivityOptions options, boolean ignoreTargetSecurity, boolean componentSpecified,
            ActivityRecord[] outActivity, TaskRecord inTask, String reason) {
            ActivityRecord[] outActivity, TaskRecord inTask, String reason,
            boolean allowPendingRemoteAnimationRegistryLookup) {


        if (TextUtils.isEmpty(reason)) {
        if (TextUtils.isEmpty(reason)) {
            throw new IllegalArgumentException("Need to specify a reason.");
            throw new IllegalArgumentException("Need to specify a reason.");
@@ -530,7 +542,7 @@ class ActivityStarter {
                aInfo, rInfo, voiceSession, voiceInteractor, resultTo, resultWho, requestCode,
                aInfo, rInfo, voiceSession, voiceInteractor, resultTo, resultWho, requestCode,
                callingPid, callingUid, callingPackage, realCallingPid, realCallingUid, startFlags,
                callingPid, callingUid, callingPackage, realCallingPid, realCallingUid, startFlags,
                options, ignoreTargetSecurity, componentSpecified, mLastStartActivityRecord,
                options, ignoreTargetSecurity, componentSpecified, mLastStartActivityRecord,
                inTask);
                inTask, allowPendingRemoteAnimationRegistryLookup);


        if (outActivity != null) {
        if (outActivity != null) {
            // mLastStartActivityRecord[0] is set in the call to startActivity above.
            // mLastStartActivityRecord[0] is set in the call to startActivity above.
@@ -560,7 +572,7 @@ class ActivityStarter {
            String callingPackage, int realCallingPid, int realCallingUid, int startFlags,
            String callingPackage, int realCallingPid, int realCallingUid, int startFlags,
            SafeActivityOptions options,
            SafeActivityOptions options,
            boolean ignoreTargetSecurity, boolean componentSpecified, ActivityRecord[] outActivity,
            boolean ignoreTargetSecurity, boolean componentSpecified, ActivityRecord[] outActivity,
            TaskRecord inTask) {
            TaskRecord inTask, boolean allowPendingRemoteAnimationRegistryLookup) {
        int err = ActivityManager.START_SUCCESS;
        int err = ActivityManager.START_SUCCESS;
        // Pull the optional Ephemeral Installer-only bundle out of the options early.
        // Pull the optional Ephemeral Installer-only bundle out of the options early.
        final Bundle verificationBundle
        final Bundle verificationBundle
@@ -709,8 +721,11 @@ class ActivityStarter {
        ActivityOptions checkedOptions = options != null
        ActivityOptions checkedOptions = options != null
                ? options.getOptions(intent, aInfo, callerApp, mSupervisor)
                ? options.getOptions(intent, aInfo, callerApp, mSupervisor)
                : null;
                : null;
        checkedOptions = mService.getActivityStartController().getPendingRemoteAnimationRegistry()
        if (allowPendingRemoteAnimationRegistryLookup) {
            checkedOptions = mService.getActivityStartController()
                    .getPendingRemoteAnimationRegistry()
                    .overrideOptionsIfNeeded(callingPackage, checkedOptions);
                    .overrideOptionsIfNeeded(callingPackage, checkedOptions);
        }
        if (mService.mController != null) {
        if (mService.mController != null) {
            try {
            try {
                // The Intent we give to the watcher has the extra data
                // The Intent we give to the watcher has the extra data
@@ -928,7 +943,8 @@ class ActivityStarter {
            IBinder resultTo, String resultWho, int requestCode, int startFlags,
            IBinder resultTo, String resultWho, int requestCode, int startFlags,
            ProfilerInfo profilerInfo, WaitResult outResult,
            ProfilerInfo profilerInfo, WaitResult outResult,
            Configuration globalConfig, SafeActivityOptions options, boolean ignoreTargetSecurity,
            Configuration globalConfig, SafeActivityOptions options, boolean ignoreTargetSecurity,
            int userId, TaskRecord inTask, String reason) {
            int userId, TaskRecord inTask, String reason,
            boolean allowPendingRemoteAnimationRegistryLookup) {
        // Refuse possible leaked file descriptors
        // Refuse possible leaked file descriptors
        if (intent != null && intent.hasFileDescriptors()) {
        if (intent != null && intent.hasFileDescriptors()) {
            throw new IllegalArgumentException("File descriptors passed in Intent");
            throw new IllegalArgumentException("File descriptors passed in Intent");
@@ -1070,7 +1086,8 @@ class ActivityStarter {
            int res = startActivity(caller, intent, ephemeralIntent, resolvedType, aInfo, rInfo,
            int res = startActivity(caller, intent, ephemeralIntent, resolvedType, aInfo, rInfo,
                    voiceSession, voiceInteractor, resultTo, resultWho, requestCode, callingPid,
                    voiceSession, voiceInteractor, resultTo, resultWho, requestCode, callingPid,
                    callingUid, callingPackage, realCallingPid, realCallingUid, startFlags, options,
                    callingUid, callingPackage, realCallingPid, realCallingUid, startFlags, options,
                    ignoreTargetSecurity, componentSpecified, outRecord, inTask, reason);
                    ignoreTargetSecurity, componentSpecified, outRecord, inTask, reason,
                    allowPendingRemoteAnimationRegistryLookup);


            Binder.restoreCallingIdentity(origId);
            Binder.restoreCallingIdentity(origId);


@@ -2567,6 +2584,11 @@ class ActivityStarter {
        return this;
        return this;
    }
    }


    ActivityStarter setAllowPendingRemoteAnimationRegistryLookup(boolean allowLookup) {
        mRequest.allowPendingRemoteAnimationRegistryLookup = allowLookup;
        return this;
    }

    void dump(PrintWriter pw, String prefix) {
    void dump(PrintWriter pw, String prefix) {
        prefix = prefix + "  ";
        prefix = prefix + "  ";
        pw.print(prefix);
        pw.print(prefix);