Keep FLAG_SHOW_WALLPAPER flag on NotificationShade.

Before this change, we controlled wallpaper visibility on the Lockscreen
by combination of visibility of NotificationShade window and
setting/resetting FLAG_SHOW_WALLPAPER flag on its window. When the flag
was removed while NotificationShade was still visible (e.g. OCCLUDE
transition starts on the Lockscreen), the wallpaper became immediately
invisible and caused a flicker.

With this change, we keep the FLAG_SHOW_WALLPAPER on NotificationShade,
and only rely on its visibility weather the wallpaper should be visible
or not on the Lockscreen.

Bug: 191438572
Test: existing tests + manual
  open GPay app from the lockscreen
  open emergency dialer and check the key pad reacts
Change-Id: I7876c92331125b00931218d9e5aca164a1ea50d9
Merged-In: I7876c92331125b00931218d9e5aca164a1ea50d9
This commit is contained in:
Issei Suzuki
2021-10-04 16:26:37 +02:00
parent 6f26ef6d74
commit 4731aa5e1c
11 changed files with 10 additions and 104 deletions

View File

@@ -20,5 +20,4 @@ interface IKeyguardStateCallback {
void onSimSecureStateChanged(boolean simSecure);
void onInputRestrictedStateChanged(boolean inputRestricted);
void onTrustedChanged(boolean trusted);
void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper);
}

View File

@@ -271,7 +271,6 @@ 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;
@@ -2532,31 +2531,6 @@ 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}
*/

View File

@@ -291,11 +291,6 @@ 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

View File

@@ -673,13 +673,6 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
}
}
}
@Override
public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) {
synchronized (KeyguardViewMediator.this) {
notifyHasLockscreenWallpaperChanged(hasLockscreenWallpaper);
}
}
};
ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() {
@@ -2899,21 +2892,6 @@ 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);
@@ -2923,7 +2901,6 @@ 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);
}

View File

@@ -119,7 +119,6 @@ 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;
@@ -235,7 +234,6 @@ 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 */);
}

View File

@@ -47,7 +47,6 @@ 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;
@@ -3304,17 +3303,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
final boolean notify = !WindowManagerService.sEnableRemoteKeyguardOccludeAnimation
|| !transitionStarted;
mKeyguardDelegate.setOccluded(isOccluded, animate, notify);
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;
return showing;
}
/** {@inheritDoc} */

View File

@@ -234,13 +234,6 @@ public class KeyguardServiceDelegate {
return false;
}
public boolean hasLockscreenWallpaper() {
if (mKeyguardService != null) {
return mKeyguardService.hasLockscreenWallpaper();
}
return false;
}
public boolean hasKeyguard() {
return mKeyguardState.deviceHasKeyguard;
}

View File

@@ -261,10 +261,6 @@ public class KeyguardServiceWrapper implements IKeyguardService {
return mKeyguardStateMonitor.isTrusted();
}
public boolean hasLockscreenWallpaper() {
return mKeyguardStateMonitor.hasLockscreenWallpaper();
}
public boolean isSecure(int userId) {
return mKeyguardStateMonitor.isSecure(userId);
}

View File

@@ -44,7 +44,6 @@ 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;
@@ -79,10 +78,6 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
return mTrusted;
}
public boolean hasLockscreenWallpaper() {
return mHasLockscreenWallpaper;
}
@Override // Binder interface
public void onShowingStateChanged(boolean showing) {
mIsShowing = showing;
@@ -110,11 +105,6 @@ 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();

View File

@@ -899,15 +899,6 @@ 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

View File

@@ -2583,13 +2583,17 @@ public class WindowManagerService extends IWindowManager.Stub
// an exit.
win.mAnimatingExit = true;
} else if (win.mDisplayContent.okToAnimate()
&& 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.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.mAnimatingExit = true;
} else {
boolean stopped = win.mActivityRecord != null ? win.mActivityRecord.mAppStopped : true;
boolean stopped = win.mActivityRecord == null || win.mActivityRecord.mAppStopped;
// 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.