Fix landscape to reverse landscape issue

Fingerprint enrollment page needs to display different types of layout
for both landscape mode and reverse landscape mode. However
onConfigurationChanged doesn't get called when landscape mode rotates to
reverse landscape mode directly, that causes it displays a wrong layout
in the both landscape and reverse landscape modes.

Trying to monitor rotation event and checking if the case that directly
turns landscape mode to reverse landscape mode happens, if so, reCreate
method will get called to re-lay out the page. There will be a flicker
problem happening in re-laying out the page but this solution still
works for users to have the correct layout.

Fix: 186372522
Test: manual test
1) Navigate to fingerprint enrollment page
2) Rotate the screen from landscape mode to reverse landscape mode
3) Observe the page and see if it has a correct layout

Change-Id: Ie94f43a6546f453c10ae9f1c3ba83e1178784950
This commit is contained in:
Mill Chen
2021-07-03 06:02:25 +08:00
parent aede51f0e7
commit 7f2496219f

View File

@@ -36,6 +36,8 @@ import android.os.Vibrator;
import android.text.TextUtils;
import android.util.Log;
import android.view.MotionEvent;
import android.view.OrientationEventListener;
import android.view.Surface;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
@@ -116,6 +118,9 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
private AccessibilityManager mAccessibilityManager;
private boolean mIsAccessibilityEnabled;
private OrientationEventListener mOrientationEventListener;
private int mPreviousRotation = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -128,6 +133,8 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
mAccessibilityManager = getSystemService(AccessibilityManager.class);
mIsAccessibilityEnabled = mAccessibilityManager.isEnabled();
listenOrientationEvent();
if (mCanAssumeUdfps) {
if (BiometricUtils.isReverseLandscape(getApplicationContext())) {
setContentView(R.layout.udfps_enroll_enrolling_land);
@@ -255,6 +262,12 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
stopIconAnimation();
}
@Override
protected void onDestroy() {
stopListenOrientationEvent();
super.onDestroy();
}
private void animateProgress(int progress) {
if (mCanAssumeUdfps) {
// UDFPS animations are owned by SystemUI
@@ -451,6 +464,31 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
}
}
private void listenOrientationEvent() {
mOrientationEventListener = new OrientationEventListener(this) {
@Override
public void onOrientationChanged(int orientation) {
final int currentRotation = getDisplay().getRotation();
if ((mPreviousRotation == Surface.ROTATION_90
&& currentRotation == Surface.ROTATION_270) || (
mPreviousRotation == Surface.ROTATION_270
&& currentRotation == Surface.ROTATION_90)) {
mPreviousRotation = currentRotation;
recreate();
}
}
};
mOrientationEventListener.enable();
mPreviousRotation = getDisplay().getRotation();
}
private void stopListenOrientationEvent() {
if (mOrientationEventListener != null) {
mOrientationEventListener.disable();
}
mOrientationEventListener = null;
}
private final Animator.AnimatorListener mProgressAnimationListener
= new Animator.AnimatorListener() {