Merge "Support an x-coordinate for fps location" into sc-v2-dev

This commit is contained in:
TreeHugger Robot
2021-09-30 14:49:25 +00:00
committed by Android (Google) Code Review
3 changed files with 61 additions and 5 deletions

View File

@@ -1556,6 +1556,13 @@
<dimen name="physical_volume_up_button_center_screen_location_y">950px</dimen>
<dimen name="physical_volume_down_button_center_screen_location_y">1150px</dimen>
<!-- Location on the screen of the center of the fingerprint sensor. For devices with under
display fingerprint sensors, this directly corresponds to the fingerprint sensor's location.
For devices with sensors on the back of the device, this corresponds to the location on the
screen directly in front of the sensor.
By default, this is set to @null to use the horizontal center of the screen. -->
<dimen name="physical_fingerprint_sensor_center_screen_location_x">@null</dimen>
<!-- Location on the screen of the center of the fingerprint sensor. For devices with under
display fingerprint sensors, this directly corresponds to the fingerprint sensor's location.
For devices with sensors on the back of the device, this corresponds to the location on the

View File

@@ -29,6 +29,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.PointF;
import android.hardware.biometrics.BiometricAuthenticator.Modality;
import android.hardware.biometrics.BiometricConstants;
@@ -97,7 +98,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
private final Provider<UdfpsController> mUdfpsControllerFactory;
private final Provider<SidefpsController> mSidefpsControllerFactory;
@Nullable private final PointF mFaceAuthSensorLocation;
@Nullable private final PointF mFingerprintLocation;
@Nullable private PointF mFingerprintLocation;
private final Set<Callback> mCallbacks = new HashSet<>();
// TODO: These should just be saved from onSaveState
@@ -481,9 +482,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
(float) faceAuthLocation[1]);
}
mFingerprintLocation = new PointF(DisplayUtils.getWidth(mContext) / 2,
mContext.getResources().getDimensionPixelSize(
com.android.systemui.R.dimen.physical_fingerprint_sensor_center_screen_location_y));
updateFingerprintLocation();
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
@@ -491,6 +490,21 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
context.registerReceiver(mBroadcastReceiver, filter);
}
private void updateFingerprintLocation() {
int xLocation = DisplayUtils.getWidth(mContext) / 2;
try {
xLocation = mContext.getResources().getDimensionPixelSize(
com.android.systemui.R.dimen
.physical_fingerprint_sensor_center_screen_location_x);
} catch (Resources.NotFoundException e) {
}
int yLocation = mContext.getResources().getDimensionPixelSize(
com.android.systemui.R.dimen.physical_fingerprint_sensor_center_screen_location_y);
mFingerprintLocation = new PointF(
xLocation,
yLocation);
}
@SuppressWarnings("deprecation")
@Override
public void start() {
@@ -767,6 +781,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
updateFingerprintLocation();
// Save the state of the current dialog (buttons showing, etc)
if (mCurrentDialog != null) {
@@ -796,6 +811,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
}
private void onOrientationChanged() {
updateFingerprintLocation();
if (mCurrentDialog != null) {
mCurrentDialog.onOrientationChanged();
}

View File

@@ -21,6 +21,7 @@ import android.content.Context
import android.content.res.Configuration
import android.graphics.PointF
import android.hardware.biometrics.BiometricSourceType
import android.util.DisplayMetrics
import android.util.Log
import androidx.annotation.VisibleForTesting
import com.android.keyguard.KeyguardUpdateMonitor
@@ -45,6 +46,7 @@ import java.io.PrintWriter
import javax.inject.Inject
import javax.inject.Provider
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.util.leak.RotationUtils
private const val WAKE_AND_UNLOCK_FADE_DURATION = 180L
@@ -182,7 +184,7 @@ class AuthRippleController @Inject constructor(
}
fun updateSensorLocation() {
fingerprintSensorLocation = authController.fingerprintSensorLocation
updateFingerprintLocation()
faceSensorLocation = authController.faceAuthSensorLocation
fingerprintSensorLocation?.let {
circleReveal = CircleReveal(
@@ -197,6 +199,35 @@ class AuthRippleController @Inject constructor(
}
}
private fun updateFingerprintLocation() {
val displayMetrics = DisplayMetrics()
sysuiContext.display?.getRealMetrics(displayMetrics)
val width = displayMetrics.widthPixels
val height = displayMetrics.heightPixels
authController.fingerprintSensorLocation?.let {
fingerprintSensorLocation = when (RotationUtils.getRotation(sysuiContext)) {
RotationUtils.ROTATION_LANDSCAPE -> {
val normalizedYPos: Float = it.y / width
val normalizedXPos: Float = it.x / height
PointF(width * normalizedYPos, height * (1 - normalizedXPos))
}
RotationUtils.ROTATION_UPSIDE_DOWN -> {
PointF(width - it.x, height - it.y)
}
RotationUtils.ROTATION_SEASCAPE -> {
val normalizedYPos: Float = it.y / width
val normalizedXPos: Float = it.x / height
PointF(width * (1 - normalizedYPos), height * normalizedXPos)
}
else -> {
// ROTATION_NONE
PointF(it.x, it.y)
}
}
}
}
private fun updateRippleColor() {
mView.setColor(
Utils.getColorAttr(sysuiContext, android.R.attr.colorAccent).defaultColor)
@@ -314,10 +345,12 @@ class AuthRippleController @Inject constructor(
}
}
"fingerprint" -> {
updateSensorLocation()
pw.println("fingerprint ripple sensorLocation=$fingerprintSensorLocation")
showRipple(BiometricSourceType.FINGERPRINT)
}
"face" -> {
updateSensorLocation()
pw.println("face ripple sensorLocation=$faceSensorLocation")
showRipple(BiometricSourceType.FACE)
}