am 69082a29: Merge "Require strong authentication after a timeout" into mnc-dr-dev

* commit '69082a298f50680128ada89a8bef777f0fadf829':
  Require strong authentication after a timeout
This commit is contained in:
Jorim Jaggi
2015-08-13 01:02:31 +00:00
committed by Android Git Automerger
20 changed files with 181 additions and 76 deletions

View File

@@ -316,6 +316,15 @@
<!-- An explanation text that the password needs to be entered since the device has just been restarted. [CHAR LIMIT=80] --> <!-- An explanation text that the password needs to be entered since the device has just been restarted. [CHAR LIMIT=80] -->
<string name="kg_prompt_reason_restart_password">Password required when you restart device.</string> <string name="kg_prompt_reason_restart_password">Password required when you restart device.</string>
<!-- An explanation text that the pattern needs to be solved since the user hasn't used strong authentication since quite some time. [CHAR LIMIT=80] -->
<string name="kg_prompt_reason_timeout_pattern">Pattern required for additional security.</string>
<!-- An explanation text that the pin needs to be entered since the user hasn't used strong authentication since quite some time. [CHAR LIMIT=80] -->
<string name="kg_prompt_reason_timeout_pin">PIN required for additional security.</string>
<!-- An explanation text that the password needs to be entered since the user hasn't used strong authentication since quite some time. [CHAR LIMIT=80] -->
<string name="kg_prompt_reason_timeout_password">Password required for additional security.</string>
<!-- An explanation text that the pattern needs to be solved since profiles have just been switched. [CHAR LIMIT=80] --> <!-- An explanation text that the pattern needs to be solved since profiles have just been switched. [CHAR LIMIT=80] -->
<string name="kg_prompt_reason_switch_profiles_pattern">Pattern required when you switch profiles.</string> <string name="kg_prompt_reason_switch_profiles_pattern">Pattern required when you switch profiles.</string>

View File

@@ -163,8 +163,9 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback {
* Show a string explaining why the security view needs to be solved. * Show a string explaining why the security view needs to be solved.
* *
* @param reason a flag indicating which string should be shown, see * @param reason a flag indicating which string should be shown, see
* {@link KeyguardSecurityView#PROMPT_REASON_NONE} * {@link KeyguardSecurityView#PROMPT_REASON_NONE},
* and {@link KeyguardSecurityView#PROMPT_REASON_RESTART} * {@link KeyguardSecurityView#PROMPT_REASON_RESTART} and
* {@link KeyguardSecurityView#PROMPT_REASON_TIMEOUT}.
*/ */
public void showPromptReason(int reason) { public void showPromptReason(int reason) {
mSecurityContainer.showPromptReason(reason); mSecurityContainer.showPromptReason(reason);
@@ -213,9 +214,12 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback {
/** /**
* Authentication has happened and it's time to dismiss keyguard. This function * Authentication has happened and it's time to dismiss keyguard. This function
* should clean up and inform KeyguardViewMediator. * should clean up and inform KeyguardViewMediator.
*
* @param strongAuth whether the user has authenticated with strong authentication like
* pattern, password or PIN but not by trust agents or fingerprint
*/ */
@Override @Override
public void finish() { public void finish(boolean strongAuth) {
// If there's a pending runnable because the user interacted with a widget // If there's a pending runnable because the user interacted with a widget
// and we're leaving keyguard, then run it. // and we're leaving keyguard, then run it.
boolean deferKeyguardDone = false; boolean deferKeyguardDone = false;
@@ -226,9 +230,9 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback {
} }
if (mViewMediatorCallback != null) { if (mViewMediatorCallback != null) {
if (deferKeyguardDone) { if (deferKeyguardDone) {
mViewMediatorCallback.keyguardDonePending(); mViewMediatorCallback.keyguardDonePending(strongAuth);
} else { } else {
mViewMediatorCallback.keyguardDone(true); mViewMediatorCallback.keyguardDone(strongAuth);
} }
} }
} }
@@ -284,32 +288,6 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback {
} }
} }
/**
* Verify that the user can get past the keyguard securely. This is called,
* for example, when the phone disables the keyguard but then wants to launch
* something else that requires secure access.
*
* The result will be propogated back via {@link KeyguardViewCallback#keyguardDone(boolean)}
*/
public void verifyUnlock() {
SecurityMode securityMode = mSecurityContainer.getSecurityMode();
if (securityMode == KeyguardSecurityModel.SecurityMode.None) {
if (mViewMediatorCallback != null) {
mViewMediatorCallback.keyguardDone(true);
}
} else if (securityMode != KeyguardSecurityModel.SecurityMode.Pattern
&& securityMode != KeyguardSecurityModel.SecurityMode.PIN
&& securityMode != KeyguardSecurityModel.SecurityMode.Password) {
// can only verify unlock when in pattern/password mode
if (mViewMediatorCallback != null) {
mViewMediatorCallback.keyguardDone(false);
}
} else {
// otherwise, go to the unlock screen, see if they can verify it
mSecurityContainer.verifyUnlock();
}
}
/** /**
* Called before this view is being removed. * Called before this view is being removed.
*/ */

View File

@@ -115,6 +115,8 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView
switch (reason) { switch (reason) {
case PROMPT_REASON_RESTART: case PROMPT_REASON_RESTART:
return R.string.kg_prompt_reason_restart_password; return R.string.kg_prompt_reason_restart_password;
case PROMPT_REASON_TIMEOUT:
return R.string.kg_prompt_reason_timeout_password;
default: default:
return 0; return 0;
} }

View File

@@ -332,7 +332,12 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_restart_pattern, mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_restart_pattern,
true /* important */); true /* important */);
break; break;
case PROMPT_REASON_TIMEOUT:
mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_timeout_pattern,
true /* important */);
break;
default: default:
break;
} }
} }

