@@ -88,7 +88,9 @@ public boolean isRunning() {
8888 }
8989
9090 // Shows the FaceLock area for a period of time
91+ // Called on the UI thread
9192 public void show (long timeoutMillis ) {
93+ removeAreaDisplayMessages ();
9294 showArea ();
9395 if (timeoutMillis > 0 )
9496 mHandler .sendEmptyMessageDelayed (MSG_HIDE_AREA_VIEW , timeoutMillis );
@@ -134,6 +136,7 @@ public boolean stop() {
134136 /**
135137 * When screen is turned on and focused, need to bind to FaceLock service if we are using
136138 * FaceLock, but only if we're not dealing with a call
139+ * Called on the UI thread
137140 */
138141 public boolean start (boolean suppressBiometricUnlock ) {
139142 final boolean tooManyFaceUnlockTries = mUpdateMonitor .getMaxFaceUnlockAttemptsReached ();
@@ -146,12 +149,13 @@ && installedAndSelected()
146149 && !suppressBiometricUnlock
147150 && !tooManyFaceUnlockTries
148151 && !backupIsTimedOut ) {
149- bind ();
150-
151152 // Show FaceLock area, but only for a little bit so lockpattern will become visible if
152153 // FaceLock fails to start or crashes
154+ // This must show before bind to guarantee that Face Unlock has a place to display
153155 show (VIEW_AREA_SERVICE_TIMEOUT );
154156
157+ bind ();
158+
155159 // When switching between portrait and landscape view while FaceLock is running, the
156160 // screen will eventually go dark unless we poke the wakelock when FaceLock is
157161 // restarted
@@ -170,6 +174,8 @@ public void initializeAreaView(View topView) {
170174 mAreaView = topView .findViewById (R .id .faceLockAreaView );
171175 if (mAreaView == null ) {
172176 Log .e (TAG , "Layout does not have areaView and FaceLock is enabled" );
177+ } else {
178+ show (0 );
173179 }
174180 } else {
175181 mAreaView = null ; // Set to null if not using FaceLock
@@ -192,16 +198,22 @@ public int getQuality() {
192198 return DevicePolicyManager .PASSWORD_QUALITY_BIOMETRIC_WEAK ;
193199 }
194200
201+ // Shows the FaceLock area
202+ // Called on the UI thread
203+ private void showArea () {
204+ if (mAreaView != null ) {
205+ mAreaView .setVisibility (View .VISIBLE );
206+ }
207+ }
208+
195209 // Handles covering or exposing FaceLock area on the client side when FaceLock starts or stops
196210 // This needs to be done in a handler because the call could be coming from a callback from the
197211 // FaceLock service that is in a thread that can't modify the UI
198212 @ Override
199213 public boolean handleMessage (Message msg ) {
200214 switch (msg .what ) {
201215 case MSG_SHOW_AREA_VIEW :
202- if (mAreaView != null ) {
203- mAreaView .setVisibility (View .VISIBLE );
204- }
216+ showArea ();
205217 break ;
206218 case MSG_HIDE_AREA_VIEW :
207219 if (mAreaView != null ) {
@@ -221,13 +233,6 @@ private void removeAreaDisplayMessages() {
221233 mHandler .removeMessages (MSG_HIDE_AREA_VIEW );
222234 }
223235
224- // Shows the FaceLock area immediately
225- private void showArea () {
226- // Remove messages to prevent a delayed hide message from undo-ing the show
227- removeAreaDisplayMessages ();
228- mHandler .sendEmptyMessage (MSG_SHOW_AREA_VIEW );
229- }
230-
231236 // Binds to FaceLock service. This call does not tell it to start, but it causes the service
232237 // to call the onServiceConnected callback, which then starts FaceLock.
233238 private void bind () {
@@ -329,7 +334,11 @@ private void stopUi() {
329334 @ Override
330335 public void unlock () {
331336 if (DEBUG ) Log .d (TAG , "FaceLock unlock()" );
332- showArea (); // Keep fallback covered
337+
338+ // Keep fallback covered
339+ removeAreaDisplayMessages ();
340+ mHandler .sendEmptyMessage (MSG_SHOW_AREA_VIEW );
341+
333342 stop ();
334343
335344 mKeyguardScreenCallback .keyguardDone (true );
0 commit comments