summaryrefslogtreecommitdiff
path: root/core/java/android/view/View.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/view/View.java')
-rw-r--r--core/java/android/view/View.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 172ad8da5381..7d2d77e251a9 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -66,6 +66,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
+import android.os.Message;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
@@ -4380,6 +4381,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
@Nullable
private RoundScrollbarRenderer mRoundScrollbarRenderer;
+ /** Used to delay visibility updates sent to the autofill manager */
+ private Handler mVisibilityChangeForAutofillHandler;
+
/**
* Simple constructor to use when creating a view from code.
*
@@ -11696,6 +11700,30 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
if (fg != null && isVisible != fg.isVisible()) {
fg.setVisible(isVisible, false);
}
+
+ if (isAutofillable()) {
+ AutofillManager afm = getAutofillManager();
+
+ if (afm != null && getAccessibilityViewId() > LAST_APP_ACCESSIBILITY_ID) {
+ if (mVisibilityChangeForAutofillHandler != null) {
+ mVisibilityChangeForAutofillHandler.removeMessages(0);
+ }
+
+ // If the view is in the background but still part of the hierarchy this is called
+ // with isVisible=false. Hence visibility==false requires further checks
+ if (isVisible) {
+ afm.notifyViewVisibilityChange(this, true);
+ } else {
+ if (mVisibilityChangeForAutofillHandler == null) {
+ mVisibilityChangeForAutofillHandler =
+ new VisibilityChangeForAutofillHandler(afm, this);
+ }
+ // Let current operation (e.g. removal of the view from the hierarchy)
+ // finish before checking state
+ mVisibilityChangeForAutofillHandler.obtainMessage(0, this).sendToTarget();
+ }
+ }
+ }
}
/**
@@ -24492,6 +24520,27 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
}
/**
+ * When a view becomes invisible checks if autofill considers the view invisible too. This
+ * happens after the regular removal operation to make sure the operation is finished by the
+ * time this is called.
+ */
+ private static class VisibilityChangeForAutofillHandler extends Handler {
+ private final AutofillManager mAfm;
+ private final View mView;
+
+ private VisibilityChangeForAutofillHandler(@NonNull AutofillManager afm,
+ @NonNull View view) {
+ mAfm = afm;
+ mView = view;
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ mAfm.notifyViewVisibilityChange(mView, mView.isShown());
+ }
+ }
+
+ /**
* Base class for derived classes that want to save and restore their own
* state in {@link android.view.View#onSaveInstanceState()}.
*/