View File

@@ -98,6 +98,8 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView
switch (reason) { switch (reason) {
case PROMPT_REASON_RESTART: case PROMPT_REASON_RESTART:
return R.string.kg_prompt_reason_restart_pin; return R.string.kg_prompt_reason_restart_pin;
case PROMPT_REASON_TIMEOUT:
return R.string.kg_prompt_reason_timeout_pin;
default: default:
return 0; return 0;
} }

View File

@@ -54,7 +54,12 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
public boolean dismiss(boolean authenticated); public boolean dismiss(boolean authenticated);
public void userActivity(); public void userActivity();
public void onSecurityModeChanged(SecurityMode securityMode, boolean needsInput); public void onSecurityModeChanged(SecurityMode securityMode, boolean needsInput);
public void finish();
/**
* @param strongAuth wheher the user has authenticated with strong authentication like
* pattern, password or PIN but not by trust agents or fingerprint
*/
public void finish(boolean strongAuth);
public void reset(); public void reset();
} }
@@ -282,7 +287,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
showWipeDialog(failedAttempts, userType); showWipeDialog(failedAttempts, userType);
} }
} }
monitor.reportFailedUnlockAttempt(); monitor.reportFailedStrongAuthUnlockAttempt();
mLockPatternUtils.reportFailedPasswordAttempt(KeyguardUpdateMonitor.getCurrentUser()); mLockPatternUtils.reportFailedPasswordAttempt(KeyguardUpdateMonitor.getCurrentUser());
if (timeoutMs > 0) { if (timeoutMs > 0) {
showTimeoutDialog(timeoutMs); showTimeoutDialog(timeoutMs);
@@ -308,6 +313,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
boolean showNextSecurityScreenOrFinish(boolean authenticated) { boolean showNextSecurityScreenOrFinish(boolean authenticated) {
if (DEBUG) Log.d(TAG, "showNextSecurityScreenOrFinish(" + authenticated + ")"); if (DEBUG) Log.d(TAG, "showNextSecurityScreenOrFinish(" + authenticated + ")");
boolean finish = false; boolean finish = false;
boolean strongAuth = false;
if (mUpdateMonitor.getUserCanSkipBouncer( if (mUpdateMonitor.getUserCanSkipBouncer(
KeyguardUpdateMonitor.getCurrentUser())) { KeyguardUpdateMonitor.getCurrentUser())) {
finish = true; finish = true;
@@ -323,6 +329,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
case Pattern: case Pattern:
case Password: case Password:
case PIN: case PIN:
strongAuth = true;
finish = true; finish = true;
break; break;
@@ -346,7 +353,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
} }
} }
if (finish) { if (finish) {
mSecurityCallback.finish(); mSecurityCallback.finish(strongAuth);
} }
return finish; return finish;
} }

