Merge "Re-calculate non-UDFPS fingerprint location onConfigChanged." into tm-qpr-dev
This commit is contained in:
@@ -129,7 +129,6 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,
|
|||||||
private float mScaleFactor = 1f;
|
private float mScaleFactor = 1f;
|
||||||
// sensor locations without any resolution scaling nor rotation adjustments:
|
// sensor locations without any resolution scaling nor rotation adjustments:
|
||||||
@Nullable private final Point mFaceSensorLocationDefault;
|
@Nullable private final Point mFaceSensorLocationDefault;
|
||||||
@Nullable private final Point mFingerprintSensorLocationDefault;
|
|
||||||
// cached sensor locations:
|
// cached sensor locations:
|
||||||
@Nullable private Point mFaceSensorLocation;
|
@Nullable private Point mFaceSensorLocation;
|
||||||
@Nullable private Point mFingerprintSensorLocation;
|
@Nullable private Point mFingerprintSensorLocation;
|
||||||
@@ -586,11 +585,23 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,
|
|||||||
@Nullable private Point getFingerprintSensorLocationInNaturalOrientation() {
|
@Nullable private Point getFingerprintSensorLocationInNaturalOrientation() {
|
||||||
if (getUdfpsLocation() != null) {
|
if (getUdfpsLocation() != null) {
|
||||||
return getUdfpsLocation();
|
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 = 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();
|
updateSensorLocations();
|
||||||
|
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
@@ -1246,7 +1244,6 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,
|
|||||||
pw.println(" mScaleFactor=" + mScaleFactor);
|
pw.println(" mScaleFactor=" + mScaleFactor);
|
||||||
pw.println(" faceAuthSensorLocationDefault=" + mFaceSensorLocationDefault);
|
pw.println(" faceAuthSensorLocationDefault=" + mFaceSensorLocationDefault);
|
||||||
pw.println(" faceAuthSensorLocation=" + getFaceSensorLocation());
|
pw.println(" faceAuthSensorLocation=" + getFaceSensorLocation());
|
||||||
pw.println(" fingerprintSensorLocationDefault=" + mFingerprintSensorLocationDefault);
|
|
||||||
pw.println(" fingerprintSensorLocationInNaturalOrientation="
|
pw.println(" fingerprintSensorLocationInNaturalOrientation="
|
||||||
+ getFingerprintSensorLocationInNaturalOrientation());
|
+ getFingerprintSensorLocationInNaturalOrientation());
|
||||||
pw.println(" fingerprintSensorLocation=" + getFingerprintSensorLocation());
|
pw.println(" fingerprintSensorLocation=" + getFingerprintSensorLocation());
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWA
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
|
import static junit.framework.Assert.assertNotSame;
|
||||||
import static junit.framework.Assert.assertNull;
|
import static junit.framework.Assert.assertNull;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
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.anyString;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.inOrder;
|
import static org.mockito.Mockito.inOrder;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
@@ -49,6 +51,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.hardware.biometrics.BiometricAuthenticator;
|
import android.hardware.biometrics.BiometricAuthenticator;
|
||||||
import android.hardware.biometrics.BiometricConstants;
|
import android.hardware.biometrics.BiometricConstants;
|
||||||
@@ -166,6 +169,8 @@ public class AuthControllerTest extends SysuiTestCase {
|
|||||||
private ArgumentCaptor<StatusBarStateController.StateListener> mStatusBarStateListenerCaptor;
|
private ArgumentCaptor<StatusBarStateController.StateListener> mStatusBarStateListenerCaptor;
|
||||||
@Captor
|
@Captor
|
||||||
private ArgumentCaptor<WakefulnessLifecycle.Observer> mWakefullnessObserverCaptor;
|
private ArgumentCaptor<WakefulnessLifecycle.Observer> mWakefullnessObserverCaptor;
|
||||||
|
@Mock
|
||||||
|
private Resources mResources;
|
||||||
|
|
||||||
private TestableContext mContextSpy;
|
private TestableContext mContextSpy;
|
||||||
private Execution mExecution;
|
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) {
|
private void showDialog(int[] sensorIds, boolean credentialAllowed) {
|
||||||
mAuthController.showAuthenticationDialog(createTestPromptInfo(),
|
mAuthController.showAuthenticationDialog(createTestPromptInfo(),
|
||||||
mReceiver /* receiver */,
|
mReceiver /* receiver */,
|
||||||
|
|||||||
Reference in New Issue
Block a user