Fix a flicker when returning to the lockscreen
If we return to the lockscreen from a FLAG_SHOW_WHEN_LOCKED activity, there was an additional black flicker as the wallpaper wasn't shown for a couple of frames. The issue is that we didn't set the wallpaper flag again, to fix another flicker with lockscreen wallpapers. Now, we pass the state whether we currently have a lockscreen wallpaper and if we don't have one, we immediately set the wallpaper flag again. Bug: 30829255 Bug: 30883413 Change-Id: I9faeaa77b98eb02058171ce19cf90b43826ebe9e
This commit is contained in:
@@ -20,4 +20,5 @@ interface IKeyguardStateCallback {
|
||||
void onSimSecureStateChanged(boolean simSecure);
|
||||
void onInputRestrictedStateChanged(boolean inputRestricted);
|
||||
void onTrustedChanged(boolean trusted);
|
||||
void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper);
|
||||
}
|
||||
@@ -178,6 +178,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
||||
private boolean mBouncer;
|
||||
private boolean mBootCompleted;
|
||||
private boolean mUserUnlocked;
|
||||
private boolean mHasLockscreenWallpaper;
|
||||
|
||||
// Device provisioning state
|
||||
private boolean mDeviceProvisioned;
|
||||
@@ -1172,6 +1173,30 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the state whether Keyguard currently has a lockscreen wallpaper.
|
||||
*
|
||||
* @param hasLockscreenWallpaper Whether Keyguard has a lockscreen wallpaper.
|
||||
*/
|
||||
public void setHasLockscreenWallpaper(boolean hasLockscreenWallpaper) {
|
||||
if (hasLockscreenWallpaper != mHasLockscreenWallpaper) {
|
||||
mHasLockscreenWallpaper = hasLockscreenWallpaper;
|
||||
for (int i = mCallbacks.size() - 1; i >= 0; 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}
|
||||
*/
|
||||
|
||||
@@ -240,4 +240,9 @@ public class KeyguardUpdateMonitorCallback {
|
||||
* has changed.
|
||||
*/
|
||||
public void onStrongAuthStateChanged(int userId) { }
|
||||
|
||||
/**
|
||||
* Called when the state whether we have a lockscreen wallpaper has changed.
|
||||
*/
|
||||
public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) { }
|
||||
}
|
||||
|
||||
@@ -16,7 +16,11 @@
|
||||
|
||||
package com.android.systemui.keyguard;
|
||||
|
||||
import android.annotation.UserIdInt;
|
||||
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST;
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW;
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManagerNative;
|
||||
@@ -82,12 +86,6 @@ import com.android.systemui.statusbar.phone.StatusBarWindowManager;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST;
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW;
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT;
|
||||
|
||||
/**
|
||||
* Mediates requests related to the keyguard. This includes queries about the
|
||||
@@ -509,7 +507,12 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) {
|
||||
synchronized (KeyguardViewMediator.this) {
|
||||
notifyHasLockscreenWallpaperChanged(hasLockscreenWallpaper);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() {
|
||||
@@ -2014,6 +2017,21 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -2023,6 +2041,7 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ import android.os.ServiceManager;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
|
||||
import libcore.io.IoUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
@@ -52,6 +54,7 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen
|
||||
private final PhoneStatusBar mBar;
|
||||
private final WallpaperManager mWallpaperManager;
|
||||
private final Handler mH;
|
||||
private final KeyguardUpdateMonitor mUpdateMonitor;
|
||||
|
||||
private boolean mCached;
|
||||
private Bitmap mCache;
|
||||
@@ -66,6 +69,7 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen
|
||||
mH = h;
|
||||
mWallpaperManager = (WallpaperManager) ctx.getSystemService(Context.WALLPAPER_SERVICE);
|
||||
mCurrentUserId = ActivityManager.getCurrentUser();
|
||||
mUpdateMonitor = KeyguardUpdateMonitor.getInstance(ctx);
|
||||
|
||||
IWallpaperManager service = IWallpaperManager.Stub.asInterface(
|
||||
ServiceManager.getService(Context.WALLPAPER_SERVICE));
|
||||
@@ -89,6 +93,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;
|
||||
@@ -181,6 +186,7 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen
|
||||
if (result.success) {
|
||||
mCached = true;
|
||||
mCache = result.bitmap;
|
||||
mUpdateMonitor.setHasLockscreenWallpaper(result.bitmap != null);
|
||||
mBar.updateMediaMetaData(
|
||||
true /* metaDataChanged */, true /* allowEnterAnimation */);
|
||||
}
|
||||
|
||||
@@ -5319,6 +5319,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
mKeyguardOccluded = false;
|
||||
mKeyguardDelegate.setOccluded(false);
|
||||
mStatusBar.getAttrs().privateFlags |= PRIVATE_FLAG_KEYGUARD;
|
||||
if (!mKeyguardDelegate.hasLockscreenWallpaper()) {
|
||||
mStatusBar.getAttrs().flags |= FLAG_SHOW_WALLPAPER;
|
||||
}
|
||||
return true;
|
||||
} else if (!wasOccluded && isOccluded && showing) {
|
||||
mKeyguardOccluded = true;
|
||||
|
||||
@@ -206,6 +206,13 @@ public class KeyguardServiceDelegate {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasLockscreenWallpaper() {
|
||||
if (mKeyguardService != null) {
|
||||
return mKeyguardService.hasLockscreenWallpaper();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isInputRestricted() {
|
||||
if (mKeyguardService != null) {
|
||||
mKeyguardState.inputRestricted = mKeyguardService.isInputRestricted();
|
||||
|
||||
@@ -238,6 +238,10 @@ public class KeyguardServiceWrapper implements IKeyguardService {
|
||||
return mKeyguardStateMonitor.isTrusted();
|
||||
}
|
||||
|
||||
public boolean hasLockscreenWallpaper() {
|
||||
return mKeyguardStateMonitor.hasLockscreenWallpaper();
|
||||
}
|
||||
|
||||
public boolean isSecure(int userId) {
|
||||
return mKeyguardStateMonitor.isSecure(userId);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -75,6 +76,10 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
|
||||
return mTrusted;
|
||||
}
|
||||
|
||||
public boolean hasLockscreenWallpaper() {
|
||||
return mHasLockscreenWallpaper;
|
||||
}
|
||||
|
||||
@Override // Binder interface
|
||||
public void onShowingStateChanged(boolean showing) {
|
||||
mIsShowing = showing;
|
||||
@@ -103,6 +108,11 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
|
||||
mTrusted = trusted;
|
||||
}
|
||||
|
||||
@Override // Binder interface
|
||||
public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) {
|
||||
mHasLockscreenWallpaper = hasLockscreenWallpaper;
|
||||
}
|
||||
|
||||
public void dump(String prefix, PrintWriter pw) {
|
||||
pw.println(prefix + TAG);
|
||||
prefix += " ";
|
||||
|
||||
Reference in New Issue
Block a user