Use ALOGD_IF in TouchInputMapper

This makes the code a little easier to read.

Bug: none
Test: enable the DEBUG_ parameters, check the logs appear
Change-Id: I6f307a7572ff512e8b5d02cbf90889e22544a4e7
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index 924c4d0..2ebbd37 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -1524,14 +1524,13 @@
         assignPointerIds(last, next);
     }
 
-    if (DEBUG_RAW_EVENTS) {
-        ALOGD("syncTouch: pointerCount %d -> %d, touching ids 0x%08x -> 0x%08x, "
-              "hovering ids 0x%08x -> 0x%08x, canceled ids 0x%08x",
-              last.rawPointerData.pointerCount, next.rawPointerData.pointerCount,
-              last.rawPointerData.touchingIdBits.value, next.rawPointerData.touchingIdBits.value,
-              last.rawPointerData.hoveringIdBits.value, next.rawPointerData.hoveringIdBits.value,
-              next.rawPointerData.canceledIdBits.value);
-    }
+    ALOGD_IF(DEBUG_RAW_EVENTS,
+             "syncTouch: pointerCount %d -> %d, touching ids 0x%08x -> 0x%08x, "
+             "hovering ids 0x%08x -> 0x%08x, canceled ids 0x%08x",
+             last.rawPointerData.pointerCount, next.rawPointerData.pointerCount,
+             last.rawPointerData.touchingIdBits.value, next.rawPointerData.touchingIdBits.value,
+             last.rawPointerData.hoveringIdBits.value, next.rawPointerData.hoveringIdBits.value,
+             next.rawPointerData.canceledIdBits.value);
 
     if (!next.rawPointerData.touchingIdBits.isEmpty() &&
         !next.rawPointerData.hoveringIdBits.isEmpty() &&
@@ -1585,9 +1584,8 @@
             nsecs_t when = mExternalStylusFusionTimeout - STYLUS_DATA_LATENCY;
             clearStylusDataPendingFlags();
             mCurrentRawState.copyFrom(mLastRawState);
-            if (DEBUG_STYLUS_FUSION) {
-                ALOGD("Timeout expired, synthesizing event with new stylus data");
-            }
+            ALOGD_IF(DEBUG_STYLUS_FUSION,
+                     "Timeout expired, synthesizing event with new stylus data");
             const nsecs_t readTime = when; // consider this synthetic event to be zero latency
             cookAndDispatch(when, readTime);
         } else if (mExternalStylusFusionTimeout == LLONG_MAX) {
@@ -1773,24 +1771,18 @@
             state.rawPointerData.pointerCount != 0;
     if (initialDown) {
         if (mExternalStylusState.pressure != 0.0f) {
-            if (DEBUG_STYLUS_FUSION) {
-                ALOGD("Have both stylus and touch data, beginning fusion");
-            }
+            ALOGD_IF(DEBUG_STYLUS_FUSION, "Have both stylus and touch data, beginning fusion");
             mExternalStylusId = state.rawPointerData.touchingIdBits.firstMarkedBit();
         } else if (timeout) {
-            if (DEBUG_STYLUS_FUSION) {
-                ALOGD("Timeout expired, assuming touch is not a stylus.");
-            }
+            ALOGD_IF(DEBUG_STYLUS_FUSION, "Timeout expired, assuming touch is not a stylus.");
             resetExternalStylus();
         } else {
             if (mExternalStylusFusionTimeout == LLONG_MAX) {
                 mExternalStylusFusionTimeout = state.when + EXTERNAL_STYLUS_DATA_TIMEOUT;
             }
-            if (DEBUG_STYLUS_FUSION) {
-                ALOGD("No stylus data but stylus is connected, requesting timeout "
-                      "(%" PRId64 "ms)",
-                      mExternalStylusFusionTimeout);
-            }
+            ALOGD_IF(DEBUG_STYLUS_FUSION,
+                     "No stylus data but stylus is connected, requesting timeout (%" PRId64 "ms)",
+                     mExternalStylusFusionTimeout);
             getContext()->requestTimeoutAtTime(mExternalStylusFusionTimeout);
             return true;
         }
@@ -1798,9 +1790,7 @@
 
     // Check if the stylus pointer has gone up.
     if (mExternalStylusId != -1 && !state.rawPointerData.touchingIdBits.hasBit(mExternalStylusId)) {
-        if (DEBUG_STYLUS_FUSION) {
-            ALOGD("Stylus pointer is going up");
-        }
+        ALOGD_IF(DEBUG_STYLUS_FUSION, "Stylus pointer is going up");
         mExternalStylusId = -1;
     }
 
@@ -1841,10 +1831,9 @@
             // Pointer went up while virtual key was down.
             mCurrentVirtualKey.down = false;
             if (!mCurrentVirtualKey.ignored) {
-                if (DEBUG_VIRTUAL_KEYS) {
-                    ALOGD("VirtualKeys: Generating key up: keyCode=%d, scanCode=%d",
-                          mCurrentVirtualKey.keyCode, mCurrentVirtualKey.scanCode);
-                }
+                ALOGD_IF(DEBUG_VIRTUAL_KEYS,
+                         "VirtualKeys: Generating key up: keyCode=%d, scanCode=%d",
+                         mCurrentVirtualKey.keyCode, mCurrentVirtualKey.scanCode);
                 dispatchVirtualKey(when, readTime, policyFlags, AKEY_EVENT_ACTION_UP,
                                    AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY);
             }
@@ -1868,10 +1857,8 @@
         // into the main display surface.
         mCurrentVirtualKey.down = false;
         if (!mCurrentVirtualKey.ignored) {
-            if (DEBUG_VIRTUAL_KEYS) {
-                ALOGD("VirtualKeys: Canceling key: keyCode=%d, scanCode=%d",
-                      mCurrentVirtualKey.keyCode, mCurrentVirtualKey.scanCode);
-            }
+            ALOGD_IF(DEBUG_VIRTUAL_KEYS, "VirtualKeys: Canceling key: keyCode=%d, scanCode=%d",
+                     mCurrentVirtualKey.keyCode, mCurrentVirtualKey.scanCode);
             dispatchVirtualKey(when, readTime, policyFlags, AKEY_EVENT_ACTION_UP,
                                AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY |
                                        AKEY_EVENT_FLAG_CANCELED);
@@ -1901,10 +1888,9 @@
                                                                virtualKey->scanCode);
 
                     if (!mCurrentVirtualKey.ignored) {
-                        if (DEBUG_VIRTUAL_KEYS) {
-                            ALOGD("VirtualKeys: Generating key down: keyCode=%d, scanCode=%d",
-                                  mCurrentVirtualKey.keyCode, mCurrentVirtualKey.scanCode);
-                        }
+                        ALOGD_IF(DEBUG_VIRTUAL_KEYS,
+                                 "VirtualKeys: Generating key down: keyCode=%d, scanCode=%d",
+                                 mCurrentVirtualKey.keyCode, mCurrentVirtualKey.scanCode);
                         dispatchVirtualKey(when, readTime, policyFlags, AKEY_EVENT_ACTION_DOWN,
                                            AKEY_EVENT_FLAG_FROM_SYSTEM |
                                                    AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY);
@@ -2696,9 +2682,7 @@
 
     // Handle TAP timeout.
     if (isTimeout) {
-        if (DEBUG_GESTURES) {
-            ALOGD("Gestures: Processing timeout");
-        }
+        ALOGD_IF(DEBUG_GESTURES, "Gestures: Processing timeout");
 
         if (mPointerGesture.lastGestureMode == PointerGesture::Mode::TAP) {
             if (when <= mPointerGesture.tapUpTime + mConfig.pointerGestureTapDragInterval) {
@@ -2707,9 +2691,7 @@
                                                    mConfig.pointerGestureTapDragInterval);
             } else {
                 // The tap is finished.
-                if (DEBUG_GESTURES) {
-                    ALOGD("Gestures: TAP finished");
-                }
+                ALOGD_IF(DEBUG_GESTURES, "Gestures: TAP finished");
                 *outFinishPreviousGesture = true;
 
                 mPointerGesture.activeGestureId = -1;
@@ -2805,11 +2787,9 @@
     // Switch states based on button and pointer state.
     if (isQuietTime) {
         // Case 1: Quiet time. (QUIET)
-        if (DEBUG_GESTURES) {
-            ALOGD("Gestures: QUIET for next %0.3fms",
-                  (mPointerGesture.quietTime + mConfig.pointerGestureQuietInterval - when) *
-                          0.000001f);
-        }
+        ALOGD_IF(DEBUG_GESTURES, "Gestures: QUIET for next %0.3fms",
+                 (mPointerGesture.quietTime + mConfig.pointerGestureQuietInterval - when) *
+                         0.000001f);
         if (mPointerGesture.lastGestureMode != PointerGesture::Mode::QUIET) {
             *outFinishPreviousGesture = true;
         }
@@ -2833,11 +2813,9 @@
         // active.  If the user first puts one finger down to click then adds another
         // finger to drag then the active pointer should switch to the finger that is
         // being dragged.
-        if (DEBUG_GESTURES) {
-            ALOGD("Gestures: BUTTON_CLICK_OR_DRAG activeTouchId=%d, "
-                  "currentFingerCount=%d",
-                  activeTouchId, currentFingerCount);
-        }
+        ALOGD_IF(DEBUG_GESTURES,
+                 "Gestures: BUTTON_CLICK_OR_DRAG activeTouchId=%d, currentFingerCount=%d",
+                 activeTouchId, currentFingerCount);
         // Reset state when just starting.
         if (mPointerGesture.lastGestureMode != PointerGesture::Mode::BUTTON_CLICK_OR_DRAG) {
             *outFinishPreviousGesture = true;
@@ -2862,11 +2840,10 @@
             }
             if (bestId >= 0 && bestId != activeTouchId) {
                 mPointerGesture.activeTouchId = activeTouchId = bestId;
-                if (DEBUG_GESTURES) {
-                    ALOGD("Gestures: BUTTON_CLICK_OR_DRAG switched pointers, "
-                          "bestId=%d, bestSpeed=%0.3f",
-                          bestId, bestSpeed);
-                }
+                ALOGD_IF(DEBUG_GESTURES,
+                         "Gestures: BUTTON_CLICK_OR_DRAG switched pointers, bestId=%d, "
+                         "bestSpeed=%0.3f",
+                         bestId, bestSpeed);
             }
         }
 
@@ -2921,9 +2898,7 @@
                 mPointerController->getPosition(&x, &y);
                 if (fabs(x - mPointerGesture.tapX) <= mConfig.pointerGestureTapSlop &&
                     fabs(y - mPointerGesture.tapY) <= mConfig.pointerGestureTapSlop) {
-                    if (DEBUG_GESTURES) {
-                        ALOGD("Gestures: TAP");
-                    }
+                    ALOGD_IF(DEBUG_GESTURES, "Gestures: TAP");
 
                     mPointerGesture.tapUpTime = when;
                     getContext()->requestTimeoutAtTime(when +
@@ -2949,10 +2924,8 @@
 
                     tapped = true;
                 } else {
-                    if (DEBUG_GESTURES) {
-                        ALOGD("Gestures: Not a TAP, deltaX=%f, deltaY=%f", x - mPointerGesture.tapX,
-                              y - mPointerGesture.tapY);
-                    }
+                    ALOGD_IF(DEBUG_GESTURES, "Gestures: Not a TAP, deltaX=%f, deltaY=%f",
+                             x - mPointerGesture.tapX, y - mPointerGesture.tapY);
                 }
             } else {
                 if (DEBUG_GESTURES) {
@@ -2969,9 +2942,7 @@
         mPointerVelocityControl.reset();
 
         if (!tapped) {
-            if (DEBUG_GESTURES) {
-                ALOGD("Gestures: NEUTRAL");
-            }
+            ALOGD_IF(DEBUG_GESTURES, "Gestures: NEUTRAL");
             mPointerGesture.activeGestureId = -1;
             mPointerGesture.currentGestureMode = PointerGesture::Mode::NEUTRAL;
             mPointerGesture.currentGestureIdBits.clear();
@@ -2992,16 +2963,12 @@
                     fabs(y - mPointerGesture.tapY) <= mConfig.pointerGestureTapSlop) {
                     mPointerGesture.currentGestureMode = PointerGesture::Mode::TAP_DRAG;
                 } else {
-                    if (DEBUG_GESTURES) {
-                        ALOGD("Gestures: Not a TAP_DRAG, deltaX=%f, deltaY=%f",
-                              x - mPointerGesture.tapX, y - mPointerGesture.tapY);
-                    }
+                    ALOGD_IF(DEBUG_GESTURES, "Gestures: Not a TAP_DRAG, deltaX=%f, deltaY=%f",
+                             x - mPointerGesture.tapX, y - mPointerGesture.tapY);
                 }
             } else {
-                if (DEBUG_GESTURES) {
-                    ALOGD("Gestures: Not a TAP_DRAG, %0.3fms time since up",
-                          (when - mPointerGesture.tapUpTime) * 0.000001f);
-                }
+                ALOGD_IF(DEBUG_GESTURES, "Gestures: Not a TAP_DRAG, %0.3fms time since up",
+                         (when - mPointerGesture.tapUpTime) * 0.000001f);
             }
         } else if (mPointerGesture.lastGestureMode == PointerGesture::Mode::TAP_DRAG) {
             mPointerGesture.currentGestureMode = PointerGesture::Mode::TAP_DRAG;
@@ -3028,14 +2995,10 @@
 
         bool down;
         if (mPointerGesture.currentGestureMode == PointerGesture::Mode::TAP_DRAG) {
-            if (DEBUG_GESTURES) {
-                ALOGD("Gestures: TAP_DRAG");
-            }
+            ALOGD_IF(DEBUG_GESTURES, "Gestures: TAP_DRAG");
             down = true;
         } else {
-            if (DEBUG_GESTURES) {
-                ALOGD("Gestures: HOVER");
-            }
+            ALOGD_IF(DEBUG_GESTURES, "Gestures: HOVER");
             if (mPointerGesture.lastGestureMode != PointerGesture::Mode::HOVER) {
                 *outFinishPreviousGesture = true;
             }
@@ -3089,13 +3052,12 @@
         } else if (!settled && currentFingerCount > lastFingerCount) {
             // Additional pointers have gone down but not yet settled.
             // Reset the gesture.
-            if (DEBUG_GESTURES) {
-                ALOGD("Gestures: Resetting gesture since additional pointers went down for "
-                      "MULTITOUCH, settle time remaining %0.3fms",
-                      (mPointerGesture.firstTouchTime +
-                       mConfig.pointerGestureMultitouchSettleInterval - when) *
-                              0.000001f);
-            }
+            ALOGD_IF(DEBUG_GESTURES,
+                     "Gestures: Resetting gesture since additional pointers went down for "
+                     "MULTITOUCH, settle time remaining %0.3fms",
+                     (mPointerGesture.firstTouchTime +
+                      mConfig.pointerGestureMultitouchSettleInterval - when) *
+                             0.000001f);
             *outCancelPreviousGesture = true;
         } else {
             // Continue previous gesture.
@@ -3109,13 +3071,12 @@
             mPointerVelocityControl.reset();
 
             // Use the centroid and pointer location as the reference points for the gesture.
-            if (DEBUG_GESTURES) {
-                ALOGD("Gestures: Using centroid as reference for MULTITOUCH, "
-                      "settle time remaining %0.3fms",
-                      (mPointerGesture.firstTouchTime +
-                       mConfig.pointerGestureMultitouchSettleInterval - when) *
-                              0.000001f);
-            }
+            ALOGD_IF(DEBUG_GESTURES,
+                     "Gestures: Using centroid as reference for MULTITOUCH, settle time remaining "
+                     "%0.3fms",
+                     (mPointerGesture.firstTouchTime +
+                      mConfig.pointerGestureMultitouchSettleInterval - when) *
+                             0.000001f);
             mCurrentRawState.rawPointerData
                     .getCentroidOfTouchingPointers(&mPointerGesture.referenceTouchX,
                                                    &mPointerGesture.referenceTouchY);
@@ -3173,10 +3134,9 @@
             if (distOverThreshold >= 2) {
                 if (currentFingerCount > 2) {
                     // There are more than two pointers, switch to FREEFORM.
-                    if (DEBUG_GESTURES) {
-                        ALOGD("Gestures: PRESS transitioned to FREEFORM, number of pointers %d > 2",
-                              currentFingerCount);
-                    }
+                    ALOGD_IF(DEBUG_GESTURES,
+                             "Gestures: PRESS transitioned to FREEFORM, number of pointers %d > 2",
+                             currentFingerCount);
                     *outCancelPreviousGesture = true;
                     mPointerGesture.currentGestureMode = PointerGesture::Mode::FREEFORM;
                 } else {
@@ -3192,11 +3152,9 @@
                     if (mutualDistance > mPointerGestureMaxSwipeWidth) {
                         // There are two pointers but they are too far apart for a SWIPE,
                         // switch to FREEFORM.
-                        if (DEBUG_GESTURES) {
-                            ALOGD("Gestures: PRESS transitioned to FREEFORM, distance %0.3f > "
-                                  "%0.3f",
-                                  mutualDistance, mPointerGestureMaxSwipeWidth);
-                        }
+                        ALOGD_IF(DEBUG_GESTURES,
+                                 "Gestures: PRESS transitioned to FREEFORM, distance %0.3f > %0.3f",
+                                 mutualDistance, mPointerGestureMaxSwipeWidth);
                         *outCancelPreviousGesture = true;
                         mPointerGesture.currentGestureMode = PointerGesture::Mode::FREEFORM;
                     } else {
@@ -3221,25 +3179,23 @@
                             float cosine = dot / (dist1 * dist2); // denominator always > 0
                             if (cosine >= mConfig.pointerGestureSwipeTransitionAngleCosine) {
                                 // Pointers are moving in the same direction.  Switch to SWIPE.
-                                if (DEBUG_GESTURES) {
-                                    ALOGD("Gestures: PRESS transitioned to SWIPE, "
-                                          "dist1 %0.3f >= %0.3f, dist2 %0.3f >= %0.3f, "
-                                          "cosine %0.3f >= %0.3f",
-                                          dist1, mConfig.pointerGestureMultitouchMinDistance, dist2,
-                                          mConfig.pointerGestureMultitouchMinDistance, cosine,
-                                          mConfig.pointerGestureSwipeTransitionAngleCosine);
-                                }
+                                ALOGD_IF(DEBUG_GESTURES,
+                                         "Gestures: PRESS transitioned to SWIPE, "
+                                         "dist1 %0.3f >= %0.3f, dist2 %0.3f >= %0.3f, "
+                                         "cosine %0.3f >= %0.3f",
+                                         dist1, mConfig.pointerGestureMultitouchMinDistance, dist2,
+                                         mConfig.pointerGestureMultitouchMinDistance, cosine,
+                                         mConfig.pointerGestureSwipeTransitionAngleCosine);
                                 mPointerGesture.currentGestureMode = PointerGesture::Mode::SWIPE;
                             } else {
                                 // Pointers are moving in different directions.  Switch to FREEFORM.
-                                if (DEBUG_GESTURES) {
-                                    ALOGD("Gestures: PRESS transitioned to FREEFORM, "
-                                          "dist1 %0.3f >= %0.3f, dist2 %0.3f >= %0.3f, "
-                                          "cosine %0.3f < %0.3f",
-                                          dist1, mConfig.pointerGestureMultitouchMinDistance, dist2,
-                                          mConfig.pointerGestureMultitouchMinDistance, cosine,
-                                          mConfig.pointerGestureSwipeTransitionAngleCosine);
-                                }
+                                ALOGD_IF(DEBUG_GESTURES,
+                                         "Gestures: PRESS transitioned to FREEFORM, "
+                                         "dist1 %0.3f >= %0.3f, dist2 %0.3f >= %0.3f, "
+                                         "cosine %0.3f < %0.3f",
+                                         dist1, mConfig.pointerGestureMultitouchMinDistance, dist2,
+                                         mConfig.pointerGestureMultitouchMinDistance, cosine,
+                                         mConfig.pointerGestureSwipeTransitionAngleCosine);
                                 *outCancelPreviousGesture = true;
                                 mPointerGesture.currentGestureMode = PointerGesture::Mode::FREEFORM;
                             }
@@ -3251,10 +3207,9 @@
             // Switch from SWIPE to FREEFORM if additional pointers go down.
             // Cancel previous gesture.
             if (currentFingerCount > 2) {
-                if (DEBUG_GESTURES) {
-                    ALOGD("Gestures: SWIPE transitioned to FREEFORM, number of pointers %d > 2",
-                          currentFingerCount);
-                }
+                ALOGD_IF(DEBUG_GESTURES,
+                         "Gestures: SWIPE transitioned to FREEFORM, number of pointers %d > 2",
+                         currentFingerCount);
                 *outCancelPreviousGesture = true;
                 mPointerGesture.currentGestureMode = PointerGesture::Mode::FREEFORM;
             }
@@ -3288,11 +3243,10 @@
         if (mPointerGesture.currentGestureMode == PointerGesture::Mode::PRESS ||
             mPointerGesture.currentGestureMode == PointerGesture::Mode::SWIPE) {
             // PRESS or SWIPE mode.
-            if (DEBUG_GESTURES) {
-                ALOGD("Gestures: PRESS or SWIPE activeTouchId=%d,"
-                      "activeGestureId=%d, currentTouchPointerCount=%d",
-                      activeTouchId, mPointerGesture.activeGestureId, currentFingerCount);
-            }
+            ALOGD_IF(DEBUG_GESTURES,
+                     "Gestures: PRESS or SWIPE activeTouchId=%d, activeGestureId=%d, "
+                     "currentTouchPointerCount=%d",
+                     activeTouchId, mPointerGesture.activeGestureId, currentFingerCount);
             ALOG_ASSERT(mPointerGesture.activeGestureId >= 0);
 
             mPointerGesture.currentGestureIdBits.clear();
@@ -3309,11 +3263,10 @@
             mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
         } else if (mPointerGesture.currentGestureMode == PointerGesture::Mode::FREEFORM) {
             // FREEFORM mode.
-            if (DEBUG_GESTURES) {
-                ALOGD("Gestures: FREEFORM activeTouchId=%d,"
-                      "activeGestureId=%d, currentTouchPointerCount=%d",
-                      activeTouchId, mPointerGesture.activeGestureId, currentFingerCount);
-            }
+            ALOGD_IF(DEBUG_GESTURES,
+                     "Gestures: FREEFORM activeTouchId=%d, activeGestureId=%d, "
+                     "currentTouchPointerCount=%d",
+                     activeTouchId, mPointerGesture.activeGestureId, currentFingerCount);
             ALOG_ASSERT(mPointerGesture.activeGestureId >= 0);
 
             mPointerGesture.currentGestureIdBits.clear();
@@ -3352,13 +3305,11 @@
                 }
             }
 
-            if (DEBUG_GESTURES) {
-                ALOGD("Gestures: FREEFORM follow up "
-                      "mappedTouchIdBits=0x%08x, usedGestureIdBits=0x%08x, "
-                      "activeGestureId=%d",
-                      mappedTouchIdBits.value, usedGestureIdBits.value,
-                      mPointerGesture.activeGestureId);
-            }
+            ALOGD_IF(DEBUG_GESTURES,
+                     "Gestures: FREEFORM follow up mappedTouchIdBits=0x%08x, "
+                     "usedGestureIdBits=0x%08x, activeGestureId=%d",
+                     mappedTouchIdBits.value, usedGestureIdBits.value,
+                     mPointerGesture.activeGestureId);
 
             BitSet32 idBits(mCurrentCookedState.fingerIdBits);
             for (uint32_t i = 0; i < currentFingerCount; i++) {
@@ -3367,18 +3318,14 @@
                 if (!mappedTouchIdBits.hasBit(touchId)) {
                     gestureId = usedGestureIdBits.markFirstUnmarkedBit();
                     mPointerGesture.freeformTouchToGestureIdMap[touchId] = gestureId;
-                    if (DEBUG_GESTURES) {
-                        ALOGD("Gestures: FREEFORM "
-                              "new mapping for touch id %d -> gesture id %d",
-                              touchId, gestureId);
-                    }
+                    ALOGD_IF(DEBUG_GESTURES,
+                             "Gestures: FREEFORM new mapping for touch id %d -> gesture id %d",
+                             touchId, gestureId);
                 } else {
                     gestureId = mPointerGesture.freeformTouchToGestureIdMap[touchId];
-                    if (DEBUG_GESTURES) {
-                        ALOGD("Gestures: FREEFORM "
-                              "existing mapping for touch id %d -> gesture id %d",
-                              touchId, gestureId);
-                    }
+                    ALOGD_IF(DEBUG_GESTURES,
+                             "Gestures: FREEFORM existing mapping for touch id %d -> gesture id %d",
+                             touchId, gestureId);
                 }
                 mPointerGesture.currentGestureIdBits.markBit(gestureId);
                 mPointerGesture.currentGestureIdToIndex[gestureId] = i;
@@ -3407,10 +3354,8 @@
             if (mPointerGesture.activeGestureId < 0) {
                 mPointerGesture.activeGestureId =
                         mPointerGesture.currentGestureIdBits.firstMarkedBit();
-                if (DEBUG_GESTURES) {
-                    ALOGD("Gestures: FREEFORM new activeGestureId=%d",
-                          mPointerGesture.activeGestureId);
-                }
+                ALOGD_IF(DEBUG_GESTURES, "Gestures: FREEFORM new activeGestureId=%d",
+                         mPointerGesture.activeGestureId);
             }
         }
     }
@@ -3820,12 +3765,11 @@
 
 const TouchInputMapper::VirtualKey* TouchInputMapper::findVirtualKeyHit(int32_t x, int32_t y) {
     for (const VirtualKey& virtualKey : mVirtualKeys) {
-        if (DEBUG_VIRTUAL_KEYS) {
-            ALOGD("VirtualKeys: Hit test (%d, %d): keyCode=%d, scanCode=%d, "
-                  "left=%d, top=%d, right=%d, bottom=%d",
-                  x, y, virtualKey.keyCode, virtualKey.scanCode, virtualKey.hitLeft,
-                  virtualKey.hitTop, virtualKey.hitRight, virtualKey.hitBottom);
-        }
+        ALOGD_IF(DEBUG_VIRTUAL_KEYS,
+                 "VirtualKeys: Hit test (%d, %d): keyCode=%d, scanCode=%d, "
+                 "left=%d, top=%d, right=%d, bottom=%d",
+                 x, y, virtualKey.keyCode, virtualKey.scanCode, virtualKey.hitLeft,
+                 virtualKey.hitTop, virtualKey.hitRight, virtualKey.hitBottom);
 
         if (virtualKey.isHit(x, y)) {
             return &virtualKey;
@@ -3996,11 +3940,10 @@
                                                      currentPointerIndex));
             usedIdBits.markBit(id);
 
-            if (DEBUG_POINTER_ASSIGNMENT) {
-                ALOGD("assignPointerIds - matched: cur=%" PRIu32 ", last=%" PRIu32 ", id=%" PRIu32
-                      ", distance=%" PRIu64,
-                      lastPointerIndex, currentPointerIndex, id, heap[0].distance);
-            }
+            ALOGD_IF(DEBUG_POINTER_ASSIGNMENT,
+                     "assignPointerIds - matched: cur=%" PRIu32 ", last=%" PRIu32 ", id=%" PRIu32
+                     ", distance=%" PRIu64,
+                     lastPointerIndex, currentPointerIndex, id, heap[0].distance);
             break;
         }
     }
@@ -4015,10 +3958,9 @@
         current.rawPointerData.markIdBit(id,
                                          current.rawPointerData.isHovering(currentPointerIndex));
 
-        if (DEBUG_POINTER_ASSIGNMENT) {
-            ALOGD("assignPointerIds - assigned: cur=%" PRIu32 ", id=%" PRIu32, currentPointerIndex,
-                  id);
-        }
+        ALOGD_IF(DEBUG_POINTER_ASSIGNMENT,
+                 "assignPointerIds - assigned: cur=%" PRIu32 ", id=%" PRIu32, currentPointerIndex,
+                 id);
     }
 }