Merge "Update side-fps affordance to account for changes in device rotation, and derive params from sensorProps and WindowManager" into sc-dev
This commit is contained in:
@@ -693,7 +693,6 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
|
||||
@Override
|
||||
protected void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
// UdfpsController is not BiometricPrompt-specific. It can be active for keyguard or
|
||||
// enrollment.
|
||||
if (mUdfpsController != null) {
|
||||
|
||||
@@ -26,9 +26,11 @@ import android.graphics.PixelFormat;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.ISidefpsController;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
@@ -45,20 +47,19 @@ import javax.inject.Inject;
|
||||
@SysUISingleton
|
||||
public class SidefpsController {
|
||||
private static final String TAG = "SidefpsController";
|
||||
// TODO (b/188690214): define and retrieve values from framework via SensorProps
|
||||
static final int DISPLAY_HEIGHT = 1804;
|
||||
static final int DISPLAY_WIDTH = 2208;
|
||||
static final int SFPS_INDICATOR_HEIGHT = 225;
|
||||
static final int SFPS_Y = 500;
|
||||
static final int SFPS_INDICATOR_WIDTH = 50;
|
||||
|
||||
@Nullable private SidefpsView mView;
|
||||
private final FingerprintManager mFingerprintManager;
|
||||
private final Context mContext;
|
||||
@NonNull private final Context mContext;
|
||||
@NonNull private final LayoutInflater mInflater;
|
||||
private final FingerprintManager mFingerprintManager;
|
||||
private final WindowManager mWindowManager;
|
||||
private final DelayableExecutor mFgExecutor;
|
||||
// TODO: update mDisplayHeight and mDisplayWidth for multi-display devices
|
||||
private final int mDisplayHeight;
|
||||
private final int mDisplayWidth;
|
||||
|
||||
private boolean mIsVisible = false;
|
||||
@Nullable private SidefpsView mView;
|
||||
|
||||
static final int SFPS_AFFORDANCE_WIDTH = 50; // in default portrait mode
|
||||
|
||||
@NonNull
|
||||
private final ISidefpsController mSidefpsControllerImpl = new ISidefpsController.Stub() {
|
||||
@@ -110,6 +111,11 @@ public class SidefpsController {
|
||||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||
mCoreLayoutParams.privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
|
||||
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
windowManager.getDefaultDisplay().getMetrics(displayMetrics);
|
||||
mDisplayHeight = displayMetrics.heightPixels;
|
||||
mDisplayWidth = displayMetrics.widthPixels;
|
||||
|
||||
mFingerprintManager.setSidefpsController(mSidefpsControllerImpl);
|
||||
}
|
||||
|
||||
@@ -122,7 +128,6 @@ public class SidefpsController {
|
||||
|
||||
void hide() {
|
||||
if (mView != null) {
|
||||
Log.v(TAG, "hideUdfpsOverlay | removing window");
|
||||
mWindowManager.removeView(mView);
|
||||
mView.setOnTouchListener(null);
|
||||
mView.setOnHoverListener(null);
|
||||
@@ -132,13 +137,14 @@ public class SidefpsController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void onConfigurationChanged() {
|
||||
// If overlay was hidden, it should remain hidden
|
||||
if (!mIsVisible) {
|
||||
// If mView is null or if view is hidden, then return.
|
||||
if (mView == null || !mIsVisible) {
|
||||
return;
|
||||
}
|
||||
// If the overlay needs to be shown, destroy the current overlay, and re-create and show
|
||||
// the overlay with the updated LayoutParams.
|
||||
// If the overlay needs to be displayed with a new configuration, destroy the current
|
||||
// overlay, and re-create and show the overlay with the updated LayoutParams.
|
||||
hide();
|
||||
show();
|
||||
}
|
||||
@@ -148,6 +154,25 @@ public class SidefpsController {
|
||||
for (FingerprintSensorPropertiesInternal props :
|
||||
mFingerprintManager.getSensorPropertiesInternal()) {
|
||||
if (props.isAnySidefpsType()) {
|
||||
// TODO(b/188690214): L155-L173 can be removed once sensorLocationX,
|
||||
// sensorLocationY, and sensorRadius are defined in sensorProps by the HAL
|
||||
int sensorLocationX = 25;
|
||||
int sensorLocationY = 610;
|
||||
int sensorRadius = 112;
|
||||
|
||||
FingerprintSensorPropertiesInternal tempProps =
|
||||
new FingerprintSensorPropertiesInternal(
|
||||
props.sensorId,
|
||||
props.sensorStrength,
|
||||
props.maxEnrollmentsPerUser,
|
||||
props.componentInfo,
|
||||
props.sensorType,
|
||||
props.resetLockoutRequiresHardwareAuthToken,
|
||||
sensorLocationX,
|
||||
sensorLocationY,
|
||||
sensorRadius
|
||||
);
|
||||
props = tempProps;
|
||||
return props;
|
||||
}
|
||||
}
|
||||
@@ -166,17 +191,30 @@ public class SidefpsController {
|
||||
*/
|
||||
private WindowManager.LayoutParams computeLayoutParams() {
|
||||
mCoreLayoutParams.flags = getCoreLayoutParamFlags();
|
||||
// Y value of top of affordance in portrait mode, X value of left of affordance in landscape
|
||||
int sfpsLocationY = mSensorProps.sensorLocationY - mSensorProps.sensorRadius;
|
||||
int sfpsAffordanceHeight = mSensorProps.sensorRadius * 2;
|
||||
|
||||
// Default dimensions assume portrait mode.
|
||||
mCoreLayoutParams.x = DISPLAY_WIDTH - SFPS_INDICATOR_WIDTH;
|
||||
mCoreLayoutParams.y = SFPS_Y;
|
||||
mCoreLayoutParams.height = SFPS_INDICATOR_HEIGHT;
|
||||
mCoreLayoutParams.width = SFPS_INDICATOR_WIDTH;
|
||||
|
||||
/*
|
||||
TODO (b/188692405): recalculate coordinates for non-portrait configurations and folding
|
||||
states
|
||||
*/
|
||||
// Calculate coordinates of drawable area for the fps affordance, accounting for orientation
|
||||
switch (mContext.getDisplay().getRotation()) {
|
||||
case Surface.ROTATION_90:
|
||||
mCoreLayoutParams.x = sfpsLocationY;
|
||||
mCoreLayoutParams.y = 0;
|
||||
mCoreLayoutParams.height = SFPS_AFFORDANCE_WIDTH;
|
||||
mCoreLayoutParams.width = sfpsAffordanceHeight;
|
||||
break;
|
||||
case Surface.ROTATION_270:
|
||||
mCoreLayoutParams.x = mDisplayHeight - sfpsLocationY - sfpsAffordanceHeight;
|
||||
mCoreLayoutParams.y = mDisplayWidth - SFPS_AFFORDANCE_WIDTH;
|
||||
mCoreLayoutParams.height = SFPS_AFFORDANCE_WIDTH;
|
||||
mCoreLayoutParams.width = sfpsAffordanceHeight;
|
||||
break;
|
||||
default: // Portrait
|
||||
mCoreLayoutParams.x = mDisplayWidth - SFPS_AFFORDANCE_WIDTH;
|
||||
mCoreLayoutParams.y = sfpsLocationY;
|
||||
mCoreLayoutParams.height = sfpsAffordanceHeight;
|
||||
mCoreLayoutParams.width = SFPS_AFFORDANCE_WIDTH;
|
||||
}
|
||||
return mCoreLayoutParams;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package com.android.systemui.biometrics;
|
||||
|
||||
import static com.android.systemui.biometrics.SidefpsController.SFPS_INDICATOR_HEIGHT;
|
||||
import static com.android.systemui.biometrics.SidefpsController.SFPS_INDICATOR_WIDTH;
|
||||
import static com.android.systemui.biometrics.SidefpsController.SFPS_AFFORDANCE_WIDTH;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
@@ -27,6 +26,7 @@ import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Surface;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
/**
|
||||
@@ -34,18 +34,22 @@ import android.widget.FrameLayout;
|
||||
*/
|
||||
public class SidefpsView extends FrameLayout {
|
||||
private static final String TAG = "SidefpsView";
|
||||
private static final int POINTER_SIZE_PX = 50;
|
||||
private static final int ROUND_RADIUS = 15;
|
||||
|
||||
@NonNull private final RectF mSensorRect;
|
||||
@NonNull private final Paint mSensorRectPaint;
|
||||
@NonNull private final Paint mPointerText;
|
||||
private static final int POINTER_SIZE_PX = 50;
|
||||
@NonNull private final Context mContext;
|
||||
|
||||
// Used to obtain the sensor location.
|
||||
@NonNull private FingerprintSensorPropertiesInternal mSensorProps;
|
||||
@Surface.Rotation private int mOrientation;
|
||||
|
||||
public SidefpsView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
super.setWillNotDraw(false);
|
||||
|
||||
mContext = context;
|
||||
mPointerText = new Paint(0 /* flags */);
|
||||
mPointerText.setAntiAlias(true);
|
||||
mPointerText.setColor(Color.WHITE);
|
||||
@@ -54,7 +58,7 @@ public class SidefpsView extends FrameLayout {
|
||||
mSensorRect = new RectF();
|
||||
mSensorRectPaint = new Paint(0 /* flags */);
|
||||
mSensorRectPaint.setAntiAlias(true);
|
||||
mSensorRectPaint.setColor(Color.BLUE);
|
||||
mSensorRectPaint.setColor(Color.BLUE); // TODO: Fix Color
|
||||
mSensorRectPaint.setStyle(Paint.Style.FILL);
|
||||
}
|
||||
|
||||
@@ -65,11 +69,19 @@ public class SidefpsView extends FrameLayout {
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
canvas.drawRect(mSensorRect, mSensorRectPaint);
|
||||
canvas.drawRoundRect(mSensorRect, ROUND_RADIUS, ROUND_RADIUS, mSensorRectPaint);
|
||||
int x, y;
|
||||
if (mOrientation == Surface.ROTATION_90 || mOrientation == Surface.ROTATION_270) {
|
||||
x = mSensorProps.sensorRadius + 10;
|
||||
y = SFPS_AFFORDANCE_WIDTH / 2 + 15;
|
||||
} else {
|
||||
x = SFPS_AFFORDANCE_WIDTH / 2 - 10;
|
||||
y = mSensorProps.sensorRadius + 30;
|
||||
}
|
||||
canvas.drawText(
|
||||
">",
|
||||
SFPS_INDICATOR_WIDTH / 2 - 10, // TODO(b/188690214): retrieve from sensorProps
|
||||
SFPS_INDICATOR_HEIGHT / 2 + 30, //TODO(b/188690214): retrieve from sensorProps
|
||||
x,
|
||||
y,
|
||||
mPointerText
|
||||
);
|
||||
}
|
||||
@@ -77,11 +89,19 @@ public class SidefpsView extends FrameLayout {
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
mOrientation = mContext.getDisplay().getRotation();
|
||||
if (mOrientation == Surface.ROTATION_90 || mOrientation == Surface.ROTATION_270) {
|
||||
right = mSensorProps.sensorRadius * 2;
|
||||
bottom = SFPS_AFFORDANCE_WIDTH;
|
||||
} else {
|
||||
right = SFPS_AFFORDANCE_WIDTH;
|
||||
bottom = mSensorProps.sensorRadius * 2;
|
||||
}
|
||||
|
||||
mSensorRect.set(
|
||||
0,
|
||||
0,
|
||||
SFPS_INDICATOR_WIDTH, //TODO(b/188690214): retrieve from sensorProps
|
||||
SFPS_INDICATOR_HEIGHT); //TODO(b/188690214): retrieve from sensorProps
|
||||
right,
|
||||
bottom);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user