Skip to content

Commit 9d20405

Browse files
author
Brian Colonna
committed
Fix 5433466 - FU out of position during orientation change
If you turn the device from portrait to landscape mode and immediately invoke the lockscreen, it will come up in landscape mode and switch to the desired portrait mode within a couple of seconds. Previously, Face Unlock would come up in landscape mode, but its position would not change once lockscreen corrected itself, causing Face Unlock to be partly off the screen. This has been fixed by checking if we are already bound to Face Unlock when the layout is created. If this is true, then the layout is being created due to a change in orientation, and we stop Face Unlock, and restart it at the new position. This commit also adds a fix where we now use INVISIBLE for the Face Unlock area when it is not showing instead of using GONE. The dimensions of the Face Unlock area is 0-by-0 when set to GONE, and we want to avoid the possibility for the Face Unlock service being assigned a zero area. I'm not sure if this was ever causing problems, but it certainly is not the intended behavior. Also cleaned up some comments and logging. Change-Id: I68deb49cb26dafb5c238167d0c23f0eed2cfb75a
1 parent 87bc53d commit 9d20405

File tree

5 files changed

+29
-16
lines changed

5 files changed

+29
-16
lines changed

core/res/res/layout/keyguard_screen_password_landscape.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206

207207
<!-- Area to overlay FaceLock -->
208208
<TextView android:id="@+id/faceLockAreaView"
209-
android:visibility="gone"
209+
android:visibility="invisible"
210210
android:layout_row="0"
211211
android:layout_column="2"
212212
android:layout_rowSpan="8"

core/res/res/layout/keyguard_screen_password_portrait.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195

196196
<!-- Area to overlay FaceLock -->
197197
<TextView android:id="@+id/faceLockAreaView"
198-
android:visibility="gone"
198+
android:visibility="invisible"
199199
android:layout_row="3"
200200
android:layout_column="0"
201201
android:layout_rowSpan="2"

core/res/res/layout/keyguard_screen_unlock_landscape.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162

163163
<!-- Area to overlay FaceLock -->
164164
<TextView android:id="@+id/faceLockAreaView"
165-
android:visibility="gone"
165+
android:visibility="invisible"
166166
android:layout_row="0"
167167
android:layout_column="1"
168168
android:layout_rowSpan="7"

core/res/res/layout/keyguard_screen_unlock_portrait.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174

175175
<!-- Area to overlay FaceLock -->
176176
<TextView android:id="@+id/faceLockAreaView"
177-
android:visibility="gone"
177+
android:visibility="invisible"
178178
android:layout_row="4"
179179
android:layout_column="0"
180180
android:layout_rowSpan="1"

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

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,14 +1136,25 @@ public int getMinimumHeight() {
11361136

11371137
// Everything below pertains to FaceLock - might want to separate this out
11381138

1139-
// Only pattern and pin unlock screens actually have a view for the FaceLock area, so it's not
1140-
// uncommon for it to not exist. But if it does exist, we need to make sure it's shown (hiding
1141-
// the fallback) if FaceLock is enabled, and make sure it's hidden (showing the unlock) if
1142-
// FaceLock is disabled
1139+
// Take care of FaceLock area when layout is created
11431140
private void initializeFaceLockAreaView(View view) {
1144-
mFaceLockAreaView = view.findViewById(R.id.faceLockAreaView);
1145-
if (mFaceLockAreaView == null) {
1146-
if (DEBUG) Log.d(TAG, "Layout does not have faceLockAreaView");
1141+
if (mLockPatternUtils.usingBiometricWeak() &&
1142+
mLockPatternUtils.isBiometricWeakInstalled()) {
1143+
mFaceLockAreaView = view.findViewById(R.id.faceLockAreaView);
1144+
if (mFaceLockAreaView == null) {
1145+
Log.e(TAG, "Layout does not have faceLockAreaView and FaceLock is enabled");
1146+
} else {
1147+
if (mBoundToFaceLockService) {
1148+
// If we are creating a layout when we are already bound to FaceLock, then we
1149+
// are undergoing an orientation change. Stop FaceLock and restart it in the
1150+
// new location.
1151+
if (DEBUG) Log.d(TAG, "Restarting FL - creating view while already bound");
1152+
stopAndUnbindFromFaceLock();
1153+
activateFaceLockIfAble();
1154+
}
1155+
}
1156+
} else {
1157+
mFaceLockAreaView = null; // Set to null if not using FaceLock
11471158
}
11481159
}
11491160

@@ -1160,7 +1171,7 @@ public boolean handleMessage(Message msg) {
11601171
break;
11611172
case MSG_HIDE_FACELOCK_AREA_VIEW:
11621173
if (mFaceLockAreaView != null) {
1163-
mFaceLockAreaView.setVisibility(View.GONE);
1174+
mFaceLockAreaView.setVisibility(View.INVISIBLE);
11641175
}
11651176
break;
11661177
default:
@@ -1196,7 +1207,8 @@ private void showFaceLockAreaWithTimeout(long timeoutMillis) {
11961207
mHandler.sendEmptyMessageDelayed(MSG_HIDE_FACELOCK_AREA_VIEW, timeoutMillis);
11971208
}
11981209

1199-
// Binds to FaceLock service, but does not tell it to start
1210+
// Binds to FaceLock service. This call does not tell it to start, but it causes the service
1211+
// to call the onServiceConnected callback, which then starts FaceLock.
12001212
public void bindToFaceLock() {
12011213
if (mLockPatternUtils.usingBiometricWeak() &&
12021214
mLockPatternUtils.isBiometricWeakInstalled()) {
@@ -1232,9 +1244,10 @@ public void stopAndUnbindFromFaceLock() {
12321244
if (DEBUG) Log.d(TAG, "after unbind from FaceLock service");
12331245
mBoundToFaceLockService = false;
12341246
} else {
1235-
// This could probably happen after the session when someone activates FaceLock
1236-
// because it wasn't active when the phone was turned on
1237-
Log.w(TAG, "Attempt to unbind from FaceLock when not bound");
1247+
// This is usually not an error when this happens. Sometimes we will tell it to
1248+
// unbind multiple times because it's called from both onWindowFocusChanged and
1249+
// onDetachedFromWindow.
1250+
if (DEBUG) Log.d(TAG, "Attempt to unbind from FaceLock when not bound");
12381251
}
12391252
}
12401253
}

0 commit comments

Comments
 (0)