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

Commit de2606dc authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Don't perform app transition of the app is not currently visible.

Yet more special casing for the window manager...  try really hard,
if we are performing an activity transition that is behind an
opaque window (like say the lock screen or status bar) to just not
do it.  And, just as important, do a reasonable transition away from
whatever is on top.

Examples:

- If the lock screen is up, and you get a call or press the
  emergency dialer button, we fade from the lock screen to the
  new UI, instead of fading to the animation going on between
  the old and new.

- If you are in something hiding the lock screen, like the
  in-call screen, and that is hidden, then fade back to the
  lock screen.

- If you select an item from the status bar, then have the
  new item displayed behind it as the status bar rolls up
  rather than seeing a second animation.  (In fact this can't
  always be done because we may not start the transition to
  the new thing until the status bar is already going away.
  But for most cases we can do this with just one anim.)
parent 126b02fa
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -661,6 +661,14 @@ public interface WindowManagerPolicy {
     */
    public boolean finishAnimationLw();

    /**
     * Return true if it is okay to perform animations for an app transition
     * that is about to occur.  You may return false for this if, for example,
     * the lock screen is currently displayed so the switch should happen
     * immediately.
     */
    public boolean allowAppAnimationsLw();
    
    /**
     * Called after the screen turns off.
     *
@@ -674,6 +682,11 @@ public interface WindowManagerPolicy {
     */
    public void screenTurnedOn();

    /**
     * Return whether the screen is currently on.
     */
    public boolean isScreenOn();
    
    /**
     * Perform any initial processing of a low-level input event before the
     * window manager handles special keys and generates a high-level event
+24 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2007, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License"); 
** you may not use this file except in compliance with the License. 
** You may obtain a copy of the License at 
**
**     http://www.apache.org/licenses/LICENSE-2.0 
**
** Unless required by applicable law or agreed to in writing, software 
** distributed under the License is distributed on an "AS IS" BASIS, 
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
** See the License for the specific language governing permissions and 
** limitations under the License.
*/
-->

<set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@anim/decelerate_interpolator">
    <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
            android:duration="@android:integer/config_mediumAnimTime" />
</set>
+2 −1
Original line number Diff line number Diff line
@@ -17,7 +17,8 @@
*/
-->

<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@anim/accelerate_interpolator">
<set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@anim/accelerate_interpolator">
	<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
            android:duration="@android:integer/config_longAnimTime" />
</set>
+1 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@

    <!-- Standard animations for a non-full-screen window or activity. -->
    <style name="Animation.LockScreen">
        <item name="windowEnterAnimation">@anim/lock_screen_enter</item>
        <item name="windowExitAnimation">@anim/lock_screen_exit</item>
    </style>

+47 −12
Original line number Diff line number Diff line
@@ -2020,7 +2020,7 @@ public class WindowManagerService extends IWindowManager.Stub
        // to hold off on removing the window until the animation is done.
        // If the display is frozen, just remove immediately, since the
        // animation wouldn't be seen.
        if (win.mSurface != null && !mDisplayFrozen) {
        if (win.mSurface != null && !mDisplayFrozen && mPolicy.isScreenOn()) {
            // If we are not currently running the exit animation, we
            // need to see about starting one.
            if (wasVisible=win.isWinVisibleLw()) {
@@ -2336,7 +2336,8 @@ public class WindowManagerService extends IWindowManager.Stub
                    win.mEnterAnimationPending = true;
                }
                if (displayed && win.mSurface != null && !win.mDrawPending
                        && !win.mCommitDrawPending && !mDisplayFrozen) {
                        && !win.mCommitDrawPending && !mDisplayFrozen
                        && mPolicy.isScreenOn()) {
                    applyEnterAnimationLocked(win);
                }
                if (displayed && (win.mAttrs.flags
@@ -2588,7 +2589,7 @@ public class WindowManagerService extends IWindowManager.Stub
        // frozen, there is no reason to animate and it can cause strange
        // artifacts when we unfreeze the display if some different animation
        // is running.
        if (!mDisplayFrozen) {
        if (!mDisplayFrozen && mPolicy.isScreenOn()) {
            int anim = mPolicy.selectAnimationLw(win, transit);
            int attr = -1;
            Animation a = null;
@@ -2671,7 +2672,7 @@ public class WindowManagerService extends IWindowManager.Stub
        // frozen, there is no reason to animate and it can cause strange
        // artifacts when we unfreeze the display if some different animation
        // is running.
        if (!mDisplayFrozen) {
        if (!mDisplayFrozen && mPolicy.isScreenOn()) {
            Animation a;
            if (lp != null && (lp.flags & FLAG_COMPATIBLE_WINDOW) != 0) {
                a = new FadeInOutAnimation(enter);
@@ -3262,7 +3263,7 @@ public class WindowManagerService extends IWindowManager.Stub
            // If the display is frozen, we won't do anything until the
            // actual window is displayed so there is no reason to put in
            // the starting window.
            if (mDisplayFrozen) {
            if (mDisplayFrozen || !mPolicy.isScreenOn()) {
                return;
            }

@@ -7491,7 +7492,7 @@ public class WindowManagerService extends IWindowManager.Stub
        // This must be called while inside a transaction.  Returns true if
        // there is more animation to run.
        boolean stepAnimationLocked(long currentTime, int dw, int dh) {
            if (!mDisplayFrozen) {
            if (!mDisplayFrozen && mPolicy.isScreenOn()) {
                // We will run animations as long as the display isn't frozen.

                if (!mDrawPending && !mCommitDrawPending && mAnimation != null) {
@@ -8421,7 +8422,7 @@ public class WindowManagerService extends IWindowManager.Stub

        // This must be called while inside a transaction.
        boolean stepAnimationLocked(long currentTime, int dw, int dh) {
            if (!mDisplayFrozen) {
            if (!mDisplayFrozen && mPolicy.isScreenOn()) {
                // We will run animations as long as the display isn't frozen.

                if (animation == sDummyAnimation) {
@@ -9391,6 +9392,7 @@ public class WindowManagerService extends IWindowManager.Stub
        try {
            boolean restart;
            boolean forceHiding = false;
            boolean wallpaperForceHidingChanged = false;

            do {
                final int transactionSequence = ++mTransactionSequence;
@@ -9411,13 +9413,16 @@ public class WindowManagerService extends IWindowManager.Stub
                    }
                }

                if (DEBUG_APP_TRANSITIONS) Log.v(TAG, "*** ANIM STEP: seq="
                        + transactionSequence + " tokensAnimating="
                        + tokensAnimating);
                        
                animating = tokensAnimating;
                restart = false;

                boolean tokenMayBeDrawn = false;
                boolean wallpaperMayChange = false;
                boolean focusMayChange = false;
                boolean wallpaperForceHidingChanged = false;

                mPolicy.beginAnimationLw(dw, dh);

@@ -9730,6 +9735,14 @@ public class WindowManagerService extends IWindowManager.Stub
                            mLastEnterAnimParams = null;
                        }

                        // If all closing windows are obscured, then there is
                        // no need to do an animation.  This is the case, for
                        // example, when this transition is being done behind
                        // the lock screen.
                        if (!mPolicy.allowAppAnimationsLw()) {
                            animLp = null;
                        }
                        
                        NN = mOpeningApps.size();
                        for (i=0; i<NN; i++) {
                            AppWindowToken wtoken = mOpeningApps.get(i);
@@ -9802,7 +9815,7 @@ public class WindowManagerService extends IWindowManager.Stub

                int adjResult = 0;

                if (wallpaperForceHidingChanged) {
                if (wallpaperForceHidingChanged && !restart && !mAppTransitionReady) {
                    // At this point, there was a window with a wallpaper that
                    // was force hiding other windows behind it, but now it
                    // is going away.  This may be simple -- just animate
@@ -9810,10 +9823,28 @@ public class WindowManagerService extends IWindowManager.Stub
                    // hard -- the wallpaper now needs to be shown behind
                    // something that was hidden.
                    WindowState oldWallpaper = mWallpaperTarget;
                    if (mLowerWallpaperTarget != null
                            && mLowerWallpaperTarget.mAppToken != null) {
                        if (DEBUG_WALLPAPER) Log.v(TAG,
                                "wallpaperForceHiding changed with lower="
                                + mLowerWallpaperTarget);
                        if (DEBUG_WALLPAPER) Log.v(TAG,
                                "hidden=" + mLowerWallpaperTarget.mAppToken.hidden +
                                " hiddenRequested=" + mLowerWallpaperTarget.mAppToken.hiddenRequested);
                        if (mLowerWallpaperTarget.mAppToken.hidden) {
                            // The lower target has become hidden before we
                            // actually started the animation...  let's completely
                            // re-evaluate everything.
                            mLowerWallpaperTarget = mUpperWallpaperTarget = null;
                            restart = true;
                        }
                    }
                    adjResult = adjustWallpaperWindowsLocked();
                    wallpaperMayChange = false;
                    if (false) Log.v(TAG, "****** OLD: " + oldWallpaper
                            + " NEW: " + mWallpaperTarget);
                    wallpaperForceHidingChanged = false;
                    if (DEBUG_WALLPAPER) Log.v(TAG, "****** OLD: " + oldWallpaper
                            + " NEW: " + mWallpaperTarget
                            + " LOWER: " + mLowerWallpaperTarget);
                    if (mLowerWallpaperTarget == null) {
                        // Whoops, we don't need a special wallpaper animation.
                        // Clear them out.
@@ -9868,6 +9899,9 @@ public class WindowManagerService extends IWindowManager.Stub
                    performLayoutLockedInner();
                }

                if (DEBUG_APP_TRANSITIONS) Log.v(TAG, "*** ANIM STEP: restart="
                        + restart);
                
            } while (restart);

            // THIRD LOOP: Update the surfaces of all windows.
@@ -10257,7 +10291,8 @@ public class WindowManagerService extends IWindowManager.Stub
            }

            if (mDimAnimator != null && mDimAnimator.mDimShown) {
                animating |= mDimAnimator.updateSurface(dimming, currentTime, mDisplayFrozen);
                animating |= mDimAnimator.updateSurface(dimming, currentTime,
                        mDisplayFrozen || !mPolicy.isScreenOn());
            }

            if (!blurring && mBlurShown) {