Prevent TextView refocus on escape key press

Bug: 329598550
Bug: 312921137
Test: atest android.widget.cts.TextViewTest
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:47824b93f3f67b11dffceaa2d00712f2f7f25d6c)
Merged-In: Ied159ac0b514a9815e7ac1e5d3328bbfa243e547
Change-Id: Ied159ac0b514a9815e7ac1e5d3328bbfa243e547
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 828004b..0ced3a6 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -8430,8 +8430,9 @@
      *            hierarchy
      * @param refocus when propagate is true, specifies whether to request the
      *            root view place new focus
+     * @hide
      */
-    void clearFocusInternal(View focused, boolean propagate, boolean refocus) {
+    public void clearFocusInternal(View focused, boolean propagate, boolean refocus) {
         if ((mPrivateFlags & PFLAG_FOCUSED) != 0) {
             mPrivateFlags &= ~PFLAG_FOCUSED;
             clearParentsWantFocus();
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 1721462..92dcf88 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -9733,7 +9733,7 @@
                         return KEY_EVENT_HANDLED;
                     }
                     if (hasFocus()) {
-                        clearFocus();
+                        clearFocusInternal(null, /* propagate */ true, /* refocus */ false);
                         InputMethodManager imm = getInputMethodManager();
                         if (imm != null) {
                             imm.hideSoftInputFromView(this, 0);