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

Commit febb733c authored by Felipe Leme's avatar Felipe Leme
Browse files

Autofill Field Classification improvements.

* Changed the remoteId -> userValue API to userValue -> categoryId so the
  category could map to multiple values (for example,
  "email" -> "email1", "email2")
* Added method and settings for maximum number of category ids.
* Tuned the default value of some settings.

Bug: 70407264

Test: atest CtsAutoFillServiceTestCases:UserDataTest \
            CtsAutoFillServiceTestCases:FieldsClassificationTest \
	    SettingsBackupTest

Change-Id: I27f348c500077937c0f4bf65db6a899fa3c41cf6
parent 90f285ba
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -38696,7 +38696,7 @@ package android.service.autofill {
  }
  public static final class FieldClassification.Match {
    method public java.lang.String getRemoteId();
    method public java.lang.String getCategoryId();
    method public float getScore();
  }
@@ -38861,6 +38861,7 @@ package android.service.autofill {
    method public int describeContents();
    method public java.lang.String getFieldClassificationAlgorithm();
    method public java.lang.String getId();
    method public static int getMaxCategoryCount();
    method public static int getMaxFieldClassificationIdsSize();
    method public static int getMaxUserDataSize();
    method public static int getMaxValueLength();
+1 −0
Original line number Diff line number Diff line
@@ -4144,6 +4144,7 @@ package android.provider {
    method public static boolean putString(android.content.ContentResolver, java.lang.String, java.lang.String, java.lang.String, boolean);
    method public static void resetToDefaults(android.content.ContentResolver, java.lang.String);
    field public static final java.lang.String AUTOFILL_FEATURE_FIELD_CLASSIFICATION = "autofill_field_classification";
    field public static final java.lang.String AUTOFILL_USER_DATA_MAX_CATEGORY_COUNT = "autofill_user_data_max_category_count";
    field public static final java.lang.String AUTOFILL_USER_DATA_MAX_FIELD_CLASSIFICATION_IDS_SIZE = "autofill_user_data_max_field_classification_size";
    field public static final java.lang.String AUTOFILL_USER_DATA_MAX_USER_DATA_SIZE = "autofill_user_data_max_user_data_size";
    field public static final java.lang.String AUTOFILL_USER_DATA_MAX_VALUE_LENGTH = "autofill_user_data_max_value_length";
+1 −0
Original line number Diff line number Diff line
@@ -541,6 +541,7 @@ package android.provider {
    field public static final java.lang.String ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED = "accessibility_display_magnification_enabled";
    field public static final java.lang.String AUTOFILL_FEATURE_FIELD_CLASSIFICATION = "autofill_field_classification";
    field public static final java.lang.String AUTOFILL_SERVICE = "autofill_service";
    field public static final java.lang.String AUTOFILL_USER_DATA_MAX_CATEGORY_COUNT = "autofill_user_data_max_category_count";
    field public static final java.lang.String AUTOFILL_USER_DATA_MAX_FIELD_CLASSIFICATION_IDS_SIZE = "autofill_user_data_max_field_classification_size";
    field public static final java.lang.String AUTOFILL_USER_DATA_MAX_USER_DATA_SIZE = "autofill_user_data_max_user_data_size";
    field public static final java.lang.String AUTOFILL_USER_DATA_MAX_VALUE_LENGTH = "autofill_user_data_max_value_length";
+11 −0
Original line number Diff line number Diff line
@@ -5384,6 +5384,17 @@ public final class Settings {
        public static final String AUTOFILL_USER_DATA_MAX_FIELD_CLASSIFICATION_IDS_SIZE =
                "autofill_user_data_max_field_classification_size";

        /**
         * Defines value returned by
         * {@link android.service.autofill.UserData#getMaxCategoryCount()}.
         *
         * @hide
         */
        @SystemApi
        @TestApi
        public static final String AUTOFILL_USER_DATA_MAX_CATEGORY_COUNT =
                "autofill_user_data_max_category_count";

        /**
         * Defines value returned by {@link android.service.autofill.UserData#getMaxValueLength()}.
         *
+9 −9
Original line number Diff line number Diff line
@@ -108,21 +108,21 @@ public final class FieldClassification {
     */
    public static final class Match {

        private final String mRemoteId;
        private final String mCategoryId;
        private final float mScore;

        /** @hide */
        public Match(String remoteId, float score) {
            mRemoteId = Preconditions.checkNotNull(remoteId);
        public Match(String categoryId, float score) {
            mCategoryId = Preconditions.checkNotNull(categoryId);
            mScore = score;
        }

        /**
         * Gets the remote id of the {@link UserData} entry.
         * Gets the category id of the {@link UserData} entry.
         */
        @NonNull
        public String getRemoteId() {
            return mRemoteId;
        public String getCategoryId() {
            return mCategoryId;
        }

        /**
@@ -149,13 +149,13 @@ public final class FieldClassification {
        public String toString() {
            if (!sDebug) return super.toString();

            final StringBuilder string = new StringBuilder("Match: remoteId=");
            Helper.appendRedacted(string, mRemoteId);
            final StringBuilder string = new StringBuilder("Match: categoryId=");
            Helper.appendRedacted(string, mCategoryId);
            return string.append(", score=").append(mScore).toString();
        }

        private void writeToParcel(@NonNull Parcel parcel) {
            parcel.writeString(mRemoteId);
            parcel.writeString(mCategoryId);
            parcel.writeFloat(mScore);
        }

Loading