From 33bc5823173cbed53205d86879dda05fb94311b4 Mon Sep 17 00:00:00 2001 From: Daniel Chapin Date: Thu, 14 Oct 2021 21:23:55 +0000 Subject: [PATCH] Revert "Keep FLAG_SHOW_WALLPAPER flag on NotificationShade." This reverts commit 7f1a5a79d136fd5c8aa5a0d600cf759eddc09b05. Reason for revert: Droidfood blocking bugs bug: 203025772 & bug: 203041994 Bug: 203041994 Bug: 203030884 Bug: 203025772 Change-Id: Iecb089045525e24b5e5ece312016eb20400da575 Merged-In: I768c13d2959fb92d2a5d038df560e1575aea0712 --- .../policy/IKeyguardStateCallback.aidl | 1 + .../keyguard/KeyguardUpdateMonitor.java | 26 +++++++++++++++++++ .../KeyguardUpdateMonitorCallback.java | 5 ++++ .../keyguard/KeyguardViewMediator.java | 23 ++++++++++++++++ .../statusbar/phone/LockscreenWallpaper.java | 2 ++ .../server/policy/PhoneWindowManager.java | 14 +++++++++- .../keyguard/KeyguardServiceDelegate.java | 7 +++++ .../keyguard/KeyguardServiceWrapper.java | 4 +++ .../policy/keyguard/KeyguardStateMonitor.java | 10 +++++++ .../com/android/server/wm/DisplayPolicy.java | 9 +++++++ .../server/wm/WindowManagerService.java | 14 ++++------ 11 files changed, 105 insertions(+), 10 deletions(-) diff --git a/core/java/com/android/internal/policy/IKeyguardStateCallback.aidl b/core/java/com/android/internal/policy/IKeyguardStateCallback.aidl index 419b1f8feac7a..8e454db4cb040 100644 --- a/core/java/com/android/internal/policy/IKeyguardStateCallback.aidl +++ b/core/java/com/android/internal/policy/IKeyguardStateCallback.aidl @@ -20,4 +20,5 @@ interface IKeyguardStateCallback { void onSimSecureStateChanged(boolean simSecure); void onInputRestrictedStateChanged(boolean inputRestricted); void onTrustedChanged(boolean trusted); + void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper); } \ No newline at end of file diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 24f367335ad98..5969e9290c9c9 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -277,6 +277,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab private boolean mBouncer; // true if bouncerIsOrWillBeShowing private boolean mAuthInterruptActive; private boolean mNeedsSlowUnlockTransition; + private boolean mHasLockscreenWallpaper; private boolean mAssistantVisible; private boolean mKeyguardOccluded; private boolean mOccludingAppRequestingFp; @@ -2577,6 +2578,31 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } } + /** + * Update the state whether Keyguard currently has a lockscreen wallpaper. + * + * @param hasLockscreenWallpaper Whether Keyguard has a lockscreen wallpaper. + */ + public void setHasLockscreenWallpaper(boolean hasLockscreenWallpaper) { + Assert.isMainThread(); + if (hasLockscreenWallpaper != mHasLockscreenWallpaper) { + mHasLockscreenWallpaper = hasLockscreenWallpaper; + for (int i = 0; i < mCallbacks.size(); i++) { + KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); + if (cb != null) { + cb.onHasLockscreenWallpaperChanged(hasLockscreenWallpaper); + } + } + } + } + + /** + * @return Whether Keyguard has a lockscreen wallpaper. + */ + public boolean hasLockscreenWallpaper() { + return mHasLockscreenWallpaper; + } + /** * Handle {@link #MSG_DPM_STATE_CHANGED} */ diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java index e970a86c65168..6aa7aaa4d4889 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java @@ -291,6 +291,11 @@ public class KeyguardUpdateMonitorCallback { */ public void onStrongAuthStateChanged(int userId) { } + /** + * Called when the state whether we have a lockscreen wallpaper has changed. + */ + public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) { } + /** * Called when the dream's window state is changed. * @param dreaming true if the dream's window has been created and is visible diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 7931cb84ce8f0..1561eb6368a8e 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -671,6 +671,13 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable, } } } + + @Override + public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) { + synchronized (KeyguardViewMediator.this) { + notifyHasLockscreenWallpaperChanged(hasLockscreenWallpaper); + } + } }; ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() { @@ -2862,6 +2869,21 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable, } } + private void notifyHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) { + int size = mKeyguardStateCallbacks.size(); + for (int i = size - 1; i >= 0; i--) { + try { + mKeyguardStateCallbacks.get(i).onHasLockscreenWallpaperChanged( + hasLockscreenWallpaper); + } catch (RemoteException e) { + Slog.w(TAG, "Failed to call onHasLockscreenWallpaperChanged", e); + if (e instanceof DeadObjectException) { + mKeyguardStateCallbacks.remove(i); + } + } + } + } + public void addStateMonitorCallback(IKeyguardStateCallback callback) { synchronized (this) { mKeyguardStateCallbacks.add(callback); @@ -2871,6 +2893,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable, callback.onInputRestrictedStateChanged(mInputRestricted); callback.onTrustedChanged(mUpdateMonitor.getUserHasTrust( KeyguardUpdateMonitor.getCurrentUser())); + callback.onHasLockscreenWallpaperChanged(mUpdateMonitor.hasLockscreenWallpaper()); } catch (RemoteException e) { Slog.w(TAG, "Failed to call to IKeyguardStateCallback", e); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java index 2a13e6bbd37e4..78fcd82dc1f5a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java @@ -119,6 +119,7 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen LoaderResult result = loadBitmap(mCurrentUserId, mSelectedUser); if (result.success) { mCached = true; + mUpdateMonitor.setHasLockscreenWallpaper(result.bitmap != null); mCache = result.bitmap; } return mCache; @@ -234,6 +235,7 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen if (result.success) { mCached = true; mCache = result.bitmap; + mUpdateMonitor.setHasLockscreenWallpaper(result.bitmap != null); mMediaManager.updateMediaMetaData( true /* metaDataChanged */, true /* allowEnterAnimation */); } diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 5b6bf1510bf2e..5acff2b6c7435 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -47,6 +47,7 @@ import static android.view.KeyEvent.KEYCODE_VOLUME_UP; import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW; +import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW; @@ -3288,7 +3289,18 @@ public class PhoneWindowManager implements WindowManagerPolicy { final boolean showing = mKeyguardDelegate.isShowing(); final boolean animate = showing && !isOccluded; mKeyguardDelegate.setOccluded(isOccluded, animate); - return showing; + + if (!showing) { + return false; + } + if (mKeyguardCandidate != null) { + if (isOccluded) { + mKeyguardCandidate.getAttrs().flags &= ~FLAG_SHOW_WALLPAPER; + } else if (!mKeyguardDelegate.hasLockscreenWallpaper()) { + mKeyguardCandidate.getAttrs().flags |= FLAG_SHOW_WALLPAPER; + } + } + return true; } /** {@inheritDoc} */ diff --git a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java index cdd36f7e25dd0..86ff33e8cc423 100644 --- a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java +++ b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java @@ -235,6 +235,13 @@ public class KeyguardServiceDelegate { return false; } + public boolean hasLockscreenWallpaper() { + if (mKeyguardService != null) { + return mKeyguardService.hasLockscreenWallpaper(); + } + return false; + } + public boolean hasKeyguard() { return mKeyguardState.deviceHasKeyguard; } diff --git a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java index ac650ec0f564a..051f555fab951 100644 --- a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java +++ b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java @@ -261,6 +261,10 @@ public class KeyguardServiceWrapper implements IKeyguardService { return mKeyguardStateMonitor.isTrusted(); } + public boolean hasLockscreenWallpaper() { + return mKeyguardStateMonitor.hasLockscreenWallpaper(); + } + public boolean isSecure(int userId) { return mKeyguardStateMonitor.isSecure(userId); } diff --git a/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java b/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java index e6511372d62ca..add0b01f18799 100644 --- a/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java +++ b/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java @@ -44,6 +44,7 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub { private volatile boolean mSimSecure = true; private volatile boolean mInputRestricted = true; private volatile boolean mTrusted = false; + private volatile boolean mHasLockscreenWallpaper = false; private int mCurrentUserId; @@ -78,6 +79,10 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub { return mTrusted; } + public boolean hasLockscreenWallpaper() { + return mHasLockscreenWallpaper; + } + @Override // Binder interface public void onShowingStateChanged(boolean showing) { mIsShowing = showing; @@ -105,6 +110,11 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub { mCallback.onTrustedChanged(); } + @Override // Binder interface + public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) { + mHasLockscreenWallpaper = hasLockscreenWallpaper; + } + public interface StateCallback { void onTrustedChanged(); void onShowingChanged(); diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index f77f31a7fb349..ccfb174e3d16c 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -898,6 +898,15 @@ public class DisplayPolicy { // letterboxed. Hence always let them extend under the cutout. attrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; break; + case TYPE_NOTIFICATION_SHADE: + // 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. + // See {@link #processKeyguardSetHiddenResultLw}. + if (mService.mPolicy.isKeyguardOccluded()) { + attrs.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; + } + break; case TYPE_TOAST: // While apps should use the dedicated toast APIs to add such windows diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index f9ca5c5e4434a..c77cd509ca4f5 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -2581,17 +2581,13 @@ public class WindowManagerService extends IWindowManager.Stub // an exit. win.mAnimatingExit = true; } else if (win.mDisplayContent.okToAnimate() - && win.mDisplayContent.mWallpaperController.isWallpaperTarget(win) - && win.mAttrs.type == TYPE_NOTIFICATION_SHADE) { - // If the wallpaper is currently behind this app window, we need to change both of them - // inside of a transaction to avoid artifacts. - // For NotificationShade, sysui is in charge of running window animation and it updates - // the client view visibility only after both NotificationShade and the wallpaper are - // hidden. So we don't need to care about exit animation, but can destroy its surface - // immediately. + && win.mDisplayContent.mWallpaperController.isWallpaperTarget(win)) { + // If the wallpaper is currently behind this + // window, we need to change both of them inside + // of a transaction to avoid artifacts. win.mAnimatingExit = true; } else { - boolean stopped = win.mActivityRecord == null || win.mActivityRecord.mAppStopped; + boolean stopped = win.mActivityRecord != null ? win.mActivityRecord.mAppStopped : true; // We set mDestroying=true so ActivityRecord#notifyAppStopped in-to destroy surfaces // will later actually destroy the surface if we do not do so here. Normally we leave // this to the exit animation.