Accessibility focus should not clear selection when taken away.
1. Currently accessibility focus removal was clearing the selection
in the view - in particular the accessibility cursor position
which in the TextView case is the selection. This leads to a
scenario where the selection may be cleared when the app does
not explect. Further, the selection should not be cleared
since the user can be say several pages in the content and
removing and putting back accessibility focus would cause a
tedious traversal to get to the previous position.
bug:6469840
Change-Id: Iba3c01600fa2c9c39f99085a5fbc4328aa539ea8
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 9f5613e..8330193 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -6279,8 +6279,6 @@
invalidate();
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED);
notifyAccessibilityStateChanged();
- // Clear the text navigation state.
- setAccessibilityCursorPosition(ACCESSIBILITY_CURSOR_POSITION_UNDEFINED);
}
// Clear the global reference of accessibility focus if this
// view or any of its descendants had accessibility focus.
@@ -6327,7 +6325,6 @@
void clearAccessibilityFocusNoCallbacks() {
if ((mPrivateFlags2 & ACCESSIBILITY_FOCUSED) != 0) {
mPrivateFlags2 &= ~ACCESSIBILITY_FOCUSED;
- setAccessibilityCursorPosition(ACCESSIBILITY_CURSOR_POSITION_UNDEFINED);
invalidate();
}
}