API REVIEW: android.view.accessibility

1. Changed all references to granularity to movement
   granularity. BTW, to be more precise it should be
   text movement granularity.

bug:6435232

Change-Id: If6366b002ca3390f74918995b342baff2cbcfd01
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 4def387..2b961a8 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4715,10 +4715,10 @@
         }
 
         if (getContentDescription() != null) {
-            info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_GRANULARITY);
-            info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_GRANULARITY);
-            info.setGranularities(AccessibilityNodeInfo.GRANULARITY_CHARACTER
-                    | AccessibilityNodeInfo.GRANULARITY_WORD);
+            info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
+            info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
+            info.setMovementGranularities(AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
+                    | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD);
         }
     }
 
diff --git a/core/java/android/view/accessibility/AccessibilityEvent.java b/core/java/android/view/accessibility/AccessibilityEvent.java
index 6d1166e..f70ffa9 100644
--- a/core/java/android/view/accessibility/AccessibilityEvent.java
+++ b/core/java/android/view/accessibility/AccessibilityEvent.java
@@ -226,9 +226,9 @@
  *   <li>{@link #getContentDescription()} - The content description of the source.</li>
  * </ul>
  * </p>
- * <b>View text traversed at granularity</b> - represents the event of traversing the
+ * <b>View text traversed at movement granularity</b> - represents the event of traversing the
  * text of a view at a given granularity. For example, moving to the next word.</br>
- * <em>Type:</em> {@link #TYPE_VIEW_TEXT_TRAVERSED_AT_GRANULARITY} </br>
+ * <em>Type:</em> {@link #TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY} </br>
  * <em>Properties:</em></br>
  * <ul>
  *   <li>{@link #getEventType()} - The type of the event.</li>
@@ -236,11 +236,12 @@
  *   <li>{@link #getClassName()} - The class name of the source.</li>
  *   <li>{@link #getPackageName()} - The package name of the source.</li>
  *   <li>{@link #getEventTime()}  - The event time.</li>
- *   <li>{@link #getText()} - The text of the current text at the granularity.</li>
+ *   <li>{@link #getText()} - The text of the current text at the movement granularity.</li>
  *   <li>{@link #isPassword()} - Whether the source is password.</li>
  *   <li>{@link #isEnabled()} - Whether the source is enabled.</li>
  *   <li>{@link #getContentDescription()} - The content description of the source.</li>
- *   <li>{@link #getGranularity()} - Sets the granularity at which a view's text was traversed.</li>
+ *   <li>{@link #getMovementGranularity()} - Sets the granularity at which a view's text
+ *       was traversed.</li>
  * </ul>
  * </p>
  * <p>
@@ -597,9 +598,9 @@
     public static final int TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED = 0x00010000;
 
     /**
-     * Represents the event of traversing the text of a view at a given granularity.
+     * Represents the event of traversing the text of a view at a given movement granularity.
      */
-    public static final int TYPE_VIEW_TEXT_TRAVERSED_AT_GRANULARITY = 0x00020000;
+    public static final int TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY = 0x00020000;
 
     /**
      * Mask for {@link AccessibilityEvent} all types.
@@ -619,7 +620,7 @@
      * @see #TYPE_VIEW_SCROLLED
      * @see #TYPE_VIEW_TEXT_SELECTION_CHANGED
      * @see #TYPE_ANNOUNCEMENT
-     * @see #TYPE_VIEW_TEXT_TRAVERSED_AT_GRANULARITY
+     * @see #TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY
      */
     public static final int TYPES_ALL_MASK = 0xFFFFFFFF;
 
@@ -633,7 +634,7 @@
     private int mEventType;
     private CharSequence mPackageName;
     private long mEventTime;
-    int mGranularity;
+    int mMovementGranularity;
 
     private final ArrayList<AccessibilityRecord> mRecords = new ArrayList<AccessibilityRecord>();
 
@@ -651,7 +652,7 @@
     void init(AccessibilityEvent event) {
         super.init(event);
         mEventType = event.mEventType;
-        mGranularity = event.mGranularity;
+        mMovementGranularity = event.mMovementGranularity;
         mEventTime = event.mEventTime;
         mPackageName = event.mPackageName;
     }
@@ -769,24 +770,24 @@
     }
 
     /**
-     * Sets the text granularity that was traversed.
+     * Sets the movement granularity that was traversed.
      *
      * @param granularity The granularity.
      *
      * @throws IllegalStateException If called from an AccessibilityService.
      */
-    public void setGranularity(int granularity) {
+    public void setMovementGranularity(int granularity) {
         enforceNotSealed();
-        mGranularity = granularity;
+        mMovementGranularity = granularity;
     }
 
     /**
-     * Gets the text granularity that was traversed.
+     * Gets the movement granularity that was traversed.
      *
      * @return The granularity.
      */
-    public int getGranularity() {
-        return mGranularity;
+    public int getMovementGranularity() {
+        return mMovementGranularity;
     }
 
     /**
@@ -877,7 +878,7 @@
     protected void clear() {
         super.clear();
         mEventType = 0;
-        mGranularity = 0;
+        mMovementGranularity = 0;
         mPackageName = null;
         mEventTime = 0;
         while (!mRecords.isEmpty()) {
@@ -894,7 +895,7 @@
     public void initFromParcel(Parcel parcel) {
         mSealed = (parcel.readInt() == 1);
         mEventType = parcel.readInt();
-        mGranularity = parcel.readInt();
+        mMovementGranularity = parcel.readInt();
         mPackageName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel);
         mEventTime = parcel.readLong();
         mConnectionId = parcel.readInt();
@@ -945,7 +946,7 @@
     public void writeToParcel(Parcel parcel, int flags) {
         parcel.writeInt(isSealed() ? 1 : 0);
         parcel.writeInt(mEventType);
-        parcel.writeInt(mGranularity);
+        parcel.writeInt(mMovementGranularity);
         TextUtils.writeToParcel(mPackageName, parcel, 0);
         parcel.writeLong(mEventTime);
         parcel.writeInt(mConnectionId);
@@ -1002,7 +1003,7 @@
         builder.append("EventType: ").append(eventTypeToString(mEventType));
         builder.append("; EventTime: ").append(mEventTime);
         builder.append("; PackageName: ").append(mPackageName);
-        builder.append("; Granularity: ").append(mGranularity);
+        builder.append("; MovementGranularity: ").append(mMovementGranularity);
         builder.append(super.toString());
         if (DEBUG) {
             builder.append("\n");
@@ -1083,8 +1084,8 @@
                 return "TYPE_VIEW_ACCESSIBILITY_FOCUSED";
             case TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED:
                 return "TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED";
-            case TYPE_VIEW_TEXT_TRAVERSED_AT_GRANULARITY:
-                return "TYPE_CURRENT_AT_GRANULARITY_CHANGED";
+            case TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY:
+                return "TYPE_CURRENT_AT_GRANULARITY_MOVEMENT_CHANGED";
             default:
                 return null;
         }
diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
index 5266c83..c0696a9 100644
--- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java
+++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
@@ -123,53 +123,56 @@
 
     /**
      * Action that requests to go to the next entity in this node's text
-     * at a given granularity. For example, move to the next character, word, etc.
+     * at a given movement granularity. For example, move to the next character,
+     * word, etc.
      * <p>
-     * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_GRANULARITY_INT}<br>
+     * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<br>
      * <strong>Example:</strong>
      * <code><pre><p>
      *   Bundle arguments = new Bundle();
-     *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_GRANULARITY_INT,
-     *           AccessibilityNodeInfo.GRANULARITY_CHARACTER);
-     *   info.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_GRANULARITY, arguments);
+     *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
+     *           AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
+     *   info.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
      * </code></pre></p>
      * </p>
      *
-     * @see #setGranularities(int)
-     * @see #getGranularities()
+     * @see #setMovementGranularities(int)
+     * @see #getMovementGranularities()
      *
-     * @see #GRANULARITY_CHARACTER
-     * @see #GRANULARITY_WORD
-     * @see #GRANULARITY_LINE
-     * @see #GRANULARITY_PARAGRAPH
-     * @see #GRANULARITY_PAGE
+     * @see #MOVEMENT_GRANULARITY_CHARACTER
+     * @see #MOVEMENT_GRANULARITY_WORD
+     * @see #MOVEMENT_GRANULARITY_LINE
+     * @see #MOVEMENT_GRANULARITY_PARAGRAPH
+     * @see #MOVEMENT_GRANULARITY_PAGE
      */
-    public static final int ACTION_NEXT_AT_GRANULARITY = 0x00000100;
+    public static final int ACTION_NEXT_AT_MOVEMENT_GRANULARITY = 0x00000100;
 
     /**
      * Action that requests to go to the previous entity in this node's text
-     * at a given granularity. For example, move to the next character, word, etc.
+     * at a given movement granularity. For example, move to the next character,
+     * word, etc.
      * <p>
-     * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_GRANULARITY_INT}<br>
+     * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<br>
      * <strong>Example:</strong>
      * <code><pre><p>
      *   Bundle arguments = new Bundle();
-     *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_GRANULARITY_INT,
-     *           AccessibilityNodeInfo.GRANULARITY_CHARACTER);
-     *   info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_GRANULARITY, arguments);
+     *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
+     *           AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
+     *   info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
+     *           arguments);
      * </code></pre></p>
      * </p>
      *
-     * @see #setGranularities(int)
-     * @see #getGranularities()
+     * @see #setMovementGranularities(int)
+     * @see #getMovementGranularities()
      *
-     * @see #GRANULARITY_CHARACTER
-     * @see #GRANULARITY_WORD
-     * @see #GRANULARITY_LINE
-     * @see #GRANULARITY_PARAGRAPH
-     * @see #GRANULARITY_PAGE
+     * @see #MOVEMENT_GRANULARITY_CHARACTER
+     * @see #MOVEMENT_GRANULARITY_WORD
+     * @see #MOVEMENT_GRANULARITY_LINE
+     * @see #MOVEMENT_GRANULARITY_PARAGRAPH
+     * @see #MOVEMENT_GRANULARITY_PAGE
      */
-    public static final int ACTION_PREVIOUS_AT_GRANULARITY = 0x00000200;
+    public static final int ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY = 0x00000200;
 
     /**
      * Action to move to the next HTML element of a given type. For example, move
@@ -202,14 +205,15 @@
     public static final int ACTION_PREVIOUS_HTML_ELEMENT = 0x00000800;
 
     /**
-     * Argument for which text granularity to be used when traversing the node text.
+     * Argument for which movement granularity to be used when traversing the node text.
      * <p>
      * <strong>Type:</strong> int<br>
-     * <strong>Actions:</strong> {@link #ACTION_NEXT_AT_GRANULARITY},
-     * {@link #ACTION_PREVIOUS_AT_GRANULARITY}
+     * <strong>Actions:</strong> {@link #ACTION_NEXT_AT_MOVEMENT_GRANULARITY},
+     * {@link #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY}
      * </p>
      */
-    public static final String ACTION_ARGUMENT_GRANULARITY_INT = "ACTION_ARGUMENT_GRANULARITY_INT";
+    public static final String ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT =
+        "ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT";
 
     /**
      * Argument for which HTML element to get moving to the next/previous HTML element.
@@ -232,32 +236,32 @@
      */
     public static final int FOCUS_ACCESSIBILITY = 2;
 
-    // Granularities
+    // Movement granularities
 
     /**
-     * Granularity bit for traversing the text of a node by character.
+     * Movement granularity bit for traversing the text of a node by character.
      */
-    public static final int GRANULARITY_CHARACTER = 0x00000001;
+    public static final int MOVEMENT_GRANULARITY_CHARACTER = 0x00000001;
 
     /**
-     * Granularity bit for traversing the text of a node by word.
+     * Movement granularity bit for traversing the text of a node by word.
      */
-    public static final int GRANULARITY_WORD = 0x00000002;
+    public static final int MOVEMENT_GRANULARITY_WORD = 0x00000002;
 
     /**
-     * Granularity bit for traversing the text of a node by line.
+     * Movement granularity bit for traversing the text of a node by line.
      */
-    public static final int GRANULARITY_LINE = 0x00000004;
+    public static final int MOVEMENT_GRANULARITY_LINE = 0x00000004;
 
     /**
-     * Granularity bit for traversing the text of a node by paragraph.
+     * Movement granularity bit for traversing the text of a node by paragraph.
      */
-    public static final int GRANULARITY_PARAGRAPH = 0x00000008;
+    public static final int MOVEMENT_GRANULARITY_PARAGRAPH = 0x00000008;
 
     /**
-     * Granularity bit for traversing the text of a node by page.
+     * Movement granularity bit for traversing the text of a node by page.
      */
-    public static final int GRANULARITY_PAGE = 0x00000010;
+    public static final int MOVEMENT_GRANULARITY_PAGE = 0x00000010;
 
     // Boolean attributes.
 
@@ -362,7 +366,7 @@
     private final SparseLongArray mChildNodeIds = new SparseLongArray();
     private int mActions;
 
-    private int mGranularities;
+    private int mMovementGranularities;
 
     private int mConnectionId = UNDEFINED;
 
@@ -586,7 +590,7 @@
     }
 
     /**
-     * Sets the text granularities for traversing the text of this node.
+     * Sets the movement granularities for traversing the text of this node.
      * <p>
      *   <strong>Note:</strong> Cannot be called from an
      *   {@link android.accessibilityservice.AccessibilityService}.
@@ -597,18 +601,18 @@
      *
      * @throws IllegalStateException If called from an AccessibilityService.
      */
-    public void setGranularities(int granularities) {
+    public void setMovementGranularities(int granularities) {
         enforceNotSealed();
-        mGranularities = granularities;
+        mMovementGranularities = granularities;
     }
 
     /**
-     * Gets the granularities for traversing the text of this node.
+     * Gets the movement granularities for traversing the text of this node.
      *
      * @return The bit mask with granularities.
      */
-    public int getGranularities() {
-        return mGranularities;
+    public int getMovementGranularities() {
+        return mMovementGranularities;
     }
 
     /**
@@ -1412,7 +1416,7 @@
 
         parcel.writeInt(mActions);
 
-        parcel.writeInt(mGranularities);
+        parcel.writeInt(mMovementGranularities);
 
         parcel.writeInt(mBooleanProperties);
 
@@ -1446,7 +1450,7 @@
         mContentDescription = other.mContentDescription;
         mActions= other.mActions;
         mBooleanProperties = other.mBooleanProperties;
-        mGranularities = other.mGranularities;
+        mMovementGranularities = other.mMovementGranularities;
         final int otherChildIdCount = other.mChildNodeIds.size();
         for (int i = 0; i < otherChildIdCount; i++) {
             mChildNodeIds.put(i, other.mChildNodeIds.valueAt(i));    
@@ -1484,7 +1488,7 @@
 
         mActions = parcel.readInt();
 
-        mGranularities = parcel.readInt();
+        mMovementGranularities = parcel.readInt();
 
         mBooleanProperties = parcel.readInt();
 
@@ -1503,7 +1507,7 @@
         mParentNodeId = ROOT_NODE_ID;
         mWindowId = UNDEFINED;
         mConnectionId = UNDEFINED;
-        mGranularities = 0;
+        mMovementGranularities = 0;
         mChildNodeIds.clear();
         mBoundsInParent.set(0, 0, 0, 0);
         mBoundsInScreen.set(0, 0, 0, 0);
@@ -1539,10 +1543,10 @@
                 return "ACTION_ACCESSIBILITY_FOCUS";
             case ACTION_CLEAR_ACCESSIBILITY_FOCUS:
                 return "ACTION_CLEAR_ACCESSIBILITY_FOCUS";
-            case ACTION_NEXT_AT_GRANULARITY:
-                return "ACTION_NEXT_AT_GRANULARITY";
-            case ACTION_PREVIOUS_AT_GRANULARITY:
-                return "ACTION_PREVIOUS_AT_GRANULARITY";
+            case ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
+                return "ACTION_NEXT_AT_MOVEMENT_GRANULARITY";
+            case ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
+                return "ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY";
             case ACTION_NEXT_HTML_ELEMENT:
                 return "ACTION_NEXT_HTML_ELEMENT";
             case ACTION_PREVIOUS_HTML_ELEMENT:
@@ -1553,25 +1557,25 @@
     }
 
     /**
-     * Gets the human readable granularity symbolic name.
+     * Gets the human readable movement granularity symbolic name.
      *
-     * @param granularity The action.
+     * @param granularity The granularity.
      * @return The symbolic name.
      */
-    private static String getGranularitySymbolicName(int granularity) {
+    private static String getMovementGranularitySymbolicName(int granularity) {
         switch (granularity) {
-            case GRANULARITY_CHARACTER:
-                return "GRANULARITY_CHARACTER";
-            case GRANULARITY_WORD:
-                return "GRANULARITY_WORD";
-            case GRANULARITY_LINE:
-                return "GRANULARITY_LINE";
-            case GRANULARITY_PARAGRAPH:
-                return "GRANULARITY_PARAGRAPH";
-            case GRANULARITY_PAGE:
-                return "GRANULARITY_PAGE";
+            case MOVEMENT_GRANULARITY_CHARACTER:
+                return "MOVEMENT_GRANULARITY_CHARACTER";
+            case MOVEMENT_GRANULARITY_WORD:
+                return "MOVEMENT_GRANULARITY_WORD";
+            case MOVEMENT_GRANULARITY_LINE:
+                return "MOVEMENT_GRANULARITY_LINE";
+            case MOVEMENT_GRANULARITY_PARAGRAPH:
+                return "MOVEMENT_GRANULARITY_PARAGRAPH";
+            case MOVEMENT_GRANULARITY_PAGE:
+                return "MOVEMENT_GRANULARITY_PAGE";
             default:
-                throw new IllegalArgumentException("Unknown granularity: " + granularity);
+                throw new IllegalArgumentException("Unknown movement granularity: " + granularity);
         }
     }
 
@@ -1622,12 +1626,12 @@
             builder.append("; virtualDescendantId: " + getVirtualDescendantId(mSourceNodeId));
             builder.append("; mParentNodeId: " + mParentNodeId);
 
-            int granularities = mGranularities;
-            builder.append("; granularities: [");
+            int granularities = mMovementGranularities;
+            builder.append("; MovementGranularities: [");
             while (granularities != 0) {
                 final int granularity = 1 << Integer.numberOfTrailingZeros(granularities);
                 granularities &= ~granularity;
-                builder.append(getGranularitySymbolicName(granularity));
+                builder.append(getMovementGranularitySymbolicName(granularity));
                 if (granularities != 0) {
                     builder.append(", ");
                 }