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

Commit 3db38ca3 authored by Priyanka Advani (xWF)'s avatar Priyanka Advani (xWF) Committed by Android (Google) Code Review
Browse files

Revert "Log a warning if content view exceeds char limit"

Revert submission 28810966-content_view_char_limit

Reason for revert: Droidmonitor created revert due to b/361222065. Will be verifying through ABTD before submission.

Reverted changes: /q/submissionid:28810966-content_view_char_limit

Change-Id: I649f913789aa00adf2eb950387fe91756e59e9f0
parent 8d84f1d4
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.content.DialogInterface;
import android.hardware.biometrics.BiometricPrompt.ButtonInfo;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;

@@ -63,7 +62,6 @@ import java.util.concurrent.Executor;
 */
@FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
public final class PromptContentViewWithMoreOptionsButton implements PromptContentViewParcelable {
    private static final String TAG = "PromptContentViewWithMoreOptionsButton";
    @VisibleForTesting
    static final int MAX_DESCRIPTION_CHARACTER_NUMBER = 225;

@@ -151,12 +149,13 @@ public final class PromptContentViewWithMoreOptionsButton implements PromptConte
         *
         * @param description The description to display.
         * @return This builder.
         * @throws IllegalArgumentException If description exceeds certain character limit.
         */
        @NonNull
        @RequiresPermission(SET_BIOMETRIC_DIALOG_ADVANCED)
        public Builder setDescription(@NonNull String description) {
            if (description.length() > MAX_DESCRIPTION_CHARACTER_NUMBER) {
                Log.w(TAG, "The character number of description exceeds "
                throw new IllegalArgumentException("The character number of description exceeds "
                        + MAX_DESCRIPTION_CHARACTER_NUMBER);
            }
            mDescription = description;
+9 −7
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;

@@ -50,7 +49,6 @@ import java.util.List;
 */
@FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
public final class PromptVerticalListContentView implements PromptContentViewParcelable {
    private static final String TAG = "PromptVerticalListContentView";
    @VisibleForTesting
    static final int MAX_ITEM_NUMBER = 20;
    @VisibleForTesting
@@ -157,11 +155,12 @@ public final class PromptVerticalListContentView implements PromptContentViewPar
         *
         * @param description The description to display.
         * @return This builder.
         * @throws IllegalArgumentException If description exceeds certain character limit.
         */
        @NonNull
        public Builder setDescription(@NonNull String description) {
            if (description.length() > MAX_DESCRIPTION_CHARACTER_NUMBER) {
                Log.w(TAG, "The character number of description exceeds "
                throw new IllegalArgumentException("The character number of description exceeds "
                        + MAX_DESCRIPTION_CHARACTER_NUMBER);
            }
            mDescription = description;
@@ -173,7 +172,8 @@ public final class PromptVerticalListContentView implements PromptContentViewPar
         *
         * @param listItem The list item view to display
         * @return This builder.
         * @throws IllegalArgumentException If the number of list items exceeds certain limit.
         * @throws IllegalArgumentException If this list item exceeds certain character limits or
         *                                  the number of list items exceeds certain limit.
         */
        @NonNull
        public Builder addListItem(@NonNull PromptContentItem listItem) {
@@ -188,7 +188,8 @@ public final class PromptVerticalListContentView implements PromptContentViewPar
         * @param listItem The list item view to display
         * @param index    The position at which to add the item
         * @return This builder.
         * @throws IllegalArgumentException If the number of list items exceeds certain limit.
         * @throws IllegalArgumentException If this list item exceeds certain character limits or
         *                                  the number of list items exceeds certain limit.
         */
        @NonNull
        public Builder addListItem(@NonNull PromptContentItem listItem, int index) {
@@ -199,7 +200,8 @@ public final class PromptVerticalListContentView implements PromptContentViewPar

        private void checkItemLimits(@NonNull PromptContentItem listItem) {
            if (doesListItemExceedsCharLimit(listItem)) {
                Log.w(TAG, "The character number of list item exceeds "
                throw new IllegalArgumentException(
                        "The character number of list item exceeds "
                                + MAX_EACH_ITEM_CHARACTER_NUMBER);
            }
            if (mContentList.size() > MAX_ITEM_NUMBER) {
+36 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.hardware.biometrics;

import static android.hardware.biometrics.PromptContentViewWithMoreOptionsButton.MAX_DESCRIPTION_CHARACTER_NUMBER;
import static android.hardware.biometrics.PromptVerticalListContentView.MAX_EACH_ITEM_CHARACTER_NUMBER;
import static android.hardware.biometrics.PromptVerticalListContentView.MAX_ITEM_NUMBER;

import static com.google.common.truth.Truth.assertThat;
@@ -117,6 +119,17 @@ public class BiometricPromptTest {
        assertThat(e).hasMessageThat().isEqualTo("Logo description passed in can not be null");
    }

    @Test
    public void testMoreOptionsButton_descriptionCharLimit() {
        IllegalArgumentException e = assertThrows(IllegalArgumentException.class,
                () -> new PromptContentViewWithMoreOptionsButton.Builder().setDescription(
                        generateRandomString(MAX_DESCRIPTION_CHARACTER_NUMBER + 1))
        );

        assertThat(e).hasMessageThat().contains(
                "The character number of description exceeds ");
    }

    @Test
    public void testMoreOptionsButton_ExecutorNull() {
        PromptContentViewWithMoreOptionsButton.Builder builder =
@@ -144,6 +157,29 @@ public class BiometricPromptTest {
                "The listener of more options button on prompt content must be set");
    }

    @Test
    public void testVerticalList_descriptionCharLimit() {
        IllegalArgumentException e = assertThrows(IllegalArgumentException.class,
                () -> new PromptVerticalListContentView.Builder().setDescription(
                        generateRandomString(MAX_DESCRIPTION_CHARACTER_NUMBER + 1))
        );

        assertThat(e).hasMessageThat().contains(
                "The character number of description exceeds ");
    }

    @Test
    public void testVerticalList_itemCharLimit() {
        IllegalArgumentException e = assertThrows(IllegalArgumentException.class,
                () -> new PromptVerticalListContentView.Builder().addListItem(
                        new PromptContentItemBulletedText(
                                generateRandomString(MAX_EACH_ITEM_CHARACTER_NUMBER + 1)))
        );

        assertThat(e).hasMessageThat().contains(
                "The character number of list item exceeds ");
    }

    @Test
    public void testVerticalList_itemNumLimit() {
        PromptVerticalListContentView.Builder builder = new PromptVerticalListContentView.Builder();
+0 −4
Original line number Diff line number Diff line
@@ -153,10 +153,6 @@ object Utils {
        return bitmap
    }

    @JvmStatic
    fun String.ellipsize(cutOffLength: Int) =
        if (length <= cutOffLength) this else replaceRange(cutOffLength, length, "...")

    // LINT.IfChange
    @JvmStatic
    /**
+3 −8
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import android.widget.LinearLayout
import android.widget.Space
import android.widget.TextView
import com.android.settingslib.Utils
import com.android.systemui.biometrics.Utils.ellipsize
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.res.R
import kotlin.math.ceil
@@ -47,8 +46,6 @@ private const val TAG = "BiometricCustomizedViewBinder"

/** Sub-binder for Biometric Prompt Customized View */
object BiometricCustomizedViewBinder {
    const val MAX_DESCRIPTION_CHARACTER_NUMBER = 225

    fun bind(
        customizedViewContainer: LinearLayout,
        contentView: PromptContentView?,
@@ -93,8 +90,7 @@ private fun LayoutInflater.inflateContentView(id: Int, description: String?): Li

    val descriptionView = contentView.requireViewById<TextView>(R.id.customized_view_description)
    if (!description.isNullOrEmpty()) {
        descriptionView.text =
            description.ellipsize(BiometricCustomizedViewBinder.MAX_DESCRIPTION_CHARACTER_NUMBER)
        descriptionView.text = description
    } else {
        descriptionView.visibility = View.GONE
    }
@@ -222,14 +218,13 @@ private fun PromptContentItem.toView(
        inflater.inflate(R.layout.biometric_prompt_content_row_item_text_view, null) as TextView
    val lp = LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1f)
    textView.layoutParams = lp
    val maxCharNumber = PromptVerticalListContentView.getMaxEachItemCharacterNumber()

    when (this) {
        is PromptContentItemPlainText -> {
            textView.text = text.ellipsize(maxCharNumber)
            textView.text = text
        }
        is PromptContentItemBulletedText -> {
            val bulletedText = SpannableString(text.ellipsize(maxCharNumber))
            val bulletedText = SpannableString(text)
            val span =
                BulletSpan(
                    getListItemBulletGapWidth(resources),
Loading