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

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

Merge "Report less data in structure to autofill provider" into oc-dev

parents 6f4aab2c c368a240
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ import android.os.PooledStringReader;
import android.os.PooledStringWriter;
import android.os.RemoteException;
import android.os.SystemClock;
import android.service.autofill.FillContext;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
@@ -1103,6 +1104,9 @@ public class AssistStructure implements Parcelable {
         * Returns the transformation that has been applied to this view, such as a translation
         * or scaling.  The returned Matrix object is owned by ViewNode; do not modify it.
         * Returns null if there is no transformation applied to the view.
         *
         * <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
         * not for Autofill purposes.
         */
        public Matrix getTransformation() {
            return mMatrix;
@@ -1112,6 +1116,9 @@ public class AssistStructure implements Parcelable {
         * Returns the visual elevation of the view, used for shadowing and other visual
         * characterstics, as set by {@link ViewStructure#setElevation
         * ViewStructure.setElevation(float)}.
         *
         * <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
         * not for Autofill purposes.
         */
        public float getElevation() {
            return mElevation;
@@ -1121,6 +1128,9 @@ public class AssistStructure implements Parcelable {
         * Returns the alpha transformation of the view, used to reduce the overall opacity
         * of the view's contents, as set by {@link ViewStructure#setAlpha
         * ViewStructure.setAlpha(float)}.
         *
         * <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
         * not for Autofill purposes.
         */
        public float getAlpha() {
            return mAlpha;
@@ -1289,6 +1299,9 @@ public class AssistStructure implements Parcelable {

        /**
         * If {@link #getText()} is non-null, this is where the current selection starts.
         *
         * <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
         * not for Autofill purposes.
         */
        public int getTextSelectionStart() {
            return mText != null ? mText.mTextSelectionStart : -1;
@@ -1298,6 +1311,9 @@ public class AssistStructure implements Parcelable {
         * If {@link #getText()} is non-null, this is where the current selection starts.
         * If there is no selection, returns the same value as {@link #getTextSelectionStart()},
         * indicating the cursor position.
         *
         * <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
         * not for Autofill purposes.
         */
        public int getTextSelectionEnd() {
            return mText != null ? mText.mTextSelectionEnd : -1;
@@ -1319,6 +1335,9 @@ public class AssistStructure implements Parcelable {
         * If there is no text background color, {@link #TEXT_COLOR_UNDEFINED} is returned.
         * Note that the text may also contain style spans that modify the color of specific
         * parts of the text.
         *
         * <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
         * not for Autofill purposes.
         */
        public int getTextBackgroundColor() {
            return mText != null ? mText.mTextBackgroundColor : TEXT_COLOR_UNDEFINED;
@@ -1329,6 +1348,9 @@ public class AssistStructure implements Parcelable {
         * with it.
         * Note that the text may also contain style spans that modify the size of specific
         * parts of the text.
         *
         * <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
         * not for Autofill purposes.
         */
        public float getTextSize() {
            return mText != null ? mText.mTextSize : 0;
@@ -1341,6 +1363,9 @@ public class AssistStructure implements Parcelable {
         * {@link #TEXT_STYLE_UNDERLINE}.
         * Note that the text may also contain style spans that modify the style of specific
         * parts of the text.
         *
         * <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
         * not for Autofill purposes.
         */
        public int getTextStyle() {
            return mText != null ? mText.mTextStyle : 0;
@@ -1351,6 +1376,9 @@ public class AssistStructure implements Parcelable {
         * in the array is a formatted line of text, and the value it contains is the offset
         * into the text string where that line starts.  May return null if there is no line
         * information.
         *
         * <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
         * not for Autofill purposes.
         */
        public int[] getTextLineCharOffsets() {
            return mText != null ? mText.mLineCharOffsets : null;
@@ -1361,6 +1389,9 @@ public class AssistStructure implements Parcelable {
         * in the array is a formatted line of text, and the value it contains is the baseline
         * where that text appears in the view.  May return null if there is no line
         * information.
         *
         * <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
         * not for Autofill purposes.
         */
        public int[] getTextLineBaselines() {
            return mText != null ? mText.mLineBaselines : null;
+5 −3
Original line number Diff line number Diff line
@@ -7351,10 +7351,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        }
        structure.setDimens(mLeft, mTop, mScrollX, mScrollY, mRight - mLeft, mBottom - mTop);
        if (!forAutofill) {
            if (!hasIdentityMatrix()) {
                structure.setTransformation(getMatrix());
            }
            structure.setElevation(getZ());
        }
        structure.setVisibility(getVisibility());
        structure.setEnabled(isEnabled());
        if (isClickable()) {
+48 −33
Original line number Diff line number Diff line
@@ -10136,7 +10136,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            if (lineCount <= 1) {
                // Simple case: this is a single line.
                final CharSequence text = getText();
                if (forAutofill) {
                    structure.setText(text);
                } else {
                    structure.setText(text, getSelectionStart(), getSelectionEnd());
                }
            } else {
                // Complex case: multi-line, could be scrolled or within a scroll container
                // so some lines are not visible.
@@ -10172,9 +10176,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                if (expandedBottomLine >= lineCount) {
                    expandedBottomLine = lineCount - 1;
                }

                // Convert lines into character offsets.
                int expandedTopChar = layout.getLineStart(expandedTopLine);
                int expandedBottomChar = layout.getLineEnd(expandedBottomLine);

                // Take into account selection -- if there is a selection, we need to expand
                // the text we are returning to include that selection.
                final int selStart = getSelectionStart();
@@ -10187,12 +10193,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                        expandedBottomChar = selEnd;
                    }
                }

                // Get the text and trim it to the range we are reporting.
                CharSequence text = getText();
                if (expandedTopChar > 0 || expandedBottomChar < text.length()) {
                    text = text.subSequence(expandedTopChar, expandedBottomChar);
                }

                if (forAutofill) {
                    structure.setText(text);
                } else {
                    structure.setText(text, selStart - expandedTopChar, selEnd - expandedTopChar);

                    final int[] lineOffsets = new int[bottomLine - topLine + 1];
                    final int[] lineBaselines = new int[bottomLine - topLine + 1];
                    final int baselineOffset = getBaselineOffset();
@@ -10202,7 +10214,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                    }
                    structure.setTextLines(lineOffsets, lineBaselines);
                }
            }

            if (!forAutofill) {
                // Extract style information that applies to the TextView as a whole.
                int style = 0;
                int typefaceStyle = getTypefaceStyle();
@@ -10230,6 +10244,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                structure.setTextStyle(getTextSize(), getCurrentTextColor(),
                        AssistStructure.ViewNode.TEXT_COLOR_UNDEFINED /* bgColor */, style);
            }
        }
        structure.setHint(getHint());
        structure.setInputType(getInputType());
    }