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

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

Merge "Public Autofill Id field in EditorInfo" into main

parents daeb8ec6 8ed8a9f4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -56907,6 +56907,7 @@ package android.view.inputmethod {
    ctor public EditorInfo();
    method public int describeContents();
    method public void dump(android.util.Printer, String);
    method @FlaggedApi("android.view.inputmethod.public_autofill_id_in_editorinfo") @Nullable public android.view.autofill.AutofillId getAutofillId();
    method @Nullable public CharSequence getInitialSelectedText(int);
    method @Nullable public android.view.inputmethod.SurroundingText getInitialSurroundingText(@IntRange(from=0) int, @IntRange(from=0) int, int);
    method @Nullable public CharSequence getInitialTextAfterCursor(@IntRange(from=0) int, int);
@@ -56916,6 +56917,7 @@ package android.view.inputmethod {
    method @NonNull public java.util.List<java.lang.Class<? extends android.view.inputmethod.HandwritingGesture>> getSupportedHandwritingGestures();
    method @FlaggedApi("android.view.inputmethod.editorinfo_handwriting_enabled") public boolean isStylusHandwritingEnabled();
    method public final void makeCompatible(int);
    method @FlaggedApi("android.view.inputmethod.public_autofill_id_in_editorinfo") public void setAutofillId(@Nullable android.view.autofill.AutofillId);
    method public void setInitialSurroundingSubText(@NonNull CharSequence, int);
    method public void setInitialSurroundingText(@NonNull CharSequence);
    method public void setInitialToolType(int);
+1 −1
Original line number Diff line number Diff line
@@ -3436,7 +3436,7 @@ public class InputMethodService extends AbstractInputMethodService {
        initialize();
        mInlineSuggestionSessionController.notifyOnStartInput(
                editorInfo == null ? null : editorInfo.packageName,
                editorInfo == null ? null : editorInfo.autofillId);
                editorInfo == null ? null : editorInfo.getAutofillId());
        if (DEBUG) Log.v(TAG, "CALL: onStartInput");
        onStartInput(editorInfo, restarting);
        if (mDecorViewVisible) {
+26 −5
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static android.view.inputmethod.EditorInfoProto.PACKAGE_NAME;
import static android.view.inputmethod.EditorInfoProto.PRIVATE_IME_OPTIONS;
import static android.view.inputmethod.EditorInfoProto.TARGET_INPUT_METHOD_USER_ID;
import static android.view.inputmethod.Flags.FLAG_EDITORINFO_HANDWRITING_ENABLED;
import static android.view.inputmethod.Flags.FLAG_PUBLIC_AUTOFILL_ID_IN_EDITORINFO;

import android.annotation.FlaggedApi;
import android.annotation.IntDef;
@@ -470,12 +471,10 @@ public class EditorInfo implements InputType, Parcelable {
    public String packageName;

    /**
     * Autofill Id for the field that's currently on focus.
     *
     * <p> Marked as hide since it's only used by framework.</p>
     * @hide
     * Autofill Id for the field that's currently on focus. See link {@link AutofillId} for more
     * details. It is set by {@link View#getAutofillId()}
     */
    public AutofillId autofillId;
    private AutofillId autofillId;

    /**
     * Identifier for the editor's field.  This is optional, and may be
@@ -1199,6 +1198,28 @@ public class EditorInfo implements InputType, Parcelable {
        mInitialToolType = toolType;
    }

    /**
     * Returns the {@link AutofillId} of the view that this {@link EditorInfo} is associated with.
     * The value is filled in with the result of {@link android.view.View#getAutofillId()
     * View.getAutofillId()} on the view that is being edited.
     *
     * Note: For virtual view(e.g. Compose or Webview), default behavior is the autofillId is the id
     * of the container view, unless the virtual view provider sets the virtual id when the
     * InputMethodManager calls {@link android.view.View#onCreateInputConnection()} on the container
     * view.
     */
    @FlaggedApi(FLAG_PUBLIC_AUTOFILL_ID_IN_EDITORINFO)
    @Nullable
    public AutofillId getAutofillId() {
        return autofillId;
    }

    /** Sets the {@link AutofillId} of the view that this {@link EditorInfo} is associated with. */
    @FlaggedApi(FLAG_PUBLIC_AUTOFILL_ID_IN_EDITORINFO)
    public void setAutofillId(@Nullable AutofillId autofillId) {
        this.autofillId = autofillId;
    }

    /**
     * Export the state of {@link EditorInfo} into a protocol buffer output stream.
     *
+2 −2
Original line number Diff line number Diff line
@@ -5179,7 +5179,7 @@ public final class InputMethodManager {
        // system can verify the consistency between the uid of this process and package name passed
        // from here. See comment of Context#getOpPackageName() for details.
        editorInfo.packageName = servedView.getContext().getOpPackageName();
        editorInfo.autofillId = servedView.getAutofillId();
        editorInfo.setAutofillId(servedView.getAutofillId());
        editorInfo.fieldId = servedView.getId();
        final InputConnection ic = servedView.onCreateInputConnection(editorInfo);
        if (DEBUG) Log.v(TAG, "Starting input: editorInfo=" + editorInfo + " ic=" + ic);
@@ -5188,7 +5188,7 @@ public final class InputMethodManager {
        // This ensures that even disconnected EditorInfos have well-defined attributes,
        // making them consistently and straightforwardly comparable.
        if (ic == null) {
            editorInfo.autofillId = AutofillId.NO_AUTOFILL_ID;
            editorInfo.setAutofillId(AutofillId.NO_AUTOFILL_ID);
            editorInfo.fieldId = 0;
        }
        return new Pair<>(ic, editorInfo);
+10 −1
Original line number Diff line number Diff line
@@ -166,3 +166,12 @@ flag {
    bug: "373788889"
    is_fixed_read_only: true
}

flag {
  name: "public_autofill_id_in_editorinfo"
  is_exported: true
  namespace: "input_method"
  description: "Guarding public API autofillId in editor info"
  bug: "342672560"
  is_fixed_read_only: true
}
Loading