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

Commit 107d801e authored by Haoran Zhang's avatar Haoran Zhang Committed by Android (Google) Code Review
Browse files

Merge "[Autofill Brute Force] Change max user input eligible for autofill...

Merge "[Autofill Brute Force] Change max user input eligible for autofill suggestion from a constant to flag." into main
parents 65381a4f 88e34907
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -255,6 +255,16 @@ public class AutofillFeatureFlags {

    // END AUTOFILL PCC CLASSIFICATION FLAGS

    /**
     * Define the max input length for autofill to show suggesiton UI
     *
     * E.g. if flag is set to 3, autofill will only show suggestions when user inputs less than 3
     * characters
     *
     * @hide
     */
    public static final String DEVICE_CONFIG_MAX_INPUT_LENGTH_FOR_AUTOFILL =
            "max_input_length_for_autofill";

    /**
     * Sets a value of delay time to show up the inline tooltip view.
@@ -295,6 +305,10 @@ public class AutofillFeatureFlags {
            DEFAULT_AFAA_SHOULD_INCLUDE_ALL_AUTOFILL_TYPE_NOT_NONE_VIEWS_IN_ASSIST_STRUCTURE = true;
    // END AUTOFILL FOR ALL APPS DEFAULTS

    /**
     * @hide
     */
    public static final int DEFAULT_MAX_INPUT_LENGTH_FOR_AUTOFILL = 3;
    private AutofillFeatureFlags() {};

    /**
+16 −0
Original line number Diff line number Diff line
@@ -223,6 +223,9 @@ public final class AutofillManagerService
    @GuardedBy("mFlagLock")
    private String mPccProviderHints;

    @GuardedBy("mFlagLock")
    private int mMaxInputLengthForAutofill;

    // Default flag values for Autofill PCC

    private static final String DEFAULT_PCC_FEATURE_PROVIDER_HINTS = "";
@@ -694,6 +697,10 @@ public final class AutofillManagerService
                    DeviceConfig.NAMESPACE_AUTOFILL,
                    AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_PCC_FEATURE_PROVIDER_HINTS,
                    DEFAULT_PCC_FEATURE_PROVIDER_HINTS);
            mMaxInputLengthForAutofill = DeviceConfig.getInt(
                    DeviceConfig.NAMESPACE_AUTOFILL,
                    AutofillFeatureFlags.DEVICE_CONFIG_MAX_INPUT_LENGTH_FOR_AUTOFILL,
                    AutofillFeatureFlags.DEFAULT_MAX_INPUT_LENGTH_FOR_AUTOFILL);
            if (verbose) {
                Slog.v(mTag, "setDeviceConfigProperties() for PCC: "
                        + "mPccClassificationEnabled=" + mPccClassificationEnabled
@@ -988,6 +995,15 @@ public final class AutofillManagerService
        }
    }

    /**
     * Return the max suggestion length
     */
    public int getMaxInputLengthForAutofill() {
        synchronized (mFlagLock) {
            return mMaxInputLengthForAutofill;
        }
    }

    @Nullable
    @VisibleForTesting
    static Map<String, String[]> getAllowedCompatModePackages(String setting) {
+3 −2
Original line number Diff line number Diff line
@@ -4596,7 +4596,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState

        getUiForShowing().showFillUi(filledId, response, filterText,
                mService.getServicePackageName(), mComponentName,
                targetLabel, targetIcon, this, mContext, id, mCompatMode);
                targetLabel, targetIcon, this, mContext, id, mCompatMode,
                mService.getMaster().getMaxInputLengthForAutofill());

        synchronized (mLock) {
            mPresentationStatsEventLogger.maybeSetCountShown(
@@ -4856,7 +4857,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                    public void onInflate() {
                        Session.this.onShown(UI_TYPE_INLINE);
                    }
                });
                }, mService.getMaster().getMaxInputLengthForAutofill());
        return mInlineSessionController.setInlineFillUiLocked(inlineFillUi);
    }

+5 −2
Original line number Diff line number Diff line
@@ -204,12 +204,14 @@ public final class AutoFillUI {
     * @param context context with the proper state (like display id) to show the UI
     * @param sessionId id of the autofill session
     * @param compatMode whether the app is being autofilled in compatibility mode.
     * @param maxInputLengthForAutofill max user input to provide suggestion
     */
    public void showFillUi(@NonNull AutofillId focusedId, @NonNull FillResponse response,
            @Nullable String filterText, @Nullable String servicePackageName,
            @NonNull ComponentName componentName, @NonNull CharSequence serviceLabel,
            @NonNull Drawable serviceIcon, @NonNull AutoFillUiCallback callback,
            @NonNull Context context, int sessionId, boolean compatMode) {
            @NonNull Context context, int sessionId, boolean compatMode,
            int maxInputLengthForAutofill) {
        if (sDebug) {
            final int size = filterText == null ? 0 : filterText.length();
            Slogf.d(TAG, "showFillUi(): id=%s, filter=%d chars, displayId=%d", focusedId, size,
@@ -229,7 +231,8 @@ public final class AutoFillUI {
            }
            hideAllUiThread(callback);
            mFillUi = new FillUi(context, response, focusedId, filterText, mOverlayControl,
                    serviceLabel, serviceIcon, mUiModeMgr.isNightMode(), new FillUi.Callback() {
                    serviceLabel, serviceIcon, mUiModeMgr.isNightMode(), maxInputLengthForAutofill,
                    new FillUi.Callback() {
                @Override
                public void onResponsePicked(FillResponse response) {
                    log.setType(MetricsEvent.TYPE_DETAIL);
+9 −4
Original line number Diff line number Diff line
@@ -127,6 +127,8 @@ final class FillUi {

    private final int mThemeId;

    private int mMaxInputLengthForAutofill;

    public static boolean isFullScreen(Context context) {
        if (sFullScreenMode != null) {
            if (sVerbose) Slog.v(TAG, "forcing full-screen mode to " + sFullScreenMode);
@@ -138,7 +140,8 @@ final class FillUi {
    FillUi(@NonNull Context context, @NonNull FillResponse response,
            @NonNull AutofillId focusedViewId, @Nullable String filterText,
            @NonNull OverlayControl overlayControl, @NonNull CharSequence serviceLabel,
            @NonNull Drawable serviceIcon, boolean nightMode, @NonNull Callback callback) {
            @NonNull Drawable serviceIcon, boolean nightMode, int maxInputLengthForAutofill,
            @NonNull Callback callback) {
        if (sVerbose) {
            Slogf.v(TAG, "nightMode: %b displayId: %d", nightMode, context.getDisplayId());
        }
@@ -146,6 +149,7 @@ final class FillUi {
        mCallback = callback;
        mFullScreen = isFullScreen(context);
        mContext = new ContextThemeWrapper(context, mThemeId);
        mMaxInputLengthForAutofill = maxInputLengthForAutofill;

        final LayoutInflater inflater = LayoutInflater.from(mContext);

@@ -432,10 +436,11 @@ final class FillUi {
                    Slog.d(TAG, "No dataset matches filter with " + size + " chars");
                }
                mCallback.requestHideFillUi();
            } else if (size > 3) {
                // Do not show suggestion if user entered four or more characters
            } else if (size > mMaxInputLengthForAutofill) {
                // Do not show suggestion if user entered more than the maximum suggesiton length
                if (sDebug) {
                    Slog.d(TAG, "Not showing fill UI because user entered more than 3 characters");
                    Slog.d(TAG, "Not showing fill UI because user entered more than "
                            + mMaxInputLengthForAutofill + " characters");
                }
                mCallback.requestHideFillUi();
            } else {
Loading