Don't remove all animation callbacks if action/who was null.

Fixes a bug in View.removeCallbacks and View.unscheduleDrawable
where it was possible for the caller to remove all animation
callbacks if it happened to specify an action or who parameter
of null.

Also refactored the callback queueing code in Choreographer
to make it more intent revealing although the behavior remains
the same.

Bug: 6144688
Change-Id: Iba29dcda6b3aaad73af664bb63feab65ae3483e5
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index a651362..61660b9 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -8852,13 +8852,15 @@
      *         (for instance, if the Runnable was not in the queue already.)
      */
     public boolean removeCallbacks(Runnable action) {
-        final AttachInfo attachInfo = mAttachInfo;
-        if (attachInfo != null) {
-            attachInfo.mHandler.removeCallbacks(action);
-            attachInfo.mViewRootImpl.mChoreographer.removeAnimationCallbacks(action, null);
-        } else {
-            // Assume that post will succeed later
-            ViewRootImpl.getRunQueue().removeCallbacks(action);
+        if (action != null) {
+            final AttachInfo attachInfo = mAttachInfo;
+            if (attachInfo != null) {
+                attachInfo.mHandler.removeCallbacks(action);
+                attachInfo.mViewRootImpl.mChoreographer.removeAnimationCallbacks(action, null);
+            } else {
+                // Assume that post will succeed later
+                ViewRootImpl.getRunQueue().removeCallbacks(action);
+            }
         }
         return true;
     }
@@ -11963,7 +11965,7 @@
      * @see #drawableStateChanged
      */
     public void unscheduleDrawable(Drawable who) {
-        if (mAttachInfo != null) {
+        if (mAttachInfo != null && who != null) {
             mAttachInfo.mViewRootImpl.mChoreographer.removeAnimationCallbacks(null, who);
         }
     }