Skip to content

Commit 51ee6a7

Browse files
Steven RossAndroid (Google) Code Review
authored andcommitted
Merge "Fixes 5429869 Only displaying FaceUnlock when window is focused"
2 parents 94e8471 + c3892c5 commit 51ee6a7

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

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

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
9898
private View mLockScreen;
9999
private View mUnlockScreen;
100100

101-
private boolean mScreenOn = false;
101+
private volatile boolean mScreenOn = false;
102+
private volatile boolean mWindowFocused = false;
102103
private boolean mEnableFallback = false; // assume no fallback UI until we know better
103104

104105
private boolean mShowLockBeforeUnlock = false;
@@ -110,6 +111,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
110111

111112
private boolean mFaceLockServiceRunning = false;
112113
private final Object mFaceLockServiceRunningLock = new Object();
114+
private final Object mFaceLockStartupLock = new Object();
113115

114116
private Handler mHandler;
115117
private final int MSG_SHOW_FACELOCK_AREA_VIEW = 0;
@@ -514,13 +516,10 @@ public void onScreenTurnedOff() {
514516
stopAndUnbindFromFaceLock();
515517
}
516518

517-
@Override
518-
public void onScreenTurnedOn() {
519-
mScreenOn = true;
520-
show();
521-
522-
// When screen is turned on, need to bind to FaceLock service if we are using FaceLock
523-
// But only if not dealing with a call
519+
/** When screen is turned on and focused, need to bind to FaceLock service if we are using
520+
* FaceLock, but only if we're not dealing with a call
521+
*/
522+
private void activateFaceLockIfAble() {
524523
final boolean transportInvisible = mTransportControlView == null ? true :
525524
mTransportControlView.getVisibility() != View.VISIBLE;
526525
if (mUpdateMonitor.getPhoneState() == TelephonyManager.CALL_STATE_IDLE
@@ -534,12 +533,34 @@ public void onScreenTurnedOn() {
534533
}
535534
}
536535

537-
/** Unbind from facelock if something covers this window (such as an alarm) */
536+
@Override
537+
public void onScreenTurnedOn() {
538+
boolean runFaceLock = false;
539+
//Make sure to start facelock iff the screen is both on and focused
540+
synchronized(mFaceLockStartupLock) {
541+
mScreenOn = true;
542+
runFaceLock = mWindowFocused;
543+
}
544+
show();
545+
if(runFaceLock) activateFaceLockIfAble();
546+
}
547+
548+
/** Unbind from facelock if something covers this window (such as an alarm)
549+
* bind to facelock if the lockscreen window just came into focus, and the screen is on
550+
*/
538551
@Override
539552
public void onWindowFocusChanged (boolean hasWindowFocus) {
553+
boolean runFaceLock = false;
554+
//Make sure to start facelock iff the screen is both on and focused
555+
synchronized(mFaceLockStartupLock) {
556+
if(mScreenOn && !mWindowFocused) runFaceLock = hasWindowFocus;
557+
mWindowFocused = hasWindowFocus;
558+
}
540559
if(!hasWindowFocus) {
541560
stopAndUnbindFromFaceLock();
542561
mHandler.sendEmptyMessage(MSG_HIDE_FACELOCK_AREA_VIEW);
562+
} else if (runFaceLock) {
563+
activateFaceLockIfAble();
543564
}
544565
}
545566

0 commit comments

Comments
 (0)