View File

@@ -22,8 +22,17 @@ public interface KeyguardSecurityView {
static public final int VIEW_REVEALED = 2; static public final int VIEW_REVEALED = 2;
int PROMPT_REASON_NONE = 0; int PROMPT_REASON_NONE = 0;
/**
* Strong auth is required because the device has just booted.
*/
int PROMPT_REASON_RESTART = 1; int PROMPT_REASON_RESTART = 1;
/**
* Strong auth is required because the user hasn't used strong auth since a while.
*/
int PROMPT_REASON_TIMEOUT = 2;
/** /**
* Interface back to keyguard to tell it when security * Interface back to keyguard to tell it when security
* @param callback * @param callback

View File

@@ -64,6 +64,7 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener; import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.ArraySet;
import android.util.Log; import android.util.Log;
import android.util.SparseBooleanArray; import android.util.SparseBooleanArray;
import android.util.SparseIntArray; import android.util.SparseIntArray;
@@ -103,6 +104,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
= "com.android.facelock.FACE_UNLOCK_STOPPED"; = "com.android.facelock.FACE_UNLOCK_STOPPED";
private static final String FINGERPRINT_WAKE_LOCK_NAME = "wake-and-unlock wakelock"; private static final String FINGERPRINT_WAKE_LOCK_NAME = "wake-and-unlock wakelock";
private static final String ACTION_STRONG_AUTH_TIMEOUT =
"com.android.systemui.ACTION_STRONG_AUTH_TIMEOUT";
private static final String USER_ID = "com.android.systemui.USER_ID";
private static final String PERMISSION_SELF = "com.android.systemui.permission.SELF";
/** /**
* Mode in which we don't need to wake up the device when we get a fingerprint. * Mode in which we don't need to wake up the device when we get a fingerprint.
*/ */
@@ -126,6 +133,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
* */ * */
private static final int FP_ONLY_WAKE = 3; private static final int FP_ONLY_WAKE = 3;
/**
* Milliseconds after unlocking with fingerprint times out, i.e. the user has to use a
* strong auth method like password, PIN or pattern.
*/
private static final long FINGERPRINT_UNLOCK_TIMEOUT_MS = 72 * 60 * 60 * 1000;
// Callback messages // Callback messages
private static final int MSG_TIME_UPDATE = 301; private static final int MSG_TIME_UPDATE = 301;
private static final int MSG_BATTERY_UPDATE = 302; private static final int MSG_BATTERY_UPDATE = 302;
@@ -173,7 +186,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
// Password attempts // Password attempts
private SparseIntArray mFailedAttempts = new SparseIntArray(); private SparseIntArray mFailedAttempts = new SparseIntArray();
private boolean mClockVisible; /** Tracks whether strong authentication hasn't been used since quite some time per user. */
private ArraySet<Integer> mStrongAuthTimedOut = new ArraySet<>();
private final ArrayList<WeakReference<KeyguardUpdateMonitorCallback>> private final ArrayList<WeakReference<KeyguardUpdateMonitorCallback>>
mCallbacks = Lists.newArrayList(); mCallbacks = Lists.newArrayList();
@@ -184,6 +198,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
private boolean mDeviceInteractive; private boolean mDeviceInteractive;
private boolean mScreenOn; private boolean mScreenOn;
private SubscriptionManager mSubscriptionManager; private SubscriptionManager mSubscriptionManager;
private AlarmManager mAlarmManager;
private List<SubscriptionInfo> mSubscriptionInfo; private List<SubscriptionInfo> mSubscriptionInfo;
private boolean mFingerprintDetectionRunning; private boolean mFingerprintDetectionRunning;
private TrustManager mTrustManager; private TrustManager mTrustManager;
@@ -549,7 +564,39 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
} }
public boolean isUnlockingWithFingerprintAllowed() { public boolean isUnlockingWithFingerprintAllowed() {
return mUserHasAuthenticatedSinceBoot; return mUserHasAuthenticatedSinceBoot && !hasFingerprintUnlockTimedOut(sCurrentUser);
}
/**
* @return true if the user hasn't use strong authentication (pattern, PIN, password) since a
* while and thus can't unlock with fingerprint, false otherwise
*/
public boolean hasFingerprintUnlockTimedOut(int userId) {
return mStrongAuthTimedOut.contains(userId);
}
public void reportSuccessfulStrongAuthUnlockAttempt() {
mStrongAuthTimedOut.remove(sCurrentUser);
scheduleStrongAuthTimeout();
}
private void scheduleStrongAuthTimeout() {
long when = SystemClock.elapsedRealtime() + FINGERPRINT_UNLOCK_TIMEOUT_MS;
Intent intent = new Intent(ACTION_STRONG_AUTH_TIMEOUT);
intent.putExtra(USER_ID, sCurrentUser);
PendingIntent sender = PendingIntent.getBroadcast(mContext,
sCurrentUser, intent, PendingIntent.FLAG_CANCEL_CURRENT);
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, when, sender);
notifyStrongAuthTimedOutChanged(sCurrentUser);
}
private void notifyStrongAuthTimedOutChanged(int userId) {
for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) {
cb.onStrongAuthTimeoutExpiredChanged(userId);
}
}
} }
static class DisplayClientState { static class DisplayClientState {
@@ -639,6 +686,17 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
} }
}; };
private final BroadcastReceiver mStrongAuthTimeoutReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (ACTION_STRONG_AUTH_TIMEOUT.equals(intent.getAction())) {
int userId = intent.getIntExtra(USER_ID, -1);
mStrongAuthTimedOut.add(userId);
notifyStrongAuthTimedOutChanged(userId);
}
}
};
private FingerprintManager.AuthenticationCallback mAuthenticationCallback private FingerprintManager.AuthenticationCallback mAuthenticationCallback
= new AuthenticationCallback() { = new AuthenticationCallback() {
@@ -871,7 +929,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
mContext = context; mContext = context;
mSubscriptionManager = SubscriptionManager.from(context); mSubscriptionManager = SubscriptionManager.from(context);
mPowerManager = context.getSystemService(PowerManager.class); mPowerManager = context.getSystemService(PowerManager.class);
mAlarmManager = context.getSystemService(AlarmManager.class);
mDeviceProvisioned = isDeviceProvisionedInSettingsDb(); mDeviceProvisioned = isDeviceProvisionedInSettingsDb();
// Since device can't be un-provisioned, we only need to register a content observer // Since device can't be un-provisioned, we only need to register a content observer
// to update mDeviceProvisioned when we are... // to update mDeviceProvisioned when we are...
if (!mDeviceProvisioned) { if (!mDeviceProvisioned) {
@@ -932,6 +992,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
e.printStackTrace(); e.printStackTrace();
} }
IntentFilter strongAuthTimeoutFilter = new IntentFilter();
strongAuthTimeoutFilter.addAction(ACTION_STRONG_AUTH_TIMEOUT);
context.registerReceiver(mStrongAuthTimeoutReceiver, strongAuthTimeoutFilter,
PERMISSION_SELF, null /* handler */);
mTrustManager = (TrustManager) context.getSystemService(Context.TRUST_SERVICE); mTrustManager = (TrustManager) context.getSystemService(Context.TRUST_SERVICE);
mTrustManager.registerTrustListener(this); mTrustManager.registerTrustListener(this);
@@ -955,7 +1019,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
private void startListeningForFingerprint() { private void startListeningForFingerprint() {
if (DEBUG) Log.v(TAG, "startListeningForFingerprint()"); if (DEBUG) Log.v(TAG, "startListeningForFingerprint()");
int userId = ActivityManager.getCurrentUser(); int userId = ActivityManager.getCurrentUser();
if (isUnlockWithFingerPrintPossible(userId)) { if (isUnlockWithFingerprintPossible(userId)) {
mUserHasAuthenticatedSinceBoot = mTrustManager.hasUserAuthenticatedSinceBoot( mUserHasAuthenticatedSinceBoot = mTrustManager.hasUserAuthenticatedSinceBoot(
ActivityManager.getCurrentUser()); ActivityManager.getCurrentUser());
if (mFingerprintCancelSignal != null) { if (mFingerprintCancelSignal != null) {
@@ -967,7 +1031,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
} }
} }
public boolean isUnlockWithFingerPrintPossible(int userId) { public boolean isUnlockWithFingerprintPossible(int userId) {
return mFpm != null && mFpm.isHardwareDetected() && !isFingerprintDisabled(userId) return mFpm != null && mFpm.isHardwareDetected() && !isFingerprintDisabled(userId)
&& mFpm.getEnrolledFingerprints(userId).size() > 0; && mFpm.getEnrolledFingerprints(userId).size() > 0;
} }
@@ -1433,7 +1497,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
return mFailedAttempts.get(sCurrentUser, 0); return mFailedAttempts.get(sCurrentUser, 0);
} }
public void reportFailedUnlockAttempt() { public void reportFailedStrongAuthUnlockAttempt() {
mFailedAttempts.put(sCurrentUser, getFailedUnlockAttempts() + 1); mFailedAttempts.put(sCurrentUser, getFailedUnlockAttempts() + 1);
} }

View File

@@ -217,4 +217,10 @@ public class KeyguardUpdateMonitorCallback {
* Called when the fingerprint running state changed. * Called when the fingerprint running state changed.
*/ */
public void onFingerprintRunningStateChanged(boolean running) { } public void onFingerprintRunningStateChanged(boolean running) { }
/**
* Called when the state that the user hasn't used strong authentication since quite some time
* has changed.
*/
public void onStrongAuthTimeoutExpiredChanged(int userId) { }
} }

View File

@@ -28,12 +28,11 @@ public interface ViewMediatorCallback {
/** /**
* Report that the keyguard is done. * Report that the keyguard is done.
* @param authenticated Whether the user securely got past the keyguard. *
* the only reason for this to be false is if the keyguard was instructed * @param strongAuth whether the user has authenticated with strong authentication like
* to appear temporarily to verify the user is supposed to get past the * pattern, password or PIN but not by trust agents or fingerprint
* keyguard, and the user fails to do so.
*/ */
void keyguardDone(boolean authenticated); void keyguardDone(boolean strongAuth);
/** /**
* Report that the keyguard is done drawing. * Report that the keyguard is done drawing.
@@ -48,8 +47,11 @@ public interface ViewMediatorCallback {
/** /**
* Report that the keyguard is dismissable, pending the next keyguardDone call. * Report that the keyguard is dismissable, pending the next keyguardDone call.
*
* @param strongAuth whether the user has authenticated with strong authentication like
* pattern, password or PIN but not by trust agents or fingerprint
*/ */
void keyguardDonePending(); void keyguardDonePending(boolean strongAuth);
/** /**
* Report when keyguard is actually gone * Report when keyguard is actually gone
@@ -85,8 +87,9 @@ public interface ViewMediatorCallback {
/** /**
* @return one of the reasons why the bouncer needs to be shown right now and the user can't use * @return one of the reasons why the bouncer needs to be shown right now and the user can't use
* his normal unlock method like fingerprint or trust agents. See * his normal unlock method like fingerprint or trust agents. See
* {@link KeyguardSecurityView#PROMPT_REASON_NONE} * {@link KeyguardSecurityView#PROMPT_REASON_NONE},
* and {@link KeyguardSecurityView#PROMPT_REASON_RESTART}. * {@link KeyguardSecurityView#PROMPT_REASON_RESTART} and
* {@link KeyguardSecurityView#PROMPT_REASON_TIMEOUT}.
*/ */
int getBouncerPromptReason(); int getBouncerPromptReason();
} }

