diff options
| author | 2023-02-16 15:13:28 +0000 | |
|---|---|---|
| committer | 2023-02-16 15:13:28 +0000 | |
| commit | 30e34bca59a2b976ddcf5b35f243a6b71a494ab6 (patch) | |
| tree | 25225d33c3b39fc431c947014cbfce957c51a601 | |
| parent | 9dfb2b2f0eed7c2dcb79788d9b6ec074a75dae53 (diff) | |
| parent | f9e4d806238cd978b6a122795a00e75358a55ec8 (diff) | |
Merge "Re-calculate non-UDFPS fingerprint location onConfigChanged." into tm-qpr-dev
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java | 35 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java | 24 |
2 files changed, 40 insertions, 19 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java index 2dc0cd34adf4..3302073af7c6 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java @@ -129,7 +129,6 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks, private float mScaleFactor = 1f; // sensor locations without any resolution scaling nor rotation adjustments: @Nullable private final Point mFaceSensorLocationDefault; - @Nullable private final Point mFingerprintSensorLocationDefault; // cached sensor locations: @Nullable private Point mFaceSensorLocation; @Nullable private Point mFingerprintSensorLocation; @@ -586,11 +585,23 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks, @Nullable private Point getFingerprintSensorLocationInNaturalOrientation() { if (getUdfpsLocation() != null) { return getUdfpsLocation(); + } else { + int xFpLocation = mCachedDisplayInfo.getNaturalWidth() / 2; + try { + xFpLocation = mContext.getResources().getDimensionPixelSize( + com.android.systemui.R.dimen + .physical_fingerprint_sensor_center_screen_location_x); + } catch (Resources.NotFoundException e) { + } + + return new Point( + (int) (xFpLocation * mScaleFactor), + (int) (mContext.getResources().getDimensionPixelSize( + com.android.systemui.R.dimen + .physical_fingerprint_sensor_center_screen_location_y) + * mScaleFactor) + ); } - return new Point( - (int) (mFingerprintSensorLocationDefault.x * mScaleFactor), - (int) (mFingerprintSensorLocationDefault.y * mScaleFactor) - ); } /** @@ -774,19 +785,6 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks, } mDisplay = mContext.getDisplay(); - mDisplay.getDisplayInfo(mCachedDisplayInfo); - int xFpLocation = mCachedDisplayInfo.getNaturalWidth() / 2; - try { - xFpLocation = mContext.getResources().getDimensionPixelSize( - com.android.systemui.R.dimen - .physical_fingerprint_sensor_center_screen_location_x); - } catch (Resources.NotFoundException e) { - } - mFingerprintSensorLocationDefault = new Point( - xFpLocation, - mContext.getResources().getDimensionPixelSize(com.android.systemui.R.dimen - .physical_fingerprint_sensor_center_screen_location_y) - ); updateSensorLocations(); IntentFilter filter = new IntentFilter(); @@ -1246,7 +1244,6 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks, pw.println(" mScaleFactor=" + mScaleFactor); pw.println(" faceAuthSensorLocationDefault=" + mFaceSensorLocationDefault); pw.println(" faceAuthSensorLocation=" + getFaceSensorLocation()); - pw.println(" fingerprintSensorLocationDefault=" + mFingerprintSensorLocationDefault); pw.println(" fingerprintSensorLocationInNaturalOrientation=" + getFingerprintSensorLocationInNaturalOrientation()); pw.println(" fingerprintSensorLocation=" + getFingerprintSensorLocation()); diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java index ace0ccb6a25b..489efd71b1c1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java @@ -25,6 +25,7 @@ import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWA import static com.google.common.truth.Truth.assertThat; import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotSame; import static junit.framework.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; @@ -33,6 +34,7 @@ import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -49,6 +51,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Configuration; +import android.content.res.Resources; import android.graphics.Point; import android.hardware.biometrics.BiometricAuthenticator; import android.hardware.biometrics.BiometricConstants; @@ -166,6 +169,8 @@ public class AuthControllerTest extends SysuiTestCase { private ArgumentCaptor<StatusBarStateController.StateListener> mStatusBarStateListenerCaptor; @Captor private ArgumentCaptor<WakefulnessLifecycle.Observer> mWakefullnessObserverCaptor; + @Mock + private Resources mResources; private TestableContext mContextSpy; private Execution mExecution; @@ -879,6 +884,25 @@ public class AuthControllerTest extends SysuiTestCase { ); } + @Test + public void testUpdateFingerprintLocation_defaultPointChanges_whenConfigChanges() { + when(mContextSpy.getResources()).thenReturn(mResources); + + doReturn(500).when(mResources) + .getDimensionPixelSize(eq(com.android.systemui.R.dimen + .physical_fingerprint_sensor_center_screen_location_y)); + mAuthController.onConfigurationChanged(null /* newConfig */); + + final Point firstFpLocation = mAuthController.getFingerprintSensorLocation(); + + doReturn(1000).when(mResources) + .getDimensionPixelSize(eq(com.android.systemui.R.dimen + .physical_fingerprint_sensor_center_screen_location_y)); + mAuthController.onConfigurationChanged(null /* newConfig */); + + assertNotSame(firstFpLocation, mAuthController.getFingerprintSensorLocation()); + } + private void showDialog(int[] sensorIds, boolean credentialAllowed) { mAuthController.showAuthenticationDialog(createTestPromptInfo(), mReceiver /* receiver */, |