Merge "Don't show wallpaper when backdrop is visible" into nyc-dev

This commit is contained in:
Adrian Roos
2016-03-15 03:26:00 +00:00
committed by Android (Google) Code Review
15 changed files with 97 additions and 41 deletions

View File

@@ -2307,7 +2307,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
case KEYGUARD_GOING_AWAY_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
keyguardGoingAway(data.readInt() != 0, data.readInt() != 0);
keyguardGoingAway(data.readInt());
reply.writeNoException();
return true;
}
@@ -5924,13 +5924,12 @@ class ActivityManagerProxy implements IActivityManager
reply.recycle();
}
public void keyguardGoingAway(boolean disableWindowAnimations,
boolean keyguardGoingToNotificationShade) throws RemoteException {
public void keyguardGoingAway(int flags)
throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeInt(disableWindowAnimations ? 1 : 0);
data.writeInt(keyguardGoingToNotificationShade ? 1 : 0);
data.writeInt(flags);
mRemote.transact(KEYGUARD_GOING_AWAY_TRANSACTION, data, reply, 0);
reply.readException();
data.recycle();

View File

@@ -475,8 +475,13 @@ public interface IActivityManager extends IInterface {
public void keyguardWaitingForActivityDrawn() throws RemoteException;
public void keyguardGoingAway(boolean disableWindowAnimations,
boolean keyguardGoingToNotificationShade) throws RemoteException;
/**
* Notify the system that the keyguard is going away.
*
* @param flags See {@link android.view.WindowManagerPolicy#KEYGUARD_GOING_AWAY_FLAG_TO_SHADE}
* etc.
*/
public void keyguardGoingAway(int flags) throws RemoteException;
public boolean shouldUpRecreateTask(IBinder token, String destAffinity)
throws RemoteException;

View File

@@ -193,8 +193,7 @@ interface IWindowManager
boolean isKeyguardSecure();
boolean inKeyguardRestrictedInputMode();
void dismissKeyguard();
void keyguardGoingAway(boolean disableWindowAnimations,
boolean keyguardGoingToNotificationShade);
void keyguardGoingAway(int flags);
void closeSystemDialogs(String reason);

View File

@@ -91,6 +91,11 @@ public interface WindowManagerPolicy {
public final static int FLAG_INTERACTIVE = 0x20000000;
public final static int FLAG_PASS_TO_USER = 0x40000000;
// Flags for IActivityManager.keyguardGoingAway()
public final static int KEYGUARD_GOING_AWAY_FLAG_TO_SHADE = 1 << 0;
public final static int KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS = 1 << 1;
public final static int KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER = 1 << 2;
// Flags used for indicating whether the internal and/or external input devices
// of some type are available.
public final static int PRESENCE_INTERNAL = 1 << 0;

View File

@@ -16,7 +16,6 @@
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#ff000000"
android:detachWallpaper="true"
android:shareInterpolator="false"
android:startOffset="100">

View File

@@ -1543,13 +1543,22 @@ public class KeyguardViewMediator extends SystemUI {
try {
mStatusBarKeyguardViewManager.keyguardGoingAway();
int flags = 0;
if (mStatusBarKeyguardViewManager.shouldDisableWindowAnimationsForUnlock()
|| mWakeAndUnlocking) {
flags |= WindowManagerPolicy.KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS;
}
if (mStatusBarKeyguardViewManager.isGoingToNotificationShade()) {
flags |= WindowManagerPolicy.KEYGUARD_GOING_AWAY_FLAG_TO_SHADE;
}
if (mStatusBarKeyguardViewManager.isUnlockWithWallpaper()) {
flags |= WindowManagerPolicy.KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER;
}
// Don't actually hide the Keyguard at the moment, wait for window
// manager until it tells us it's safe to do so with
// startKeyguardExitAnimation.
ActivityManagerNative.getDefault().keyguardGoingAway(
mStatusBarKeyguardViewManager.shouldDisableWindowAnimationsForUnlock()
|| mWakeAndUnlocking,
mStatusBarKeyguardViewManager.isGoingToNotificationShade());
ActivityManagerNative.getDefault().keyguardGoingAway(flags);
} catch (RemoteException e) {
Log.e(TAG, "Error while calling WindowManager", e);
}

View File

@@ -1887,10 +1887,16 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
if (mBackdrop.getVisibility() != View.VISIBLE) {
mBackdrop.setVisibility(View.VISIBLE);
if (allowEnterAnimation) {
mBackdrop.animate().alpha(1f);
mBackdrop.animate().alpha(1f).withEndAction(new Runnable() {
@Override
public void run() {
mStatusBarWindowManager.setBackdropShowing(true);
}
});
} else {
mBackdrop.animate().cancel();
mBackdrop.setAlpha(1f);
mStatusBarWindowManager.setBackdropShowing(true);
}
metaDataChanged = true;
if (DEBUG_MEDIA) {
@@ -1948,7 +1954,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
// We are unlocking directly - no animation!
mBackdrop.setVisibility(View.GONE);
mBackdropBack.setImageDrawable(null);
mStatusBarWindowManager.setBackdropShowing(false);
} 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

View File

@@ -227,6 +227,10 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
mStatusBarWindowManager.setKeyguardNeedsInput(needsInput);
}
public boolean isUnlockWithWallpaper() {
return mStatusBarWindowManager.isShowingWallpaper();
}
public void setOccluded(boolean occluded) {
if (occluded && !mOccluded && mShowing) {
if (mPhoneStatusBar.isInLaunchTransition()) {

View File

@@ -100,12 +100,16 @@ public class StatusBarWindowManager implements RemoteInputController.Callback {
private void applyKeyguardFlags(State state) {
if (state.keyguardShowing) {
mLpChanged.flags |= WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
mLpChanged.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
} else {
mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
mLpChanged.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
}
if (state.keyguardShowing && !state.backdropShowing) {
mLpChanged.flags |= WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
} else {
mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
}
}
private void adjustScreenOrientation(State state) {
@@ -255,6 +259,11 @@ public class StatusBarWindowManager implements RemoteInputController.Callback {
apply(mCurrentState);
}
public void setBackdropShowing(boolean showing) {
mCurrentState.backdropShowing = showing;
apply(mCurrentState);
}
public void setKeyguardFadingAway(boolean keyguardFadingAway) {
mCurrentState.keyguardFadingAway = keyguardFadingAway;
apply(mCurrentState);
@@ -323,6 +332,10 @@ public class StatusBarWindowManager implements RemoteInputController.Callback {
pw.println(mCurrentState);
}
public boolean isShowingWallpaper() {
return !mCurrentState.backdropShowing;
}
private static class State {
boolean keyguardShowing;
boolean keyguardOccluded;
@@ -338,6 +351,7 @@ public class StatusBarWindowManager implements RemoteInputController.Callback {
boolean forceCollapsed;
boolean forceDozeBrightness;
boolean forceUserActivity;
boolean backdropShowing;
/**
* The {@link BaseStatusBar} state from the status bar.

View File

@@ -6497,15 +6497,13 @@ public final class ActivityManagerService extends ActivityManagerNative
}
@Override
public void keyguardGoingAway(boolean disableWindowAnimations,
boolean keyguardGoingToNotificationShade) {
public void keyguardGoingAway(int flags) {
enforceNotIsolatedCaller("keyguardGoingAway");
final long token = Binder.clearCallingIdentity();
try {
synchronized (this) {
if (DEBUG_LOCKSCREEN) logLockScreen("");
mWindowManager.keyguardGoingAway(disableWindowAnimations,
keyguardGoingToNotificationShade);
mWindowManager.keyguardGoingAway(flags);
if (mLockScreenShown == LOCK_SCREEN_SHOWN) {
mLockScreenShown = LOCK_SCREEN_HIDDEN;
updateSleepIfNeededLocked();

View File

@@ -508,10 +508,11 @@ class WallpaperController {
replacing = replacing || w.mWillReplaceWindow;
// If the app is executing an animation because the keyguard is going away,
// keep the wallpaper during the animation so it doesn't flicker out.
// If the app is executing an animation because the keyguard is going away (and the
// keyguard was showing the wallpaper) keep the wallpaper during the animation so it
// doesn't flicker out.
final boolean hasWallpaper = (w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0
|| (w.mAppToken != null && w.mWinAnimator.mKeyguardGoingAwayAnimation);
|| (w.mAppToken != null && w.mWinAnimator.mKeyguardGoingAwayWithWallpaper);
if (hasWallpaper && w.isOnScreen() && (mWallpaperTarget == w || w.isDrawFinishedLw())) {
if (DEBUG_WALLPAPER) Slog.v(TAG, "Found wallpaper target: #" + i + "=" + w);
result.setWallpaperTarget(w, i);

View File

@@ -22,6 +22,9 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_SYSTEM_ERROR;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
import static android.view.WindowManagerPolicy.KEYGUARD_GOING_AWAY_FLAG_TO_SHADE;
import static android.view.WindowManagerPolicy.KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS;
import static android.view.WindowManagerPolicy.KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_KEYGUARD;
@@ -98,8 +101,7 @@ public class WindowAnimator {
boolean mInitialized = false;
boolean mKeyguardGoingAway;
boolean mKeyguardGoingAwayToNotificationShade;
boolean mKeyguardGoingAwayDisableWindowAnimations;
int mKeyguardGoingAwayFlags;
/** Use one animation for all entering activities after keyguard is dismissed. */
Animation mPostKeyguardExitAnimation;
@@ -243,6 +245,13 @@ public class WindowAnimator {
final WindowList windows = mService.getWindowListLocked(displayId);
final boolean keyguardGoingAwayToShade =
(mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_TO_SHADE) != 0;
final boolean keyguardGoingAwayNoAnimation =
(mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS) != 0;
final boolean keyguardGoingAwayWithWallpaper =
(mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER) != 0;
if (mKeyguardGoingAway) {
for (int i = windows.size() - 1; i >= 0; i--) {
WindowState win = windows.get(i);
@@ -261,6 +270,8 @@ public class WindowAnimator {
winAnimator.mAnimationIsEntrance = false;
winAnimator.mAnimationStartTime = -1;
winAnimator.mKeyguardGoingAwayAnimation = true;
winAnimator.mKeyguardGoingAwayWithWallpaper
= keyguardGoingAwayWithWallpaper;
}
} else {
if (DEBUG_KEYGUARD) Slog.d(TAG,
@@ -392,10 +403,13 @@ public class WindowAnimator {
if (DEBUG_KEYGUARD) Slog.v(TAG,
"Applying existing Keyguard exit animation to new window: win="
+ win);
Animation a = mPolicy.createForceHideEnterAnimation(
false, mKeyguardGoingAwayToNotificationShade);
Animation a = mPolicy.createForceHideEnterAnimation(false,
keyguardGoingAwayToShade);
winAnimator.setAnimation(a, mPostKeyguardExitAnimation.getStartTime());
winAnimator.mKeyguardGoingAwayAnimation = true;
winAnimator.mKeyguardGoingAwayWithWallpaper
= keyguardGoingAwayWithWallpaper;
}
final WindowState currentFocus = mService.mCurrentFocus;
if (currentFocus == null || currentFocus.mLayer < win.mLayer) {
@@ -463,18 +477,20 @@ public class WindowAnimator {
// being force-hidden, apply the appropriate animation to them if animations are not
// disabled.
if (unForceHiding != null) {
if (!mKeyguardGoingAwayDisableWindowAnimations) {
if (!keyguardGoingAwayNoAnimation) {
boolean first = true;
for (int i=unForceHiding.size()-1; i>=0; i--) {
final WindowStateAnimator winAnimator = unForceHiding.get(i);
Animation a = mPolicy.createForceHideEnterAnimation(
wallpaperInUnForceHiding && !startingInUnForceHiding,
mKeyguardGoingAwayToNotificationShade);
keyguardGoingAwayToShade);
if (a != null) {
if (DEBUG_KEYGUARD) Slog.v(TAG,
"Starting keyguard exit animation on window " + winAnimator.mWin);
winAnimator.setAnimation(a);
winAnimator.mKeyguardGoingAwayAnimation = true;
winAnimator.mKeyguardGoingAwayWithWallpaper
= keyguardGoingAwayWithWallpaper;
if (first) {
mPostKeyguardExitAnimation = a;
mPostKeyguardExitAnimation.setStartTime(mCurrentTime);
@@ -489,11 +505,10 @@ public class WindowAnimator {
// Wallpaper is going away in un-force-hide motion, animate it as well.
if (!wallpaperInUnForceHiding && wallpaper != null
&& !mKeyguardGoingAwayDisableWindowAnimations) {
if (!wallpaperInUnForceHiding && wallpaper != null && !keyguardGoingAwayNoAnimation) {
if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: wallpaper animating away");
Animation a = mPolicy.createForceHideWallpaperExitAnimation(
mKeyguardGoingAwayToNotificationShade);
keyguardGoingAwayToShade);
if (a != null) {
wallpaper.mWinAnimator.setAnimation(a);
}

View File

@@ -5179,18 +5179,16 @@ public class WindowManagerService extends IWindowManager.Stub
}
@Override
public void keyguardGoingAway(boolean disableWindowAnimations,
boolean keyguardGoingToNotificationShade) {
public void keyguardGoingAway(int flags) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Requires DISABLE_KEYGUARD permission");
}
if (DEBUG_KEYGUARD) Slog.d(TAG_WM, "keyguardGoingAway: disableWinAnim="
+ disableWindowAnimations + " kgToNotifShade=" + keyguardGoingToNotificationShade);
if (DEBUG_KEYGUARD) Slog.d(TAG_WM,
"keyguardGoingAway: flags=0x" + Integer.toHexString(flags));
synchronized (mWindowMap) {
mAnimator.mKeyguardGoingAway = true;
mAnimator.mKeyguardGoingAwayToNotificationShade = keyguardGoingToNotificationShade;
mAnimator.mKeyguardGoingAwayDisableWindowAnimations = disableWindowAnimations;
mAnimator.mKeyguardGoingAwayFlags = flags;
mWindowPlacerLocked.requestTraversal();
}
}

View File

@@ -160,6 +160,7 @@ class WindowStateAnimator {
boolean mEnteringAnimation;
boolean mKeyguardGoingAwayAnimation;
boolean mKeyguardGoingAwayWithWallpaper;
/** The pixel format of the underlying SurfaceControl */
int mSurfaceFormat;
@@ -250,6 +251,7 @@ class WindowStateAnimator {
mAnimation.cancel();
mAnimation = null;
mKeyguardGoingAwayAnimation = false;
mKeyguardGoingAwayWithWallpaper = false;
}
}
@@ -381,6 +383,7 @@ class WindowStateAnimator {
mAnimating = false;
mKeyguardGoingAwayAnimation = false;
mKeyguardGoingAwayWithWallpaper = false;
mLocalAnimating = false;
if (mAnimation != null) {
mAnimation.cancel();

View File

@@ -492,8 +492,7 @@ public class IWindowManagerImpl implements IWindowManager {
}
@Override
public void keyguardGoingAway(boolean disableWindowAnimations,
boolean keyguardGoingToNotificationShade) throws RemoteException {
public void keyguardGoingAway(int flags) throws RemoteException {
}
@Override