Commit e6ffa411 authored by rituj's avatar rituj Committed by Bruno Martins

BiometricPrompt: Automatically add padding to incorporate FOD

This effectively hides the default icon in the traditional
biometrics prompt, so that only FOD icon is displayed.
Signed-off-by: default avatarRituj Beniwal <ritujbeniwal@gmail.com>
Change-Id: I20b250ac59f0631e77356986a2d935d97842f9bb
parent 4df37d4c
......@@ -22,6 +22,7 @@ import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.android.systemui.R;
......@@ -76,6 +77,18 @@ public class AuthBiometricFingerprintView extends AuthBiometricView {
showTouchSensorString();
}
@Override
void onFinishInflateInternal() {
super.onFinishInflateInternal();
if (mHasFod) {
mIconView.setVisibility(View.INVISIBLE);
mIconView.setPadding(0, 0, 0, 0);
// Add IndicatorView above the biometric icon
removeView(mIndicatorView);
addView(mIndicatorView, indexOfChild(mIconView));
}
}
private void showTouchSensorString() {
mIndicatorView.setText(R.string.fingerprint_dialog_touch_sensor);
mIndicatorView.setTextColor(mTextColorHint);
......
......@@ -24,6 +24,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.biometrics.BiometricPrompt;
import android.os.Bundle;
import android.os.Handler;
......@@ -40,8 +41,12 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import lineageos.app.LineageContextConstants;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
......@@ -186,6 +191,8 @@ public abstract class AuthBiometricView extends LinearLayout {
protected boolean mDialogSizeAnimating;
protected Bundle mSavedState;
protected boolean mHasFod;
/**
* Delay after authentication is confirmed, before the dialog should be animated away.
*/
......@@ -248,6 +255,10 @@ public abstract class AuthBiometricView extends LinearLayout {
mAccessibilityManager = context.getSystemService(AccessibilityManager.class);
PackageManager packageManager = context.getPackageManager();
mHasFod = packageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT) &&
packageManager.hasSystemFeature(LineageContextConstants.Features.FOD);
mResetErrorRunnable = () -> {
updateState(getStateForAfterError());
handleResetAfterError();
......@@ -703,9 +714,22 @@ public abstract class AuthBiometricView extends LinearLayout {
final View child = getChildAt(i);
if (child.getId() == R.id.biometric_icon) {
child.measure(
MeasureSpec.makeMeasureSpec(newWidth, MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
if (this instanceof AuthBiometricFingerprintView && mHasFod) {
final int buttonBarHeight =
findViewById(R.id.button_bar).getLayoutParams().height;
// The view is invisible, so it still takes space and
// we use that to adjust for the FOD icon
final int fodHeight = Dependency.get(StatusBar.class).getFodHeight(true) -
buttonBarHeight - findViewById(R.id.button_bar).getPaddingTop();
child.measure(
MeasureSpec.makeMeasureSpec(newWidth, MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(fodHeight, MeasureSpec.EXACTLY));
} else {
child.measure(
MeasureSpec.makeMeasureSpec(newWidth, MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
}
} else if (child.getId() == R.id.button_bar) {
child.measure(
MeasureSpec.makeMeasureSpec(newWidth, MeasureSpec.EXACTLY),
......
......@@ -30,6 +30,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.Gravity;
import android.view.MotionEvent;
......@@ -423,6 +424,16 @@ public class FODCircleView extends ImageView {
dispatchHide();
}
public int getHeight(boolean includeDecor) {
DisplayMetrics dm = new DisplayMetrics();
if (includeDecor) {
mWindowManager.getDefaultDisplay().getMetrics(dm);
} else {
mWindowManager.getDefaultDisplay().getRealMetrics(dm);
}
return dm.heightPixels - mPositionY + mSize / 2;
}
private void updateAlpha() {
setAlpha(mIsDreaming ? 0.5f : 1.0f);
}
......
......@@ -100,6 +100,10 @@ public class FODCircleViewImpl extends SystemUI implements CommandQueue.Callback
}
}
public int getHeight(boolean includeDecor) {
return mFodCircleView.getHeight(includeDecor);
}
public void registerCallback(FODCircleViewImplCallback callback) {
Assert.isMainThread();
Slog.v(TAG, "*** register callback for " + callback);
......
......@@ -4694,4 +4694,8 @@ public class StatusBar extends SystemUI implements DemoMode,
}
return null;
}
public int getFodHeight(boolean includeDecor) {
return mFODCircleViewImpl.getHeight(includeDecor);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment