Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3844eca9 authored by Austin Delgado's avatar Austin Delgado Committed by Android (Google) Code Review
Browse files

Merge "Remove ConstraintBp Flag" into main

parents 0d4952a2 e5246ed9
Loading
Loading
Loading
Loading
+0 −6
Original line number Original line Diff line number Diff line
@@ -3,9 +3,3 @@ container: "system"


# NOTE: Keep alphabetized to help limit merge conflicts from multiple simultaneous editors.
# NOTE: Keep alphabetized to help limit merge conflicts from multiple simultaneous editors.
flag {
    name: "constraint_bp"
    namespace: "biometrics_framework"
    description: "Refactors Biometric Prompt to use a ConstraintLayout"
    bug: "288175072"
}
+3 −7
Original line number Original line Diff line number Diff line
@@ -148,8 +148,6 @@ public class AuthControllerTest extends SysuiTestCase {
    @Mock
    @Mock
    private WakefulnessLifecycle mWakefulnessLifecycle;
    private WakefulnessLifecycle mWakefulnessLifecycle;
    @Mock
    @Mock
    private AuthDialogPanelInteractionDetector mPanelInteractionDetector;
    @Mock
    private UserManager mUserManager;
    private UserManager mUserManager;
    @Mock
    @Mock
    private LockPatternUtils mLockPatternUtils;
    private LockPatternUtils mLockPatternUtils;
@@ -1059,10 +1057,9 @@ public class AuthControllerTest extends SysuiTestCase {
            super(context, null /* applicationCoroutineScope */,
            super(context, null /* applicationCoroutineScope */,
                    mExecution, mCommandQueue, mActivityTaskManager, mWindowManager,
                    mExecution, mCommandQueue, mActivityTaskManager, mWindowManager,
                    mFingerprintManager, mFaceManager, () -> mUdfpsController, mDisplayManager,
                    mFingerprintManager, mFaceManager, () -> mUdfpsController, mDisplayManager,
                    mWakefulnessLifecycle, mPanelInteractionDetector, mUserManager,
                    mWakefulnessLifecycle, mUserManager, mLockPatternUtils, () -> mUdfpsLogger,
                    mLockPatternUtils, () -> mUdfpsLogger, () -> mLogContextInteractor,
                    () -> mLogContextInteractor, () -> mPromptSelectionInteractor,
                    () -> mPromptSelectionInteractor, () -> mCredentialViewModel,
                    () -> mCredentialViewModel, () -> mPromptViewModel, mInteractionJankMonitor,
                    () -> mPromptViewModel, mInteractionJankMonitor,
                    mHandler, mBackgroundExecutor, mUdfpsUtils, mVibratorHelper);
                    mHandler, mBackgroundExecutor, mUdfpsUtils, mVibratorHelper);
        }
        }


@@ -1071,7 +1068,6 @@ public class AuthControllerTest extends SysuiTestCase {
                boolean requireConfirmation, int userId, int[] sensorIds,
                boolean requireConfirmation, int userId, int[] sensorIds,
                String opPackageName, boolean skipIntro, long operationId, long requestId,
                String opPackageName, boolean skipIntro, long operationId, long requestId,
                WakefulnessLifecycle wakefulnessLifecycle,
                WakefulnessLifecycle wakefulnessLifecycle,
                AuthDialogPanelInteractionDetector panelInteractionDetector,
                UserManager userManager,
                UserManager userManager,
                LockPatternUtils lockPatternUtils, PromptViewModel viewModel) {
                LockPatternUtils lockPatternUtils, PromptViewModel viewModel) {


+0 −141
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2021 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 static org.junit.Assert.assertEquals;

import android.hardware.biometrics.ComponentInfoInternal;
import android.hardware.biometrics.SensorLocationInternal;
import android.hardware.biometrics.SensorProperties;
import android.hardware.fingerprint.FingerprintSensorProperties;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.systemui.SysuiTestCase;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.ArrayList;
import java.util.List;

@RunWith(AndroidJUnit4.class)
@SmallTest
public class UdfpsDialogMeasureAdapterTest extends SysuiTestCase {
    @Test
    public void testUdfpsBottomSpacerHeightForPortrait() {
        final int displayHeightPx = 3000;
        final int navbarHeightPx = 10;
        final int dialogBottomMarginPx = 20;
        final int buttonBarHeightPx = 100;
        final int textIndicatorHeightPx = 200;

        final int sensorLocationX = 540;
        final int sensorLocationY = 1600;
        final int sensorRadius = 100;

        final List<ComponentInfoInternal> componentInfo = new ArrayList<>();
        componentInfo.add(new ComponentInfoInternal("faceSensor" /* componentId */,
                "vendor/model/revision" /* hardwareVersion */, "1.01" /* firmwareVersion */,
                "00000001" /* serialNumber */, "" /* softwareVersion */));
        componentInfo.add(new ComponentInfoInternal("matchingAlgorithm" /* componentId */,
                "" /* hardwareVersion */, "" /* firmwareVersion */, "" /* serialNumber */,
                "vendor/version/revision" /* softwareVersion */));

        final FingerprintSensorPropertiesInternal props = new FingerprintSensorPropertiesInternal(
                0 /* sensorId */, SensorProperties.STRENGTH_STRONG, 5 /* maxEnrollmentsPerUser */,
                componentInfo,
                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL,
                true /* halControlsIllumination */,
                true /* resetLockoutRequiresHardwareAuthToken */,
                List.of(new SensorLocationInternal("" /* displayId */,
                        sensorLocationX, sensorLocationY, sensorRadius)));

        assertEquals(970,
                UdfpsDialogMeasureAdapter.calculateBottomSpacerHeightForPortrait(
                        props, displayHeightPx, textIndicatorHeightPx, buttonBarHeightPx,
                        dialogBottomMarginPx, navbarHeightPx, 1.0f /* resolutionScale */
                ));
    }

    @Test
    public void testUdfpsBottomSpacerHeightForLandscape_whenMoreSpaceAboveIcon() {
        final int titleHeightPx = 320;
        final int subtitleHeightPx = 240;
        final int descriptionHeightPx = 200;
        final int topSpacerHeightPx = 550;
        final int textIndicatorHeightPx = 190;
        final int buttonBarHeightPx = 160;
        final int navbarBottomInsetPx = 75;

        assertEquals(885,
                UdfpsDialogMeasureAdapter.calculateBottomSpacerHeightForLandscape(
                        titleHeightPx, subtitleHeightPx, descriptionHeightPx, topSpacerHeightPx,
                        textIndicatorHeightPx, buttonBarHeightPx, navbarBottomInsetPx));
    }

    @Test
    public void testUdfpsBottomSpacerHeightForLandscape_whenMoreSpaceBelowIcon() {
        final int titleHeightPx = 315;
        final int subtitleHeightPx = 160;
        final int descriptionHeightPx = 75;
        final int topSpacerHeightPx = 220;
        final int textIndicatorHeightPx = 290;
        final int buttonBarHeightPx = 360;
        final int navbarBottomInsetPx = 205;

        assertEquals(-85,
                UdfpsDialogMeasureAdapter.calculateBottomSpacerHeightForLandscape(
                        titleHeightPx, subtitleHeightPx, descriptionHeightPx, topSpacerHeightPx,
                        textIndicatorHeightPx, buttonBarHeightPx, navbarBottomInsetPx));
    }

    @Test
    public void testUdfpsHorizontalSpacerWidthForLandscape() {
        final int displayWidthPx = 3000;
        final int dialogMarginPx = 20;
        final int navbarHorizontalInsetPx = 75;

        final int sensorLocationX = 540;
        final int sensorLocationY = 1600;
        final int sensorRadius = 100;

        final List<ComponentInfoInternal> componentInfo = new ArrayList<>();
        componentInfo.add(new ComponentInfoInternal("faceSensor" /* componentId */,
                "vendor/model/revision" /* hardwareVersion */, "1.01" /* firmwareVersion */,
                "00000001" /* serialNumber */, "" /* softwareVersion */));
        componentInfo.add(new ComponentInfoInternal("matchingAlgorithm" /* componentId */,
                "" /* hardwareVersion */, "" /* firmwareVersion */, "" /* serialNumber */,
                "vendor/version/revision" /* softwareVersion */));

        final FingerprintSensorPropertiesInternal props = new FingerprintSensorPropertiesInternal(
                0 /* sensorId */, SensorProperties.STRENGTH_STRONG, 5 /* maxEnrollmentsPerUser */,
                componentInfo,
                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL,
                true /* halControlsIllumination */,
                true /* resetLockoutRequiresHardwareAuthToken */,
                List.of(new SensorLocationInternal("" /* displayId */,
                        sensorLocationX, sensorLocationY, sensorRadius)));

        assertEquals(1205,
                UdfpsDialogMeasureAdapter.calculateHorizontalSpacerWidthForLandscape(
                        props, displayWidthPx, dialogMarginPx, navbarHorizontalInsetPx,
                        1.0f /* resolutionScale */));
    }
}
+0 −208
Original line number Original line Diff line number Diff line
<!--
  ~ Copyright (C) 2023 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.ui.BiometricPromptLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/contents"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/logo"
        android:layout_width="@dimen/biometric_auth_icon_size"
        android:layout_height="@dimen/biometric_auth_icon_size"
        android:layout_gravity="center"
        android:scaleType="fitXY"/>

    <TextView
        android:id="@+id/logo_description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="@integer/biometric_dialog_text_gravity"
        android:singleLine="true"
        android:marqueeRepeatLimit="1"
        android:ellipsize="marquee"/>

    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="@integer/biometric_dialog_text_gravity"
        android:singleLine="true"
        android:marqueeRepeatLimit="1"
        android:ellipsize="marquee"
        style="@style/TextAppearance.AuthCredential.OldTitle"/>

    <TextView
        android:id="@+id/subtitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="@integer/biometric_dialog_text_gravity"
        android:singleLine="true"
        android:marqueeRepeatLimit="1"
        android:ellipsize="marquee"
        style="@style/TextAppearance.AuthCredential.OldSubtitle"/>

    <TextView
        android:id="@+id/description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="@integer/biometric_dialog_text_gravity"
        android:scrollbars ="vertical"
        android:importantForAccessibility="no"
        style="@style/TextAppearance.AuthCredential.OldDescription"/>

    <Space
        android:id="@+id/space_above_content"
        android:layout_width="match_parent"
        android:layout_height="24dp"
        android:visibility="gone" />

    <LinearLayout
        android:id="@+id/customized_view_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fadeScrollbars="false"
        android:gravity="center_vertical"
        android:orientation="vertical"
        android:scrollbars="vertical"
        android:visibility="gone" />

    <Space android:id="@+id/space_above_icon"
        android:layout_width="match_parent"
        android:layout_height="48dp" />

    <FrameLayout
        android:id="@+id/biometric_icon_frame"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center">

        <com.android.systemui.biometrics.BiometricPromptLottieViewWrapper
            android:id="@+id/biometric_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:contentDescription="@null"
            android:scaleType="fitXY" />

        <com.android.systemui.biometrics.BiometricPromptLottieViewWrapper
            android:id="@+id/biometric_icon_overlay"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:contentDescription="@null"
            android:scaleType="fitXY" />
    </FrameLayout>

    <!-- For sensors such as UDFPS, this view is used during custom measurement/layout to add extra
         padding so that the biometric icon is always in the right physical position. -->
    <Space android:id="@+id/space_below_icon"
        android:layout_width="match_parent"
        android:layout_height="12dp" />

    <TextView
        android:id="@+id/indicator"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingHorizontal="24dp"
        android:textSize="12sp"
        android:gravity="center_horizontal"
        android:accessibilityLiveRegion="polite"
        android:singleLine="true"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"
        android:scrollHorizontally="true"
        android:fadingEdge="horizontal"
        android:textColor="@color/biometric_dialog_gray"/>

    <LinearLayout
        android:id="@+id/button_bar"
        android:layout_width="match_parent"
        android:layout_height="88dp"
        style="?android:attr/buttonBarStyle"
        android:orientation="horizontal"
        android:paddingTop="24dp">

        <Space android:id="@+id/leftSpacer"
            android:layout_width="8dp"
            android:layout_height="match_parent"
            android:visibility="visible" />

        <!-- Negative Button, reserved for app -->
        <Button android:id="@+id/button_negative"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@*android:style/Widget.DeviceDefault.Button.Borderless.Colored"
            android:layout_gravity="center_vertical"
            android:ellipsize="end"
            android:maxLines="2"
            android:maxWidth="@dimen/biometric_dialog_button_negative_max_width"
            android:visibility="gone"/>
        <!-- Cancel Button, replaces negative button when biometric is accepted -->
        <Button android:id="@+id/button_cancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@*android:style/Widget.DeviceDefault.Button.Borderless.Colored"
            android:layout_gravity="center_vertical"
            android:maxWidth="@dimen/biometric_dialog_button_negative_max_width"
            android:text="@string/cancel"
            android:visibility="gone"/>
        <!-- "Use Credential" Button, replaces if device credential is allowed -->
        <Button android:id="@+id/button_use_credential"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@*android:style/Widget.DeviceDefault.Button.Borderless.Colored"
            android:layout_gravity="center_vertical"
            android:maxWidth="@dimen/biometric_dialog_button_negative_max_width"
            android:visibility="gone"/>

        <Space android:id="@+id/middleSpacer"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:visibility="visible"/>

        <!-- Positive Button -->
        <Button android:id="@+id/button_confirm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@*android:style/Widget.DeviceDefault.Button.Colored"
            android:layout_gravity="center_vertical"
            android:ellipsize="end"
            android:maxLines="2"
            android:maxWidth="@dimen/biometric_dialog_button_positive_max_width"
            android:text="@string/biometric_dialog_confirm"
            android:visibility="gone"/>
        <!-- Try Again Button -->
        <Button android:id="@+id/button_try_again"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@*android:style/Widget.DeviceDefault.Button.Colored"
            android:layout_gravity="center_vertical"
            android:ellipsize="end"
            android:maxLines="2"
            android:maxWidth="@dimen/biometric_dialog_button_positive_max_width"
            android:text="@string/biometric_dialog_try_again"
            android:visibility="gone"/>

        <Space android:id="@+id/rightSpacer"
            android:layout_width="8dp"
            android:layout_height="match_parent"
            android:visibility="visible" />
    </LinearLayout>

</com.android.systemui.biometrics.ui.BiometricPromptLayout>
+15 −236

File changed.

Preview size limit exceeded, changes collapsed.

Loading