Skip to content

Commit 0c66f05

Browse files
Brian ColonnaAndroid (Google) Code Review
authored andcommitted
Merge "Fix 5323545 - FaceLock no longer appears when taking a call"
2 parents d83baa4 + 267cb2b commit 0c66f05

5 files changed

Lines changed: 31 additions & 50 deletions

File tree

core/java/com/android/internal/policy/IFaceLockCallback.aidl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ import android.os.IBinder;
2121
oneway interface IFaceLockCallback {
2222
void unlock();
2323
void cancel();
24-
void sleepDevice();
2524
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,4 +593,7 @@ public boolean isClockVisible() {
593593
return mClockVisible;
594594
}
595595

596+
public int getPhoneState() {
597+
return mPhoneState;
598+
}
596599
}

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,6 @@ public KeyguardViewCallback getCallback() {
127127
*/
128128
abstract public void cleanUp();
129129

130-
/**
131-
* These were added to support FaceLock because the KeyguardViewManager needs to tell the
132-
* LockPatternKeyguardView when to bind and and unbind with FaceLock service. Although
133-
* implemented in LockPatternKeyguardView, these are not implemented in anything else
134-
* derived from KeyguardViewBase
135-
*/
136-
abstract public void bindToFaceLock();
137-
abstract public void stopAndUnbindFromFaceLock();
138-
139130
@Override
140131
public boolean dispatchKeyEvent(KeyEvent event) {
141132
if (shouldEventKeepScreenOnWhileKeyguardShowing(event)) {

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,6 @@ public synchronized void onScreenTurnedOff() {
205205
mScreenOn = false;
206206
if (mKeyguardView != null) {
207207
mKeyguardView.onScreenTurnedOff();
208-
209-
// When screen is turned off, need to unbind from FaceLock service if using FaceLock
210-
mKeyguardView.stopAndUnbindFromFaceLock();
211208
}
212209
}
213210

@@ -218,9 +215,6 @@ public synchronized void onScreenTurnedOn(
218215
if (mKeyguardView != null) {
219216
mKeyguardView.onScreenTurnedOn();
220217

221-
// When screen is turned on, need to bind to FaceLock service if we are using FaceLock
222-
mKeyguardView.bindToFaceLock();
223-
224218
// Caller should wait for this window to be shown before turning
225219
// on the screen.
226220
if (mKeyguardHost.getVisibility() == View.VISIBLE) {
@@ -277,12 +271,6 @@ public boolean wakeWhenReadyTq(int keyCode) {
277271
public synchronized void hide() {
278272
if (DEBUG) Log.d(TAG, "hide()");
279273

280-
if (mKeyguardView != null) {
281-
// When view is hidden, need to unbind from FaceLock service if we are using FaceLock
282-
// e.g., when device becomes unlocked
283-
mKeyguardView.stopAndUnbindFromFaceLock();
284-
}
285-
286274
if (mKeyguardHost != null) {
287275
mKeyguardHost.setVisibility(View.GONE);
288276
// Don't do this right away, so we can let the view continue to animate

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

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ public void onScreenTurnedOff() {
504504
} else {
505505
((KeyguardScreen) mUnlockScreen).onPause();
506506
}
507+
508+
// When screen is turned off, need to unbind from FaceLock service if using FaceLock
509+
stopAndUnbindFromFaceLock();
507510
}
508511

509512
@Override
@@ -514,6 +517,14 @@ public void onScreenTurnedOn() {
514517
} else {
515518
((KeyguardScreen) mUnlockScreen).onResume();
516519
}
520+
521+
// When screen is turned on, need to bind to FaceLock service if we are using FaceLock
522+
// But only if not dealing with a call
523+
if (mUpdateMonitor.getPhoneState() == TelephonyManager.CALL_STATE_IDLE) {
524+
bindToFaceLock();
525+
} else {
526+
mHandler.sendEmptyMessage(MSG_HIDE_FACELOCK_AREA_VIEW);
527+
}
517528
}
518529

519530
private void recreateLockScreen() {
@@ -543,6 +554,11 @@ private void recreateUnlockScreen(UnlockMode unlockMode) {
543554
@Override
544555
protected void onDetachedFromWindow() {
545556
removeCallbacks(mRecreateRunnable);
557+
558+
// When view is hidden, need to unbind from FaceLock service if we are using FaceLock
559+
// e.g., when device becomes unlocked
560+
stopAndUnbindFromFaceLock();
561+
546562
super.onDetachedFromWindow();
547563
}
548564

@@ -952,8 +968,9 @@ public int getMinimumHeight() {
952968
// Everything below pertains to FaceLock - might want to separate this out
953969

954970
// Only pattern and pin unlock screens actually have a view for the FaceLock area, so it's not
955-
// uncommon for it to not exist. But if it does exist, we need to make sure it's showing if
956-
// FaceLock is enabled, and make sure it's not showing if FaceLock is disabled
971+
// uncommon for it to not exist. But if it does exist, we need to make sure it's shown (hiding
972+
// the fallback) if FaceLock is enabled, and make sure it's hidden (showing the unlock) if
973+
// FaceLock is disabled
957974
private void initializeFaceLockAreaView(View view) {
958975
mFaceLockAreaView = view.findViewById(R.id.faceLockAreaView);
959976
if (mFaceLockAreaView == null) {
@@ -997,9 +1014,7 @@ public void bindToFaceLock() {
9971014
if (DEBUG) Log.d(TAG, "after bind to FaceLock service");
9981015
mBoundToFaceLockService = true;
9991016
} else {
1000-
// On startup I've seen onScreenTurnedOn() get called twice without
1001-
// onScreenTurnedOff() being called in between, which can cause this (bcolonna)
1002-
if (DEBUG) Log.w(TAG, "Attempt to bind to FaceLock when already bound");
1017+
Log.w(TAG, "Attempt to bind to FaceLock when already bound");
10031018
}
10041019
}
10051020
}
@@ -1017,7 +1032,7 @@ public void stopAndUnbindFromFaceLock() {
10171032
} else {
10181033
// This could probably happen after the session when someone activates FaceLock
10191034
// because it wasn't active when the phone was turned on
1020-
if (DEBUG) Log.w(TAG, "Attempt to unbind from FaceLock when not bound");
1035+
Log.w(TAG, "Attempt to unbind from FaceLock when not bound");
10211036
}
10221037
}
10231038
}
@@ -1048,7 +1063,7 @@ public void onServiceDisconnected(ComponentName className) {
10481063
mFaceLockService = null;
10491064
mFaceLockServiceRunning = false;
10501065
}
1051-
if (DEBUG) Log.w(TAG, "Unexpected disconnect from FaceLock service");
1066+
Log.w(TAG, "Unexpected disconnect from FaceLock service");
10521067
}
10531068
};
10541069

@@ -1099,36 +1114,21 @@ public void stopFaceLock()
10991114
// Stops the FaceLock UI and indicates that the phone should be unlocked
11001115
@Override
11011116
public void unlock() {
1102-
if (DEBUG) Log.d(TAG, "FaceLock unlock");
1103-
// Note that we don't hide the client FaceLockAreaView because we want to keep the
1104-
// lock screen covered while the phone is unlocked
1105-
1117+
if (DEBUG) Log.d(TAG, "FaceLock unlock()");
1118+
mHandler.sendEmptyMessage(MSG_SHOW_FACELOCK_AREA_VIEW); // Keep fallback covered
11061119
stopFaceLock();
1120+
11071121
mKeyguardScreenCallback.keyguardDone(true);
11081122
mKeyguardScreenCallback.reportSuccessfulUnlockAttempt();
11091123
}
11101124

11111125
// Stops the FaceLock UI and exposes the backup method without unlocking
1126+
// This means either the user has cancelled out or FaceLock failed to recognize them
11121127
@Override
11131128
public void cancel() {
1114-
// In this case, either the user has cancelled out, or FaceLock failed to recognize them
1115-
if (DEBUG) Log.d(TAG, "FaceLock cancel");
1116-
// Here we hide the client FaceLockViewArea to expose the underlying backup method
1117-
mHandler.sendEmptyMessage(MSG_HIDE_FACELOCK_AREA_VIEW);
1118-
stopFaceLock();
1119-
}
1120-
1121-
// Stops the FaceLock UI and puts the phone to sleep
1122-
@Override
1123-
public void sleepDevice() {
1124-
// In this case, it appears the phone has been turned on accidentally
1125-
if (DEBUG) Log.d(TAG, "FaceLock accidental turn on");
1126-
// Here we hide the client FaceLockViewArea to expose the underlying backup method
1127-
mHandler.sendEmptyMessage(MSG_HIDE_FACELOCK_AREA_VIEW);
1129+
if (DEBUG) Log.d(TAG, "FaceLock cancel()");
1130+
mHandler.sendEmptyMessage(MSG_HIDE_FACELOCK_AREA_VIEW); // Expose fallback
11281131
stopFaceLock();
1129-
// TODO(bcolonna): how do we put the phone back to sleep (i.e., turn off the screen)
1130-
// TODO(bcolonna): this should be removed once the service is no longer calling it
1131-
// because we are just going to let the lockscreen timeout
11321132
}
11331133
};
11341134
}

0 commit comments

Comments
 (0)