Skip to content

Commit 7726289

Browse files
author
Steven Ross
committed
Making FaceUnlock not pop up for overlays Fixes 5451837 Fixes 5446341
When the screen turns on because of an incoming phone call or when the emergency dialer is selected, FaceUnlock is deactivated until the phone call is completed and the screen is turned off. This also checks for non-phone overlays. If the lockscreen becomes unfocused while the screen is on, we assume that the reason is an overlay and prevent FaceUnlock from starting. The normal clock app is not considered an overlay by this approach, and thus it works as intended (back button brings up FaceUnlock). Also reverts: https://android-git.corp.google.com/g/#/c/139885/2 to make FaceUnlock appear when music is playing again Change-Id: Id715878556667d2b7e35c30a28d91be6a4eee575
1 parent 3505abf commit 7726289

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

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

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
136136

137137

138138
private boolean mRequiresSim;
139-
private volatile boolean mEmergencyCall;
139+
//True if we have some sort of overlay on top of the Lockscreen
140+
//Also true if we've activated a phone call, either emergency dialing or incoming
141+
//This resets when the phone is turned off with no current call
142+
private boolean mHasOverlay;
140143

141144

142145
/**
@@ -243,8 +246,6 @@ public void requestHide(View view) {
243246
}
244247
};
245248

246-
private TransportControlView mTransportControlView;
247-
248249
/**
249250
* @return Whether we are stuck on the lock screen because the sim is
250251
* missing.
@@ -277,7 +278,7 @@ public LockPatternKeyguardView(
277278
mUpdateMonitor = updateMonitor;
278279
mLockPatternUtils = lockPatternUtils;
279280
mWindowController = controller;
280-
mEmergencyCall = false;
281+
mHasOverlay = false;
281282

282283
mUpdateMonitor.registerInfoCallback(this);
283284

@@ -332,7 +333,7 @@ public void recreateMe(Configuration config) {
332333
}
333334

334335
public void takeEmergencyCallAction() {
335-
mEmergencyCall = true;
336+
mHasOverlay = true;
336337
// FaceLock must be stopped if it is running when emergency call is pressed
337338
stopAndUnbindFromFaceLock();
338339

@@ -514,9 +515,10 @@ public void reset() {
514515

515516
@Override
516517
public void onScreenTurnedOff() {
518+
if (DEBUG) Log.d(TAG, "screen off");
517519
mScreenOn = false;
518520
mForgotPattern = false;
519-
mEmergencyCall = false;
521+
mHasOverlay = mUpdateMonitor.getPhoneState() != TelephonyManager.CALL_STATE_IDLE;
520522
if (mMode == Mode.LockScreen) {
521523
((KeyguardScreen) mLockScreen).onPause();
522524
} else {
@@ -531,10 +533,7 @@ public void onScreenTurnedOff() {
531533
* FaceLock, but only if we're not dealing with a call
532534
*/
533535
private void activateFaceLockIfAble() {
534-
final boolean transportInvisible = mTransportControlView == null ? true :
535-
mTransportControlView.getVisibility() != View.VISIBLE;
536-
if (mUpdateMonitor.getPhoneState() == TelephonyManager.CALL_STATE_IDLE
537-
&& transportInvisible) {
536+
if (mUpdateMonitor.getPhoneState() == TelephonyManager.CALL_STATE_IDLE && !mHasOverlay) {
538537
bindToFaceLock();
539538
// Show FaceLock area, but only for a little bit so lockpattern will become visible if
540539
// FaceLock fails to start or crashes
@@ -546,6 +545,7 @@ private void activateFaceLockIfAble() {
546545

547546
@Override
548547
public void onScreenTurnedOn() {
548+
if (DEBUG) Log.d(TAG, "screen on");
549549
boolean runFaceLock = false;
550550
//Make sure to start facelock iff the screen is both on and focused
551551
synchronized(mFaceLockStartupLock) {
@@ -561,22 +561,19 @@ public void onScreenTurnedOn() {
561561
*/
562562
@Override
563563
public void onWindowFocusChanged (boolean hasWindowFocus) {
564-
if(DEBUG) Log.d(TAG, hasWindowFocus ? "focused" : "unfocused");
564+
if (DEBUG) Log.d(TAG, hasWindowFocus ? "focused" : "unfocused");
565565
boolean runFaceLock = false;
566566
//Make sure to start facelock iff the screen is both on and focused
567567
synchronized(mFaceLockStartupLock) {
568568
if(mScreenOn && !mWindowFocused) runFaceLock = hasWindowFocus;
569569
mWindowFocused = hasWindowFocus;
570570
}
571571
if(!hasWindowFocus) {
572+
mHasOverlay = true;
572573
stopAndUnbindFromFaceLock();
573574
hideFaceLockArea();
574575
} else if (runFaceLock) {
575-
//Don't activate facelock while the user is calling 911!
576-
if(mEmergencyCall) mEmergencyCall = false;
577-
else {
578-
activateFaceLockIfAble();
579-
}
576+
activateFaceLockIfAble();
580577
}
581578
}
582579

@@ -589,7 +586,7 @@ public void show() {
589586
}
590587

591588
if (mLockPatternUtils.usingBiometricWeak() &&
592-
mLockPatternUtils.isBiometricWeakInstalled()) {
589+
mLockPatternUtils.isBiometricWeakInstalled() && !mHasOverlay) {
593590
// Note that show() gets called before the screen turns off to set it up for next time
594591
// it is turned on. We don't want to set a timeout on the FaceLock area here because it
595592
// may be gone by the time the screen is turned on again. We set the timout when the
@@ -664,6 +661,7 @@ public void onDeviceProvisioned() {}
664661
public void onPhoneStateChanged(int phoneState) {
665662
if (DEBUG) Log.d(TAG, "phone state: " + phoneState);
666663
if(phoneState == TelephonyManager.CALL_STATE_RINGING) {
664+
mHasOverlay = true;
667665
stopAndUnbindFromFaceLock();
668666
hideFaceLockArea();
669667
}
@@ -891,13 +889,13 @@ View createUnlockScreenFor(UnlockMode unlockMode) {
891889
}
892890

893891
private void initializeTransportControlView(View view) {
894-
mTransportControlView = (TransportControlView) view.findViewById(R.id.transport);
895-
if (mTransportControlView == null) {
892+
TransportControlView tcv = (TransportControlView) view.findViewById(R.id.transport);
893+
if (tcv == null) {
896894
if (DEBUG) Log.w(TAG, "Couldn't find transport control widget");
897895
} else {
898896
mUpdateMonitor.reportClockVisible(true);
899-
mTransportControlView.setVisibility(View.GONE); // hide until it requests being shown.
900-
mTransportControlView.setCallback(mWidgetCallback);
897+
tcv.setVisibility(View.GONE); // hide until it requests being shown.
898+
tcv.setCallback(mWidgetCallback);
901899
}
902900
}
903901

0 commit comments

Comments
 (0)