From db7da0eb8b7d515c168d5b410764e24c9a0f9431 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Mon, 22 Apr 2013 18:34:02 -0700 Subject: Fixing bugs exposed when moving accessibility CTS tests to UiAutomation. 1. UiAutomation#executeAndWaitForEvent method was invoking the passed runnable while holding the lock which may lead to a deadlock. For example: a runnable that calls getActivity() gets us into a state like this. 2. UI automation services did not get all capabilities such a service can have. Now a UI test service gets all of them. 3. When UiAutomation was exiting for event fired as a result of a performed action, it was checking whether the received evnet time is strictly before the time of executing the command that should fire the event. However, if the execution is fast enough, i.e. less than one millisecond, then the event time and the execution time are the same. This was leading to a missed signal in rare cases. 4. AccessibilityNodeInfoCache was not clearing the relevant state for accessibility focus clearing event. 5. Accessibility text traversal in TextView was partially using text and partially content description - broken. Now we are using the text since for text view and content desc for other views. In other words, we are using the most precise text we have. 6. AccessibilityManagerService was not granting capabilities of a UiAutomation service - plainly wrong. CTS change:https://googleplex-android-review.googlesource.com/#/c/300693/ bug:8695422 bug:8657560 Change-Id: I9afc5c3c69eb51f1c01930959232f44681b15e86 --- core/java/android/widget/TextView.java | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'core/java/android/widget/TextView.java') diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 1246051a09bf..9e3f87f447bc 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -8042,7 +8042,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener info.setEditable(true); } - if (TextUtils.isEmpty(getContentDescription()) && !TextUtils.isEmpty(mText)) { + if (!TextUtils.isEmpty(mText)) { info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY); info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY); info.setMovementGranularities(AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER @@ -8051,6 +8051,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE); } + if (isFocused()) { if (canSelectText()) { info.addAction(AccessibilityNodeInfo.ACTION_SET_SELECTION); @@ -8655,13 +8656,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener */ @Override public CharSequence getIterableTextForAccessibility() { - if (!TextUtils.isEmpty(mText)) { - if (!(mText instanceof Spannable)) { - setText(mText, BufferType.SPANNABLE); - } - return mText; + if (!(mText instanceof Spannable)) { + setText(mText, BufferType.SPANNABLE); } - return super.getIterableTextForAccessibility(); + return mText; } /** @@ -8697,13 +8695,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener */ @Override public int getAccessibilitySelectionStart() { - if (TextUtils.isEmpty(getContentDescription())) { - final int selectionStart = getSelectionStart(); - if (selectionStart >= 0) { - return selectionStart; - } - } - return ACCESSIBILITY_CURSOR_POSITION_UNDEFINED; + return getSelectionStart(); } /** @@ -8718,13 +8710,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener */ @Override public int getAccessibilitySelectionEnd() { - if (TextUtils.isEmpty(getContentDescription())) { - final int selectionEnd = getSelectionEnd(); - if (selectionEnd >= 0) { - return selectionEnd; - } - } - return ACCESSIBILITY_CURSOR_POSITION_UNDEFINED; + return getSelectionEnd(); } /** -- cgit v1.2.3