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
|
@Override
|
||||||
protected void onConfigurationChanged(Configuration newConfig) {
|
protected void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
|
|
||||||
// UdfpsController is not BiometricPrompt-specific. It can be active for keyguard or
|
// UdfpsController is not BiometricPrompt-specific. It can be active for keyguard or
|
||||||
// enrollment.
|
// enrollment.
|
||||||
if (mUdfpsController != null) {
|
if (mUdfpsController != null) {
|
||||||
|
|||||||
@@ -26,9 +26,11 @@ import android.graphics.PixelFormat;
|
|||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||||
import android.hardware.fingerprint.ISidefpsController;
|
import android.hardware.fingerprint.ISidefpsController;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Surface;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
@@ -45,20 +47,19 @@ import javax.inject.Inject;
|
|||||||
@SysUISingleton
|
@SysUISingleton
|
||||||
public class SidefpsController {
|
public class SidefpsController {
|
||||||
private static final String TAG = "SidefpsController";
|
private static final String TAG = "SidefpsController";
|
||||||
// TODO (b/188690214): define and retrieve values from framework via SensorProps
|
@NonNull private final Context mContext;
|
||||||
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 LayoutInflater mInflater;
|
@NonNull private final LayoutInflater mInflater;
|
||||||
|
private final FingerprintManager mFingerprintManager;
|
||||||
private final WindowManager mWindowManager;
|
private final WindowManager mWindowManager;
|
||||||
private final DelayableExecutor mFgExecutor;
|
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;
|
private boolean mIsVisible = false;
|
||||||
|
@Nullable private SidefpsView mView;
|
||||||
|
|
||||||
|
static final int SFPS_AFFORDANCE_WIDTH = 50; // in default portrait mode
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final ISidefpsController mSidefpsControllerImpl = new ISidefpsController.Stub() {
|
private final ISidefpsController mSidefpsControllerImpl = new ISidefpsController.Stub() {
|
||||||
@@ -110,6 +111,11 @@ public class SidefpsController {
|
|||||||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||||
mCoreLayoutParams.privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
|
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);
|
mFingerprintManager.setSidefpsController(mSidefpsControllerImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +128,6 @@ public class SidefpsController {
|
|||||||
|
|
||||||
void hide() {
|
void hide() {
|
||||||
if (mView != null) {
|
if (mView != null) {
|
||||||
Log.v(TAG, "hideUdfpsOverlay | removing window");
|
|
||||||
mWindowManager.removeView(mView);
|
mWindowManager.removeView(mView);
|
||||||
mView.setOnTouchListener(null);
|
mView.setOnTouchListener(null);
|
||||||
mView.setOnHoverListener(null);
|
mView.setOnHoverListener(null);
|
||||||
@@ -132,13 +137,14 @@ public class SidefpsController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void onConfigurationChanged() {
|
void onConfigurationChanged() {
|
||||||
// If overlay was hidden, it should remain hidden
|
// If mView is null or if view is hidden, then return.
|
||||||
if (!mIsVisible) {
|
if (mView == null || !mIsVisible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If the overlay needs to be shown, destroy the current overlay, and re-create and show
|
// If the overlay needs to be displayed with a new configuration, destroy the current
|
||||||
// the overlay with the updated LayoutParams.
|
// overlay, and re-create and show the overlay with the updated LayoutParams.
|
||||||
hide();
|
hide();
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
@@ -148,6 +154,25 @@ public class SidefpsController {
|
|||||||
for (FingerprintSensorPropertiesInternal props :
|
for (FingerprintSensorPropertiesInternal props :
|
||||||
mFingerprintManager.getSensorPropertiesInternal()) {
|
mFingerprintManager.getSensorPropertiesInternal()) {
|
||||||
if (props.isAnySidefpsType()) {
|
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;
|
return props;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,17 +191,30 @@ public class SidefpsController {
|
|||||||
*/
|
*/
|
||||||
private WindowManager.LayoutParams computeLayoutParams() {
|
private WindowManager.LayoutParams computeLayoutParams() {
|
||||||
mCoreLayoutParams.flags = getCoreLayoutParamFlags();
|
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.
|
// Calculate coordinates of drawable area for the fps affordance, accounting for orientation
|
||||||
mCoreLayoutParams.x = DISPLAY_WIDTH - SFPS_INDICATOR_WIDTH;
|
switch (mContext.getDisplay().getRotation()) {
|
||||||
mCoreLayoutParams.y = SFPS_Y;
|
case Surface.ROTATION_90:
|
||||||
mCoreLayoutParams.height = SFPS_INDICATOR_HEIGHT;
|
mCoreLayoutParams.x = sfpsLocationY;
|
||||||
mCoreLayoutParams.width = SFPS_INDICATOR_WIDTH;
|
mCoreLayoutParams.y = 0;
|
||||||
|
mCoreLayoutParams.height = SFPS_AFFORDANCE_WIDTH;
|
||||||
/*
|
mCoreLayoutParams.width = sfpsAffordanceHeight;
|
||||||
TODO (b/188692405): recalculate coordinates for non-portrait configurations and folding
|
break;
|
||||||
states
|
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;
|
return mCoreLayoutParams;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.biometrics;
|
package com.android.systemui.biometrics;
|
||||||
|
|
||||||
import static com.android.systemui.biometrics.SidefpsController.SFPS_INDICATOR_HEIGHT;
|
import static com.android.systemui.biometrics.SidefpsController.SFPS_AFFORDANCE_WIDTH;
|
||||||
import static com.android.systemui.biometrics.SidefpsController.SFPS_INDICATOR_WIDTH;
|
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -27,6 +26,7 @@ import android.graphics.Paint;
|
|||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.view.Surface;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,18 +34,22 @@ import android.widget.FrameLayout;
|
|||||||
*/
|
*/
|
||||||
public class SidefpsView extends FrameLayout {
|
public class SidefpsView extends FrameLayout {
|
||||||
private static final String TAG = "SidefpsView";
|
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 RectF mSensorRect;
|
||||||
@NonNull private final Paint mSensorRectPaint;
|
@NonNull private final Paint mSensorRectPaint;
|
||||||
@NonNull private final Paint mPointerText;
|
@NonNull private final Paint mPointerText;
|
||||||
private static final int POINTER_SIZE_PX = 50;
|
@NonNull private final Context mContext;
|
||||||
|
|
||||||
// Used to obtain the sensor location.
|
// Used to obtain the sensor location.
|
||||||
@NonNull private FingerprintSensorPropertiesInternal mSensorProps;
|
@NonNull private FingerprintSensorPropertiesInternal mSensorProps;
|
||||||
|
@Surface.Rotation private int mOrientation;
|
||||||
|
|
||||||
public SidefpsView(Context context, AttributeSet attrs) {
|
public SidefpsView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
super.setWillNotDraw(false);
|
super.setWillNotDraw(false);
|
||||||
|
mContext = context;
|
||||||
mPointerText = new Paint(0 /* flags */);
|
mPointerText = new Paint(0 /* flags */);
|
||||||
mPointerText.setAntiAlias(true);
|
mPointerText.setAntiAlias(true);
|
||||||
mPointerText.setColor(Color.WHITE);
|
mPointerText.setColor(Color.WHITE);
|
||||||
@@ -54,7 +58,7 @@ public class SidefpsView extends FrameLayout {
|
|||||||
mSensorRect = new RectF();
|
mSensorRect = new RectF();
|
||||||
mSensorRectPaint = new Paint(0 /* flags */);
|
mSensorRectPaint = new Paint(0 /* flags */);
|
||||||
mSensorRectPaint.setAntiAlias(true);
|
mSensorRectPaint.setAntiAlias(true);
|
||||||
mSensorRectPaint.setColor(Color.BLUE);
|
mSensorRectPaint.setColor(Color.BLUE); // TODO: Fix Color
|
||||||
mSensorRectPaint.setStyle(Paint.Style.FILL);
|
mSensorRectPaint.setStyle(Paint.Style.FILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,11 +69,19 @@ public class SidefpsView extends FrameLayout {
|
|||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
super.onDraw(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(
|
canvas.drawText(
|
||||||
">",
|
">",
|
||||||
SFPS_INDICATOR_WIDTH / 2 - 10, // TODO(b/188690214): retrieve from sensorProps
|
x,
|
||||||
SFPS_INDICATOR_HEIGHT / 2 + 30, //TODO(b/188690214): retrieve from sensorProps
|
y,
|
||||||
mPointerText
|
mPointerText
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -77,11 +89,19 @@ public class SidefpsView extends FrameLayout {
|
|||||||
@Override
|
@Override
|
||||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||||
super.onLayout(changed, left, top, right, 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(
|
mSensorRect.set(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
SFPS_INDICATOR_WIDTH, //TODO(b/188690214): retrieve from sensorProps
|
right,
|
||||||
SFPS_INDICATOR_HEIGHT); //TODO(b/188690214): retrieve from sensorProps
|
bottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user