Skip to content

Commit fe444b4

Browse files
author
Steven Ross
committed
Always showing FaceUnlock view before bind fixes 6330358
Sets the view to visible directly on the UI thread when feasible this includes all cases where FaceUnlock is bound. The delay in processing a message was causing the bug. This additionally replaces the call in the keyguardview show with one when the facelockareaview is initialized. Change-Id: I8511f175d68023372e11d6e76fa1c44df6ac8a3d
1 parent cf6960e commit fe444b4

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

policy/src/com/android/internal/policy/impl/BiometricSensorUnlock.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ interface BiometricSensorUnlock {
2929
// Show the interface, but don't start the unlock procedure. The interface should disappear
3030
// after the specified timeout. If the timeout is 0, the interface shows until another event,
3131
// such as calling hide(), causes it to disappear.
32+
// Called on the UI Thread
3233
public void show(long timeoutMilliseconds);
3334

3435
// Hide the interface, if any, exposing the lockscreen.
@@ -39,6 +40,7 @@ interface BiometricSensorUnlock {
3940

4041
// Start the unlock procedure. Returns ‘false’ if it can’t be started or if the backup should
4142
// be used.
43+
// Called on the UI thread.
4244
public boolean start(boolean suppressBiometricUnlock);
4345

4446
// Provide a view to work within.

policy/src/com/android/internal/policy/impl/FaceUnlock.java

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -613,13 +613,7 @@ public void show() {
613613
((KeyguardScreen) mUnlockScreen).onResume();
614614
}
615615

616-
if (mBiometricUnlock.installedAndSelected() && !mSupressBiometricUnlock) {
617-
// Note that show() gets called before the screen turns off to set it up for next time
618-
// it is turned on. We don't want to set a timeout on the biometric unlock here because
619-
// it may be gone by the time the screen is turned on again. We set the timeout when
620-
// the screen turns on instead.
621-
mBiometricUnlock.show(0);
622-
} else {
616+
if (!mBiometricUnlock.installedAndSelected() || mSupressBiometricUnlock) {
623617
mBiometricUnlock.hide();
624618
}
625619
}

0 commit comments

Comments
 (0)