Loading services/core/java/com/android/server/policy/PhoneWindowManager.java +43 −19 Original line number Diff line number Diff line Loading @@ -140,6 +140,7 @@ import android.view.animation.Animation; import android.view.animation.AnimationSet; import android.view.animation.AnimationUtils; import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.logging.MetricsLogger; import com.android.internal.policy.PhoneWindow; import com.android.internal.policy.IShortcutService; Loading Loading @@ -597,6 +598,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { private static final int DISMISS_KEYGUARD_CONTINUE = 2; // Keyguard has been dismissed. int mDismissKeyguard = DISMISS_KEYGUARD_NONE; /** * Indicates that we asked the Keyguard to be dismissed and we just wait for the Keyguard to * dismiss itself. */ @GuardedBy("Lw") private boolean mCurrentlyDismissingKeyguard; /** The window that is currently dismissing the keyguard. Dismissing the keyguard must only * be done once per window. */ private WindowState mWinDismissingKeyguard; Loading Loading @@ -3707,10 +3715,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { @Override public boolean canShowDismissingWindowWhileLockedLw() { // If the keyguard is trusted, it will unlock without a challange. Therefore, windows with // FLAG_DISMISS_KEYGUARD don't need to be force hidden, as they will unlock the phone right // away anyways. return mKeyguardDelegate != null && mKeyguardDelegate.isTrusted(); // If the keyguard is trusted, it will unlock without a challenge. Therefore, if we are in // the process of dismissing Keyguard, we don't need to hide them as the phone will be // unlocked right away in any case. return mKeyguardDelegate != null && mKeyguardDelegate.isTrusted() && mCurrentlyDismissingKeyguard; } private void launchAssistLongPressAction() { Loading Loading @@ -5417,22 +5426,27 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } else if (mDismissKeyguard != DISMISS_KEYGUARD_NONE) { mKeyguardHidden = false; boolean willDismiss = false; if (mDismissKeyguard == DISMISS_KEYGUARD_START) { final boolean trusted = mKeyguardDelegate.isTrusted(); if (trusted) { // No need to un-occlude keyguard - we'll dimiss it right away anyways. } else if (setKeyguardOccludedLw(false)) { willDismiss = trusted && mKeyguardOccluded && mKeyguardDelegate != null && mKeyguardDelegate.isShowing(); if (willDismiss) { mCurrentlyDismissingKeyguard = true; } // Only launch the next keyguard unlock window once per window. mHandler.post(() -> mKeyguardDelegate.dismiss( trusted /* allowWhileOccluded */)); } // If we are currently dismissing Keyguard, there is no need to unocclude it. if (!mCurrentlyDismissingKeyguard) { if (setKeyguardOccludedLw(false)) { changes |= FINISH_LAYOUT_REDO_LAYOUT | FINISH_LAYOUT_REDO_CONFIG | FINISH_LAYOUT_REDO_WALLPAPER; } if (mDismissKeyguard == DISMISS_KEYGUARD_START) { // Only launch the next keyguard unlock window once per window. mHandler.post(new Runnable() { @Override public void run() { mKeyguardDelegate.dismiss(trusted /* allowWhileOccluded */); } }); } } else { mWinDismissingKeyguard = null; Loading Loading @@ -5487,6 +5501,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } private void onKeyguardShowingStateChanged(boolean showing) { if (!showing) { synchronized (mWindowManagerFuncs.getWindowManagerLock()) { mCurrentlyDismissingKeyguard = false; } } } private boolean isStatusBarKeyguard() { return mStatusBar != null && (mStatusBar.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; Loading Loading @@ -7016,7 +7038,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { /** {@inheritDoc} */ @Override public void systemReady() { mKeyguardDelegate = new KeyguardServiceDelegate(mContext); mKeyguardDelegate = new KeyguardServiceDelegate(mContext, this::onKeyguardShowingStateChanged); mKeyguardDelegate.onSystemReady(); readCameraLensCoverState(); Loading Loading @@ -8097,6 +8120,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { pw.print(" mForceStatusBarFromKeyguard="); pw.println(mForceStatusBarFromKeyguard); pw.print(prefix); pw.print("mDismissKeyguard="); pw.print(mDismissKeyguard); pw.print(" mCurrentlyDismissingKeyguard="); pw.println(mCurrentlyDismissingKeyguard); pw.print(" mWinDismissingKeyguard="); pw.print(mWinDismissingKeyguard); pw.print(" mHomePressed="); pw.println(mHomePressed); pw.print(prefix); pw.print("mAllowLockscreenWhenOn="); pw.print(mAllowLockscreenWhenOn); Loading services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java +6 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import com.android.internal.policy.IKeyguardDrawnCallback; import com.android.internal.policy.IKeyguardExitCallback; import com.android.internal.policy.IKeyguardService; import com.android.server.UiThread; import com.android.server.policy.keyguard.KeyguardStateMonitor.OnShowingStateChangedCallback; import java.io.PrintWriter; Loading @@ -49,6 +50,7 @@ public class KeyguardServiceDelegate { private final Handler mScrimHandler; private final KeyguardState mKeyguardState = new KeyguardState(); private DrawnListener mDrawnListenerWhenConnect; private final OnShowingStateChangedCallback mShowingStateChangedCallback; private static final class KeyguardState { KeyguardState() { Loading Loading @@ -116,9 +118,11 @@ public class KeyguardServiceDelegate { } }; public KeyguardServiceDelegate(Context context) { public KeyguardServiceDelegate(Context context, OnShowingStateChangedCallback showingStateChangedCallback) { mContext = context; mScrimHandler = UiThread.getHandler(); mShowingStateChangedCallback = showingStateChangedCallback; mScrim = createScrim(context, mScrimHandler); } Loading Loading @@ -154,7 +158,7 @@ public class KeyguardServiceDelegate { public void onServiceConnected(ComponentName name, IBinder service) { if (DEBUG) Log.v(TAG, "*** Keyguard connected (yay!)"); mKeyguardService = new KeyguardServiceWrapper(mContext, IKeyguardService.Stub.asInterface(service)); IKeyguardService.Stub.asInterface(service), mShowingStateChangedCallback); if (mKeyguardState.systemIsReady) { // If the system is ready, it means keyguard crashed and restarted. mKeyguardService.onSystemReady(); Loading services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java +5 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import com.android.internal.policy.IKeyguardDrawnCallback; import com.android.internal.policy.IKeyguardExitCallback; import com.android.internal.policy.IKeyguardService; import com.android.internal.policy.IKeyguardStateCallback; import com.android.server.policy.keyguard.KeyguardStateMonitor.OnShowingStateChangedCallback; import java.io.PrintWriter; Loading @@ -39,9 +40,11 @@ public class KeyguardServiceWrapper implements IKeyguardService { private IKeyguardService mService; private String TAG = "KeyguardServiceWrapper"; public KeyguardServiceWrapper(Context context, IKeyguardService service) { public KeyguardServiceWrapper(Context context, IKeyguardService service, OnShowingStateChangedCallback showingStateChangedCallback) { mService = service; mKeyguardStateMonitor = new KeyguardStateMonitor(context, service); mKeyguardStateMonitor = new KeyguardStateMonitor(context, service, showingStateChangedCallback); } @Override // Binder interface Loading services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java +9 −1 Original line number Diff line number Diff line Loading @@ -49,10 +49,13 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub { private int mCurrentUserId; private final LockPatternUtils mLockPatternUtils; private final OnShowingStateChangedCallback mOnShowingStateChangedCallback; public KeyguardStateMonitor(Context context, IKeyguardService service) { public KeyguardStateMonitor(Context context, IKeyguardService service, OnShowingStateChangedCallback showingStateChangedCallback) { mLockPatternUtils = new LockPatternUtils(context); mCurrentUserId = ActivityManager.getCurrentUser(); mOnShowingStateChangedCallback = showingStateChangedCallback; try { service.addStateMonitorCallback(this); } catch (RemoteException e) { Loading Loading @@ -83,6 +86,7 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub { @Override // Binder interface public void onShowingStateChanged(boolean showing) { mIsShowing = showing; mOnShowingStateChangedCallback.onShowingStateChanged(showing); } @Override // Binder interface Loading Loading @@ -122,4 +126,8 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub { pw.println(prefix + "mTrusted=" + mTrusted); pw.println(prefix + "mCurrentUserId=" + mCurrentUserId); } public interface OnShowingStateChangedCallback { void onShowingStateChanged(boolean showing); } } No newline at end of file Loading
services/core/java/com/android/server/policy/PhoneWindowManager.java +43 −19 Original line number Diff line number Diff line Loading @@ -140,6 +140,7 @@ import android.view.animation.Animation; import android.view.animation.AnimationSet; import android.view.animation.AnimationUtils; import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.logging.MetricsLogger; import com.android.internal.policy.PhoneWindow; import com.android.internal.policy.IShortcutService; Loading Loading @@ -597,6 +598,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { private static final int DISMISS_KEYGUARD_CONTINUE = 2; // Keyguard has been dismissed. int mDismissKeyguard = DISMISS_KEYGUARD_NONE; /** * Indicates that we asked the Keyguard to be dismissed and we just wait for the Keyguard to * dismiss itself. */ @GuardedBy("Lw") private boolean mCurrentlyDismissingKeyguard; /** The window that is currently dismissing the keyguard. Dismissing the keyguard must only * be done once per window. */ private WindowState mWinDismissingKeyguard; Loading Loading @@ -3707,10 +3715,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { @Override public boolean canShowDismissingWindowWhileLockedLw() { // If the keyguard is trusted, it will unlock without a challange. Therefore, windows with // FLAG_DISMISS_KEYGUARD don't need to be force hidden, as they will unlock the phone right // away anyways. return mKeyguardDelegate != null && mKeyguardDelegate.isTrusted(); // If the keyguard is trusted, it will unlock without a challenge. Therefore, if we are in // the process of dismissing Keyguard, we don't need to hide them as the phone will be // unlocked right away in any case. return mKeyguardDelegate != null && mKeyguardDelegate.isTrusted() && mCurrentlyDismissingKeyguard; } private void launchAssistLongPressAction() { Loading Loading @@ -5417,22 +5426,27 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } else if (mDismissKeyguard != DISMISS_KEYGUARD_NONE) { mKeyguardHidden = false; boolean willDismiss = false; if (mDismissKeyguard == DISMISS_KEYGUARD_START) { final boolean trusted = mKeyguardDelegate.isTrusted(); if (trusted) { // No need to un-occlude keyguard - we'll dimiss it right away anyways. } else if (setKeyguardOccludedLw(false)) { willDismiss = trusted && mKeyguardOccluded && mKeyguardDelegate != null && mKeyguardDelegate.isShowing(); if (willDismiss) { mCurrentlyDismissingKeyguard = true; } // Only launch the next keyguard unlock window once per window. mHandler.post(() -> mKeyguardDelegate.dismiss( trusted /* allowWhileOccluded */)); } // If we are currently dismissing Keyguard, there is no need to unocclude it. if (!mCurrentlyDismissingKeyguard) { if (setKeyguardOccludedLw(false)) { changes |= FINISH_LAYOUT_REDO_LAYOUT | FINISH_LAYOUT_REDO_CONFIG | FINISH_LAYOUT_REDO_WALLPAPER; } if (mDismissKeyguard == DISMISS_KEYGUARD_START) { // Only launch the next keyguard unlock window once per window. mHandler.post(new Runnable() { @Override public void run() { mKeyguardDelegate.dismiss(trusted /* allowWhileOccluded */); } }); } } else { mWinDismissingKeyguard = null; Loading Loading @@ -5487,6 +5501,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } private void onKeyguardShowingStateChanged(boolean showing) { if (!showing) { synchronized (mWindowManagerFuncs.getWindowManagerLock()) { mCurrentlyDismissingKeyguard = false; } } } private boolean isStatusBarKeyguard() { return mStatusBar != null && (mStatusBar.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; Loading Loading @@ -7016,7 +7038,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { /** {@inheritDoc} */ @Override public void systemReady() { mKeyguardDelegate = new KeyguardServiceDelegate(mContext); mKeyguardDelegate = new KeyguardServiceDelegate(mContext, this::onKeyguardShowingStateChanged); mKeyguardDelegate.onSystemReady(); readCameraLensCoverState(); Loading Loading @@ -8097,6 +8120,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { pw.print(" mForceStatusBarFromKeyguard="); pw.println(mForceStatusBarFromKeyguard); pw.print(prefix); pw.print("mDismissKeyguard="); pw.print(mDismissKeyguard); pw.print(" mCurrentlyDismissingKeyguard="); pw.println(mCurrentlyDismissingKeyguard); pw.print(" mWinDismissingKeyguard="); pw.print(mWinDismissingKeyguard); pw.print(" mHomePressed="); pw.println(mHomePressed); pw.print(prefix); pw.print("mAllowLockscreenWhenOn="); pw.print(mAllowLockscreenWhenOn); Loading
services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java +6 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import com.android.internal.policy.IKeyguardDrawnCallback; import com.android.internal.policy.IKeyguardExitCallback; import com.android.internal.policy.IKeyguardService; import com.android.server.UiThread; import com.android.server.policy.keyguard.KeyguardStateMonitor.OnShowingStateChangedCallback; import java.io.PrintWriter; Loading @@ -49,6 +50,7 @@ public class KeyguardServiceDelegate { private final Handler mScrimHandler; private final KeyguardState mKeyguardState = new KeyguardState(); private DrawnListener mDrawnListenerWhenConnect; private final OnShowingStateChangedCallback mShowingStateChangedCallback; private static final class KeyguardState { KeyguardState() { Loading Loading @@ -116,9 +118,11 @@ public class KeyguardServiceDelegate { } }; public KeyguardServiceDelegate(Context context) { public KeyguardServiceDelegate(Context context, OnShowingStateChangedCallback showingStateChangedCallback) { mContext = context; mScrimHandler = UiThread.getHandler(); mShowingStateChangedCallback = showingStateChangedCallback; mScrim = createScrim(context, mScrimHandler); } Loading Loading @@ -154,7 +158,7 @@ public class KeyguardServiceDelegate { public void onServiceConnected(ComponentName name, IBinder service) { if (DEBUG) Log.v(TAG, "*** Keyguard connected (yay!)"); mKeyguardService = new KeyguardServiceWrapper(mContext, IKeyguardService.Stub.asInterface(service)); IKeyguardService.Stub.asInterface(service), mShowingStateChangedCallback); if (mKeyguardState.systemIsReady) { // If the system is ready, it means keyguard crashed and restarted. mKeyguardService.onSystemReady(); Loading
services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java +5 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import com.android.internal.policy.IKeyguardDrawnCallback; import com.android.internal.policy.IKeyguardExitCallback; import com.android.internal.policy.IKeyguardService; import com.android.internal.policy.IKeyguardStateCallback; import com.android.server.policy.keyguard.KeyguardStateMonitor.OnShowingStateChangedCallback; import java.io.PrintWriter; Loading @@ -39,9 +40,11 @@ public class KeyguardServiceWrapper implements IKeyguardService { private IKeyguardService mService; private String TAG = "KeyguardServiceWrapper"; public KeyguardServiceWrapper(Context context, IKeyguardService service) { public KeyguardServiceWrapper(Context context, IKeyguardService service, OnShowingStateChangedCallback showingStateChangedCallback) { mService = service; mKeyguardStateMonitor = new KeyguardStateMonitor(context, service); mKeyguardStateMonitor = new KeyguardStateMonitor(context, service, showingStateChangedCallback); } @Override // Binder interface Loading
services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java +9 −1 Original line number Diff line number Diff line Loading @@ -49,10 +49,13 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub { private int mCurrentUserId; private final LockPatternUtils mLockPatternUtils; private final OnShowingStateChangedCallback mOnShowingStateChangedCallback; public KeyguardStateMonitor(Context context, IKeyguardService service) { public KeyguardStateMonitor(Context context, IKeyguardService service, OnShowingStateChangedCallback showingStateChangedCallback) { mLockPatternUtils = new LockPatternUtils(context); mCurrentUserId = ActivityManager.getCurrentUser(); mOnShowingStateChangedCallback = showingStateChangedCallback; try { service.addStateMonitorCallback(this); } catch (RemoteException e) { Loading Loading @@ -83,6 +86,7 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub { @Override // Binder interface public void onShowingStateChanged(boolean showing) { mIsShowing = showing; mOnShowingStateChangedCallback.onShowingStateChanged(showing); } @Override // Binder interface Loading Loading @@ -122,4 +126,8 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub { pw.println(prefix + "mTrusted=" + mTrusted); pw.println(prefix + "mCurrentUserId=" + mCurrentUserId); } public interface OnShowingStateChangedCallback { void onShowingStateChanged(boolean showing); } } No newline at end of file