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

Commit 889b15b4 authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by android-build-merger
Browse files

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

am: d19113b3

Change-Id: I492245dee87450b1b54fef2c06c600ac290adffe
parents 8c921a8f d19113b3
Loading
Loading
Loading
Loading
+31 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ import android.os.PooledStringReader;
import android.os.PooledStringWriter;
import android.os.PooledStringWriter;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemClock;
import android.service.autofill.FillContext;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Log;
import android.util.Log;
import android.util.Pair;
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
         * 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.
         * 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.
         * 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() {
        public Matrix getTransformation() {
            return mMatrix;
            return mMatrix;
@@ -1112,6 +1116,9 @@ public class AssistStructure implements Parcelable {
         * Returns the visual elevation of the view, used for shadowing and other visual
         * Returns the visual elevation of the view, used for shadowing and other visual
         * characterstics, as set by {@link ViewStructure#setElevation
         * characterstics, as set by {@link ViewStructure#setElevation
         * ViewStructure.setElevation(float)}.
         * ViewStructure.setElevation(float)}.
         *
         * <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
         * not for Autofill purposes.
         */
         */
        public float getElevation() {
        public float getElevation() {
            return mElevation;
            return mElevation;
@@ -1121,6 +1128,9 @@ public class AssistStructure implements Parcelable {
         * Returns the alpha transformation of the view, used to reduce the overall opacity
         * Returns the alpha transformation of the view, used to reduce the overall opacity
         * of the view's contents, as set by {@link ViewStructure#setAlpha
         * of the view's contents, as set by {@link ViewStructure#setAlpha
         * ViewStructure.setAlpha(float)}.
         * ViewStructure.setAlpha(float)}.
         *
         * <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
         * not for Autofill purposes.
         */
         */
        public float getAlpha() {
        public float getAlpha() {
            return mAlpha;
            return mAlpha;
@@ -1289,6 +1299,9 @@ public class AssistStructure implements Parcelable {


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

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

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

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

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

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


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