Loading core/java/android/hardware/biometrics/PromptContentViewWithMoreOptionsButton.java +2 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading core/java/android/hardware/biometrics/PromptVerticalListContentView.java +9 −7 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading Loading @@ -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; Loading @@ -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) { Loading @@ -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) { Loading @@ -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) { Loading core/tests/coretests/src/android/hardware/biometrics/BiometricPromptTest.java +36 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 = Loading Loading @@ -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(); Loading packages/SystemUI/shared/biometrics/src/com/android/systemui/biometrics/Utils.kt +0 −4 Original line number Diff line number Diff line Loading @@ -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 /** Loading packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricCustomizedViewBinder.kt +3 −8 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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?, Loading Loading @@ -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 } Loading Loading @@ -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 Loading
core/java/android/hardware/biometrics/PromptContentViewWithMoreOptionsButton.java +2 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading
core/java/android/hardware/biometrics/PromptVerticalListContentView.java +9 −7 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading Loading @@ -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; Loading @@ -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) { Loading @@ -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) { Loading @@ -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) { Loading
core/tests/coretests/src/android/hardware/biometrics/BiometricPromptTest.java +36 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 = Loading Loading @@ -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(); Loading
packages/SystemUI/shared/biometrics/src/com/android/systemui/biometrics/Utils.kt +0 −4 Original line number Diff line number Diff line Loading @@ -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 /** Loading
packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricCustomizedViewBinder.kt +3 −8 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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?, Loading Loading @@ -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 } Loading Loading @@ -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