am 093318ee: Merge "Add importantForAccessibility mode to block entire hierarchy" into klp-dev

* commit '093318eeac4fd839c722a902612c2f00e1da2f71':
  Add importantForAccessibility mode to block entire hierarchy
This commit is contained in:
Alan Viverette
2013-10-03 13:35:23 -07:00
committed by Android Git Automerger
4 changed files with 41 additions and 20 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -2120,6 +2120,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.
*/
@@ -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:
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);
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;
}
parent = parent.getParent();
}
return mode == IMPORTANT_FOR_ACCESSIBILITY_YES || isActionableForAccessibility()
|| hasListenersForAccessibility() || getAccessibilityNodeProvider() != null
|| getAccessibilityLiveRegion() != ACCESSIBILITY_LIVE_REGION_NONE;
}
/**

View File

@@ -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