Merge "Animate activity when launching over keyguard"
diff --git a/core/res/res/anim/keyguard_occlude_open_enter.xml b/core/res/res/anim/keyguard_occlude_open_enter.xml
new file mode 100644
index 0000000..e742616
--- /dev/null
+++ b/core/res/res/anim/keyguard_occlude_open_enter.xml
@@ -0,0 +1,30 @@
+<?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 2f45cce..140bb7d8 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2156,6 +2156,7 @@
<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 042e4ff..b80cd30 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 require a password or just fade away.
+ * If keyguard will just fade away or will require a password.
*/
- private boolean mCurrentlySecure;
+ private boolean mFadeAway;
/**
* 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 secure, boolean pulsing,
+ int keyguardStatusHeight, float dark, boolean fadeAway, boolean pulsing,
int bouncerTop) {
mMinTopMargin = minTopMargin + mContainerTopPadding;
mMaxShadeBottom = maxShadeBottom;
@@ -144,7 +144,7 @@
mHeight = parentHeight;
mKeyguardStatusHeight = keyguardStatusHeight;
mDarkAmount = dark;
- mCurrentlySecure = secure;
+ mFadeAway = fadeAway;
mPulsing = pulsing;
mBouncerTop = bouncerTop;
}
@@ -198,7 +198,7 @@
float clockYRegular = getExpandedClockPosition();
boolean hasEnoughSpace = mMinTopMargin + mKeyguardStatusHeight < mBouncerTop;
- float clockYTarget = mCurrentlySecure && hasEnoughSpace ?
+ float clockYTarget = !mFadeAway && hasEnoughSpace ?
mMinTopMargin : -mKeyguardStatusHeight;
// Move clock up while collapsing the shade
@@ -218,11 +218,11 @@
*/
private float getClockAlpha(int y) {
float alphaKeyguard;
- if (mCurrentlySecure) {
- alphaKeyguard = 1;
- } else {
+ if (mFadeAway) {
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 be8bf02..7db5802 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -524,7 +524,8 @@
totalHeight,
mKeyguardStatusView.getHeight(),
mInterpolatedDarkAmount,
- mStatusBar.isKeyguardCurrentlySecure(),
+ !mStatusBar.isKeyguardCurrentlySecure()
+ || mStatusBar.isKeyguardOccludeAnimationRunning(),
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 4c91a9d..dd4ea3d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -322,6 +322,8 @@
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. */
@@ -543,6 +545,7 @@
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.
@@ -1641,7 +1644,7 @@
boolean wakeAndUnlock = mBiometricUnlockController != null
&& mBiometricUnlockController.isWakeAndUnlock();
- if (mLaunchTransitionFadingAway || wakeAndUnlock) {
+ if (mLaunchTransitionFadingAway && !mIsOccluded || wakeAndUnlock) {
mBackdrop.setVisibility(View.INVISIBLE);
Trace.endSection();
return;
@@ -1760,7 +1763,8 @@
boolean cannotAnimateDoze = mDozing && !ScrimState.AOD.getAnimateChange();
if (mBiometricUnlockController.getMode()
== BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING
- || hideBecauseOccluded || cannotAnimateDoze) {
+ || hideBecauseOccluded && !mKeyguardOccludeAnimationRunning
+ || cannotAnimateDoze) {
// We are unlocking directly - no animation!
mBackdrop.setVisibility(View.GONE);
@@ -1771,7 +1775,9 @@
mBackdrop.animate()
.alpha(SRC_MIN_ALPHA)
.setInterpolator(Interpolators.ACCELERATE_DECELERATE)
- .setDuration(300)
+ .setDuration(
+ mKeyguardOccludeAnimationRunning
+ ? FADE_BACKDROP_DURATION_FAST : FADE_BACKDROP_DURATION)
.setStartDelay(0)
.withEndAction(() -> {
mBackdrop.setVisibility(View.GONE);
@@ -3668,6 +3674,27 @@
}
/**
+ * 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() {
@@ -4012,7 +4039,7 @@
private void showBouncerIfKeyguard() {
if ((mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)
- && !mKeyguardViewMediator.isHiding()) {
+ && !mKeyguardViewMediator.isHiding() && !mKeyguardOccludeAnimationRunning) {
showBouncer(true /* scrimmed */);
}
}
@@ -4512,6 +4539,11 @@
@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();
}
@@ -4753,7 +4785,7 @@
? ScrimState.BOUNCER_SCRIMMED : ScrimState.BOUNCER;
mScrimController.transitionTo(state);
} else if (isInLaunchTransition() || mLaunchCameraOnScreenTurningOn
- || launchingAffordanceWithPreview) {
+ || launchingAffordanceWithPreview || mKeyguardOccludeAnimationRunning) {
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 c4424d8..97088bd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -365,6 +365,11 @@
}
});
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 a38328a..f83fb43 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
@@ -144,7 +144,8 @@
state.scrimsVisibility == ScrimController.VISIBILITY_FULLY_OPAQUE;
final boolean keyguardOrAod = state.keyguardShowing
|| (state.dozing && mDozeParameters.getAlwaysOn());
- if (keyguardOrAod && !state.backdropShowing && !scrimsOccludingWallpaper) {
+ if (keyguardOrAod && !state.backdropShowing && !scrimsOccludingWallpaper
+ && !state.keyguardOccluded) {
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 a8b92a6..966684a 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -2445,13 +2445,11 @@
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 wallpaper and keyguard flag so that any change in-flight after setting
- // the keyguard as occluded wouldn't set these flags again.
+ // remove the keyguard flag so that any change in-flight after setting
+ // the keyguard as occluded wouldn't set the flag again.
// See {@link #processKeyguardSetHiddenResultLw}.
if (mKeyguardOccluded) {
- attrs.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
}
break;
@@ -5511,17 +5509,13 @@
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, false /* animate */);
+ mKeyguardDelegate.setOccluded(true, !mShowingDream /* 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 d73606f..7ee35e7 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 = null;
+ a = loadAnimationRes(lp, com.android.internal.R.anim.keyguard_occlude_open_enter);
} 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) {