Revert "Animate activity when launching over keyguard"

This reverts commit 468f2d3e065b8b35b8b83fd37cfe2a6d28bf98ed.

Breaking emergency dialer
Bug: 112339366

Change-Id: Id1dc7b3b1e0c3628097926c47babfb52d0fdb99c
(cherry picked from commit dbf172ebd962d6bbff58daf82d2545c119314d28)
diff --git a/core/res/res/anim/keyguard_occlude_open_enter.xml b/core/res/res/anim/keyguard_occlude_open_enter.xml
deleted file mode 100644
index e742616..0000000
--- a/core/res/res/anim/keyguard_occlude_open_enter.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2018 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:shareInterpolator="false">
-    <translate
-        android:fromYDelta="90%"
-        android:toYDelta="0%"
-        android:interpolator="@interpolator/fast_out_slow_in"
-        android:duration="400"/>
-    <alpha
-        android:fromAlpha="0.0"
-        android:toAlpha="1.0"
-        android:interpolator="@interpolator/fast_out_slow_in"
-        android:duration="300"/>
-</set>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 140bb7d..2f45cce 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2156,7 +2156,6 @@
   <java-symbol type="anim" name="push_down_out" />
   <java-symbol type="anim" name="push_up_in" />
   <java-symbol type="anim" name="push_up_out" />
-  <java-symbol type="anim" name="keyguard_occlude_open_enter" />
   <java-symbol type="anim" name="lock_screen_behind_enter" />
   <java-symbol type="anim" name="lock_screen_behind_enter_wallpaper" />
   <java-symbol type="anim" name="lock_screen_behind_enter_fade_in" />
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java
index b80cd30..042e4ff 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java
@@ -103,9 +103,9 @@
     private float mDarkAmount;
 
     /**
-     * If keyguard will just fade away or will require a password.
+     * If keyguard will require a password or just fade away.
      */
