Remove duplicated UDFPS view into single fingerprint view.

Bug: 217393533
Test: manual (using BP test app)
Change-Id: I9969bf26f119b2e0b267f9363f6084f8316040b1
This commit is contained in:
Joe Bolinger
2022-02-01 14:47:30 -08:00
parent 5706587d69
commit b7e2433127
5 changed files with 59 additions and 118 deletions

View File

@@ -1,26 +0,0 @@
<!--
~ Copyright (C) 2020 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<com.android.systemui.biometrics.AuthBiometricUdfpsView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contents"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/auth_biometric_contents"/>
</com.android.systemui.biometrics.AuthBiometricUdfpsView>

View File

@@ -17,11 +17,15 @@
package com.android.systemui.biometrics;
import android.annotation.NonNull;
import android.content.Context;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
@@ -31,6 +35,9 @@ public class AuthBiometricFingerprintView extends AuthBiometricView {
private static final String TAG = "BiometricPrompt/AuthBiometricFingerprintView";
private boolean mIsUdfps = false;
@Nullable private UdfpsDialogMeasureAdapter mUdfpsAdapter;
public AuthBiometricFingerprintView(Context context) {
this(context, null);
}
@@ -39,6 +46,50 @@ public class AuthBiometricFingerprintView extends AuthBiometricView {
super(context, attrs);
}
@Override
AuthDialog.LayoutParams onMeasureInternal(int width, int height) {
final AuthDialog.LayoutParams layoutParams = super.onMeasureInternal(width, height);
return mUdfpsAdapter != null
? mUdfpsAdapter.onMeasureInternal(width, height, layoutParams)
: layoutParams;
}
/**
* Set the properties of this sensor so the view can be customized prior to layout.
*
* @param sensorProps sensor properties
*/
public void setSensorProperties(@NonNull FingerprintSensorPropertiesInternal sensorProps) {
mIsUdfps = sensorProps.isAnyUdfpsType();
mUdfpsAdapter = mIsUdfps ? new UdfpsDialogMeasureAdapter(this, sensorProps) : null;
}
@Override
void onLayoutInternal() {
super.onLayoutInternal();
if (mUdfpsAdapter != null) {
// Move the UDFPS icon and indicator text if necessary. This probably only needs to happen
// for devices where the UDFPS sensor is too low.
// TODO(b/201510778): Update this logic to support cases where the sensor or text overlap
// the button bar area.
final int bottomSpacerHeight = mUdfpsAdapter.getBottomSpacerHeight();
Log.w(TAG, "bottomSpacerHeight: " + bottomSpacerHeight);
if (bottomSpacerHeight < 0) {
FrameLayout iconFrame = findViewById(R.id.biometric_icon_frame);
iconFrame.setTranslationY(-bottomSpacerHeight);
TextView indicator = findViewById(R.id.indicator);
indicator.setTranslationY(-bottomSpacerHeight);
}
}
}
/** If this view is for a UDFPS sensor. */
public boolean isUdfps() {
return mIsUdfps;
}
@Override
protected int getDelayAfterAuthenticatedDurationMs() {
return 0;

View File

@@ -1,80 +0,0 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.biometrics;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.android.systemui.R;
/**
* Manages the layout for under-display fingerprint sensors (UDFPS). Ensures that UI elements
* do not overlap with
*/
public class AuthBiometricUdfpsView extends AuthBiometricFingerprintView {
private static final String TAG = "AuthBiometricUdfpsView";
@Nullable private UdfpsDialogMeasureAdapter mMeasureAdapter;
public AuthBiometricUdfpsView(Context context) {
this(context, null /* attrs */);
}
public AuthBiometricUdfpsView(Context context, AttributeSet attrs) {
super(context, attrs);
}
void setSensorProps(@NonNull FingerprintSensorPropertiesInternal sensorProps) {
if (mMeasureAdapter == null || mMeasureAdapter.getSensorProps() != sensorProps) {
mMeasureAdapter = new UdfpsDialogMeasureAdapter(this, sensorProps);
}
}
@Override
@NonNull
AuthDialog.LayoutParams onMeasureInternal(int width, int height) {
final AuthDialog.LayoutParams layoutParams = super.onMeasureInternal(width, height);
return mMeasureAdapter != null
? mMeasureAdapter.onMeasureInternal(width, height, layoutParams)
: layoutParams;
}
@Override
void onLayoutInternal() {
super.onLayoutInternal();
// Move the UDFPS icon and indicator text if necessary. This probably only needs to happen
// for devices where the UDFPS sensor is too low.
// TODO(b/201510778): Update this logic to support cases where the sensor or text overlap
// the button bar area.
final int bottomSpacerHeight = mMeasureAdapter.getBottomSpacerHeight();
Log.w(TAG, "bottomSpacerHeight: " + bottomSpacerHeight);
if (bottomSpacerHeight < 0) {
FrameLayout iconFrame = findViewById(R.id.biometric_icon_frame);
iconFrame.setTranslationY(-bottomSpacerHeight);
TextView indicator = findViewById(R.id.indicator);
indicator.setTranslationY(-bottomSpacerHeight);
}
}
}

View File

@@ -319,15 +319,11 @@ public class AuthContainerView extends LinearLayout
}
}
if (sensorProps.isAnyUdfpsType()) {
AuthBiometricUdfpsView udfpsView = (AuthBiometricUdfpsView) factory
.inflate(R.layout.auth_biometric_udfps_view, null, false);
udfpsView.setSensorProps(sensorProps);
mBiometricView = udfpsView;
} else {
mBiometricView = (AuthBiometricFingerprintView) factory
.inflate(R.layout.auth_biometric_fingerprint_view, null, false);
}
final AuthBiometricFingerprintView fpView = (AuthBiometricFingerprintView)
factory.inflate(R.layout.auth_biometric_fingerprint_view, null, false);
fpView.setSensorProperties(sensorProps);
mBiometricView = fpView;
} else if (Utils.containsSensorId(mFaceProps, singleSensorAuthId)) {
mBiometricView = (AuthBiometricFaceView)
factory.inflate(R.layout.auth_biometric_face_view, null, false);
@@ -555,8 +551,8 @@ public class AuthContainerView extends LinearLayout
}
private static boolean shouldUpdatePositionForUdfps(@NonNull View view) {
if (view instanceof AuthBiometricUdfpsView) {
return true;
if (view instanceof AuthBiometricFingerprintView) {
return ((AuthBiometricFingerprintView) view).isUdfps();
}
if (view instanceof AuthBiometricFaceToFingerprintView) {

View File

@@ -23,7 +23,7 @@ import android.util.AttributeSet
*
* Currently doesn't draw anything.
*
* Note that [AuthBiometricUdfpsView] also shows UDFPS animations. At some point we should
* Note that [AuthBiometricFingerprintView] also shows UDFPS animations. At some point we should
* de-dupe this if necessary.
*/
class UdfpsBpView(context: Context, attrs: AttributeSet?) : UdfpsAnimationView(context, attrs) {