Merge "[DO NOT MERGE] Keyguard - Treat messsages to lock with priority" into qt-dev

This commit is contained in:
TreeHugger Robot
2022-11-28 22:55:00 +00:00
committed by Android (Google) Code Review
4 changed files with 25 additions and 7 deletions

View File

@@ -16,7 +16,7 @@
package com.android.internal.policy;
interface IKeyguardStateCallback {
void onShowingStateChanged(boolean showing);
void onShowingStateChanged(boolean showing, int userId);
void onSimSecureStateChanged(boolean simSecure);
void onInputRestrictedStateChanged(boolean inputRestricted);
void onTrustedChanged(boolean trusted);

View File

@@ -1233,7 +1233,9 @@ public class KeyguardViewMediator extends SystemUI {
public void doKeyguardTimeout(Bundle options) {
mHandler.removeMessages(KEYGUARD_TIMEOUT);
Message msg = mHandler.obtainMessage(KEYGUARD_TIMEOUT, options);
mHandler.sendMessage(msg);
// Treat these messages with priority - A call to timeout means the device should lock
// as soon as possible and not wait for other messages on the thread to process first.
mHandler.sendMessageAtFrontOfQueue(msg);
}
/**
@@ -1420,12 +1422,15 @@ public class KeyguardViewMediator extends SystemUI {
* @see #handleShow
*/
private void showLocked(Bundle options) {
Trace.beginSection("KeyguardViewMediator#showLocked aqcuiring mShowKeyguardWakeLock");
Trace.beginSection("KeyguardViewMediator#showLocked acquiring mShowKeyguardWakeLock");
if (DEBUG) Log.d(TAG, "showLocked");
// ensure we stay awake until we are finished displaying the keyguard
mShowKeyguardWakeLock.acquire();
Message msg = mHandler.obtainMessage(SHOW, options);
mHandler.sendMessage(msg);
// Treat these messages with priority - This call can originate from #doKeyguardTimeout,
// meaning the device should lock as soon as possible and not wait for other messages on
// the thread to process first.
mHandler.sendMessageAtFrontOfQueue(msg);
Trace.endSection();
}
@@ -1584,6 +1589,7 @@ public class KeyguardViewMediator extends SystemUI {
case KEYGUARD_TIMEOUT:
synchronized (KeyguardViewMediator.this) {
doKeyguardLocked((Bundle) msg.obj);
notifyDefaultDisplayCallbacks(mShowing);
}
break;
case DISMISS:
@@ -2154,7 +2160,7 @@ public class KeyguardViewMediator extends SystemUI {
for (int i = size - 1; i >= 0; i--) {
IKeyguardStateCallback callback = mKeyguardStateCallbacks.get(i);
try {
callback.onShowingStateChanged(showing);
callback.onShowingStateChanged(showing, KeyguardUpdateMonitor.getCurrentUser());
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onShowingStateChanged", e);
if (e instanceof DeadObjectException) {
@@ -2202,7 +2208,7 @@ public class KeyguardViewMediator extends SystemUI {
mKeyguardStateCallbacks.add(callback);
try {
callback.onSimSecureStateChanged(mUpdateMonitor.isSimPinSecure());
callback.onShowingStateChanged(mShowing);
callback.onShowingStateChanged(mShowing, KeyguardUpdateMonitor.getCurrentUser());
callback.onInputRestrictedStateChanged(mInputRestricted);
callback.onTrustedChanged(mUpdateMonitor.getUserHasTrust(
KeyguardUpdateMonitor.getCurrentUser()));

View File

@@ -192,6 +192,12 @@ public class KeyguardServiceWrapper implements IKeyguardService {
@Override // Binder interface
public void doKeyguardTimeout(Bundle options) {
int userId = mKeyguardStateMonitor.getCurrentUser();
if (mKeyguardStateMonitor.isSecure(userId)) {
// Preemptively inform the cache that the keyguard will soon be showing, as calls to
// doKeyguardTimeout are a signal to lock the device as soon as possible.
mKeyguardStateMonitor.onShowingStateChanged(true, userId);
}
try {
mService.doKeyguardTimeout(options);
} catch (RemoteException e) {

View File

@@ -83,8 +83,14 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
return mHasLockscreenWallpaper;
}
public int getCurrentUser() {
return mCurrentUserId;
}
@Override // Binder interface
public void onShowingStateChanged(boolean showing) {
public void onShowingStateChanged(boolean showing, int userId) {
if (userId != mCurrentUserId) return;
mIsShowing = showing;
mCallback.onShowingChanged();