Merge "Code cleanup."
diff --git a/core/java/android/view/ViewAncestor.java b/core/java/android/view/ViewAncestor.java
index 8085ea8..cf9a1c8 100644
--- a/core/java/android/view/ViewAncestor.java
+++ b/core/java/android/view/ViewAncestor.java
@@ -45,9 +45,7 @@
 import android.os.ParcelFileDescriptor;
 import android.os.Process;
 import android.os.RemoteException;
-import android.os.ServiceManager;
 import android.os.SystemClock;
-import android.os.SystemProperties;
 import android.util.AndroidRuntimeException;
 import android.util.DisplayMetrics;
 import android.util.EventLog;
@@ -672,6 +670,7 @@
         if (!mTraversalScheduled) {
             mTraversalScheduled = true;
 
+            //noinspection ConstantConditions
             if (ViewDebug.DEBUG_LATENCY && mLastTraversalFinishedTimeNanos != 0) {
                 final long now = System.nanoTime();
                 Log.d(TAG, "Latency: Scheduled traversal, it has been "
@@ -1909,20 +1908,22 @@
     public void focusableViewAvailable(View v) {
         checkThread();
 
-        if (mView != null && !mView.hasFocus()) {
-            v.requestFocus();
-        } else {
-            // the one case where will transfer focus away from the current one
-            // is if the current view is a view group that prefers to give focus
-            // to its children first AND the view is a descendant of it.
-            mFocusedView = mView.findFocus();
-            boolean descendantsHaveDibsOnFocus =
-                    (mFocusedView instanceof ViewGroup) &&
-                        (((ViewGroup) mFocusedView).getDescendantFocusability() ==
-                                ViewGroup.FOCUS_AFTER_DESCENDANTS);
-            if (descendantsHaveDibsOnFocus && isViewDescendantOf(v, mFocusedView)) {
-                // If a view gets the focus, the listener will be invoked from requestChildFocus()
+        if (mView != null) {
+            if (!mView.hasFocus()) {
                 v.requestFocus();
+            } else {
+                // the one case where will transfer focus away from the current one
+                // is if the current view is a view group that prefers to give focus
+                // to its children first AND the view is a descendant of it.
+                mFocusedView = mView.findFocus();
+                boolean descendantsHaveDibsOnFocus =
+                        (mFocusedView instanceof ViewGroup) &&
+                            (((ViewGroup) mFocusedView).getDescendantFocusability() ==
+                                    ViewGroup.FOCUS_AFTER_DESCENDANTS);
+                if (descendantsHaveDibsOnFocus && isViewDescendantOf(v, mFocusedView)) {
+                    // If a view gets the focus, the listener will be invoked from requestChildFocus()
+                    v.requestFocus();
+                }
             }
         }
     }
@@ -1986,9 +1987,7 @@
             // At this point the resources have been updated to
             // have the most recent config, whatever that is.  Use
             // the on in them which may be newer.
-            if (mView != null) {
-                config = mView.getResources().getConfiguration();
-            }
+            config = mView.getResources().getConfiguration();
             if (force || mLastConfiguration.diff(config) != 0) {
                 mLastConfiguration.setTo(config);
                 mView.dispatchConfigurationChanged(config);
@@ -2207,6 +2206,7 @@
             if ((event.getFlags()&KeyEvent.FLAG_FROM_SYSTEM) != 0) {
                 // The IME is trying to say this event is from the
                 // system!  Bad bad bad!
+                //noinspection UnusedAssignment
                 event = KeyEvent.changeFlags(event, event.getFlags() & ~KeyEvent.FLAG_FROM_SYSTEM);
             }
             deliverKeyEventPostIme((KeyEvent)msg.obj, false);
@@ -2240,7 +2240,7 @@
         }
     }
     
-    private void startInputEvent(InputEvent event, InputQueue.FinishedCallback finishedCallback) {
+    private void startInputEvent(InputQueue.FinishedCallback finishedCallback) {
         if (mFinishedCallback != null) {
             Slog.w(TAG, "Received a new input event from the input queue but there is "
                     + "already an unfinished input event in progress.");
@@ -2454,9 +2454,6 @@
         if (isDown) {
             ensureTouchMode(true);
         }
-        if(false) {
-            captureMotionLog("captureDispatchPointer", event);
-        }
 
         // Offset the scroll position.
         if (mCurScrollY != 0) {
@@ -2534,6 +2531,7 @@
         if (sendDone) {
             finishInputEvent(event, handled);
         }
+        //noinspection ConstantConditions
         if (LOCAL_LOGV || WATCH_POINTER) {
             if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
                 Log.i(TAG, "Done dispatching!");
@@ -2859,52 +2857,6 @@
         return false;
     }
 
-    /**
-     * log motion events
-     */
-    private static void captureMotionLog(String subTag, MotionEvent ev) {
-        //check dynamic switch
-        if (ev == null ||
-                SystemProperties.getInt(ViewDebug.SYSTEM_PROPERTY_CAPTURE_EVENT, 0) == 0) {
-            return;
-        }
-
-        StringBuilder sb = new StringBuilder(subTag + ": ");
-        sb.append(ev.getDownTime()).append(',');
-        sb.append(ev.getEventTime()).append(',');
-        sb.append(ev.getAction()).append(',');
-        sb.append(ev.getX()).append(',');
-        sb.append(ev.getY()).append(',');
-        sb.append(ev.getPressure()).append(',');
-        sb.append(ev.getSize()).append(',');
-        sb.append(ev.getMetaState()).append(',');
-        sb.append(ev.getXPrecision()).append(',');
-        sb.append(ev.getYPrecision()).append(',');
-        sb.append(ev.getDeviceId()).append(',');
-        sb.append(ev.getEdgeFlags());
-        Log.d(TAG, sb.toString());
-    }
-    /**
-     * log motion events
-     */
-    private static void captureKeyLog(String subTag, KeyEvent ev) {
-        //check dynamic switch
-        if (ev == null ||
-                SystemProperties.getInt(ViewDebug.SYSTEM_PROPERTY_CAPTURE_EVENT, 0) == 0) {
-            return;
-        }
-        StringBuilder sb = new StringBuilder(subTag + ": ");
-        sb.append(ev.getDownTime()).append(',');
-        sb.append(ev.getEventTime()).append(',');
-        sb.append(ev.getAction()).append(',');
-        sb.append(ev.getKeyCode()).append(',');
-        sb.append(ev.getRepeatCount()).append(',');
-        sb.append(ev.getMetaState()).append(',');
-        sb.append(ev.getDeviceId()).append(',');
-        sb.append(ev.getScanCode());
-        Log.d(TAG, sb.toString());
-    }
-
     int enqueuePendingEvent(Object event, boolean sendDone) {
         int seq = mPendingEventSeq+1;
         if (seq < 0) seq = 0;
@@ -2993,10 +2945,6 @@
             return;
         }
 
-        if (false) {
-            captureKeyLog("captureDispatchKeyEvent", event);
-        }
-
         // Make sure the fallback event policy sees all keys that will be delivered to the
         // view hierarchy.
         mFallbackEventHandler.preDispatchKeyEvent(event);
@@ -3392,12 +3340,12 @@
     
     private final InputHandler mInputHandler = new InputHandler() {
         public void handleKey(KeyEvent event, InputQueue.FinishedCallback finishedCallback) {
-            startInputEvent(event, finishedCallback);
+            startInputEvent(finishedCallback);
             dispatchKey(event, true);
         }
 
         public void handleMotion(MotionEvent event, InputQueue.FinishedCallback finishedCallback) {
-            startInputEvent(event, finishedCallback);
+            startInputEvent(finishedCallback);
             dispatchMotion(event, true);
         }
     };
@@ -3429,10 +3377,6 @@
         sendMessageAtTime(msg, event.getEventTime());
     }
     
-    public void dispatchMotion(MotionEvent event) {
-        dispatchMotion(event, false);
-    }
-
     private void dispatchMotion(MotionEvent event, boolean sendDone) {
         int source = event.getSource();
         if ((source & InputDevice.SOURCE_CLASS_POINTER) != 0) {
@@ -3444,10 +3388,6 @@
         }
     }
 
-    public void dispatchPointer(MotionEvent event) {
-        dispatchPointer(event, false);
-    }
-
     private void dispatchPointer(MotionEvent event, boolean sendDone) {
         Message msg = obtainMessage(DISPATCH_POINTER);
         msg.obj = event;
@@ -3455,10 +3395,6 @@
         sendMessageAtTime(msg, event.getEventTime());
     }
 
-    public void dispatchTrackball(MotionEvent event) {
-        dispatchTrackball(event, false);
-    }
-
     private void dispatchTrackball(MotionEvent event, boolean sendDone) {
         Message msg = obtainMessage(DISPATCH_TRACKBALL);
         msg.obj = event;
diff --git a/core/java/android/view/ViewDebug.java b/core/java/android/view/ViewDebug.java
index 4aa8727..f014070 100644
--- a/core/java/android/view/ViewDebug.java
+++ b/core/java/android/view/ViewDebug.java
@@ -92,12 +92,6 @@
     public static final boolean TRACE_RECYCLER = false;
 
     /**
-     * The system property of dynamic switch for capturing event information
-     * when it is set, we log key events, touch/motion and trackball events
-     */
-    static final String SYSTEM_PROPERTY_CAPTURE_EVENT = "debug.captureevent";
-
-    /**
      * Profiles drawing times in the events log.
      *
      * @hide