-    private boolean mFadeAway;
+    private boolean mCurrentlySecure;
 
     /**
      * Dozing and receiving a notification (AOD notification.)
@@ -135,7 +135,7 @@
 
     public void setup(int minTopMargin, int maxShadeBottom, int notificationStackHeight,
             float panelExpansion, int parentHeight,
-            int keyguardStatusHeight, float dark, boolean fadeAway, boolean pulsing,
+            int keyguardStatusHeight, float dark, boolean secure, boolean pulsing,
             int bouncerTop) {
         mMinTopMargin = minTopMargin + mContainerTopPadding;
         mMaxShadeBottom = maxShadeBottom;
@@ -144,7 +144,7 @@
         mHeight = parentHeight;
         mKeyguardStatusHeight = keyguardStatusHeight;
         mDarkAmount = dark;
-        mFadeAway = fadeAway;
+        mCurrentlySecure = secure;
         mPulsing = pulsing;
         mBouncerTop = bouncerTop;
     }
@@ -198,7 +198,7 @@
 
         float clockYRegular = getExpandedClockPosition();
         boolean hasEnoughSpace = mMinTopMargin + mKeyguardStatusHeight < mBouncerTop;
-        float clockYTarget = !mFadeAway && hasEnoughSpace ?
+        float clockYTarget = mCurrentlySecure && hasEnoughSpace ?
                 mMinTopMargin : -mKeyguardStatusHeight;
 
         // Move clock up while collapsing the shade
@@ -218,11 +218,11 @@
      */
     private float getClockAlpha(int y) {
         float alphaKeyguard;
-        if (mFadeAway) {
+        if (mCurrentlySecure) {
+            alphaKeyguard = 1;
+        } else {
             alphaKeyguard = Math.max(0, y / Math.max(1f, getExpandedClockPosition()));
             alphaKeyguard = Interpolators.ACCELERATE.getInterpolation(alphaKeyguard);
-        } else {
-            alphaKeyguard = 1;
         }
         return MathUtils.lerp(alphaKeyguard, 1f, mDarkAmount);
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 7db5802..be8bf02 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -524,8 +524,7 @@
                     totalHeight,
                     mKeyguardStatusView.getHeight(),
                     mInterpolatedDarkAmount,
-                    !mStatusBar.isKeyguardCurrentlySecure()
-                            || mStatusBar.isKeyguardOccludeAnimationRunning(),
+                    mStatusBar.isKeyguardCurrentlySecure(),
                     mPulsing,
                     mBouncerTop);
             mClockPositionAlgorithm.run(mClockPositionResult);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index dd4ea3d..4c91a9d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -322,8 +322,6 @@
     public static final int FADE_KEYGUARD_START_DELAY = 100;
     public static final int FADE_KEYGUARD_DURATION = 300;
     public static final int FADE_KEYGUARD_DURATION_PULSING = 96;
-    public static final int FADE_BACKDROP_DURATION = 300;
-    public static final int FADE_BACKDROP_DURATION_FAST = 240;
 
     /** If true, the system is in the half-boot-to-decryption-screen state.
      * Prudently disable QS and notifications.  */
@@ -545,7 +543,6 @@
     private boolean mIsOccluded;
     private boolean mWereIconsJustHidden;
     private boolean mBouncerWasShowingWhenHidden;
-    private boolean mKeyguardOccludeAnimationRunning;
 
     // Notifies StatusBarKeyguardViewManager every time the keyguard transition is over,
     // this animation is tied to the scrim for historic reasons.
@@ -1644,7 +1641,7 @@
 
         boolean wakeAndUnlock = mBiometricUnlockController != null
             && mBiometricUnlockController.isWakeAndUnlock();
-        if (mLaunchTransitionFadingAway && !mIsOccluded || wakeAndUnlock) {
+        if (mLaunchTransitionFadingAway || wakeAndUnlock) {
             mBackdrop.setVisibility(View.INVISIBLE);
             Trace.endSection();
             return;
@@ -1763,8 +1760,7 @@
                 boolean cannotAnimateDoze = mDozing && !ScrimState.AOD.getAnimateChange();
                 if (mBiometricUnlockController.getMode()
                         == BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING
-                        || hideBecauseOccluded  && !mKeyguardOccludeAnimationRunning
-                        || cannotAnimateDoze) {
+                        || hideBecauseOccluded || cannotAnimateDoze) {
 
                     // We are unlocking directly - no animation!
                     mBackdrop.setVisibility(View.GONE);
@@ -1775,9 +1771,7 @@
                     mBackdrop.animate()
                             .alpha(SRC_MIN_ALPHA)
                             .setInterpolator(Interpolators.ACCELERATE_DECELERATE)
-                            .setDuration(
-                                    mKeyguardOccludeAnimationRunning
-                                            ? FADE_BACKDROP_DURATION_FAST : FADE_BACKDROP_DURATION)
+                            .setDuration(300)
                             .setStartDelay(0)
                             .withEndAction(() -> {
                                 mBackdrop.setVisibility(View.GONE);
@@ -3674,27 +3668,6 @@
     }
 
     /**
-    * Is keyguard being occluded by a newly launched activity.
-    */
-    public boolean isKeyguardOccludeAnimationRunning() {
-        return mKeyguardOccludeAnimationRunning;
-    }
-
-    /**
-     * Plays the animation when new activity is launched over keyguard.
-     */
-    public void animateKeyguardOccluding() {
-        mKeyguardOccludeAnimationRunning = true;
-        addPostCollapseAction(() -> {
-            mStatusBarKeyguardViewManager.reset(true /* hideBouncerWhenShowing */);
-            mKeyguardOccludeAnimationRunning = false;
-        });
-        mStatusBarKeyguardViewManager.animateCollapsePanels(1.0f /* speedfactor */);
-        updateScrimController();
-        updateMediaMetaData(false /* metaDataChanged */, true /* allowEnterAnimation */);
-    }
-
-    /**
      * Plays the animation when an activity that was occluding Keyguard goes away.
      */
     public void animateKeyguardUnoccluding() {
@@ -4039,7 +4012,7 @@
 
     private void showBouncerIfKeyguard() {
         if ((mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)
-                && !mKeyguardViewMediator.isHiding() && !mKeyguardOccludeAnimationRunning) {
+                && !mKeyguardViewMediator.isHiding()) {
             showBouncer(true /* scrimmed */);
         }
     }
@@ -4539,11 +4512,6 @@
 
         @Override
         public void onStartedGoingToSleep() {
-            // in case we start going to sleep while new animation is launching over keyguard, make
-            // sure to finish it
-            if (mKeyguardOccludeAnimationRunning) {
-                runPostCollapseRunnables();
-            }
             notifyHeadsUpGoingToSleep();
             dismissVolumeDialog();
         }
@@ -4785,7 +4753,7 @@
                     ? ScrimState.BOUNCER_SCRIMMED : ScrimState.BOUNCER;
             mScrimController.transitionTo(state);
         } else if (isInLaunchTransition() || mLaunchCameraOnScreenTurningOn
-                || launchingAffordanceWithPreview || mKeyguardOccludeAnimationRunning) {
+                || launchingAffordanceWithPreview) {
             mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback);
         } else if (mBrightnessMirrorVisible) {
             mScrimController.transitionTo(ScrimState.BRIGHTNESS_MIRROR);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index 97088bd..c4424d8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -365,11 +365,6 @@
                             }
                         });
                 return;
-            } else if (animate) {
-                mOccluded = true;
-                mStatusBar.animateKeyguardOccluding();
-                mStatusBarWindowManager.setKeyguardOccluded(mOccluded);
-                return;
             }
         } else if (!occluded && mOccluded && mShowing) {
             StatsLog.write(StatsLog.KEYGUARD_STATE_CHANGED,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
index f83fb43..a38328a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
@@ -144,8 +144,7 @@
                 state.scrimsVisibility == ScrimController.VISIBILITY_FULLY_OPAQUE;
         final boolean keyguardOrAod = state.keyguardShowing
                 || (state.dozing && mDozeParameters.getAlwaysOn());
-        if (keyguardOrAod && !state.backdropShowing && !scrimsOccludingWallpaper
-                && !state.keyguardOccluded) {
+        if (keyguardOrAod && !state.backdropShowing && !scrimsOccludingWallpaper) {
             mLpChanged.flags |= WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
         } else {
             mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index ed1dc58..12e1adb 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -2452,11 +2452,13 @@
                 attrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
                 break;
             case TYPE_STATUS_BAR:
+
                 // If the Keyguard is in a hidden state (occluded by another window), we force to
-                // remove the keyguard flag so that any change in-flight after setting
-                // the keyguard as occluded wouldn't set the flag again.
+                // remove the wallpaper and keyguard flag so that any change in-flight after setting
+                // the keyguard as occluded wouldn't set these flags again.
                 // See {@link #processKeyguardSetHiddenResultLw}.
                 if (mKeyguardOccluded) {
+                    attrs.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
                     attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
                 }
                 break;
@@ -5517,13 +5519,17 @@
             mKeyguardDelegate.setOccluded(false, true /* animate */);
             if (mStatusBar != null) {
                 mStatusBar.getAttrs().privateFlags |= PRIVATE_FLAG_KEYGUARD;
+                if (!mKeyguardDelegate.hasLockscreenWallpaper()) {
+                    mStatusBar.getAttrs().flags |= FLAG_SHOW_WALLPAPER;
+                }
             }
             return true;
         } else if (isOccluded && changed && showing) {
             mKeyguardOccluded = true;
-            mKeyguardDelegate.setOccluded(true, !mShowingDream /* animate */);
+            mKeyguardDelegate.setOccluded(true, false /* animate */);
             if (mStatusBar != null) {
                 mStatusBar.getAttrs().privateFlags &= ~PRIVATE_FLAG_KEYGUARD;
+                mStatusBar.getAttrs().flags &= ~FLAG_SHOW_WALLPAPER;
             }
             return true;
         } else if (changed) {
diff --git a/services/core/java/com/android/server/wm/AppTransition.java b/services/core/java/com/android/server/wm/AppTransition.java
index 7ee35e7..d73606f 100644
--- a/services/core/java/com/android/server/wm/AppTransition.java
+++ b/services/core/java/com/android/server/wm/AppTransition.java
@@ -1557,7 +1557,7 @@
         if (isKeyguardGoingAwayTransit(transit) && enter) {
             a = loadKeyguardExitAnimation(transit);
         } else if (transit == TRANSIT_KEYGUARD_OCCLUDE) {
-            a = loadAnimationRes(lp, com.android.internal.R.anim.keyguard_occlude_open_enter);
+            a = null;
         } else if (transit == TRANSIT_KEYGUARD_UNOCCLUDE && !enter) {
             a = loadAnimationRes(lp, com.android.internal.R.anim.wallpaper_open_exit);
         } else if (transit == TRANSIT_CRASHING_ACTIVITY_CLOSE) {