Loading core/java/android/view/View.java +39 −23 Original line number Diff line number Diff line Loading @@ -3406,18 +3406,33 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private static final int PFLAG4_NOTIFIED_CONTENT_CAPTURE_ADDED = 0x20; private static final int PFLAG4_LAST_CONTENT_CAPTURE_NOTIFICATION_TYPE = 0x40; /* End of masks for mPrivateFlags4 */ private static final int CONTENT_CAPTURE_NOTIFICATION_TYPE_APPEARED = 1; private static final int CONTENT_CAPTURE_NOTIFICATION_TYPE_DISAPPEARED = 0; /** @hide */ @IntDef(flag = true, prefix = { "CONTENT_CAPTURE_NOTIFICATION_TYPE_" }, value = { CONTENT_CAPTURE_NOTIFICATION_TYPE_APPEARED, CONTENT_CAPTURE_NOTIFICATION_TYPE_DISAPPEARED }) @Retention(RetentionPolicy.SOURCE) public @interface ContentCaptureNotificationType {} private @interface ContentCaptureNotificationType {} /* End of masks for mPrivateFlags4 */ /** @hide */ protected static final int VIEW_STRUCTURE_FOR_ASSIST = 0; /** @hide */ protected static final int VIEW_STRUCTURE_FOR_AUTOFILL = 1; /** @hide */ protected static final int VIEW_STRUCTURE_FOR_CONTENT_CAPTURE = 2; /** @hide */ @IntDef(flag = true, prefix = { "VIEW_STRUCTURE_FOR" }, value = { VIEW_STRUCTURE_FOR_ASSIST, VIEW_STRUCTURE_FOR_AUTOFILL, VIEW_STRUCTURE_FOR_CONTENT_CAPTURE }) @Retention(RetentionPolicy.SOURCE) public @interface ViewStructureType {} /** * Always allow a user to over-scroll this view, provided it is a Loading Loading @@ -8043,8 +8058,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * fills in all data that can be inferred from the view itself. */ public void onProvideStructure(ViewStructure structure) { onProvideStructureForAssistOrAutofillOrViewCapture(structure, /* forAutofill = */ false, /* forViewCapture= */ false, /* flags= */ 0); onProvideStructure(structure, VIEW_STRUCTURE_FOR_ASSIST, /* flags= */ 0); } /** Loading Loading @@ -8117,8 +8131,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @see #AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS */ public void onProvideAutofillStructure(ViewStructure structure, @AutofillFlags int flags) { onProvideStructureForAssistOrAutofillOrViewCapture(structure, /* forAutofill = */ true, /* forViewCapture= */ false, flags); onProvideStructure(structure, VIEW_STRUCTURE_FOR_AUTOFILL, flags); } /** Loading Loading @@ -8150,13 +8163,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * virtual views are rendered. */ public boolean onProvideContentCaptureStructure(@NonNull ViewStructure structure, int flags) { onProvideStructureForAssistOrAutofillOrViewCapture(structure, /* forAutofill = */ false, /* forViewCapture= */ true, flags); onProvideStructure(structure, VIEW_STRUCTURE_FOR_CONTENT_CAPTURE, flags); return true; } private void onProvideStructureForAssistOrAutofillOrViewCapture(ViewStructure structure, boolean forAutofill, boolean forViewCapture, @AutofillFlags int flags) { /** @hide */ protected void onProvideStructure(@NonNull ViewStructure structure, @ViewStructureType int viewFor, int flags) { final int id = mID; if (id != NO_ID && !isViewIdGenerated(id)) { String pkg, type, entry; Loading @@ -8172,11 +8185,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } else { structure.setId(id, null, null, null); } if (forViewCapture) { if (viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { //TODO(b/111276913): STOPSHIP - don't set it if not needed structure.setDataIsSensitive(false); } if (forAutofill || forViewCapture) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { final @AutofillType int autofillType = getAutofillType(); // Don't need to fill autofill info if view does not support it. // For example, only TextViews that are editable support autofill Loading @@ -8190,7 +8205,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, int ignoredParentLeft = 0; int ignoredParentTop = 0; if (forAutofill && (flags & AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS) == 0) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL && (flags & AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS) == 0) { View parentGroup = null; ViewParent viewParent = getParent(); Loading @@ -8213,7 +8229,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, structure.setDimens(ignoredParentLeft + mLeft, ignoredParentTop + mTop, mScrollX, mScrollY, mRight - mLeft, mBottom - mTop); if (!forAutofill) { if (viewFor == VIEW_STRUCTURE_FOR_ASSIST || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { if (!hasIdentityMatrix()) { structure.setTransformation(getMatrix()); } Loading Loading @@ -8907,10 +8924,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** * Helper used to notify the {@link IntelligenceManager}anager when the view is removed or * Helper used to notify the {@link IntelligenceManager} when the view is removed or * added, based on whether it's laid out and visible, and without knowing if the parent removed * it from the view * hierarchy. * it from the view hierarchy. */ // TODO(b/111276913): make sure the current algorithm covers all cases. For example, it should // probably be called every time notifyEnterOrExitForAutoFillIfNeeded() is called as well. Loading Loading @@ -9084,7 +9100,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * {@link #onProvideVirtualStructure}. */ public void dispatchProvideStructure(ViewStructure structure) { dispatchProvideStructureForAssistOrAutofill(structure, false, 0); dispatchProvideStructure(structure, VIEW_STRUCTURE_FOR_ASSIST, /* flags= */ 0); } /** Loading Loading @@ -9126,12 +9142,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ public void dispatchProvideAutofillStructure(@NonNull ViewStructure structure, @AutofillFlags int flags) { dispatchProvideStructureForAssistOrAutofill(structure, true, flags); dispatchProvideStructure(structure, VIEW_STRUCTURE_FOR_AUTOFILL, flags); } private void dispatchProvideStructureForAssistOrAutofill(ViewStructure structure, boolean forAutofill, @AutofillFlags int flags) { if (forAutofill) { private void dispatchProvideStructure(@NonNull ViewStructure structure, @ViewStructureType int viewFor, @AutofillFlags int flags) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) { structure.setAutofillId(getAutofillId()); onProvideAutofillStructure(structure, flags); onProvideAutofillVirtualStructure(structure, flags); core/java/android/widget/AdapterView.java +16 −6 Original line number Diff line number Diff line Loading @@ -1309,7 +1309,16 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup { @Override public void onProvideAutofillStructure(ViewStructure structure, int flags) { super.onProvideAutofillStructure(structure, flags); } /** @hide */ @Override protected void onProvideStructure(@NonNull ViewStructure structure, @ViewStructureType int viewFor, int flags) { super.onProvideStructure(structure, viewFor, flags); if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { final Adapter adapter = getAdapter(); if (adapter == null) return; Loading @@ -1319,3 +1328,4 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup { } } } } core/java/android/widget/CompoundButton.java +8 −3 Original line number Diff line number Diff line Loading @@ -578,12 +578,17 @@ public abstract class CompoundButton extends Button implements Checkable { stream.addProperty("checked", isChecked()); } /** @hide */ @Override public void onProvideAutofillStructure(ViewStructure structure, int flags) { super.onProvideAutofillStructure(structure, flags); protected void onProvideStructure(@NonNull ViewStructure structure, @ViewStructureType int viewFor, int flags) { super.onProvideStructure(structure, viewFor, flags); if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) { structure.setDataIsSensitive(!mCheckedFromResource); } } @Override public void autofill(AutofillValue value) { Loading core/java/android/widget/RadioGroup.java +9 −3 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.widget; import android.annotation.IdRes; import android.annotation.NonNull; import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.TypedArray; Loading Loading @@ -424,11 +425,16 @@ public class RadioGroup extends LinearLayout { } } /** @hide */ @Override public void onProvideAutofillStructure(ViewStructure structure, int flags) { super.onProvideAutofillStructure(structure, flags); protected void onProvideStructure(@NonNull ViewStructure structure, @ViewStructureType int viewFor, int flags) { super.onProvideStructure(structure, viewFor, flags); if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) { structure.setDataIsSensitive(mCheckedId != mInitialCheckedId); } } @Override public void autofill(AutofillValue value) { Loading core/java/android/widget/TextView.java +22 −33 Original line number Diff line number Diff line Loading @@ -6076,7 +6076,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (needEditableForNotification) { sendAfterTextChanged((Editable) text); } else { notifyManagersAfterTextChanged(); notifyListeningManagersAfterTextChanged(); } // SelectionModifierCursorController depends on textCanBeSelected, which depends on text Loading Loading @@ -10124,13 +10124,16 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } // Always notify AutoFillManager - it will return right away if autofill is disabled. notifyManagersAfterTextChanged(); notifyListeningManagersAfterTextChanged(); hideErrorIfUnchanged(); } private void notifyManagersAfterTextChanged() { /** * Notify managers (such as {@link AutofillManager} and {@link IntelligenceManager}) that are * interested on text changes. */ private void notifyListeningManagersAfterTextChanged() { // Autofill if (isAutofillable()) { Loading Loading @@ -10911,34 +10914,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return TextView.class.getName(); } /** @hide */ @Override public void onProvideStructure(ViewStructure structure) { super.onProvideStructure(structure); onProvideStructureForAssistOrAutofillOrViewCapture(structure, /* forAutofill = */ false, /* forViewCapture= */ false); } @Override public void onProvideAutofillStructure(ViewStructure structure, int flags) { super.onProvideAutofillStructure(structure, flags); onProvideStructureForAssistOrAutofillOrViewCapture(structure, /* forAutofill = */ true, /* forViewCapture= */ false); } @Override public boolean onProvideContentCaptureStructure(ViewStructure structure, int flags) { final boolean notifyManager = super.onProvideContentCaptureStructure(structure, flags); onProvideStructureForAssistOrAutofillOrViewCapture(structure, /* forAutofill = */ false, /* forViewCapture= */ true); return notifyManager; } protected void onProvideStructure(@NonNull ViewStructure structure, @ViewStructureType int viewFor, int flags) { super.onProvideStructure(structure, viewFor, flags); private void onProvideStructureForAssistOrAutofillOrViewCapture(ViewStructure structure, boolean forAutofill, boolean forViewCapture) { final boolean isPassword = hasPasswordTransformationMethod() || isPasswordInputType(getInputType()); if (forAutofill || forViewCapture) { if (forAutofill) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) { structure.setDataIsSensitive(!mTextSetFromXmlOrResourceId); } if (mTextId != ResourceId.ID_NULL) { Loading @@ -10953,7 +10939,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } if (!isPassword || forAutofill || forViewCapture) { if (!isPassword || viewFor == VIEW_STRUCTURE_FOR_AUTOFILL || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { if (mLayout == null) { assumeLayout(); } Loading @@ -10962,7 +10949,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (lineCount <= 1) { // Simple case: this is a single line. final CharSequence text = getText(); if (forAutofill) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) { structure.setText(text); } else { structure.setText(text, getSelectionStart(), getSelectionEnd()); Loading Loading @@ -11026,7 +11013,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener text = text.subSequence(expandedTopChar, expandedBottomChar); } if (forAutofill) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) { structure.setText(text); } else { structure.setText(text, selStart - expandedTopChar, selEnd - expandedTopChar); Loading @@ -11042,7 +11029,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } if (!forAutofill) { if (viewFor == VIEW_STRUCTURE_FOR_ASSIST || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { // Extract style information that applies to the TextView as a whole. int style = 0; int typefaceStyle = getTypefaceStyle(); Loading Loading @@ -11070,7 +11058,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener structure.setTextStyle(getTextSize(), getCurrentTextColor(), AssistStructure.ViewNode.TEXT_COLOR_UNDEFINED /* bgColor */, style); } if (forAutofill || forViewCapture) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { structure.setMinTextEms(getMinEms()); structure.setMaxTextEms(getMaxEms()); int maxLength = -1; Loading Loading
core/java/android/view/View.java +39 −23 Original line number Diff line number Diff line Loading @@ -3406,18 +3406,33 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private static final int PFLAG4_NOTIFIED_CONTENT_CAPTURE_ADDED = 0x20; private static final int PFLAG4_LAST_CONTENT_CAPTURE_NOTIFICATION_TYPE = 0x40; /* End of masks for mPrivateFlags4 */ private static final int CONTENT_CAPTURE_NOTIFICATION_TYPE_APPEARED = 1; private static final int CONTENT_CAPTURE_NOTIFICATION_TYPE_DISAPPEARED = 0; /** @hide */ @IntDef(flag = true, prefix = { "CONTENT_CAPTURE_NOTIFICATION_TYPE_" }, value = { CONTENT_CAPTURE_NOTIFICATION_TYPE_APPEARED, CONTENT_CAPTURE_NOTIFICATION_TYPE_DISAPPEARED }) @Retention(RetentionPolicy.SOURCE) public @interface ContentCaptureNotificationType {} private @interface ContentCaptureNotificationType {} /* End of masks for mPrivateFlags4 */ /** @hide */ protected static final int VIEW_STRUCTURE_FOR_ASSIST = 0; /** @hide */ protected static final int VIEW_STRUCTURE_FOR_AUTOFILL = 1; /** @hide */ protected static final int VIEW_STRUCTURE_FOR_CONTENT_CAPTURE = 2; /** @hide */ @IntDef(flag = true, prefix = { "VIEW_STRUCTURE_FOR" }, value = { VIEW_STRUCTURE_FOR_ASSIST, VIEW_STRUCTURE_FOR_AUTOFILL, VIEW_STRUCTURE_FOR_CONTENT_CAPTURE }) @Retention(RetentionPolicy.SOURCE) public @interface ViewStructureType {} /** * Always allow a user to over-scroll this view, provided it is a Loading Loading @@ -8043,8 +8058,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * fills in all data that can be inferred from the view itself. */ public void onProvideStructure(ViewStructure structure) { onProvideStructureForAssistOrAutofillOrViewCapture(structure, /* forAutofill = */ false, /* forViewCapture= */ false, /* flags= */ 0); onProvideStructure(structure, VIEW_STRUCTURE_FOR_ASSIST, /* flags= */ 0); } /** Loading Loading @@ -8117,8 +8131,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @see #AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS */ public void onProvideAutofillStructure(ViewStructure structure, @AutofillFlags int flags) { onProvideStructureForAssistOrAutofillOrViewCapture(structure, /* forAutofill = */ true, /* forViewCapture= */ false, flags); onProvideStructure(structure, VIEW_STRUCTURE_FOR_AUTOFILL, flags); } /** Loading Loading @@ -8150,13 +8163,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * virtual views are rendered. */ public boolean onProvideContentCaptureStructure(@NonNull ViewStructure structure, int flags) { onProvideStructureForAssistOrAutofillOrViewCapture(structure, /* forAutofill = */ false, /* forViewCapture= */ true, flags); onProvideStructure(structure, VIEW_STRUCTURE_FOR_CONTENT_CAPTURE, flags); return true; } private void onProvideStructureForAssistOrAutofillOrViewCapture(ViewStructure structure, boolean forAutofill, boolean forViewCapture, @AutofillFlags int flags) { /** @hide */ protected void onProvideStructure(@NonNull ViewStructure structure, @ViewStructureType int viewFor, int flags) { final int id = mID; if (id != NO_ID && !isViewIdGenerated(id)) { String pkg, type, entry; Loading @@ -8172,11 +8185,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } else { structure.setId(id, null, null, null); } if (forViewCapture) { if (viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { //TODO(b/111276913): STOPSHIP - don't set it if not needed structure.setDataIsSensitive(false); } if (forAutofill || forViewCapture) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { final @AutofillType int autofillType = getAutofillType(); // Don't need to fill autofill info if view does not support it. // For example, only TextViews that are editable support autofill Loading @@ -8190,7 +8205,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, int ignoredParentLeft = 0; int ignoredParentTop = 0; if (forAutofill && (flags & AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS) == 0) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL && (flags & AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS) == 0) { View parentGroup = null; ViewParent viewParent = getParent(); Loading @@ -8213,7 +8229,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, structure.setDimens(ignoredParentLeft + mLeft, ignoredParentTop + mTop, mScrollX, mScrollY, mRight - mLeft, mBottom - mTop); if (!forAutofill) { if (viewFor == VIEW_STRUCTURE_FOR_ASSIST || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { if (!hasIdentityMatrix()) { structure.setTransformation(getMatrix()); } Loading Loading @@ -8907,10 +8924,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** * Helper used to notify the {@link IntelligenceManager}anager when the view is removed or * Helper used to notify the {@link IntelligenceManager} when the view is removed or * added, based on whether it's laid out and visible, and without knowing if the parent removed * it from the view * hierarchy. * it from the view hierarchy. */ // TODO(b/111276913): make sure the current algorithm covers all cases. For example, it should // probably be called every time notifyEnterOrExitForAutoFillIfNeeded() is called as well. Loading Loading @@ -9084,7 +9100,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * {@link #onProvideVirtualStructure}. */ public void dispatchProvideStructure(ViewStructure structure) { dispatchProvideStructureForAssistOrAutofill(structure, false, 0); dispatchProvideStructure(structure, VIEW_STRUCTURE_FOR_ASSIST, /* flags= */ 0); } /** Loading Loading @@ -9126,12 +9142,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ public void dispatchProvideAutofillStructure(@NonNull ViewStructure structure, @AutofillFlags int flags) { dispatchProvideStructureForAssistOrAutofill(structure, true, flags); dispatchProvideStructure(structure, VIEW_STRUCTURE_FOR_AUTOFILL, flags); } private void dispatchProvideStructureForAssistOrAutofill(ViewStructure structure, boolean forAutofill, @AutofillFlags int flags) { if (forAutofill) { private void dispatchProvideStructure(@NonNull ViewStructure structure, @ViewStructureType int viewFor, @AutofillFlags int flags) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) { structure.setAutofillId(getAutofillId()); onProvideAutofillStructure(structure, flags); onProvideAutofillVirtualStructure(structure, flags);
core/java/android/widget/AdapterView.java +16 −6 Original line number Diff line number Diff line Loading @@ -1309,7 +1309,16 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup { @Override public void onProvideAutofillStructure(ViewStructure structure, int flags) { super.onProvideAutofillStructure(structure, flags); } /** @hide */ @Override protected void onProvideStructure(@NonNull ViewStructure structure, @ViewStructureType int viewFor, int flags) { super.onProvideStructure(structure, viewFor, flags); if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { final Adapter adapter = getAdapter(); if (adapter == null) return; Loading @@ -1319,3 +1328,4 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup { } } } }
core/java/android/widget/CompoundButton.java +8 −3 Original line number Diff line number Diff line Loading @@ -578,12 +578,17 @@ public abstract class CompoundButton extends Button implements Checkable { stream.addProperty("checked", isChecked()); } /** @hide */ @Override public void onProvideAutofillStructure(ViewStructure structure, int flags) { super.onProvideAutofillStructure(structure, flags); protected void onProvideStructure(@NonNull ViewStructure structure, @ViewStructureType int viewFor, int flags) { super.onProvideStructure(structure, viewFor, flags); if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) { structure.setDataIsSensitive(!mCheckedFromResource); } } @Override public void autofill(AutofillValue value) { Loading
core/java/android/widget/RadioGroup.java +9 −3 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.widget; import android.annotation.IdRes; import android.annotation.NonNull; import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.TypedArray; Loading Loading @@ -424,11 +425,16 @@ public class RadioGroup extends LinearLayout { } } /** @hide */ @Override public void onProvideAutofillStructure(ViewStructure structure, int flags) { super.onProvideAutofillStructure(structure, flags); protected void onProvideStructure(@NonNull ViewStructure structure, @ViewStructureType int viewFor, int flags) { super.onProvideStructure(structure, viewFor, flags); if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) { structure.setDataIsSensitive(mCheckedId != mInitialCheckedId); } } @Override public void autofill(AutofillValue value) { Loading
core/java/android/widget/TextView.java +22 −33 Original line number Diff line number Diff line Loading @@ -6076,7 +6076,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (needEditableForNotification) { sendAfterTextChanged((Editable) text); } else { notifyManagersAfterTextChanged(); notifyListeningManagersAfterTextChanged(); } // SelectionModifierCursorController depends on textCanBeSelected, which depends on text Loading Loading @@ -10124,13 +10124,16 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } // Always notify AutoFillManager - it will return right away if autofill is disabled. notifyManagersAfterTextChanged(); notifyListeningManagersAfterTextChanged(); hideErrorIfUnchanged(); } private void notifyManagersAfterTextChanged() { /** * Notify managers (such as {@link AutofillManager} and {@link IntelligenceManager}) that are * interested on text changes. */ private void notifyListeningManagersAfterTextChanged() { // Autofill if (isAutofillable()) { Loading Loading @@ -10911,34 +10914,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return TextView.class.getName(); } /** @hide */ @Override public void onProvideStructure(ViewStructure structure) { super.onProvideStructure(structure); onProvideStructureForAssistOrAutofillOrViewCapture(structure, /* forAutofill = */ false, /* forViewCapture= */ false); } @Override public void onProvideAutofillStructure(ViewStructure structure, int flags) { super.onProvideAutofillStructure(structure, flags); onProvideStructureForAssistOrAutofillOrViewCapture(structure, /* forAutofill = */ true, /* forViewCapture= */ false); } @Override public boolean onProvideContentCaptureStructure(ViewStructure structure, int flags) { final boolean notifyManager = super.onProvideContentCaptureStructure(structure, flags); onProvideStructureForAssistOrAutofillOrViewCapture(structure, /* forAutofill = */ false, /* forViewCapture= */ true); return notifyManager; } protected void onProvideStructure(@NonNull ViewStructure structure, @ViewStructureType int viewFor, int flags) { super.onProvideStructure(structure, viewFor, flags); private void onProvideStructureForAssistOrAutofillOrViewCapture(ViewStructure structure, boolean forAutofill, boolean forViewCapture) { final boolean isPassword = hasPasswordTransformationMethod() || isPasswordInputType(getInputType()); if (forAutofill || forViewCapture) { if (forAutofill) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) { structure.setDataIsSensitive(!mTextSetFromXmlOrResourceId); } if (mTextId != ResourceId.ID_NULL) { Loading @@ -10953,7 +10939,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } if (!isPassword || forAutofill || forViewCapture) { if (!isPassword || viewFor == VIEW_STRUCTURE_FOR_AUTOFILL || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { if (mLayout == null) { assumeLayout(); } Loading @@ -10962,7 +10949,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (lineCount <= 1) { // Simple case: this is a single line. final CharSequence text = getText(); if (forAutofill) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) { structure.setText(text); } else { structure.setText(text, getSelectionStart(), getSelectionEnd()); Loading Loading @@ -11026,7 +11013,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener text = text.subSequence(expandedTopChar, expandedBottomChar); } if (forAutofill) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) { structure.setText(text); } else { structure.setText(text, selStart - expandedTopChar, selEnd - expandedTopChar); Loading @@ -11042,7 +11029,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } if (!forAutofill) { if (viewFor == VIEW_STRUCTURE_FOR_ASSIST || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { // Extract style information that applies to the TextView as a whole. int style = 0; int typefaceStyle = getTypefaceStyle(); Loading Loading @@ -11070,7 +11058,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener structure.setTextStyle(getTextSize(), getCurrentTextColor(), AssistStructure.ViewNode.TEXT_COLOR_UNDEFINED /* bgColor */, style); } if (forAutofill || forViewCapture) { if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { structure.setMinTextEms(getMinEms()); structure.setMaxTextEms(getMaxEms()); int maxLength = -1; Loading