diff options
| author | 2019-10-31 11:26:20 -0700 | |
|---|---|---|
| committer | 2019-10-31 12:38:03 -0700 | |
| commit | c9cb2e8307b50ea1867e898123b66af46f64bbdd (patch) | |
| tree | 3286da22c19a03da4a8421c7772d880ffc075b12 | |
| parent | 6de324573079d2060a315ee20990f67b4d5c240d (diff) | |
Make getStateDescription() in View none final
Do not make getStateDescription final, since it can cause
compatibility issues with existing derived classes that define
a getStateDescription. Also replaced call to
getContentDescription() to mContentDescription. This is because
if a subclass overrides it, we don't want it to affect the value
used in accessibility service (cause divergence in accessibility
event and accessibilityNodeInfo).
Bug: 143652980
Test: no needed
Change-Id: I36c94c85eb258b3c9474090d841c925331d22d73
| -rw-r--r-- | api/current.txt | 2 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 15 |
2 files changed, 9 insertions, 8 deletions
diff --git a/api/current.txt b/api/current.txt index 2cf1f44ebb6c..d8355ede4456 100644 --- a/api/current.txt +++ b/api/current.txt @@ -50659,7 +50659,7 @@ package android.view { method public final int getScrollY(); method @android.view.ViewDebug.ExportedProperty(category="drawing") @ColorInt public int getSolidColor(); method @LayoutRes public int getSourceLayoutResId(); - method @android.view.ViewDebug.ExportedProperty(category="accessibility") @Nullable public final CharSequence getStateDescription(); + method @android.view.ViewDebug.ExportedProperty(category="accessibility") @Nullable public CharSequence getStateDescription(); method public android.animation.StateListAnimator getStateListAnimator(); method protected int getSuggestedMinimumHeight(); method protected int getSuggestedMinimumWidth(); diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 1599afb358e0..b90ce876aeb3 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -8727,7 +8727,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, structure.setContextClickable(true); } structure.setClassName(getAccessibilityClassName().toString()); - structure.setContentDescription(getContentDescription()); + structure.setContentDescription(mContentDescription); } /** @@ -9934,8 +9934,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, info.setImportantForAccessibility(isImportantForAccessibility()); info.setPackageName(mContext.getPackageName()); info.setClassName(getAccessibilityClassName()); - info.setStateDescription(getStateDescription()); - info.setContentDescription(getContentDescription()); + info.setStateDescription(mStateDescription); + info.setContentDescription(mContentDescription); info.setEnabled(isEnabled()); info.setClickable(isClickable()); @@ -10318,7 +10318,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @see #setStateDescription(CharSequence) */ @ViewDebug.ExportedProperty(category = "accessibility") - public final @Nullable CharSequence getStateDescription() { + public @Nullable CharSequence getStateDescription() { return mStateDescription; } @@ -13724,7 +13724,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ @UnsupportedAppUsage public CharSequence getIterableTextForAccessibility() { - return getContentDescription(); + return mContentDescription; } /** @@ -29514,9 +29514,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, stream.addProperty("text:textAlignment", getTextAlignment()); // accessibility - CharSequence contentDescription = getContentDescription(); stream.addProperty("accessibility:contentDescription", - contentDescription == null ? "" : contentDescription.toString()); + mContentDescription == null ? "" : mContentDescription.toString()); + stream.addProperty("accessibility:stateDescription", + mStateDescription == null ? "" : mStateDescription.toString()); stream.addProperty("accessibility:labelFor", getLabelFor()); stream.addProperty("accessibility:importantForAccessibility", getImportantForAccessibility()); } |