Merge "When keyguard exits use same anim for all windows" into lmp-mr1-dev

This commit is contained in:
Craig Mautner
2014-11-05 19:07:59 +00:00
committed by Android (Google) Code Review
4 changed files with 103 additions and 92 deletions

View File

@@ -48,6 +48,7 @@ import android.media.Ringtone;
import android.media.RingtoneManager; import android.media.RingtoneManager;
import android.media.session.MediaSessionLegacyHelper; import android.media.session.MediaSessionLegacyHelper;
import android.os.Bundle; import android.os.Bundle;
import android.os.Debug;
import android.os.FactoryTest; import android.os.FactoryTest;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
@@ -116,6 +117,7 @@ import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import static android.view.WindowManager.LayoutParams.*; import static android.view.WindowManager.LayoutParams.*;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT; import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT;
@@ -2106,11 +2108,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void removeStartingWindow(IBinder appToken, View window) { public void removeStartingWindow(IBinder appToken, View window) {
if (DEBUG_STARTING_WINDOW) { if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Removing starting window for " + appToken + ": "
RuntimeException e = new RuntimeException("here"); + window + " Callers=" + Debug.getCallers(4));
e.fillInStackTrace();
Log.v(TAG, "Removing starting window for " + appToken + ": " + window, e);
}
if (window != null) { if (window != null) {
WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
@@ -2306,24 +2305,19 @@ public class PhoneWindowManager implements WindowManagerPolicy {
boolean goingToNotificationShade) { boolean goingToNotificationShade) {
if (goingToNotificationShade) { if (goingToNotificationShade) {
return AnimationUtils.loadAnimation(mContext, R.anim.lock_screen_behind_enter_fade_in); return AnimationUtils.loadAnimation(mContext, R.anim.lock_screen_behind_enter_fade_in);
} else if (onWallpaper) {
Animation a = AnimationUtils.loadAnimation(mContext,
R.anim.lock_screen_behind_enter_wallpaper);
AnimationSet set = (AnimationSet) a;
// TODO: Use XML interpolators when we have log interpolators available in XML.
set.getAnimations().get(0).setInterpolator(mLogDecelerateInterpolator);
set.getAnimations().get(1).setInterpolator(mLogDecelerateInterpolator);
return set;
} else {
Animation a = AnimationUtils.loadAnimation(mContext,
R.anim.lock_screen_behind_enter);
AnimationSet set = (AnimationSet) a;
// TODO: Use XML interpolators when we have log interpolators available in XML.
set.getAnimations().get(0).setInterpolator(mLogDecelerateInterpolator);
return set;
} }
AnimationSet set = (AnimationSet) AnimationUtils.loadAnimation(mContext, onWallpaper ?
R.anim.lock_screen_behind_enter_wallpaper :
R.anim.lock_screen_behind_enter);
// TODO: Use XML interpolators when we have log interpolators available in XML.
final List<Animation> animations = set.getAnimations();
for (int i = animations.size() - 1; i >= 0; --i) {
animations.get(i).setInterpolator(mLogDecelerateInterpolator);
}
return set;
} }

View File

@@ -91,6 +91,9 @@ public class WindowAnimator {
boolean mKeyguardGoingAwayToNotificationShade; boolean mKeyguardGoingAwayToNotificationShade;
boolean mKeyguardGoingAwayDisableWindowAnimations; boolean mKeyguardGoingAwayDisableWindowAnimations;
/** Use one animation for all entering activities after keyguard is dismissed. */
Animation mPostKeyguardExitAnimation;
// forceHiding states. // forceHiding states.
static final int KEYGUARD_NOT_SHOWN = 0; static final int KEYGUARD_NOT_SHOWN = 0;
static final int KEYGUARD_ANIMATING_IN = 1; static final int KEYGUARD_ANIMATING_IN = 1;
@@ -220,9 +223,6 @@ public class WindowAnimator {
++mAnimTransactionSequence; ++mAnimTransactionSequence;
final WindowList windows = mService.getWindowListLocked(displayId); final WindowList windows = mService.getWindowListLocked(displayId);
ArrayList<WindowStateAnimator> unForceHiding = null;
boolean wallpaperInUnForceHiding = false;
WindowState wallpaper = null;
if (mKeyguardGoingAway) { if (mKeyguardGoingAway) {
for (int i = windows.size() - 1; i >= 0; i--) { for (int i = windows.size() - 1; i >= 0; i--) {
@@ -261,6 +261,9 @@ public class WindowAnimator {
final AppWindowToken appShowWhenLocked = winShowWhenLocked == null ? final AppWindowToken appShowWhenLocked = winShowWhenLocked == null ?
null : winShowWhenLocked.mAppToken; null : winShowWhenLocked.mAppToken;
boolean wallpaperInUnForceHiding = false;
ArrayList<WindowStateAnimator> unForceHiding = null;
WindowState wallpaper = null;
for (int i = windows.size() - 1; i >= 0; i--) { for (int i = windows.size() - 1; i >= 0; i--) {
WindowState win = windows.get(i); WindowState win = windows.get(i);
WindowStateAnimator winAnimator = win.mWinAnimator; WindowStateAnimator winAnimator = win.mWinAnimator;
@@ -327,40 +330,53 @@ public class WindowAnimator {
} else if (mPolicy.canBeForceHidden(win, win.mAttrs)) { } else if (mPolicy.canBeForceHidden(win, win.mAttrs)) {
final boolean hideWhenLocked = !((win.mIsImWindow && showImeOverKeyguard) || final boolean hideWhenLocked = !((win.mIsImWindow && showImeOverKeyguard) ||
(appShowWhenLocked != null && appShowWhenLocked == win.mAppToken)); (appShowWhenLocked != null && appShowWhenLocked == win.mAppToken));
final boolean changed;
if (((mForceHiding == KEYGUARD_ANIMATING_IN) if (((mForceHiding == KEYGUARD_ANIMATING_IN)
&& (!winAnimator.isAnimating() || hideWhenLocked)) && (!winAnimator.isAnimating() || hideWhenLocked))
|| ((mForceHiding == KEYGUARD_SHOWN) && hideWhenLocked)) { || ((mForceHiding == KEYGUARD_SHOWN) && hideWhenLocked)) {
changed = win.hideLw(false, false); if (!win.hideLw(false, false)) {
if ((DEBUG_KEYGUARD || WindowManagerService.DEBUG_VISIBILITY) // Was already hidden
&& changed) Slog.v(TAG, "Now policy hidden: " + win); continue;
}
if (DEBUG_KEYGUARD || WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG,
"Now policy hidden: " + win);
} else { } else {
changed = win.showLw(false, false); if (!win.showLw(false, false)) {
if ((DEBUG_KEYGUARD || WindowManagerService.DEBUG_VISIBILITY) // Was already showing.
&& changed) Slog.v(TAG, "Now policy shown: " + win); continue;
if (changed) { }
if ((mBulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0 final boolean visibleNow = win.isVisibleNow();
&& win.isVisibleNow() /*w.isReadyForDisplay()*/) { if (!visibleNow) {
if (unForceHiding == null) { // Couldn't really show, must showLw() again when win becomes visible.
unForceHiding = new ArrayList<WindowStateAnimator>(); win.hideLw(false, false);
} continue;
unForceHiding.add(winAnimator); }
if ((flags & FLAG_SHOW_WALLPAPER) != 0) { if (DEBUG_KEYGUARD || WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG,
wallpaperInUnForceHiding = true; "Now policy shown: " + win);
} if ((mBulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0) {
if (unForceHiding == null) {
unForceHiding = new ArrayList<>();
} }
final WindowState currentFocus = mService.mCurrentFocus; unForceHiding.add(winAnimator);
if (currentFocus == null || currentFocus.mLayer < win.mLayer) { if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
// We are showing on to of the current wallpaperInUnForceHiding = true;
// focus, so re-evaluate focus to make
// sure it is correct.
if (WindowManagerService.DEBUG_FOCUS_LIGHT) Slog.v(TAG,
"updateWindowsLocked: setting mFocusMayChange true");
mService.mFocusMayChange = true;
} }
} else if (mPostKeyguardExitAnimation != null) {
// We're already in the middle of an animation. Use the existing
// animation to bring in this window.
winAnimator.setAnimation(mPostKeyguardExitAnimation);
winAnimator.keyguardGoingAwayAnimation = true;
}
final WindowState currentFocus = mService.mCurrentFocus;
if (currentFocus == null || currentFocus.mLayer < win.mLayer) {
// We are showing on top of the current
// focus, so re-evaluate focus to make
// sure it is correct.
if (WindowManagerService.DEBUG_FOCUS_LIGHT) Slog.v(TAG,
"updateWindowsLocked: setting mFocusMayChange true");
mService.mFocusMayChange = true;
} }
} }
if (changed && (flags & FLAG_SHOW_WALLPAPER) != 0) { if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE; mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
setPendingLayoutChanges(Display.DEFAULT_DISPLAY, setPendingLayoutChanges(Display.DEFAULT_DISPLAY,
WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER); WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
@@ -403,42 +419,44 @@ public class WindowAnimator {
// If we have windows that are being show due to them no longer // If we have windows that are being show due to them no longer
// being force-hidden, apply the appropriate animation to them. // being force-hidden, apply the appropriate animation to them.
if (unForceHiding != null) { if (unForceHiding != null) {
boolean startKeyguardExit = true; // This only happens the first time that we detect the keyguard is animating out.
for (int i=unForceHiding.size()-1; i>=0; i--) { if (mKeyguardGoingAwayDisableWindowAnimations) {
Animation a = null; if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: skipping anim for windows");
if (!mKeyguardGoingAwayDisableWindowAnimations) { } else {
a = mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding, if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: created anim for windows");
mKeyguardGoingAwayToNotificationShade); mPostKeyguardExitAnimation = mPolicy.createForceHideEnterAnimation(
if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: created anim=" + a wallpaperInUnForceHiding, mKeyguardGoingAwayToNotificationShade);
+ " for win=" + unForceHiding.get(i)); }
} else { if (mPostKeyguardExitAnimation != null) {
if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: skipping anim for win=" for (int i=unForceHiding.size()-1; i>=0; i--) {
+ unForceHiding.get(i));
}
if (a != null) {
final WindowStateAnimator winAnimator = unForceHiding.get(i); final WindowStateAnimator winAnimator = unForceHiding.get(i);
winAnimator.setAnimation(a); winAnimator.setAnimation(mPostKeyguardExitAnimation);
winAnimator.keyguardGoingAwayAnimation = true; winAnimator.keyguardGoingAwayAnimation = true;
if (startKeyguardExit && mKeyguardGoingAway) {
// Do one time only.
mPolicy.startKeyguardExitAnimation(mCurrentTime + a.getStartOffset(),
a.getDuration());
mKeyguardGoingAway = false;
startKeyguardExit = false;
}
} }
} }
}
// Wallpaper is going away in un-force-hide motion, animate it as well. if (mPostKeyguardExitAnimation != null) {
if (!wallpaperInUnForceHiding && wallpaper != null // We're in the midst of a keyguard exit animation.
&& !mKeyguardGoingAwayDisableWindowAnimations) { if (mKeyguardGoingAway) {
if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: wallpaper animating away"); mPolicy.startKeyguardExitAnimation(mCurrentTime +
Animation a = mPolicy.createForceHideWallpaperExitAnimation( mPostKeyguardExitAnimation.getStartOffset(),
mKeyguardGoingAwayToNotificationShade); mPostKeyguardExitAnimation.getDuration());
if (a != null) { mKeyguardGoingAway = false;
WindowStateAnimator animator = wallpaper.mWinAnimator; } else if (mPostKeyguardExitAnimation.hasEnded()) {
animator.setAnimation(a); // Done with the animation, reset.
} mPostKeyguardExitAnimation = null;
}
}
// Wallpaper is going away in un-force-hide motion, animate it as well.
if (!wallpaperInUnForceHiding && wallpaper != null
&& !mKeyguardGoingAwayDisableWindowAnimations) {
if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: wallpaper animating away");
Animation a = mPolicy.createForceHideWallpaperExitAnimation(
mKeyguardGoingAwayToNotificationShade);
if (a != null) {
wallpaper.mWinAnimator.setAnimation(a);
} }
} }
} }

View File

@@ -9783,7 +9783,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (!w.isDrawnLw()) { if (!w.isDrawnLw()) {
Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurfaceControl Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurfaceControl
+ " pv=" + w.mPolicyVisibility + " pv=" + w.mPolicyVisibility
+ " mDrawState=" + winAnimator.mDrawState + " mDrawState=" + winAnimator.drawStateToString()
+ " ah=" + w.mAttachedHidden + " ah=" + w.mAttachedHidden
+ " th=" + atoken.hiddenRequested + " th=" + atoken.hiddenRequested
+ " a=" + winAnimator.mAnimating); + " a=" + winAnimator.mAnimating);

View File

@@ -167,14 +167,14 @@ class WindowStateAnimator {
private static final int SYSTEM_UI_FLAGS_LAYOUT_STABLE_FULLSCREEN = private static final int SYSTEM_UI_FLAGS_LAYOUT_STABLE_FULLSCREEN =
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
static String drawStateToString(int state) { String drawStateToString() {
switch (state) { switch (mDrawState) {
case NO_SURFACE: return "NO_SURFACE"; case NO_SURFACE: return "NO_SURFACE";
case DRAW_PENDING: return "DRAW_PENDING"; case DRAW_PENDING: return "DRAW_PENDING";
case COMMIT_DRAW_PENDING: return "COMMIT_DRAW_PENDING"; case COMMIT_DRAW_PENDING: return "COMMIT_DRAW_PENDING";
case READY_TO_SHOW: return "READY_TO_SHOW"; case READY_TO_SHOW: return "READY_TO_SHOW";
case HAS_DRAWN: return "HAS_DRAWN"; case HAS_DRAWN: return "HAS_DRAWN";
default: return Integer.toString(state); default: return Integer.toString(mDrawState);
} }
} }
int mDrawState; int mDrawState;
@@ -489,7 +489,7 @@ class WindowStateAnimator {
if (DEBUG_STARTING_WINDOW && if (DEBUG_STARTING_WINDOW &&
mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
Slog.v(TAG, "Finishing drawing window " + mWin + ": mDrawState=" Slog.v(TAG, "Finishing drawing window " + mWin + ": mDrawState="
+ drawStateToString(mDrawState)); + drawStateToString());
} }
if (mDrawState == DRAW_PENDING) { if (mDrawState == DRAW_PENDING) {
if (DEBUG_SURFACE_TRACE || DEBUG_ANIM || SHOW_TRANSACTIONS || DEBUG_ORIENTATION) if (DEBUG_SURFACE_TRACE || DEBUG_ANIM || SHOW_TRANSACTIONS || DEBUG_ORIENTATION)
@@ -510,18 +510,17 @@ class WindowStateAnimator {
if (DEBUG_STARTING_WINDOW && if (DEBUG_STARTING_WINDOW &&
mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
Slog.i(TAG, "commitFinishDrawingLocked: " + mWin + " cur mDrawState=" Slog.i(TAG, "commitFinishDrawingLocked: " + mWin + " cur mDrawState="
+ drawStateToString(mDrawState)); + drawStateToString());
} }
if (mDrawState != COMMIT_DRAW_PENDING) { if (mDrawState != COMMIT_DRAW_PENDING && mDrawState != READY_TO_SHOW) {
return false; return false;
} }
if (DEBUG_SURFACE_TRACE || DEBUG_ANIM) { if (DEBUG_SURFACE_TRACE || DEBUG_ANIM) {
Slog.i(TAG, "commitFinishDrawingLocked: mDrawState=READY_TO_SHOW " + mSurfaceControl); Slog.i(TAG, "commitFinishDrawingLocked: mDrawState=READY_TO_SHOW " + mSurfaceControl);
} }
mDrawState = READY_TO_SHOW; mDrawState = READY_TO_SHOW;
final boolean starting = mWin.mAttrs.type == TYPE_APPLICATION_STARTING;
final AppWindowToken atoken = mWin.mAppToken; final AppWindowToken atoken = mWin.mAppToken;
if (atoken == null || atoken.allDrawn || starting) { if (atoken == null || atoken.allDrawn || mWin.mAttrs.type == TYPE_APPLICATION_STARTING) {
performShowLocked(); performShowLocked();
} }
return true; return true;
@@ -1868,7 +1867,7 @@ class WindowStateAnimator {
if (dumpAll) { if (dumpAll) {
pw.print(prefix); pw.print("mSurface="); pw.println(mSurfaceControl); pw.print(prefix); pw.print("mSurface="); pw.println(mSurfaceControl);
pw.print(prefix); pw.print("mDrawState="); pw.print(prefix); pw.print("mDrawState=");
pw.print(drawStateToString(mDrawState)); pw.print(drawStateToString());
pw.print(" mLastHidden="); pw.println(mLastHidden); pw.print(" mLastHidden="); pw.println(mLastHidden);
} }
pw.print(prefix); pw.print("Surface: shown="); pw.print(mSurfaceShown); pw.print(prefix); pw.print("Surface: shown="); pw.print(mSurfaceShown);