Keyguard: Refactoring for improving trusted unlock while occluded
am: d88eb2693b
Change-Id: I91f6bfe7a0573ad31785c5a3d1bff03a24d1107c
This commit is contained in:
@@ -135,6 +135,12 @@ public interface WindowManagerPolicy {
|
||||
void registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver)
|
||||
throws RemoteException;
|
||||
|
||||
/**
|
||||
* @return true if windows with FLAG_DISMISS_KEYGUARD should be allowed to show even if
|
||||
* the keyguard is locked.
|
||||
*/
|
||||
boolean canShowDismissingWindowWhileLockedLw();
|
||||
|
||||
/**
|
||||
* Interface to the Window Manager state associated with a particular
|
||||
* window. You can hold on to an instance of this interface from the call
|
||||
|
||||
@@ -34,7 +34,7 @@ oneway interface IKeyguardService {
|
||||
void addStateMonitorCallback(IKeyguardStateCallback callback);
|
||||
void verifyUnlock(IKeyguardExitCallback callback);
|
||||
void keyguardDone(boolean authenticated, boolean wakeup);
|
||||
void dismiss();
|
||||
void dismiss(boolean allowWhileOccluded);
|
||||
void onDreamingStarted();
|
||||
void onDreamingStopped();
|
||||
|
||||
|
||||
@@ -19,4 +19,5 @@ interface IKeyguardStateCallback {
|
||||
void onShowingStateChanged(boolean showing);
|
||||
void onSimSecureStateChanged(boolean simSecure);
|
||||
void onInputRestrictedStateChanged(boolean inputRestricted);
|
||||
void onTrustedChanged(boolean trusted);
|
||||
}
|
||||
@@ -98,9 +98,9 @@ public class KeyguardService extends Service {
|
||||
}
|
||||
|
||||
@Override // Binder interface
|
||||
public void dismiss() {
|
||||
public void dismiss(boolean allowWhileOccluded) {
|
||||
checkPermission();
|
||||
mKeyguardViewMediator.dismiss();
|
||||
mKeyguardViewMediator.dismiss(allowWhileOccluded);
|
||||
}
|
||||
|
||||
@Override // Binder interface
|
||||
|
||||
@@ -363,7 +363,7 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
UserInfo info = UserManager.get(mContext).getUserInfo(userId);
|
||||
if (info != null && (info.isGuest() || info.isDemo())) {
|
||||
// If we just switched to a guest, try to dismiss keyguard.
|
||||
dismiss();
|
||||
dismiss(false /* allowWhileOccluded */);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -500,6 +500,17 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
userId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrustChanged(int userId) {
|
||||
if (userId == KeyguardUpdateMonitor.getCurrentUser()) {
|
||||
synchronized (KeyguardViewMediator.this) {
|
||||
notifyTrustedChangedLocked(mUpdateMonitor.getUserHasTrust(userId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() {
|
||||
@@ -1253,15 +1264,16 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
|
||||
/**
|
||||
* Dismiss the keyguard through the security layers.
|
||||
* @param allowWhileOccluded if true, dismiss the keyguard even if it's currently occluded.
|
||||
*/
|
||||
public void handleDismiss() {
|
||||
if (mShowing && !mOccluded) {
|
||||
public void handleDismiss(boolean allowWhileOccluded) {
|
||||
if (mShowing && (allowWhileOccluded || !mOccluded)) {
|
||||
mStatusBarKeyguardViewManager.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
mHandler.sendEmptyMessage(DISMISS);
|
||||
public void dismiss(boolean allowWhileOccluded) {
|
||||
mHandler.obtainMessage(DISMISS, allowWhileOccluded ? 1 : 0, 0).sendToTarget();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1355,6 +1367,9 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
*/
|
||||
public void setCurrentUser(int newUserId) {
|
||||
KeyguardUpdateMonitor.setCurrentUser(newUserId);
|
||||
synchronized (this) {
|
||||
notifyTrustedChangedLocked(mUpdateMonitor.getUserHasTrust(newUserId));
|
||||
}
|
||||
}
|
||||
|
||||
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||
@@ -1463,7 +1478,7 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
}
|
||||
break;
|
||||
case DISMISS:
|
||||
handleDismiss();
|
||||
handleDismiss(msg.arg1 == 1 ? true : false /* allowWhileOccluded */);
|
||||
break;
|
||||
case START_KEYGUARD_EXIT_ANIM:
|
||||
Trace.beginSection("KeyguardViewMediator#handleMessage START_KEYGUARD_EXIT_ANIM");
|
||||
@@ -1989,6 +2004,20 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyTrustedChangedLocked(boolean trusted) {
|
||||
int size = mKeyguardStateCallbacks.size();
|
||||
for (int i = size - 1; i >= 0; i--) {
|
||||
try {
|
||||
mKeyguardStateCallbacks.get(i).onTrustedChanged(trusted);
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG, "Failed to call notifyTrustedChangedLocked", e);
|
||||
if (e instanceof DeadObjectException) {
|
||||
mKeyguardStateCallbacks.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addStateMonitorCallback(IKeyguardStateCallback callback) {
|
||||
synchronized (this) {
|
||||
mKeyguardStateCallbacks.add(callback);
|
||||
@@ -1996,8 +2025,10 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
callback.onSimSecureStateChanged(mUpdateMonitor.isSimPinSecure());
|
||||
callback.onShowingStateChanged(mShowing);
|
||||
callback.onInputRestrictedStateChanged(mInputRestricted);
|
||||
callback.onTrustedChanged(mUpdateMonitor.getUserHasTrust(
|
||||
KeyguardUpdateMonitor.getCurrentUser()));
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG, "Failed to call onShowingStateChanged or onSimSecureStateChanged or onInputRestrictedStateChanged", e);
|
||||
Slog.w(TAG, "Failed to call to IKeyguardStateCallback", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3641,6 +3641,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShowDismissingWindowWhileLockedLw() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void launchAssistLongPressAction() {
|
||||
performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
|
||||
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST);
|
||||
@@ -5347,7 +5352,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mKeyguardDelegate.dismiss();
|
||||
mKeyguardDelegate.dismiss(false /* allowWhileOccluded */);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -6583,7 +6588,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
@Override
|
||||
public void run() {
|
||||
// ask the keyguard to prompt the user to authenticate if necessary
|
||||
mKeyguardDelegate.dismiss();
|
||||
mKeyguardDelegate.dismiss(false /* allowWhileOccluded */);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -199,6 +199,13 @@ public class KeyguardServiceDelegate {
|
||||
return mKeyguardState.showing;
|
||||
}
|
||||
|
||||
public boolean isTrusted() {
|
||||
if (mKeyguardService != null) {
|
||||
return mKeyguardService.isTrusted();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isInputRestricted() {
|
||||
if (mKeyguardService != null) {
|
||||
mKeyguardState.inputRestricted = mKeyguardService.isInputRestricted();
|
||||
@@ -220,14 +227,15 @@ public class KeyguardServiceDelegate {
|
||||
|
||||
public void setOccluded(boolean isOccluded) {
|
||||
if (mKeyguardService != null) {
|
||||
if (DEBUG) Log.v(TAG, "setOccluded(" + isOccluded + ")");
|
||||
mKeyguardService.setOccluded(isOccluded);
|
||||
}
|
||||
mKeyguardState.occluded = isOccluded;
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
public void dismiss(boolean allowWhileOccluded) {
|
||||
if (mKeyguardService != null) {
|
||||
mKeyguardService.dismiss();
|
||||
mKeyguardService.dismiss(allowWhileOccluded);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,9 +81,9 @@ public class KeyguardServiceWrapper implements IKeyguardService {
|
||||
}
|
||||
|
||||
@Override // Binder interface
|
||||
public void dismiss() {
|
||||
public void dismiss(boolean allowWhileOccluded) {
|
||||
try {
|
||||
mService.dismiss();
|
||||
mService.dismiss(allowWhileOccluded);
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG , "Remote Exception", e);
|
||||
}
|
||||
@@ -234,6 +234,10 @@ public class KeyguardServiceWrapper implements IKeyguardService {
|
||||
return mKeyguardStateMonitor.isShowing();
|
||||
}
|
||||
|
||||
public boolean isTrusted() {
|
||||
return mKeyguardStateMonitor.isTrusted();
|
||||
}
|
||||
|
||||
public boolean isSecure(int userId) {
|
||||
return mKeyguardStateMonitor.isSecure(userId);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
|
||||
private volatile boolean mIsShowing = true;
|
||||
private volatile boolean mSimSecure = true;
|
||||
private volatile boolean mInputRestricted = true;
|
||||
private volatile boolean mTrusted = false;
|
||||
|
||||
private int mCurrentUserId;
|
||||
|
||||
@@ -70,6 +71,10 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
|
||||
return mInputRestricted;
|
||||
}
|
||||
|
||||
public boolean isTrusted() {
|
||||
return mTrusted;
|
||||
}
|
||||
|
||||
@Override // Binder interface
|
||||
public void onShowingStateChanged(boolean showing) {
|
||||
mIsShowing = showing;
|
||||
@@ -93,12 +98,18 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
|
||||
mInputRestricted = inputRestricted;
|
||||
}
|
||||
|
||||
@Override // Binder interface
|
||||
public void onTrustedChanged(boolean trusted) {
|
||||
mTrusted = trusted;
|
||||
}
|
||||
|
||||
public void dump(String prefix, PrintWriter pw) {
|
||||
pw.println(prefix + TAG);
|
||||
prefix += " ";
|
||||
pw.println(prefix + "mIsShowing=" + mIsShowing);
|
||||
pw.println(prefix + "mSimSecure=" + mSimSecure);
|
||||
pw.println(prefix + "mInputRestricted=" + mInputRestricted);
|
||||
pw.println(prefix + "mTrusted=" + mTrusted);
|
||||
pw.println(prefix + "mCurrentUserId=" + mCurrentUserId);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.server.wm;
|
||||
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
|
||||
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.PRIVATE_FLAG_KEYGUARD;
|
||||
@@ -233,6 +234,12 @@ public class WindowAnimator {
|
||||
|| (win.mAttrs.privateFlags & PRIVATE_FLAG_SYSTEM_ERROR) != 0;
|
||||
}
|
||||
|
||||
// Allow showing a window that dismisses Keyguard if the policy allows it. This is used for
|
||||
// when the policy knows that the Keyguard can be dismissed without user interaction to
|
||||
// provide a smooth transition in that case.
|
||||
allowWhenLocked |= (win.mAttrs.flags & FLAG_DISMISS_KEYGUARD) != 0
|
||||
&& mPolicy.canShowDismissingWindowWhileLockedLw();
|
||||
|
||||
// Only hide windows if the keyguard is active and not animating away.
|
||||
boolean keyguardOn = mPolicy.isKeyguardShowingOrOccluded()
|
||||
&& mForceHiding != KEYGUARD_ANIMATING_OUT;
|
||||
|
||||
Reference in New Issue
Block a user