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

Commit 4461181f authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Don't run autoFill on detached view or mode=manual

We only run autoFill on views that are attached, auto-fillable, not
auto-fill blocked, resolvedMode=auto and focused. If any of the
conditions change we have to re-evaluate the auto-fill state.

This reverts commit e572989b.

Test: Ran amended ViewAttributesTest, set a PIN for the device
      (previously crashed)
Bug: 35701500
Change-Id: Idcdf1fd7b7dee6bfbc800fb84fdc1c72dcb088f9
parent 63890300
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -44915,6 +44915,7 @@ package android.view {
    method public float getPivotX();
    method public float getPivotY();
    method public android.view.PointerIcon getPointerIcon();
    method public int getResolvedAutoFillMode();
    method public android.content.res.Resources getResources();
    method public final boolean getRevealOnFocusHint();
    method public final int getRight();
@@ -45862,6 +45863,7 @@ package android.view {
    method public abstract int getLayoutDirection();
    method public abstract android.view.ViewParent getParent();
    method public abstract android.view.ViewParent getParentForAccessibility();
    method public default int getResolvedAutoFillMode();
    method public abstract int getTextAlignment();
    method public abstract int getTextDirection();
    method public abstract deprecated void invalidateChild(android.view.View, android.graphics.Rect);
@@ -47212,10 +47214,12 @@ package android.view.autofill {
  }
  public final class AutoFillManager {
    method public void focusChanged(android.view.View, boolean);
    method public void reset();
    method public void startAutoFillRequest(android.view.View);
    method public void startAutoFillRequestOnVirtualView(android.view.View, int, android.graphics.Rect);
    method public void stopAutoFillRequest(android.view.View);
    method public void stopAutoFillRequestOnVirtualView(android.view.View, int);
    method public void valueChanged(android.view.View);
    method public void virtualFocusChanged(android.view.View, int, android.graphics.Rect, boolean);
    method public void virtualValueChanged(android.view.View, int, android.view.autofill.AutoFillValue);
    field public static final java.lang.String EXTRA_ASSIST_STRUCTURE = "android.view.autofill.extra.ASSIST_STRUCTURE";
    field public static final java.lang.String EXTRA_AUTHENTICATION_RESULT = "android.view.autofill.extra.AUTHENTICATION_RESULT";
+6 −2
Original line number Diff line number Diff line
@@ -48301,6 +48301,7 @@ package android.view {
    method public float getPivotX();
    method public float getPivotY();
    method public android.view.PointerIcon getPointerIcon();
    method public int getResolvedAutoFillMode();
    method public android.content.res.Resources getResources();
    method public final boolean getRevealOnFocusHint();
    method public final int getRight();
@@ -49248,6 +49249,7 @@ package android.view {
    method public abstract int getLayoutDirection();
    method public abstract android.view.ViewParent getParent();
    method public abstract android.view.ViewParent getParentForAccessibility();
    method public default int getResolvedAutoFillMode();
    method public abstract int getTextAlignment();
    method public abstract int getTextDirection();
    method public abstract deprecated void invalidateChild(android.view.View, android.graphics.Rect);
@@ -50601,10 +50603,12 @@ package android.view.autofill {
  }
  public final class AutoFillManager {
    method public void focusChanged(android.view.View, boolean);
    method public void reset();
    method public void startAutoFillRequest(android.view.View);
    method public void startAutoFillRequestOnVirtualView(android.view.View, int, android.graphics.Rect);
    method public void stopAutoFillRequest(android.view.View);
    method public void stopAutoFillRequestOnVirtualView(android.view.View, int);
    method public void valueChanged(android.view.View);
    method public void virtualFocusChanged(android.view.View, int, android.graphics.Rect, boolean);
    method public void virtualValueChanged(android.view.View, int, android.view.autofill.AutoFillValue);
    field public static final java.lang.String EXTRA_ASSIST_STRUCTURE = "android.view.autofill.extra.ASSIST_STRUCTURE";
    field public static final java.lang.String EXTRA_AUTHENTICATION_RESULT = "android.view.autofill.extra.AUTHENTICATION_RESULT";
+6 −2
Original line number Diff line number Diff line
@@ -45271,6 +45271,7 @@ package android.view {
    method public float getPivotX();
    method public float getPivotY();
    method public android.view.PointerIcon getPointerIcon();
    method public int getResolvedAutoFillMode();
    method public android.content.res.Resources getResources();
    method public final boolean getRevealOnFocusHint();
    method public final int getRight();
@@ -46225,6 +46226,7 @@ package android.view {
    method public abstract int getLayoutDirection();
    method public abstract android.view.ViewParent getParent();
    method public abstract android.view.ViewParent getParentForAccessibility();
    method public default int getResolvedAutoFillMode();
    method public abstract int getTextAlignment();
    method public abstract int getTextDirection();
    method public abstract deprecated void invalidateChild(android.view.View, android.graphics.Rect);
@@ -47577,10 +47579,12 @@ package android.view.autofill {
  }
  public final class AutoFillManager {
    method public void focusChanged(android.view.View, boolean);
    method public void reset();
    method public void startAutoFillRequest(android.view.View);
    method public void startAutoFillRequestOnVirtualView(android.view.View, int, android.graphics.Rect);
    method public void stopAutoFillRequest(android.view.View);
    method public void stopAutoFillRequestOnVirtualView(android.view.View, int);
    method public void valueChanged(android.view.View);
    method public void virtualFocusChanged(android.view.View, int, android.graphics.Rect, boolean);
    method public void virtualValueChanged(android.view.View, int, android.view.autofill.AutoFillValue);
    field public static final java.lang.String EXTRA_ASSIST_STRUCTURE = "android.view.autofill.extra.ASSIST_STRUCTURE";
    field public static final java.lang.String EXTRA_AUTHENTICATION_RESULT = "android.view.autofill.extra.AUTHENTICATION_RESULT";
+61 −11
Original line number Diff line number Diff line
@@ -953,7 +953,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    public @interface AutoFillMode {}
    /**
     * This view inherits the autofill state from it's parent. If there is no parent it is
     * This view inherits the auto-fill state from it's parent. If there is no parent it is
     * {@link #AUTO_FILL_MODE_AUTO}.
     * Use with {@link #setAutoFillMode(int)} and <a href="#attr_android:autoFillMode">
     * {@code android:autoFillMode}.
@@ -968,7 +968,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    public static final int AUTO_FILL_MODE_AUTO = 1;
    /**
     * Require the user to manually force an auto-fill request.
     * Do not trigger an auto-fill request if this view is focused. The user can still force
     * an auto-fill request.
     * <p>This does not prevent this field from being auto-filled if an auto-fill operation is
     * triggered from a different view.</p>
     *
     * Use with {@link #setAutoFillMode(int)} and <a href="#attr_android:autoFillMode">{@code
     * android:autoFillMode}.
     */
@@ -6670,13 +6674,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            imm.focusIn(this);
        }
        if (isAutoFillable()) {
            AutoFillManager afm = getAutoFillManager();
            if (afm != null) {
                afm.focusChanged(this, gainFocus);
            }
        }
        invalidate(true);
        ListenerInfo li = mListenerInfo;
        if (li != null && li.mOnFocusChangeListener != null) {
@@ -6686,6 +6683,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        if (mAttachInfo != null) {
            mAttachInfo.mKeyDispatchState.reset(this);
        }
        if (isAutoFillable() && isAttachedToWindow()
                && getResolvedAutoFillMode() == AUTO_FILL_MODE_AUTO) {
            AutoFillManager afm = getAutoFillManager();
            if (afm != null) {
                if (gainFocus) {
                    afm.startAutoFillRequest(this);
                } else {
                    afm.stopAutoFillRequest(this);
                }
            }
        }
    }
    /**
@@ -7248,8 +7257,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * <ol>
     * <li>Also implement {@link #autoFillVirtual(int, AutoFillValue)} to auto-fill the virtual
     * children.
     * <li>Call {@link android.view.autofill.AutoFillManager#virtualFocusChanged(View, int, Rect,
     * boolean)} when the focus inside the view changed.
     * <li>Call
     * {@link android.view.autofill.AutoFillManager#startAutoFillRequestOnVirtualView} and
     * {@link android.view.autofill.AutoFillManager#stopAutoFillRequestOnVirtualView(View, int)}
     * when the focus inside the view changed.
     * <li>Call {@link android.view.autofill.AutoFillManager#virtualValueChanged(View, int,
     * AutoFillValue)} when the value of a child changed.
     * <li>Call {@link android.view.autofill.AutoFillManager#reset()} when the auto-fill context
@@ -9483,6 +9494,31 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        return (mPrivateFlags3 & PFLAG3_AUTO_FILL_MODE_MASK) >> PFLAG3_AUTO_FILL_MODE_SHIFT;
    }
    /**
     * Returns the resolved auto-fill mode for this view.
     *
     * This is the same as {@link #getAutoFillMode()} but if the mode is
     * {@link #AUTO_FILL_MODE_INHERIT} the parents auto-fill mode will be returned.
     *
     * @return One of {@link #AUTO_FILL_MODE_AUTO}, or {@link #AUTO_FILL_MODE_MANUAL}. If the auto-
     *         fill mode can not be resolved e.g. {@link #getAutoFillMode()} is
     *         {@link #AUTO_FILL_MODE_INHERIT} and the {@link View} is detached
     *         {@link #AUTO_FILL_MODE_AUTO} is returned.
     */
    public @AutoFillMode int getResolvedAutoFillMode() {
        @AutoFillMode int autoFillMode = getAutoFillMode();
        if (autoFillMode == AUTO_FILL_MODE_INHERIT) {
            if (mParent == null) {
                return AUTO_FILL_MODE_AUTO;
            } else {
                return mParent.getResolvedAutoFillMode();
            }
        } else {
            return autoFillMode;
        }
    }
    /**
     * Find the nearest view in the specified direction that can take focus.
     * This does not actually give focus to that view.
@@ -16619,6 +16655,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            refreshDrawableState();
        }
        needGlobalAttributesUpdate(false);
        if (isAutoFillable() && isFocused() && getResolvedAutoFillMode() == AUTO_FILL_MODE_AUTO) {
            AutoFillManager afm = getAutoFillManager();
            if (afm != null) {
                afm.startAutoFillRequest(this);
            }
        }
    }
    void dispatchDetachedFromWindow() {
@@ -16665,6 +16708,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        if (mOverlay != null) {
            mOverlay.getOverlayView().dispatchDetachedFromWindow();
        }
        if (isAutoFillable() && isFocused() && getResolvedAutoFillMode() == AUTO_FILL_MODE_AUTO) {
            AutoFillManager afm = getAutoFillManager();
            if (afm != null) {
                afm.stopAutoFillRequest(this);
            }
        }
    }
    /**
+13 −0
Original line number Diff line number Diff line
@@ -659,4 +659,17 @@ public interface ViewParent {
     * @return true if the action was consumed by this ViewParent
     */
    public boolean onNestedPrePerformAccessibilityAction(View target, int action, Bundle arguments);

    /**
     * Return the resolved auto-fill mode.
     *
     * @return One of {@link View#AUTO_FILL_MODE_AUTO}, {@link View#AUTO_FILL_MODE_MANUAL} if the
     *         auto-fill mode can be resolved. If the auto-fill mode cannot be resolved
     *         {@link View#AUTO_FILL_MODE_AUTO}.
     *
     * @see View#getResolvedAutoFillMode()
     */
    default @View.AutoFillMode int getResolvedAutoFillMode() {
        return View.AUTO_FILL_MODE_AUTO;
    }
}
Loading