am 58e378b0: Merge "Start fingerprint authentication in onStartedGoingToSleep" into mnc-dr-dev

* commit '58e378b02561d8f606066537b193b0eb62e2404f':
  Start fingerprint authentication in onStartedGoingToSleep
This commit is contained in:
Jorim Jaggi
2015-09-18 00:48:47 +00:00
committed by Android Git Automerger
4 changed files with 64 additions and 4 deletions

View File

@@ -129,6 +129,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
private static final int MSG_REPORT_EMERGENCY_CALL_ACTION = 318; private static final int MSG_REPORT_EMERGENCY_CALL_ACTION = 318;
private static final int MSG_STARTED_WAKING_UP = 319; private static final int MSG_STARTED_WAKING_UP = 319;
private static final int MSG_FINISHED_GOING_TO_SLEEP = 320; private static final int MSG_FINISHED_GOING_TO_SLEEP = 320;
private static final int MSG_STARTED_GOING_TO_SLEEP = 321;
private static final int MSG_KEYGUARD_BOUNCER_CHANGED = 322; private static final int MSG_KEYGUARD_BOUNCER_CHANGED = 322;
private static final int MSG_FACE_UNLOCK_STATE_CHANGED = 327; private static final int MSG_FACE_UNLOCK_STATE_CHANGED = 327;
private static final int MSG_SIM_SUBSCRIPTION_INFO_CHANGED = 328; private static final int MSG_SIM_SUBSCRIPTION_INFO_CHANGED = 328;
@@ -170,6 +171,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
* until the Keyguard has been dismissed. * until the Keyguard has been dismissed.
*/ */
private boolean mFingerprintAlreadyAuthenticated; private boolean mFingerprintAlreadyAuthenticated;
private boolean mGoingToSleep;
private boolean mBouncer; private boolean mBouncer;
private boolean mBootCompleted; private boolean mBootCompleted;
@@ -249,6 +251,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
case MSG_REPORT_EMERGENCY_CALL_ACTION: case MSG_REPORT_EMERGENCY_CALL_ACTION:
handleReportEmergencyCallAction(); handleReportEmergencyCallAction();
break; break;
case MSG_STARTED_GOING_TO_SLEEP:
handleStartedGoingToSleep(msg.arg1);
break;
case MSG_FINISHED_GOING_TO_SLEEP: case MSG_FINISHED_GOING_TO_SLEEP:
handleFinishedGoingToSleep(msg.arg1); handleFinishedGoingToSleep(msg.arg1);
break; break;
@@ -884,16 +889,29 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
} }
} }
protected void handleFinishedGoingToSleep(int arg1) { protected void handleStartedGoingToSleep(int arg1) {
clearFingerprintRecognized(); clearFingerprintRecognized();
final int count = mCallbacks.size(); final int count = mCallbacks.size();
for (int i = 0; i < count; i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) {
cb.onStartedGoingToSleep(arg1);
}
}
mGoingToSleep = true;
mFingerprintAlreadyAuthenticated = false;
updateFingerprintListeningState();
}
protected void handleFinishedGoingToSleep(int arg1) {
mGoingToSleep = false;
final int count = mCallbacks.size();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) { if (cb != null) {
cb.onFinishedGoingToSleep(arg1); cb.onFinishedGoingToSleep(arg1);
} }
} }
mFingerprintAlreadyAuthenticated = false;
updateFingerprintListeningState(); updateFingerprintListeningState();
} }
@@ -1032,8 +1050,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
} }
private boolean shouldListenForFingerprint() { private boolean shouldListenForFingerprint() {
return (mKeyguardIsVisible || !mDeviceInteractive || mBouncer) && !mSwitchingUser return (mKeyguardIsVisible || !mDeviceInteractive || mBouncer || mGoingToSleep)
&& !mFingerprintAlreadyAuthenticated && !isFingerprintDisabled(getCurrentUser()); && !mSwitchingUser && !mFingerprintAlreadyAuthenticated
&& !isFingerprintDisabled(getCurrentUser());
} }
private void startListeningForFingerprint() { private void startListeningForFingerprint() {
@@ -1605,6 +1624,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
mHandler.sendEmptyMessage(MSG_STARTED_WAKING_UP); mHandler.sendEmptyMessage(MSG_STARTED_WAKING_UP);
} }
public void dispatchStartedGoingToSleep(int why) {
mHandler.sendMessage(mHandler.obtainMessage(MSG_STARTED_GOING_TO_SLEEP, why, 0));
}
public void dispatchFinishedGoingToSleep(int why) { public void dispatchFinishedGoingToSleep(int why) {
synchronized(this) { synchronized(this) {
mDeviceInteractive = false; mDeviceInteractive = false;
@@ -1630,6 +1653,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
return mDeviceInteractive; return mDeviceInteractive;
} }
public boolean isGoingToSleep() {
return mGoingToSleep;
}
/** /**
* Find the next SubscriptionId for a SIM in the given state, favoring lower slot numbers first. * Find the next SubscriptionId for a SIM in the given state, favoring lower slot numbers first.
* @param state * @param state

View File

@@ -152,6 +152,12 @@ public class KeyguardUpdateMonitorCallback {
*/ */
public void onStartedWakingUp() { } public void onStartedWakingUp() { }
/**
* Called when the device has started going to sleep.
* @param why see {@link #onFinishedGoingToSleep(int)}
*/
public void onStartedGoingToSleep(int why) { }
/** /**
* Called when the device has finished going to sleep. * Called when the device has finished going to sleep.
* @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_ADMIN}, * @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_ADMIN},

View File

@@ -678,6 +678,7 @@ public class KeyguardViewMediator extends SystemUI {
playSounds(true); playSounds(true);
} }
} }
KeyguardUpdateMonitor.getInstance(mContext).dispatchStartedGoingToSleep(why);
notifyStartedGoingToSleep(); notifyStartedGoingToSleep();
} }

View File

@@ -93,6 +93,8 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
private KeyguardViewMediator mKeyguardViewMediator; private KeyguardViewMediator mKeyguardViewMediator;
private ScrimController mScrimController; private ScrimController mScrimController;
private PhoneStatusBar mPhoneStatusBar; private PhoneStatusBar mPhoneStatusBar;
private boolean mGoingToSleep;
private int mPendingAuthenticatedUserId = -1;
public FingerprintUnlockController(Context context, public FingerprintUnlockController(Context context,
StatusBarWindowManager statusBarWindowManager, StatusBarWindowManager statusBarWindowManager,
@@ -161,6 +163,10 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
@Override @Override
public void onFingerprintAuthenticated(int userId) { public void onFingerprintAuthenticated(int userId) {
if (mUpdateMonitor.isGoingToSleep()) {
mPendingAuthenticatedUserId = userId;
return;
}
boolean wasDeviceInteractive = mUpdateMonitor.isDeviceInteractive(); boolean wasDeviceInteractive = mUpdateMonitor.isDeviceInteractive();
mMode = calculateMode(); mMode = calculateMode();
if (!wasDeviceInteractive) { if (!wasDeviceInteractive) {
@@ -205,6 +211,26 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
mPhoneStatusBar.notifyFpAuthModeChanged(); mPhoneStatusBar.notifyFpAuthModeChanged();
} }
@Override
public void onStartedGoingToSleep(int why) {
mPendingAuthenticatedUserId = -1;
}
@Override
public void onFinishedGoingToSleep(int why) {
if (mPendingAuthenticatedUserId != -1) {
// Post this to make sure it's executed after the device is fully locked.
mHandler.post(new Runnable() {
@Override
public void run() {
onFingerprintAuthenticated(mPendingAuthenticatedUserId);
}
});
}
mPendingAuthenticatedUserId = -1;
}
public int getMode() { public int getMode() {
return mMode; return mMode;
} }