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

Commit bc2aabe8 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Revert "Revert "Elevate remote/recents animation priority""

This reverts commit a8b48ab7.

Original issue has been fixed in follow up CL.

Bug: 73555925
Change-Id: Ie0a157a91c3c66df52370adad7b188f59c4749ea
parent 3bfe2b15
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.os.IBinder;
import android.os.SystemClock;
import android.service.voice.IVoiceInteractionSession;
import android.util.SparseIntArray;
import android.view.RemoteAnimationAdapter;

import com.android.internal.app.IVoiceInteractor;

@@ -263,6 +264,17 @@ public abstract class ActivityManagerInternal {
     */
    public abstract void setHasOverlayUi(int pid, boolean hasOverlayUi);

    /**
     * Sets if the given pid is currently running a remote animation, which is taken a signal for
     * determining oom adjustment and scheduling behavior.
     *
     * @param pid The pid we are setting overlay UI for.
     * @param runningRemoteAnimation True if the process is running a remote animation, false
     *                               otherwise.
     * @see RemoteAnimationAdapter
     */
    public abstract void setRunningRemoteAnimation(int pid, boolean runningRemoteAnimation);

    /**
     * Called after the network policy rules are updated by
     * {@link com.android.server.net.NetworkPolicyManagerService} for a specific {@param uid} and
+17 −0
Original line number Diff line number Diff line
@@ -52,6 +52,9 @@ public class RemoteAnimationAdapter implements Parcelable {
    private final long mDuration;
    private final long mStatusBarTransitionDelay;

    /** @see #getCallingPid */
    private int mCallingPid;

    /**
     * @param runner The interface that gets notified when we actually need to start the animation.
     * @param duration The duration of the animation.
@@ -83,6 +86,20 @@ public class RemoteAnimationAdapter implements Parcelable {
        return mStatusBarTransitionDelay;
    }

    /**
     * To be called by system_server to keep track which pid is running this animation.
     */
    public void setCallingPid(int pid) {
        mCallingPid = pid;
    }

    /**
     * @return The pid of the process running the animation.
     */
    public int getCallingPid() {
        return mCallingPid;
    }

    @Override
    public int describeContents() {
        return 0;
+10 −0
Original line number Diff line number Diff line
@@ -70,6 +70,16 @@ public class RemoteAnimationDefinition implements Parcelable {
        mTransitionAnimationMap = in.readSparseArray(null /* loader */);
    }

    /**
     * To be called by system_server to keep track which pid is running the remote animations inside
     * this definition.
     */
    public void setCallingPid(int pid) {
        for (int i = mTransitionAnimationMap.size() - 1; i >= 0; i--) {
            mTransitionAnimationMap.valueAt(i).setCallingPid(pid);
        }
    }

    @Override
    public int describeContents() {
        return 0;
+42 −3
Original line number Diff line number Diff line
@@ -5149,6 +5149,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    public void startRecentsActivity(Intent intent, IAssistDataReceiver assistDataReceiver,
                IRecentsAnimationRunner recentsAnimationRunner) {
        enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "startRecentsActivity()");
        final int callingPid = Binder.getCallingPid();
        final long origId = Binder.clearCallingIdentity();
        try {
            synchronized (this) {
@@ -5174,7 +5175,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                // Start a new recents animation
                final RecentsAnimation anim = new RecentsAnimation(this, mStackSupervisor,
                        mActivityStartController, mWindowManager, mUserController);
                        mActivityStartController, mWindowManager, mUserController, callingPid);
                anim.startRecentsActivity(intent, recentsAnimationRunner, recentsComponent,
                        recentsUid);
            }
@@ -14337,6 +14338,28 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
    }
    void setRunningRemoteAnimation(int pid, boolean runningRemoteAnimation) {
        synchronized (ActivityManagerService.this) {
            final ProcessRecord pr;
            synchronized (mPidsSelfLocked) {
                pr = mPidsSelfLocked.get(pid);
                if (pr == null) {
                    Slog.w(TAG, "setRunningRemoteAnimation called on unknown pid: " + pid);
                    return;
                }
            }
            if (pr.runningRemoteAnimation == runningRemoteAnimation) {
                return;
            }
            pr.runningRemoteAnimation = runningRemoteAnimation;
            if (DEBUG_OOM_ADJ) {
                Slog.i(TAG, "Setting runningRemoteAnimation=" + pr.runningRemoteAnimation
                        + " for pid=" + pid);
            }
            updateOomAdjLocked(pr, true);
        }
    }
    public final void enterSafeMode() {
        synchronized(this) {
            // It only makes sense to do this before the system is ready
@@ -22747,6 +22770,12 @@ public class ActivityManagerService extends IActivityManager.Stub
            foregroundActivities = true;
            procState = PROCESS_STATE_CUR_TOP;
            if (DEBUG_OOM_ADJ_REASON) Slog.d(TAG, "Making top: " + app);
        } else if (app.runningRemoteAnimation) {
            adj = ProcessList.VISIBLE_APP_ADJ;
            schedGroup = ProcessList.SCHED_GROUP_TOP_APP;
            app.adjType = "running-remote-anim";
            procState = PROCESS_STATE_CUR_TOP;
            if (DEBUG_OOM_ADJ_REASON) Slog.d(TAG, "Making running remote anim: " + app);
        } else if (app.instr != null) {
            // Don't want to kill running instrumentation.
            adj = ProcessList.FOREGROUND_APP_ADJ;
@@ -22822,7 +22851,9 @@ public class ActivityManagerService extends IActivityManager.Stub
                        app.adjType = "vis-activity";
                        if (DEBUG_OOM_ADJ_REASON) Slog.d(TAG, "Raise to vis-activity: " + app);
                    }
                    if (schedGroup < ProcessList.SCHED_GROUP_DEFAULT) {
                        schedGroup = ProcessList.SCHED_GROUP_DEFAULT;
                    }
                    app.cached = false;
                    app.empty = false;
                    foregroundActivities = true;
@@ -22845,7 +22876,9 @@ public class ActivityManagerService extends IActivityManager.Stub
                        app.adjType = "pause-activity";
                        if (DEBUG_OOM_ADJ_REASON) Slog.d(TAG, "Raise to pause-activity: " + app);
                    }
                    if (schedGroup < ProcessList.SCHED_GROUP_DEFAULT) {
                        schedGroup = ProcessList.SCHED_GROUP_DEFAULT;
                    }
                    app.cached = false;
                    app.empty = false;
                    foregroundActivities = true;
@@ -25986,6 +26019,11 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
        }
        @Override
        public void setRunningRemoteAnimation(int pid, boolean runningRemoteAnimation) {
            ActivityManagerService.this.setRunningRemoteAnimation(pid, runningRemoteAnimation);
        }
        /**
         * Called after the network policy rules are updated by
         * {@link com.android.server.net.NetworkPolicyManagerService} for a specific {@param uid}
@@ -26535,6 +26573,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            throws RemoteException {
        enforceCallingPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS,
                "registerRemoteAnimations");
        definition.setCallingPid(Binder.getCallingPid());
        synchronized (this) {
            final ActivityRecord r = ActivityRecord.isInStackLocked(token);
            if (r == null) {
+9 −2
Original line number Diff line number Diff line
@@ -129,6 +129,12 @@ final class ProcessRecord {
                                // When true the process will oom adj score will be set to
                                // ProcessList#PERCEPTIBLE_APP_ADJ at minimum to reduce the chance
                                // of the process getting killed.
    boolean runningRemoteAnimation; // Is the process currently running a RemoteAnimation? When true
                                // the process will be set to use the
                                // ProcessList#SCHED_GROUP_TOP_APP scheduling group to boost
                                // performance, as well as oom adj score will be set to
                                // ProcessList#VISIBLE_APP_ADJ at minimum to reduce the chance
                                // of the process getting killed.
    boolean pendingUiClean;     // Want to clean up resources from showing UI?
    boolean hasAboveClient;     // Bound using BIND_ABOVE_CLIENT, so want to be lower
    boolean treatLikeActivity;  // Bound using BIND_TREAT_LIKE_ACTIVITY
@@ -336,9 +342,10 @@ final class ProcessRecord {
                    pw.print(" hasAboveClient="); pw.print(hasAboveClient);
                    pw.print(" treatLikeActivity="); pw.println(treatLikeActivity);
        }
        if (hasTopUi || hasOverlayUi) {
        if (hasTopUi || hasOverlayUi || runningRemoteAnimation) {
            pw.print(prefix); pw.print("hasTopUi="); pw.print(hasTopUi);
                    pw.print(" hasOverlayUi="); pw.println(hasOverlayUi);
                    pw.print(" hasOverlayUi="); pw.print(hasOverlayUi);
                    pw.print(" runningRemoteAnimation="); pw.println(runningRemoteAnimation);
        }
        if (foregroundServices || forcingToImportant != null) {
            pw.print(prefix); pw.print("foregroundServices="); pw.print(foregroundServices);
Loading