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

Commit a514c9aa authored by chaviw's avatar chaviw Committed by android-build-merger
Browse files

Merge "Notify WM that app is delayed closing due to the possibility of PIP." into pi-dev

am: 47d9d980

Change-Id: I6b9e3426f35e66596e96068601e4166887586487
parents 28476b0a 47d9d980
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -778,6 +778,13 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
        }
    }

    /**
     * See {@link AppWindowContainerController#setWillCloseOrEnterPip(boolean)}
     */
    void setWillCloseOrEnterPip(boolean willCloseOrEnterPip) {
        getWindowContainerController().setWillCloseOrEnterPip(willCloseOrEnterPip);
    }

    static class Token extends IApplicationToken.Stub {
        private final WeakReference<ActivityRecord> weakActivity;
        private final String name;
+6 −1
Original line number Diff line number Diff line
@@ -1556,6 +1556,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "Complete pause: " + prev);

        if (prev != null) {
            prev.setWillCloseOrEnterPip(false);
            final boolean wasStopping = prev.isState(STOPPING);
            prev.setState(PAUSED, "completePausedLocked");
            if (prev.finishing) {
@@ -2421,11 +2422,12 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        mStackSupervisor.setLaunchSource(next.info.applicationInfo.uid);

        boolean lastResumedCanPip = false;
        ActivityRecord lastResumed = null;
        final ActivityStack lastFocusedStack = mStackSupervisor.getLastStack();
        if (lastFocusedStack != null && lastFocusedStack != this) {
            // So, why aren't we using prev here??? See the param comment on the method. prev doesn't
            // represent the last resumed activity. However, the last focus stack does if it isn't null.
            final ActivityRecord lastResumed = lastFocusedStack.mResumedActivity;
            lastResumed = lastFocusedStack.mResumedActivity;
            if (userLeaving && inMultiWindowMode() && lastFocusedStack.shouldBeVisible(next)) {
                // The user isn't leaving if this stack is the multi-window mode and the last
                // focused stack should still be visible.
@@ -2460,6 +2462,9 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
                mService.updateLruProcessLocked(next.app, true, null);
            }
            if (DEBUG_STACK) mStackSupervisor.validateTopActivitiesLocked();
            if (lastResumed != null) {
                lastResumed.setWillCloseOrEnterPip(true);
            }
            return true;
        } else if (mResumedActivity == next && next.isState(RESUMED)
                && mStackSupervisor.allResumedActivitiesComplete()) {
+15 −0
Original line number Diff line number Diff line
@@ -753,6 +753,21 @@ public class AppWindowContainerController
        return mListener != null && mListener.keyDispatchingTimedOut(reason, windowPid);
    }

    /**
     * Notifies AWT that this app is waiting to pause in order to determine if it will enter PIP.
     * This information helps AWT know that the app is in the process of pausing before it gets the
     * signal on the WM side.
     */
    public void setWillCloseOrEnterPip(boolean willCloseOrEnterPip) {
        synchronized (mWindowMap) {
            if (mContainer == null) {
                return;
            }

            mContainer.setWillCloseOrEnterPip(willCloseOrEnterPip);
        }
    }

    @Override
    public String toString() {
        return "AppWindowContainerController{"
+25 −2
Original line number Diff line number Diff line
@@ -32,12 +32,11 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;

import static android.view.WindowManager.TRANSIT_DOCK_TASK_FROM_RECENTS;
import static android.view.WindowManager.TRANSIT_WALLPAPER_OPEN;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
import static android.view.WindowManager.TRANSIT_UNSET;
import static com.android.server.wm.AppTransition.isKeyguardGoingAwayTransit;

import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
@@ -257,6 +256,13 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
    private RemoteAnimationDefinition mRemoteAnimationDefinition;
    private AnimatingAppWindowTokenRegistry mAnimatingAppWindowTokenRegistry;

    /**
     * A flag to determine if this AWT is in the process of closing or entering PIP. This is needed
     * to help AWT know that the app is in the process of closing but hasn't yet started closing on
     * the WM side.
     */
    private boolean mWillCloseOrEnterPip;

    AppWindowToken(WindowManagerService service, IApplicationToken token, boolean voiceInteraction,
            DisplayContent dc, long inputDispatchingTimeoutNanos, boolean fullscreen,
            boolean showForAllUsers, int targetSdk, int orientation, int rotationAnimationHint,
@@ -2235,4 +2241,21 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
    boolean isLetterboxOverlappingWith(Rect rect) {
        return mLetterbox != null && mLetterbox.isOverlappingWith(rect);
    }

    /**
     * Sets if this AWT is in the process of closing or entering PIP.
     * {@link #mWillCloseOrEnterPip}}
     */
    void setWillCloseOrEnterPip(boolean willCloseOrEnterPip) {
        mWillCloseOrEnterPip = willCloseOrEnterPip;
    }

    /**
     * Returns whether this AWT is considered closing. Conditions are either
     * 1. Is this app animating and was requested to be hidden
     * 2. App is delayed closing since it might enter PIP.
     */
    boolean isClosingOrEnteringPip() {
        return (isAnimating() && hiddenRequested) || mWillCloseOrEnterPip;
    }
}
+1 −4
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
import static android.app.AppOpsManager.MODE_ALLOWED;
import static android.app.AppOpsManager.MODE_DEFAULT;
import static android.app.AppOpsManager.OP_NONE;
import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW;
import static android.app.AppOpsManager.OP_TOAST_WINDOW;
import static android.os.PowerManager.DRAW_WAKE_LOCK;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.Display.DEFAULT_DISPLAY;
@@ -2737,8 +2735,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
    }

    boolean isClosing() {
        return mAnimatingExit || (mAppToken != null && mAppToken.isAnimating()
                && mAppToken.hiddenRequested);
        return mAnimatingExit || (mAppToken != null && mAppToken.isClosingOrEnteringPip());
    }

    void addWinAnimatorToList(ArrayList<WindowStateAnimator> animators) {
+1 −1

File changed.

Contains only whitespace changes.

Loading