A11y: Prevent utterance from resetting RemoteInputView

Fixes a bug where the RemoteInputView would issue an
utterance upon resetting the view because it was not
hidden at that point.

Change-Id: I3f80b903c0b3e55c308bda8d4f18aa0b586aa328
Fixes: 30103313
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
index cdd452f..ab2a8bc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
@@ -38,6 +38,7 @@
 import android.view.ViewAnimationUtils;
 import android.view.ViewGroup;
 import android.view.ViewParent;
+import android.view.accessibility.AccessibilityEvent;
 import android.view.inputmethod.CompletionInfo;
 import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.InputConnection;
@@ -86,6 +87,8 @@
     private int mRevealCy;
     private int mRevealR;
 
+    private boolean mResetting;
+
     public RemoteInputView(Context context, AttributeSet attrs) {
         super(context, attrs);
     }
@@ -281,6 +284,8 @@
     }
 
     private void reset() {
+        mResetting = true;
+
         mEditText.getText().clear();
         mEditText.setEnabled(true);
         mSendButton.setVisibility(VISIBLE);
@@ -288,6 +293,19 @@
         mController.removeSpinning(mEntry.key);
         updateSendButton();
         onDefocus(false /* animate */);
+
+        mResetting = false;
+    }
+
+    @Override
+    public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
+        if (mResetting && child == mEditText) {
+            // Suppress text events if it happens during resetting. Ideally this would be
+            // suppressed by the text view not being shown, but that doesn't work here because it
+            // needs to stay visible for the animation.
+            return false;
+        }
+        return super.onRequestSendAccessibilityEvent(child, event);
     }
 
     private void updateSendButton() {