View File

@@ -80,7 +80,8 @@ public class KeyguardService extends Service {
@Override // Binder interface @Override // Binder interface
public void keyguardDone(boolean authenticated, boolean wakeup) { public void keyguardDone(boolean authenticated, boolean wakeup) {
checkPermission(); checkPermission();
mKeyguardViewMediator.keyguardDone(authenticated, wakeup); // TODO: Remove wakeup
mKeyguardViewMediator.keyguardDone(authenticated);
} }
@Override // Binder interface @Override // Binder interface

View File

@@ -465,13 +465,14 @@ public class KeyguardViewMediator extends SystemUI {
mUpdateMonitor.isUnlockingWithFingerprintAllowed(); mUpdateMonitor.isUnlockingWithFingerprintAllowed();
if (mStatusBarKeyguardViewManager.isBouncerShowing()) { if (mStatusBarKeyguardViewManager.isBouncerShowing()) {
if (unlockingWithFingerprintAllowed) { if (unlockingWithFingerprintAllowed) {
mStatusBarKeyguardViewManager.notifyKeyguardAuthenticated(); mStatusBarKeyguardViewManager.notifyKeyguardAuthenticated(
false /* strongAuth */);
} }
} else { } else {
if (wakeAndUnlocking && mShowing && unlockingWithFingerprintAllowed) { if (wakeAndUnlocking && mShowing && unlockingWithFingerprintAllowed) {
mWakeAndUnlocking = true; mWakeAndUnlocking = true;
mStatusBarKeyguardViewManager.setWakeAndUnlocking(); mStatusBarKeyguardViewManager.setWakeAndUnlocking();
keyguardDone(true, true); keyguardDone(true);
} else if (mShowing && mDeviceInteractive) { } else if (mShowing && mDeviceInteractive) {
if (wakeAndUnlocking) { if (wakeAndUnlocking) {
mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested(); mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested();
@@ -490,9 +491,12 @@ public class KeyguardViewMediator extends SystemUI {
KeyguardViewMediator.this.userActivity(); KeyguardViewMediator.this.userActivity();
} }
public void keyguardDone(boolean authenticated) { public void keyguardDone(boolean strongAuth) {
if (!mKeyguardDonePending) { if (!mKeyguardDonePending) {
KeyguardViewMediator.this.keyguardDone(authenticated, true); KeyguardViewMediator.this.keyguardDone(true /* authenticated */);
}
if (strongAuth) {
mUpdateMonitor.reportSuccessfulStrongAuthUnlockAttempt();
} }
} }
@@ -506,12 +510,15 @@ public class KeyguardViewMediator extends SystemUI {
} }
@Override @Override
public void keyguardDonePending() { public void keyguardDonePending(boolean strongAuth) {
mKeyguardDonePending = true; mKeyguardDonePending = true;
mHideAnimationRun = true; mHideAnimationRun = true;
mStatusBarKeyguardViewManager.startPreHideAnimation(null /* finishRunnable */); mStatusBarKeyguardViewManager.startPreHideAnimation(null /* finishRunnable */);
mHandler.sendEmptyMessageDelayed(KEYGUARD_DONE_PENDING_TIMEOUT, mHandler.sendEmptyMessageDelayed(KEYGUARD_DONE_PENDING_TIMEOUT,
KEYGUARD_DONE_PENDING_TIMEOUT_MS); KEYGUARD_DONE_PENDING_TIMEOUT_MS);
if (strongAuth) {
mUpdateMonitor.reportSuccessfulStrongAuthUnlockAttempt();
}
} }
@Override @Override
@@ -524,7 +531,7 @@ public class KeyguardViewMediator extends SystemUI {
if (mKeyguardDonePending) { if (mKeyguardDonePending) {
// Somebody has called keyguardDonePending before, which means that we are // Somebody has called keyguardDonePending before, which means that we are
// authenticated // authenticated
KeyguardViewMediator.this.keyguardDone(true /* authenticated */, true /* wakeUp */); KeyguardViewMediator.this.keyguardDone(true /* authenticated */);
} }
} }
@@ -552,9 +559,12 @@ public class KeyguardViewMediator extends SystemUI {
public int getBouncerPromptReason() { public int getBouncerPromptReason() {
int currentUser = ActivityManager.getCurrentUser(); int currentUser = ActivityManager.getCurrentUser();
if ((mUpdateMonitor.getUserTrustIsManaged(currentUser) if ((mUpdateMonitor.getUserTrustIsManaged(currentUser)
|| mUpdateMonitor.isUnlockWithFingerPrintPossible(currentUser)) || mUpdateMonitor.isUnlockWithFingerprintPossible(currentUser))
&& !mTrustManager.hasUserAuthenticatedSinceBoot(currentUser)) { && !mTrustManager.hasUserAuthenticatedSinceBoot(currentUser)) {
return KeyguardSecurityView.PROMPT_REASON_RESTART; return KeyguardSecurityView.PROMPT_REASON_RESTART;
} else if (mUpdateMonitor.isUnlockWithFingerprintPossible(currentUser)
&& mUpdateMonitor.hasFingerprintUnlockTimedOut(currentUser)) {
return KeyguardSecurityView.PROMPT_REASON_TIMEOUT;
} }
return KeyguardSecurityView.PROMPT_REASON_NONE; return KeyguardSecurityView.PROMPT_REASON_NONE;
} }
@@ -1189,10 +1199,10 @@ public class KeyguardViewMediator extends SystemUI {
} }
}; };
public void keyguardDone(boolean authenticated, boolean wakeup) { public void keyguardDone(boolean authenticated) {
if (DEBUG) Log.d(TAG, "keyguardDone(" + authenticated + ")"); if (DEBUG) Log.d(TAG, "keyguardDone(" + authenticated +")");
EventLog.writeEvent(70000, 2); EventLog.writeEvent(70000, 2);
Message msg = mHandler.obtainMessage(KEYGUARD_DONE, authenticated ? 1 : 0, wakeup ? 1 : 0); Message msg = mHandler.obtainMessage(KEYGUARD_DONE, authenticated ? 1 : 0);
mHandler.sendMessage(msg); mHandler.sendMessage(msg);
} }
@@ -1235,14 +1245,11 @@ public class KeyguardViewMediator extends SystemUI {
handleNotifyStartedWakingUp(); handleNotifyStartedWakingUp();
break; break;
case KEYGUARD_DONE: case KEYGUARD_DONE:
handleKeyguardDone(msg.arg1 != 0, msg.arg2 != 0); handleKeyguardDone(msg.arg1 != 0);
break; break;
case KEYGUARD_DONE_DRAWING: case KEYGUARD_DONE_DRAWING:
handleKeyguardDoneDrawing(); handleKeyguardDoneDrawing();
break; break;
case KEYGUARD_DONE_AUTHENTICATING:
keyguardDone(true, true);
break;
case SET_OCCLUDED: case SET_OCCLUDED:
handleSetOccluded(msg.arg1 != 0); handleSetOccluded(msg.arg1 != 0);
break; break;
@@ -1272,7 +1279,7 @@ public class KeyguardViewMediator extends SystemUI {
* @see #keyguardDone * @see #keyguardDone
* @see #KEYGUARD_DONE * @see #KEYGUARD_DONE
*/ */
private void handleKeyguardDone(boolean authenticated, boolean wakeup) { private void handleKeyguardDone(boolean authenticated) {
if (DEBUG) Log.d(TAG, "handleKeyguardDone"); if (DEBUG) Log.d(TAG, "handleKeyguardDone");
synchronized (this) { synchronized (this) {
resetKeyguardDonePendingLocked(); resetKeyguardDonePendingLocked();
@@ -1585,6 +1592,7 @@ public class KeyguardViewMediator extends SystemUI {
synchronized (this) { synchronized (this) {
if (DEBUG) Log.d(TAG, "handleNotifyScreenTurnedOff"); if (DEBUG) Log.d(TAG, "handleNotifyScreenTurnedOff");
mStatusBarKeyguardViewManager.onScreenTurnedOff(); mStatusBarKeyguardViewManager.onScreenTurnedOff();
mWakeAndUnlocking = false;
} }
} }

View File

@@ -21,7 +21,6 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences;
import com.android.systemui.Prefs; import com.android.systemui.Prefs;
import com.android.systemui.R; import com.android.systemui.R;

View File

@@ -20,7 +20,6 @@ import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.ActivityOptions; import android.app.ActivityOptions;
import android.app.ITaskStackListener; import android.app.ITaskStackListener;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;

View File

@@ -33,7 +33,6 @@ import android.view.View;
import android.view.ViewStub; import android.view.ViewStub;
import android.widget.Toast; import android.widget.Toast;
import com.android.internal.logging.MetricsConstants;
import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsLogger;
import com.android.systemui.Prefs; import com.android.systemui.Prefs;
import com.android.systemui.R; import com.android.systemui.R;

View File

@@ -20,10 +20,8 @@ import android.app.ActivityManager;
import android.app.ActivityManagerNative; import android.app.ActivityManagerNative;
import android.app.ActivityOptions; import android.app.ActivityOptions;
import android.app.AppGlobals; import android.app.AppGlobals;
import android.app.IActivityContainer;
import android.app.IActivityManager; import android.app.IActivityManager;
import android.app.ITaskStackListener; import android.app.ITaskStackListener;
import android.app.SearchManager;
import android.appwidget.AppWidgetHost; import android.appwidget.AppWidgetHost;
import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo; import android.appwidget.AppWidgetProviderInfo;
@@ -54,15 +52,12 @@ import android.os.ParcelFileDescriptor;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings; import android.provider.Settings;
import android.util.Log; import android.util.Log;
import android.util.MutableBoolean; import android.util.MutableBoolean;
import android.util.Pair; import android.util.Pair;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.Display; import android.view.Display;
import android.view.DisplayInfo;
import android.view.SurfaceControl;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
@@ -71,7 +66,6 @@ import com.android.systemui.Prefs;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.recents.Constants; import com.android.systemui.recents.Constants;
import com.android.systemui.recents.Recents; import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsAppWidgetHost;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;

View File

@@ -647,6 +647,11 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
public void onFingerprintRunningStateChanged(boolean running) { public void onFingerprintRunningStateChanged(boolean running) {
mLockIcon.update(); mLockIcon.update();
} }
@Override
public void onStrongAuthTimeoutExpiredChanged(int userId) {
mLockIcon.update();
}
}; };
public void setKeyguardIndicationController( public void setKeyguardIndicationController(

View File

@@ -26,6 +26,8 @@ import android.view.accessibility.AccessibilityEvent;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardHostView; import com.android.keyguard.KeyguardHostView;
import com.android.keyguard.KeyguardSecurityView; import com.android.keyguard.KeyguardSecurityView;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.keyguard.R; import com.android.keyguard.R;
import com.android.keyguard.ViewMediatorCallback; import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.DejankUtils; import com.android.systemui.DejankUtils;
@@ -47,6 +49,13 @@ public class KeyguardBouncer {
private ViewGroup mRoot; private ViewGroup mRoot;
private boolean mShowingSoon; private boolean mShowingSoon;
private int mBouncerPromptReason; private int mBouncerPromptReason;
private KeyguardUpdateMonitorCallback mUpdateMonitorCallback =
new KeyguardUpdateMonitorCallback() {
@Override
public void onStrongAuthTimeoutExpiredChanged(int userId) {
mBouncerPromptReason = mCallback.getBouncerPromptReason();
}
};
public KeyguardBouncer(Context context, ViewMediatorCallback callback, public KeyguardBouncer(Context context, ViewMediatorCallback callback,
LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager, LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager,
@@ -56,6 +65,7 @@ public class KeyguardBouncer {
mLockPatternUtils = lockPatternUtils; mLockPatternUtils = lockPatternUtils;
mContainer = container; mContainer = container;
mWindowManager = windowManager; mWindowManager = windowManager;
KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallback);
} }
public void show(boolean resetSecuritySelection) { public void show(boolean resetSecuritySelection) {
@@ -247,8 +257,8 @@ public class KeyguardBouncer {
return mKeyguardView.interceptMediaKey(event); return mKeyguardView.interceptMediaKey(event);
} }
public void notifyKeyguardAuthenticated() { public void notifyKeyguardAuthenticated(boolean strongAuth) {
ensureView(); ensureView();
mKeyguardView.finish(); mKeyguardView.finish(strongAuth);
} }
} }

View File

@@ -480,8 +480,8 @@ public class StatusBarKeyguardViewManager {
* Notifies that the user has authenticated by other means than using the bouncer, for example, * Notifies that the user has authenticated by other means than using the bouncer, for example,
* fingerprint. * fingerprint.
*/ */
public void notifyKeyguardAuthenticated() { public void notifyKeyguardAuthenticated(boolean strongAuth) {
mBouncer.notifyKeyguardAuthenticated(); mBouncer.notifyKeyguardAuthenticated(strongAuth);
} }
public void setWakeAndUnlocking() { public void setWakeAndUnlocking() {

View File

@@ -143,6 +143,11 @@ public class UnlockMethodCache {
public void onFaceUnlockStateChanged(boolean running, int userId) { public void onFaceUnlockStateChanged(boolean running, int userId) {
update(false /* updateAlways */); update(false /* updateAlways */);
} }
@Override
public void onStrongAuthTimeoutExpiredChanged(int userId) {
update(false /* updateAlways */);
}
}; };
public boolean isTrustManaged() { public boolean isTrustManaged() {