Add animation when unoccluding windows (1/2) am: 6626f54e65

am: 314c05db45

Change-Id: I0e9d85e8f90d00fe835c0622438ac5b6afd2b52d
This commit is contained in:
Jorim Jaggi
2016-08-30 02:33:24 +00:00
committed by android-build-merger
19 changed files with 136 additions and 40 deletions

View File

@@ -507,6 +507,11 @@ public interface WindowManagerPolicy {
* Retrieves the {@param outBounds} from the stack with id {@param stackId}.
*/
void getStackBounds(int stackId, Rect outBounds);
/**
* Overrides all currently playing app animations with {@param a}.
*/
void overridePlayingAppAnimationsLw(Animation a);
}
public interface PointerEventListener {

View File

@@ -28,8 +28,9 @@ oneway interface IKeyguardService {
* FLAG_SHOW_ON_LOCK_SCREEN.
*
* @param isOccluded Whether the Keyguard is occluded by another window.
* @param animate Whether to play an animation for the state change.
*/
void setOccluded(boolean isOccluded);
void setOccluded(boolean isOccluded, boolean animate);
void addStateMonitorCallback(IKeyguardStateCallback callback);
void verifyUnlock(IKeyguardExitCallback callback);

View File

@@ -1947,6 +1947,7 @@
<java-symbol type="anim" name="lock_screen_behind_enter_fade_in" />
<java-symbol type="anim" name="lock_screen_wallpaper_exit" />
<java-symbol type="anim" name="launch_task_behind_source" />
<java-symbol type="anim" name="wallpaper_open_exit" />
<java-symbol type="bool" name="config_alwaysUseCdmaRssi" />
<java-symbol type="dimen" name="status_bar_icon_size" />

View File

@@ -90,10 +90,10 @@ public class KeyguardService extends Service {
}
@Override // Binder interface
public void setOccluded(boolean isOccluded) {
public void setOccluded(boolean isOccluded, boolean animate) {
Trace.beginSection("KeyguardService.mBinder#setOccluded");
checkPermission();
mKeyguardViewMediator.setOccluded(isOccluded);
mKeyguardViewMediator.setOccluded(isOccluded, animate);
Trace.endSection();
}

View File

@@ -1114,11 +1114,11 @@ public class KeyguardViewMediator extends SystemUI {
/**
* Notify us when the keyguard is occluded by another window
*/
public void setOccluded(boolean isOccluded) {
public void setOccluded(boolean isOccluded, boolean animate) {
Trace.beginSection("KeyguardViewMediator#setOccluded");
if (DEBUG) Log.d(TAG, "setOccluded " + isOccluded);
mHandler.removeMessages(SET_OCCLUDED);
Message msg = mHandler.obtainMessage(SET_OCCLUDED, (isOccluded ? 1 : 0), 0);
Message msg = mHandler.obtainMessage(SET_OCCLUDED, isOccluded ? 1 : 0, animate ? 1 : 0);
mHandler.sendMessage(msg);
Trace.endSection();
}
@@ -1126,7 +1126,7 @@ public class KeyguardViewMediator extends SystemUI {
/**
* Handles SET_OCCLUDED message sent by setOccluded()
*/
private void handleSetOccluded(boolean isOccluded) {
private void handleSetOccluded(boolean isOccluded, boolean animate) {
Trace.beginSection("KeyguardViewMediator#handleSetOccluded");
synchronized (KeyguardViewMediator.this) {
if (mHiding && isOccluded) {
@@ -1137,7 +1137,7 @@ public class KeyguardViewMediator extends SystemUI {
if (mOccluded != isOccluded) {
mOccluded = isOccluded;
mStatusBarKeyguardViewManager.setOccluded(isOccluded);
mStatusBarKeyguardViewManager.setOccluded(isOccluded, animate);
updateActivityLockScreenState();
adjustStatusBarLocked();
}
@@ -1468,7 +1468,7 @@ public class KeyguardViewMediator extends SystemUI {
break;
case SET_OCCLUDED:
Trace.beginSection("KeyguardViewMediator#handleMessage SET_OCCLUDED");
handleSetOccluded(msg.arg1 != 0);
handleSetOccluded(msg.arg1 != 0, msg.arg2 != 0);
Trace.endSection();
break;
case KEYGUARD_TIMEOUT:

View File

@@ -92,6 +92,7 @@ public abstract class PanelView extends FrameLayout {
* Whether an instant expand request is currently pending and we are just waiting for layout.
*/
private boolean mInstantExpanding;
private boolean mAnimateAfterExpanding;
PanelBar mBar;
@@ -656,7 +657,7 @@ public abstract class PanelView extends FrameLayout {
vel = 0;
}
mFlingAnimationUtils.apply(animator, mExpandedHeight, target, vel, getHeight());
if (expandBecauseOfFalsing) {
if (vel == 0) {
animator.setDuration(350);
}
} else {
@@ -870,6 +871,7 @@ public abstract class PanelView extends FrameLayout {
}
mInstantExpanding = true;
mAnimateAfterExpanding = animate;
mUpdateFlingOnLayout = false;
abortAnimations();
cancelPeek();
@@ -894,7 +896,7 @@ public abstract class PanelView extends FrameLayout {
if (mStatusBar.getStatusBarWindow().getHeight()
!= mStatusBar.getStatusBarHeight()) {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
if (animate) {
if (mAnimateAfterExpanding) {
notifyExpandingStarted();
fling(0, true /* expand */);
} else {

View File

@@ -279,6 +279,14 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
*/
private static final int REMOTE_INPUT_KEPT_ENTRY_AUTO_CANCEL_DELAY = 200;
/**
* Never let the alpha become zero for surfaces that draw with SRC - otherwise the RenderNode
* won't draw anything and uninitialized memory will show through
* if mScrimSrcModeEnabled. Note that 0.001 is rounded down to 0 in
* libhwui.
*/
private static final float SRC_MIN_ALPHA = 0.002f;
static {
boolean onlyCoreApps;
boolean freeformWindowManagement;
@@ -2209,17 +2217,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
if (mBackdrop.getVisibility() != View.VISIBLE) {
mBackdrop.setVisibility(View.VISIBLE);
if (allowEnterAnimation) {
mBackdrop.animate().alpha(1f).withEndAction(new Runnable() {
@Override
public void run() {
mStatusBarWindowManager.setBackdropShowing(true);
}
});
mBackdrop.setAlpha(SRC_MIN_ALPHA);
mBackdrop.animate().alpha(1f);
} else {
mBackdrop.animate().cancel();
mBackdrop.setAlpha(1f);
mStatusBarWindowManager.setBackdropShowing(true);
}
mStatusBarWindowManager.setBackdropShowing(true);
metaDataChanged = true;
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: Fading in album artwork");
@@ -2282,11 +2286,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
} else {
mStatusBarWindowManager.setBackdropShowing(false);
mBackdrop.animate()
// Never let the alpha become zero - otherwise the RenderNode
// won't draw anything and uninitialized memory will show through
// if mScrimSrcModeEnabled. Note that 0.001 is rounded down to 0 in
// libhwui.
.alpha(0.002f)
.alpha(SRC_MIN_ALPHA)
.setInterpolator(Interpolators.ACCELERATE_DECELERATE)
.setDuration(300)
.setStartDelay(0)
@@ -2301,7 +2301,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
});
if (mKeyguardFadingAway) {
mBackdrop.animate()
// Make it disappear faster, as the focus should be on the activity
// behind.
.setDuration(mKeyguardFadingAwayDuration / 2)
@@ -4119,6 +4118,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
.start();
}
/**
* Plays the animation when an activity that was occluding Keyguard goes away.
*/
public void animateKeyguardUnoccluding() {
mScrimController.animateKeyguardUnoccluding(500);
mNotificationPanel.setExpandedFraction(0f);
animateExpandNotificationsPanel();
}
/**
* Starts the timeout when we try to start the affordances on Keyguard. We usually rely that
* Keyguard goes away via fadeKeyguardAfterLaunchTransition, however, that might not happen

View File

@@ -196,6 +196,14 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
}
}
public void animateKeyguardUnoccluding(long duration) {
mAnimateChange = false;
setScrimBehindColor(0f);
mAnimateChange = true;
scheduleUpdate();
mDurationOverride = duration;
}
public void animateGoingToFullShade(long delay, long duration) {
mDurationOverride = duration;
mAnimationDelay = delay;

View File

@@ -242,7 +242,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
return mStatusBarWindowManager.isShowingWallpaper();
}
public void setOccluded(boolean occluded) {
public void setOccluded(boolean occluded, boolean animate) {
if (occluded && !mOccluded && mShowing) {
if (mPhoneStatusBar.isInLaunchTransition()) {
mOccluded = true;
@@ -258,9 +258,12 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
}
}
mOccluded = occluded;
mPhoneStatusBar.updateMediaMetaData(false, false);
mPhoneStatusBar.updateMediaMetaData(false, animate && !occluded);
mStatusBarWindowManager.setKeyguardOccluded(occluded);
reset();
if (animate && !occluded) {
mPhoneStatusBar.animateKeyguardUnoccluding();
}
}
public boolean isOccluded() {

View File

@@ -5399,15 +5399,18 @@ public class PhoneWindowManager implements WindowManagerPolicy {
boolean showing = mKeyguardDelegate.isShowing();
if (wasOccluded && !isOccluded && showing) {
mKeyguardOccluded = false;
mKeyguardDelegate.setOccluded(false);
mKeyguardDelegate.setOccluded(false, true /* animate */);
mStatusBar.getAttrs().privateFlags |= PRIVATE_FLAG_KEYGUARD;
if (!mKeyguardDelegate.hasLockscreenWallpaper()) {
mStatusBar.getAttrs().flags |= FLAG_SHOW_WALLPAPER;
}
Animation anim = AnimationUtils.loadAnimation(mContext,
com.android.internal.R.anim.wallpaper_open_exit);
mWindowManagerFuncs.overridePlayingAppAnimationsLw(anim);
return true;
} else if (!wasOccluded && isOccluded && showing) {
mKeyguardOccluded = true;
mKeyguardDelegate.setOccluded(true);
mKeyguardDelegate.setOccluded(true, false /* animate */);
mStatusBar.getAttrs().privateFlags &= ~PRIVATE_FLAG_KEYGUARD;
mStatusBar.getAttrs().flags &= ~FLAG_SHOW_WALLPAPER;
return true;

View File

@@ -188,7 +188,7 @@ public class KeyguardServiceDelegate {
mKeyguardService.onBootCompleted();
}
if (mKeyguardState.occluded) {
mKeyguardService.setOccluded(mKeyguardState.occluded);
mKeyguardService.setOccluded(mKeyguardState.occluded, false /* animate */);
}
}
@@ -240,10 +240,10 @@ public class KeyguardServiceDelegate {
}
}
public void setOccluded(boolean isOccluded) {
public void setOccluded(boolean isOccluded, boolean animate) {
if (mKeyguardService != null) {
if (DEBUG) Log.v(TAG, "setOccluded(" + isOccluded + ")");
mKeyguardService.setOccluded(isOccluded);
if (DEBUG) Log.v(TAG, "setOccluded(" + isOccluded + ") animate=" + animate);
mKeyguardService.setOccluded(isOccluded, animate);
}
mKeyguardState.occluded = isOccluded;
}

View File

@@ -63,9 +63,9 @@ public class KeyguardServiceWrapper implements IKeyguardService {
}
@Override // Binder interface
public void setOccluded(boolean isOccluded) {
public void setOccluded(boolean isOccluded, boolean animate) {
try {
mService.setOccluded(isOccluded);
mService.setOccluded(isOccluded, animate);
} catch (RemoteException e) {
Slog.w(TAG , "Remote Exception", e);
}

View File

@@ -30,6 +30,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerService.WINDOW_REPLACEMENT_TIMEOUT_DURATION;
import static com.android.server.wm.WindowManagerService.H.NOTIFY_ACTIVITY_DRAWN;
import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_NONE;
import com.android.server.input.InputApplicationHandle;
import com.android.server.wm.WindowManagerService.H;
@@ -44,6 +45,7 @@ import android.util.Slog;
import android.view.IApplicationToken;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Animation;
import java.io.PrintWriter;
import java.util.ArrayDeque;
@@ -838,6 +840,18 @@ class AppWindowToken extends WindowToken {
}
}
/**
* See {@link WindowManagerService#overridePlayingAppAnimationsLw}
*/
void overridePlayingAppAnimations(Animation a) {
if (mAppAnimator.isAnimating()) {
final WindowState win = findMainWindow();
final int width = win.mContainingFrame.width();
final int height = win.mContainingFrame.height();
mAppAnimator.setAnimation(a, width, height, false, STACK_CLIP_NONE);
}
}
@Override
void dump(PrintWriter pw, String prefix) {
super.dump(pw, prefix);

View File

@@ -35,6 +35,7 @@ import android.util.Slog;
import android.view.Display;
import android.view.DisplayInfo;
import android.view.Surface;
import android.view.animation.Animation;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -674,4 +675,13 @@ class DisplayContent {
return touchedWin;
}
/**
* See {@link WindowManagerService#overridePlayingAppAnimationsLw}.
*/
void overridePlayingAppAnimationsLw(Animation a) {
for (int i = mStacks.size() - 1; i >= 0; i--) {
mStacks.get(i).overridePlayingAppAnimations(a);
}
}
}

View File

@@ -38,6 +38,7 @@ import android.util.EventLog;
import android.util.Slog;
import android.view.DisplayInfo;
import android.view.Surface;
import android.view.animation.Animation;
import com.android.server.EventLogTags;
@@ -765,6 +766,15 @@ class Task implements DimLayer.DimLayerUser {
return mStack.getDisplayContent().getDisplayInfo();
}
/**
* See {@link WindowManagerService#overridePlayingAppAnimationsLw}
*/
void overridePlayingAppAnimations(Animation a) {
for (int i = mAppTokens.size() - 1; i >= 0; i--) {
mAppTokens.get(i).overridePlayingAppAnimations(a);
}
}
@Override
public String toString() {
return "{taskId=" + mTaskId + " appTokens=" + mAppTokens + " mdr=" + mDeferRemoval + "}";

View File

@@ -44,6 +44,7 @@ import android.util.SparseArray;
import android.view.DisplayInfo;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.animation.Animation;
import com.android.internal.policy.DividerSnapAlgorithm;
import com.android.internal.policy.DividerSnapAlgorithm.SnapTarget;
@@ -1367,4 +1368,13 @@ public class TaskStack implements DimLayer.DimLayerUser,
public boolean getBoundsAnimating() {
return mBoundsAnimating;
}
/**
* See {@link WindowManagerService#overridePlayingAppAnimationsLw}
*/
void overridePlayingAppAnimations(Animation a) {
for (int i = mTasks.size() - 1; i >= 0; --i) {
mTasks.get(i).overridePlayingAppAnimations(a);
}
}
}

View File

@@ -757,14 +757,16 @@ class WallpaperController {
}
// Now stick it in. For apps over wallpaper keep the wallpaper at the bottommost
// layer. For keyguard over wallpaper put the wallpaper under the keyguard.
// layer. For keyguard over wallpaper put the wallpaper under the lowest window that
// is currently on screen, i.e. not hidden by policy.
int insertionIndex = 0;
if (visible && wallpaperTarget != null) {
final int type = wallpaperTarget.mAttrs.type;
final int privateFlags = wallpaperTarget.mAttrs.privateFlags;
if ((privateFlags & PRIVATE_FLAG_KEYGUARD) != 0
|| type == TYPE_KEYGUARD_SCRIM) {
insertionIndex = windows.indexOf(wallpaperTarget);
insertionIndex = Math.min(windows.indexOf(wallpaperTarget),
findLowestWindowOnScreen(windows));
}
}
if (DEBUG_WALLPAPER_LIGHT || DEBUG_WINDOW_MOVEMENT
@@ -781,6 +783,21 @@ class WallpaperController {
return changed;
}
/**
* @return The index in {@param windows} of the lowest window that is currently on screen and
* not hidden by the policy.
*/
private int findLowestWindowOnScreen(WindowList windows) {
final int size = windows.size();
for (int index = 0; index < size; index++) {
final WindowState win = windows.get(index);
if (win.isOnScreen()) {
return index;
}
}
return Integer.MAX_VALUE;
}
boolean adjustWallpaperWindows() {
mService.mWindowPlacerLocked.mWallpaperMayChange = false;

View File

@@ -234,14 +234,12 @@ public class WindowAnimator {
boolean allowWhenLocked = false;
// Show IME over the keyguard if the target allows it
allowWhenLocked |= (win.mIsImWindow || imeTarget == win) && showImeOverKeyguard;
// Show SHOW_WHEN_LOCKED windows that turn on the screen
allowWhenLocked |= (win.mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0 && win.mTurnOnScreen;
// Show SHOW_WHEN_LOCKED windows
allowWhenLocked |= (win.mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0;
if (appShowWhenLocked != null) {
allowWhenLocked |= appShowWhenLocked == win.mAppToken
// Show all SHOW_WHEN_LOCKED windows if some apps are shown over lockscreen
|| (win.mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0
// Show error dialogs over apps that dismiss keyguard.
// Show error dialogs over apps that are shown on lockscreen
|| (win.mAttrs.privateFlags & PRIVATE_FLAG_SYSTEM_ERROR) != 0;
}

View File

@@ -249,6 +249,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_KEEP_SCREEN_ON;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowStateAnimator.DRAW_PENDING;
import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_NONE;
/** {@hide} */
public class WindowManagerService extends IWindowManager.Stub
@@ -5211,6 +5212,11 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
@Override
public void overridePlayingAppAnimationsLw(Animation a) {
getDefaultDisplayContentLocked().overridePlayingAppAnimationsLw(a);
}
/**
* Re-sizes a stack and its containing tasks.
* @param stackId Id of stack to resize.