diff options
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | core/java/android/accessibilityservice/AccessibilityServiceInfo.java | 11 | ||||
-rw-r--r-- | core/java/android/view/View.java | 44 | ||||
-rw-r--r-- | core/res/res/values/attrs.xml | 3 |
4 files changed, 40 insertions, 19 deletions
diff --git a/api/current.txt b/api/current.txt index e8f4204..b8447af 100644 --- a/api/current.txt +++ b/api/current.txt @@ -28337,6 +28337,7 @@ package android.view { field public static final int HAPTIC_FEEDBACK_ENABLED = 268435456; // 0x10000000 field public static final int IMPORTANT_FOR_ACCESSIBILITY_AUTO = 0; // 0x0 field public static final int IMPORTANT_FOR_ACCESSIBILITY_NO = 2; // 0x2 + field public static final int IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS = 4; // 0x4 field public static final int IMPORTANT_FOR_ACCESSIBILITY_YES = 1; // 0x1 field public static final int INVISIBLE = 4; // 0x4 field public static final int KEEP_SCREEN_ON = 67108864; // 0x4000000 diff --git a/core/java/android/accessibilityservice/AccessibilityServiceInfo.java b/core/java/android/accessibilityservice/AccessibilityServiceInfo.java index 059945f..bdc4fdd 100644 --- a/core/java/android/accessibilityservice/AccessibilityServiceInfo.java +++ b/core/java/android/accessibilityservice/AccessibilityServiceInfo.java @@ -178,12 +178,13 @@ public class AccessibilityServiceInfo implements Parcelable { * If this flag is set the system will regard views that are not important * for accessibility in addition to the ones that are important for accessibility. * That is, views that are marked as not important for accessibility via - * {@link View#IMPORTANT_FOR_ACCESSIBILITY_NO} and views that are marked as - * potentially important for accessibility via + * {@link View#IMPORTANT_FOR_ACCESSIBILITY_NO} or + * {@link View#IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS} and views that are + * marked as potentially important for accessibility via * {@link View#IMPORTANT_FOR_ACCESSIBILITY_AUTO} for which the system has determined - * that are not important for accessibility, are both reported while querying the - * window content and also the accessibility service will receive accessibility events - * from them. + * that are not important for accessibility, are reported while querying the window + * content and also the accessibility service will receive accessibility events from + * them. * <p> * <strong>Note:</strong> For accessibility services targeting API version * {@link Build.VERSION_CODES#JELLY_BEAN} or higher this flag has to be explicitly diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 06f00f7..f763d19 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -2121,6 +2121,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, public static final int IMPORTANT_FOR_ACCESSIBILITY_NO = 0x00000002; /** + * The view is not important for accessibility, nor are any of its + * descendant views. + */ + public static final int IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS = 0x00000004; + + /** * The default whether the view is important for accessibility. */ static final int IMPORTANT_FOR_ACCESSIBILITY_DEFAULT = IMPORTANT_FOR_ACCESSIBILITY_AUTO; @@ -2130,14 +2136,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * whether a view is important for accessibility. */ static final int PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK = (IMPORTANT_FOR_ACCESSIBILITY_AUTO - | IMPORTANT_FOR_ACCESSIBILITY_YES | IMPORTANT_FOR_ACCESSIBILITY_NO) + | IMPORTANT_FOR_ACCESSIBILITY_YES | IMPORTANT_FOR_ACCESSIBILITY_NO + | IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) << PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT; /** * Shift for the bits in {@link #mPrivateFlags2} related to the * "accessibilityLiveRegion" attribute. */ - static final int PFLAG2_ACCESSIBILITY_LIVE_REGION_SHIFT = 22; + static final int PFLAG2_ACCESSIBILITY_LIVE_REGION_SHIFT = 23; /** * Live region mode specifying that accessibility services should not @@ -6999,12 +7006,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @see #IMPORTANT_FOR_ACCESSIBILITY_YES * @see #IMPORTANT_FOR_ACCESSIBILITY_NO + * @see #IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO */ @ViewDebug.ExportedProperty(category = "accessibility", mapping = { @ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_AUTO, to = "auto"), @ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_YES, to = "yes"), - @ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_NO, to = "no") + @ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_NO, to = "no"), + @ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, + to = "noHideDescendants") }) public int getImportantForAccessibility() { return (mPrivateFlags2 & PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK) @@ -7074,6 +7084,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @see #IMPORTANT_FOR_ACCESSIBILITY_YES * @see #IMPORTANT_FOR_ACCESSIBILITY_NO + * @see #IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO */ public void setImportantForAccessibility(int mode) { @@ -7101,19 +7112,24 @@ public class View implements Drawable.Callback, KeyEvent.Callback, public boolean isImportantForAccessibility() { final int mode = (mPrivateFlags2 & PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK) >> PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT; - switch (mode) { - case IMPORTANT_FOR_ACCESSIBILITY_YES: - return true; - case IMPORTANT_FOR_ACCESSIBILITY_NO: + if (mode == IMPORTANT_FOR_ACCESSIBILITY_NO + || mode == IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) { + return false; + } + + // Check parent mode to ensure we're not hidden. + ViewParent parent = mParent; + while (parent instanceof View) { + if (((View) parent).getImportantForAccessibility() + == IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) { return false; - case IMPORTANT_FOR_ACCESSIBILITY_AUTO: - return isActionableForAccessibility() || hasListenersForAccessibility() - || getAccessibilityNodeProvider() != null - || getAccessibilityLiveRegion() != ACCESSIBILITY_LIVE_REGION_NONE; - default: - throw new IllegalArgumentException("Unknow important for accessibility mode: " - + mode); + } + parent = parent.getParent(); } + + return mode == IMPORTANT_FOR_ACCESSIBILITY_YES || isActionableForAccessibility() + || hasListenersForAccessibility() || getAccessibilityNodeProvider() != null + || getAccessibilityLiveRegion() != ACCESSIBILITY_LIVE_REGION_NONE; } /** diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 275afb8..c3dc4ff 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -2182,6 +2182,9 @@ <enum name="yes" value="1" /> <!-- The view is not important for accessibility. --> <enum name="no" value="2" /> + <!-- The view is not important for accessibility, nor are any of its descendant + views. --> + <enum name="noHideDescendants" value="4" /> </attr> <!-- Indicates to accessibility services whether the user should be notified when |