@@ -52,26 +52,19 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback {
5252 private View mFaceUnlockView ;
5353
5454 private Handler mHandler ;
55- private final int MSG_SHOW_FACE_UNLOCK_VIEW = 0 ;
56- private final int MSG_HIDE_FACE_UNLOCK_VIEW = 1 ;
57- private final int MSG_SERVICE_CONNECTED = 2 ;
58- private final int MSG_SERVICE_DISCONNECTED = 3 ;
59- private final int MSG_UNLOCK = 4 ;
60- private final int MSG_CANCEL = 5 ;
61- private final int MSG_REPORT_FAILED_ATTEMPT = 6 ;
62- private final int MSG_EXPOSE_FALLBACK = 7 ;
63- private final int MSG_POKE_WAKELOCK = 8 ;
55+ private final int MSG_SERVICE_CONNECTED = 0 ;
56+ private final int MSG_SERVICE_DISCONNECTED = 1 ;
57+ private final int MSG_UNLOCK = 2 ;
58+ private final int MSG_CANCEL = 3 ;
59+ private final int MSG_REPORT_FAILED_ATTEMPT = 4 ;
60+ private final int MSG_EXPOSE_FALLBACK = 5 ;
61+ private final int MSG_POKE_WAKELOCK = 6 ;
6462
6563 // TODO: This was added for the purpose of adhering to what the biometric interface expects
6664 // the isRunning() function to return. However, it is probably not necessary to have both
6765 // mRunning and mServiceRunning. I'd just rather wait to change that logic.
6866 private volatile boolean mIsRunning = false ;
6967
70- // Long enough to stay visible while the service starts
71- // Short enough to not have to wait long for backup if service fails to start or crashes
72- // The service can take a couple of seconds to start on the first try after boot
73- private final int SERVICE_STARTUP_VIEW_TIMEOUT = 3000 ;
74-
7568 // So the user has a consistent amount of time when brought to the backup method from Face
7669 // Unlock
7770 private final int BACKUP_LOCK_TIMEOUT = 5000 ;
@@ -110,30 +103,11 @@ public boolean isRunning() {
110103 }
111104
112105 /**
113- * Sets the Face Unlock view to visible, hiding it after the specified amount of time. If
114- * timeoutMillis is 0, no hide is performed. Called on the UI thread.
106+ * Dismisses face unlock and goes to the backup lock
115107 */
116- public void show (long timeoutMillis ) {
117- if (DEBUG ) Log .d (TAG , "show()" );
118- if (mHandler .getLooper () != Looper .myLooper ()) {
119- Log .e (TAG , "show() called off of the UI thread" );
120- }
121- removeDisplayMessages ();
122- if (timeoutMillis > 0 ) {
123- mHandler .sendEmptyMessageDelayed (MSG_HIDE_FACE_UNLOCK_VIEW , timeoutMillis );
124- }
125- }
126-
127- /**
128- * Hides the Face Unlock view.
129- */
130- public void hide () {
131- if (DEBUG ) Log .d (TAG , "hide()" );
132- // Removes any wakelock messages to make sure they don't cause the screen to turn back on.
133- mHandler .removeMessages (MSG_POKE_WAKELOCK );
134- // Remove messages to prevent a delayed show message from undo-ing the hide
135- removeDisplayMessages ();
136- mHandler .sendEmptyMessage (MSG_HIDE_FACE_UNLOCK_VIEW );
108+ public void stopAndShowBackup () {
109+ if (DEBUG ) Log .d (TAG , "stopAndShowBackup()" );
110+ mHandler .sendEmptyMessage (MSG_CANCEL );
137111 }
138112
139113 /**
@@ -151,10 +125,6 @@ public boolean start() {
151125 Log .w (TAG , "start() called when already running" );
152126 }
153127
154- // Show Face Unlock view, but only for a little bit so lockpattern will become visible if
155- // Face Unlock fails to start or crashes
156- // This must show before bind to guarantee that Face Unlock has a place to display
157- show (SERVICE_STARTUP_VIEW_TIMEOUT );
158128 if (!mBoundToService ) {
159129 Log .d (TAG , "Binding to Face Unlock service for user="
160130 + mLockPatternUtils .getCurrentUser ());
@@ -234,12 +204,6 @@ public int getQuality() {
234204 */
235205 public boolean handleMessage (Message msg ) {
236206 switch (msg .what ) {
237- case MSG_SHOW_FACE_UNLOCK_VIEW :
238- handleShowFaceUnlockView ();
239- break ;
240- case MSG_HIDE_FACE_UNLOCK_VIEW :
241- handleHideFaceUnlockView ();
242- break ;
243207 case MSG_SERVICE_CONNECTED :
244208 handleServiceConnected ();
245209 break ;
@@ -268,22 +232,6 @@ public boolean handleMessage(Message msg) {
268232 return true ;
269233 }
270234
271- /**
272- * Sets the Face Unlock view to visible, thus covering the backup lock.
273- */
274- void handleShowFaceUnlockView () {
275- if (DEBUG ) Log .d (TAG , "handleShowFaceUnlockView()" );
276- // Not required
277- }
278-
279- /**
280- * Hide face unlock and show backup
281- */
282- void handleHideFaceUnlockView () {
283- if (DEBUG ) Log .d (TAG , "handleHideFaceUnlockView()" );
284- mKeyguardScreenCallback .showBackupSecurity ();
285- }
286-
287235 /**
288236 * Tells the service to start its UI via an AIDL interface. Called when the
289237 * onServiceConnected() callback is received.
@@ -347,23 +295,21 @@ void handleServiceDisconnected() {
347295 }
348296
349297 /**
350- * Stops the Face Unlock service and tells the device to grant access to the user. Shows the
351- * Face Unlock view to keep the backup lock covered while the device unlocks.
298+ * Stops the Face Unlock service and tells the device to grant access to the user.
352299 */
353300 void handleUnlock () {
354301 if (DEBUG ) Log .d (TAG , "handleUnlock()" );
355- removeDisplayMessages ();
356302 stop ();
357303 mKeyguardScreenCallback .reportSuccessfulUnlockAttempt ();
358304 mKeyguardScreenCallback .dismiss (true );
359305 }
360306
361307 /**
362- * Stops the Face Unlock service and exposes the backup lock.
308+ * Stops the Face Unlock service and goes to the backup lock.
363309 */
364310 void handleCancel () {
365311 if (DEBUG ) Log .d (TAG , "handleCancel()" );
366- mKeyguardScreenCallback .dismiss ( false );
312+ mKeyguardScreenCallback .showBackupSecurity ( );
367313 stop ();
368314 mKeyguardScreenCallback .userActivity (BACKUP_LOCK_TIMEOUT );
369315 }
@@ -397,15 +343,6 @@ void handlePokeWakelock(int millis) {
397343 }
398344 }
399345
400- /**
401- * Removes show and hide messages from the message queue. Called to prevent delayed show/hide
402- * messages from undoing a new message.
403- */
404- private void removeDisplayMessages () {
405- mHandler .removeMessages (MSG_SHOW_FACE_UNLOCK_VIEW );
406- mHandler .removeMessages (MSG_HIDE_FACE_UNLOCK_VIEW );
407- }
408-
409346 /**
410347 * Implements service connection methods.
411348 */
@@ -508,7 +445,7 @@ public void reportFailedAttempt() {
508445 * Called when the Face Unlock service starts displaying the UI, indicating that the backup
509446 * unlock can be exposed because the Face Unlock service is now covering the backup with its
510447 * UI.
511- ** /
448+ */
512449 public void exposeFallback () {
513450 if (DEBUG ) Log .d (TAG , "exposeFallback()" );
514451 mHandler .sendEmptyMessage (MSG_EXPOSE_FALLBACK );
0 commit comments