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

Commit ea8feabe authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Minor improvements on autofill compat mode:"

parents 28ddc0a6 fd3f8f6f
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.view;
import static android.view.accessibility.AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED;
import static java.lang.Math.max;
import android.animation.AnimatorInflater;
@@ -8378,7 +8379,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            AccessibilityNodeProvider provider, AccessibilityNodeInfo info,
            boolean forAutofill) {
        structure.setId(AccessibilityNodeInfo.getVirtualDescendantId(info.getSourceNodeId()),
                null, null, null);
                null, null, info.getViewIdResourceName());
        Rect rect = structure.getTempRect();
        info.getBoundsInParent(rect);
        structure.setDimens(rect.left, rect.top, 0, 0, rect.width(), rect.height());
@@ -8418,6 +8419,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        CharSequence cname = info.getClassName();
        structure.setClassName(cname != null ? cname.toString() : null);
        structure.setContentDescription(info.getContentDescription());
        if (forAutofill) {
            final int maxTextLength = info.getMaxTextLength();
            if (maxTextLength != -1) {
                structure.setMaxTextLength(maxTextLength);
            }
            structure.setHint(info.getHintText());
        }
        if ((info.getText() != null || info.getError() != null)) {
            structure.setText(info.getText(), info.getTextSelectionStart(),
                    info.getTextSelectionEnd());
@@ -8428,7 +8436,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                    final AutofillValue autofillValue = AutofillValue.forText(structure.getText());
                    structure.setAutofillValue(autofillValue);
                    if (info.isPassword()) {
                        structure.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
                        structure.setInputType(InputType.TYPE_CLASS_TEXT
                                | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                    }
                } else {
                    structure.setDataIsSensitive(false);
+14 −11
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@

package android.view.autofill;

import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST;
import static android.view.autofill.Helper.sDebug;
import static android.view.autofill.Helper.sVerbose;

import android.accessibilityservice.AccessibilityServiceInfo;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -47,13 +51,14 @@ import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
import android.view.accessibility.AccessibilityWindowInfo;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.Preconditions;

import org.xmlpull.v1.XmlPullParserException;
import sun.misc.Cleaner;

import java.io.IOException;
import java.io.PrintWriter;
@@ -66,9 +71,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;

import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST;
import static android.view.autofill.Helper.sDebug;
import static android.view.autofill.Helper.sVerbose;
import sun.misc.Cleaner;

// TODO: use java.lang.ref.Cleaner once Android supports Java 9

@@ -616,11 +619,9 @@ public final class AutofillManager {
    /**
     * @hide
     */
    public boolean isCompatibilityModeEnabled() {
        synchronized (mLock) {
    public boolean isCompatibilityModeEnabledLocked() {
        return mCompatibilityBridge != null;
    }
    }

    /**
     * Checks whether autofill is enabled for the current user.
@@ -1381,7 +1382,8 @@ public final class AutofillManager {
            @NonNull AutofillValue value, int flags) {
        if (sVerbose) {
            Log.v(TAG, "startSessionLocked(): id=" + id + ", bounds=" + bounds + ", value=" + value
                    + ", flags=" + flags + ", state=" + getStateAsStringLocked());
                    + ", flags=" + flags + ", state=" + getStateAsStringLocked()
                    + ", compatMode=" + isCompatibilityModeEnabledLocked());
        }
        if (mState != STATE_UNKNOWN && !isFinishedLocked() && (flags & FLAG_MANUAL_REQUEST) == 0) {
            if (sVerbose) {
@@ -1392,7 +1394,7 @@ public final class AutofillManager {
        }
        try {
            final AutofillClient client = getClient();
            if (client == null) return; // NOTE: getClient() already logd it..
            if (client == null) return; // NOTE: getClient() already logged it..

            mSessionId = mService.startSession(client.autofillClientGetActivityToken(),
                    mServiceClient.asBinder(), id, bounds, value, mContext.getUserId(),
@@ -1939,7 +1941,8 @@ public final class AutofillManager {
        pw.print(pfx); pw.print("fillable ids: "); pw.println(mFillableIds);
        pw.print(pfx); pw.print("save trigger id: "); pw.println(mSaveTriggerId);
        pw.print(pfx); pw.print("save on finish(): "); pw.println(mSaveOnFinish);
        pw.print(pfx); pw.print("compat mode enabled: "); pw.println(isCompatibilityModeEnabled());
        pw.print(pfx); pw.print("compat mode enabled: "); pw.println(
                isCompatibilityModeEnabledLocked());
        pw.print(pfx); pw.print("debug: "); pw.print(sDebug);
        pw.print(" verbose: "); pw.println(sVerbose);
    }