Remove InputConsumer, replacing with InputQueue.

Change-Id: Ib06907278457aaee842b123adc072840ca3602d8
diff --git a/api/current.xml b/api/current.xml
index 37538c3..f8c644e 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -26330,7 +26330,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<implements name="android.view.InputConsumer.Callback">
+<implements name="android.view.InputQueue.Callback">
 </implements>
 <implements name="android.view.SurfaceHolder.Callback">
 </implements>
@@ -26342,7 +26342,7 @@
  visibility="public"
 >
 </constructor>
-<method name="onInputConsumerCreated"
+<method name="onInputQueueCreated"
  return="void"
  abstract="false"
  native="false"
@@ -26352,10 +26352,10 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="consumer" type="android.view.InputConsumer">
+<parameter name="queue" type="android.view.InputQueue">
 </parameter>
 </method>
-<method name="onInputConsumerDestroyed"
+<method name="onInputQueueDestroyed"
  return="void"
  abstract="false"
  native="false"
@@ -26365,7 +26365,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="consumer" type="android.view.InputConsumer">
+<parameter name="queue" type="android.view.InputQueue">
 </parameter>
 </method>
 <method name="surfaceChanged"
@@ -172775,23 +172775,23 @@
 </parameter>
 </constructor>
 </class>
-<class name="InputConsumer"
+<class name="InputQueue"
  extends="java.lang.Object"
  abstract="false"
  static="false"
- final="false"
+ final="true"
  deprecated="not deprecated"
  visibility="public"
 >
 </class>
-<interface name="InputConsumer.Callback"
+<interface name="InputQueue.Callback"
  abstract="true"
  static="true"
  final="false"
  deprecated="not deprecated"
  visibility="public"
 >
-<method name="onInputConsumerCreated"
+<method name="onInputQueueCreated"
  return="void"
  abstract="true"
  native="false"
@@ -172801,10 +172801,10 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="consumer" type="android.view.InputConsumer">
+<parameter name="queue" type="android.view.InputQueue">
 </parameter>
 </method>
-<method name="onInputConsumerDestroyed"
+<method name="onInputQueueDestroyed"
  return="void"
  abstract="true"
  native="false"
@@ -172814,7 +172814,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="consumer" type="android.view.InputConsumer">
+<parameter name="queue" type="android.view.InputQueue">
 </parameter>
 </method>
 </interface>
@@ -187271,7 +187271,7 @@
 <parameter name="event" type="android.view.MotionEvent">
 </parameter>
 </method>
-<method name="takeInputChannel"
+<method name="takeInputQueue"
  return="void"
  abstract="true"
  native="false"
@@ -187281,7 +187281,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="callback" type="android.view.InputConsumer.Callback">
+<parameter name="callback" type="android.view.InputQueue.Callback">
 </parameter>
 </method>
 <method name="takeKeyEvents"
diff --git a/core/java/android/app/NativeActivity.java b/core/java/android/app/NativeActivity.java
index 973ad60..429d164 100644
--- a/core/java/android/app/NativeActivity.java
+++ b/core/java/android/app/NativeActivity.java
@@ -7,7 +7,7 @@
 import android.content.pm.PackageManager;
 import android.os.Bundle;
 import android.view.InputChannel;
-import android.view.InputConsumer;
+import android.view.InputQueue;
 import android.view.SurfaceHolder;
 
 import java.io.File;
@@ -17,7 +17,7 @@
  * purely in native code.  That is, a game (or game-like thing).
  */
 public class NativeActivity extends Activity implements SurfaceHolder.Callback,
-        InputConsumer.Callback {
+        InputQueue.Callback {
     public static final String META_DATA_LIB_NAME = "android.app.lib_name";
     
     private int mNativeHandle;
@@ -45,7 +45,7 @@
         ActivityInfo ai;
         
         getWindow().takeSurface(this);
-        getWindow().takeInputChannel(this);
+        getWindow().takeInputQueue(this);
         
         try {
             ai = getPackageManager().getActivityInfo(
@@ -145,11 +145,11 @@
         onSurfaceDestroyedNative(mNativeHandle, holder);
     }
     
-    public void onInputConsumerCreated(InputConsumer consumer) {
-        onInputChannelCreatedNative(mNativeHandle, consumer.getInputChannel());
+    public void onInputQueueCreated(InputQueue queue) {
+        onInputChannelCreatedNative(mNativeHandle, queue.getInputChannel());
     }
     
-    public void onInputConsumerDestroyed(InputConsumer consumer) {
-        onInputChannelDestroyedNative(mNativeHandle, consumer.getInputChannel());
+    public void onInputQueueDestroyed(InputQueue queue) {
+        onInputChannelDestroyedNative(mNativeHandle, queue.getInputChannel());
     }
 }
diff --git a/core/java/android/view/InputConsumer.java b/core/java/android/view/InputConsumer.java
deleted file mode 100644
index 63b26c6..0000000
--- a/core/java/android/view/InputConsumer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.view;
-
-/**
- * Handle for consuming raw input events.
- */
-public class InputConsumer {
-    public static interface Callback {
-        void onInputConsumerCreated(InputConsumer consumer);
-        void onInputConsumerDestroyed(InputConsumer consumer);
-    }
-
-    final InputChannel mChannel;
-    
-    /** @hide */
-    public InputConsumer(InputChannel channel) {
-        mChannel = channel;
-    }
-    
-    /** @hide */
-    public InputChannel getInputChannel() {
-        return mChannel;
-    }
-}
diff --git a/core/java/android/view/InputQueue.java b/core/java/android/view/InputQueue.java
index b38f7d5..7feee38 100644
--- a/core/java/android/view/InputQueue.java
+++ b/core/java/android/view/InputQueue.java
@@ -21,16 +21,25 @@
 
 /**
  * An input queue provides a mechanism for an application to receive incoming
- * input events sent over an input channel.  Signalling is implemented by MessageQueue.
- * @hide
+ * input events.  Currently only usable from native code.
  */
 public final class InputQueue {
     private static final String TAG = "InputQueue";
     
+    public static interface Callback {
+        void onInputQueueCreated(InputQueue queue);
+        void onInputQueueDestroyed(InputQueue queue);
+    }
+
+    final InputChannel mChannel;
+    
     // Describes the interpretation of an event.
     // XXX This concept is tentative.  See comments in android/input.h.
+    /** @hide */
     public static final int INPUT_EVENT_NATURE_KEY = 1;
+    /** @hide */
     public static final int INPUT_EVENT_NATURE_TOUCH = 2;
+    /** @hide */
     public static final int INPUT_EVENT_NATURE_TRACKBALL = 3;
     
     private static Object sLock = new Object();
@@ -40,7 +49,14 @@
     private static native void nativeUnregisterInputChannel(InputChannel inputChannel);
     private static native void nativeFinished(long finishedToken);
     
-    private InputQueue() {
+    /** @hide */
+    public InputQueue(InputChannel channel) {
+        mChannel = channel;
+    }
+    
+    /** @hide */
+    public InputChannel getInputChannel() {
+        return mChannel;
     }
     
     /**
@@ -48,6 +64,7 @@
      * @param inputChannel The input channel to register.
      * @param inputHandler The input handler to input events send to the target.
      * @param messageQueue The message queue on whose thread the handler should be invoked.
+     * @hide
      */
     public static void registerInputChannel(InputChannel inputChannel, InputHandler inputHandler,
             MessageQueue messageQueue) {
@@ -71,6 +88,7 @@
      * Unregisters an input channel.
      * Does nothing if the channel is not currently registered.
      * @param inputChannel The input channel to unregister.
+     * @hide
      */
     public static void unregisterInputChannel(InputChannel inputChannel) {
         if (inputChannel == null) {
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 8984b74..4854190 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -154,8 +154,8 @@
 
     final View.AttachInfo mAttachInfo;
     InputChannel mInputChannel;
-    InputConsumer.Callback mInputConsumerCallback;
-    InputConsumer mInputConsumer;
+    InputQueue.Callback mInputQueueCallback;
+    InputQueue mInputQueue;
     
     final Rect mTempRect; // used in the transaction to not thrash the heap.
     final Rect mVisRect; // used to retrieve visible rect of focused view.
@@ -558,12 +558,12 @@
 
                 if (WindowManagerPolicy.ENABLE_NATIVE_INPUT_DISPATCH) {
                     if (view instanceof RootViewSurfaceTaker) {
-                        mInputConsumerCallback =
-                            ((RootViewSurfaceTaker)view).willYouTakeTheInputConsumer();
+                        mInputQueueCallback =
+                            ((RootViewSurfaceTaker)view).willYouTakeTheInputQueue();
                     }
-                    if (mInputConsumerCallback != null) {
-                        mInputConsumer = new InputConsumer(mInputChannel);
-                        mInputConsumerCallback.onInputConsumerCreated(mInputConsumer);
+                    if (mInputQueueCallback != null) {
+                        mInputQueue = new InputQueue(mInputChannel);
+                        mInputQueueCallback.onInputQueueCreated(mInputQueue);
                     } else {
                         InputQueue.registerInputChannel(mInputChannel, mInputHandler,
                                 Looper.myQueue());
@@ -1747,9 +1747,9 @@
 
         if (WindowManagerPolicy.ENABLE_NATIVE_INPUT_DISPATCH) {
             if (mInputChannel != null) {
-                if (mInputConsumerCallback != null) {
-                    mInputConsumerCallback.onInputConsumerDestroyed(mInputConsumer);
-                    mInputConsumerCallback = null;
+                if (mInputQueueCallback != null) {
+                    mInputQueueCallback.onInputQueueDestroyed(mInputQueue);
+                    mInputQueueCallback = null;
                 } else {
                     InputQueue.unregisterInputChannel(mInputChannel);
                 }
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index b00d33d..f40734b 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -481,11 +481,11 @@
     public abstract void takeSurface(SurfaceHolder.Callback callback);
     
     /**
-     * Take ownership of this window's InputChannel.  The window will no
-     * longer read and dispatch input events from the channel; it is your
+     * Take ownership of this window's InputQueue.  The window will no
+     * longer read and dispatch input events from the queue; it is your
      * responsibility to do so.
      */
-    public abstract void takeInputChannel(InputConsumer.Callback callback);
+    public abstract void takeInputQueue(InputQueue.Callback callback);
     
     /**
      * Return whether this window is being displayed with a floating style
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index f8ab04c..642c313 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -3892,6 +3892,17 @@
                 mHistoryBaseTime = rec.time;
             }
         }
+        
+        long oldnow = SystemClock.elapsedRealtime() - (5*60*100);
+        if (oldnow > 0) {
+            // If the system process has restarted, but not the entire
+            // system, then the mHistoryBaseTime already accounts for
+            // much of the elapsed time.  We thus want to adjust it back,
+            // to avoid large gaps in the data.  We determine we are
+            // in this case by arbitrarily saying it is so if at this
+            // point in boot the elapsed time is already more than 5 seconds.
+            mHistoryBaseTime -= oldnow;
+        }
     }
     
     void writeHistory(Parcel out) {
diff --git a/core/java/com/android/internal/view/RootViewSurfaceTaker.java b/core/java/com/android/internal/view/RootViewSurfaceTaker.java
index 991266a..7ff8d4c 100644
--- a/core/java/com/android/internal/view/RootViewSurfaceTaker.java
+++ b/core/java/com/android/internal/view/RootViewSurfaceTaker.java
@@ -1,6 +1,6 @@
 package com.android.internal.view;
 
-import android.view.InputConsumer;
+import android.view.InputQueue;
 import android.view.SurfaceHolder;
 
 /** hahahah */
@@ -9,5 +9,5 @@
     void setSurfaceType(int type);
     void setSurfaceFormat(int format);
     void setSurfaceKeepScreenOn(boolean keepOn);
-    InputConsumer.Callback willYouTakeTheInputConsumer();
+    InputQueue.Callback willYouTakeTheInputQueue();
 }
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 7877611..5642588 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -44,7 +44,6 @@
 import android.media.AudioManager;
 import android.net.Uri;
 import android.os.Bundle;
-import android.os.Message;
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.os.SystemClock;
@@ -56,14 +55,13 @@
 import android.util.SparseArray;
 import android.view.Gravity;
 import android.view.HapticFeedbackConstants;
-import android.view.InputConsumer;
+import android.view.InputQueue;
 import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.MotionEvent;
-import android.view.Surface;
 import android.view.SurfaceHolder;
 import android.view.View;
 import android.view.ViewGroup;
@@ -71,7 +69,6 @@
 import android.view.VolumePanel;
 import android.view.Window;
 import android.view.WindowManager;
-import android.view.InputConsumer.Callback;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityManager;
 import android.view.animation.Animation;
@@ -110,7 +107,7 @@
     SurfaceHolder.Callback mTakeSurfaceCallback;
     BaseSurfaceHolder mSurfaceHolder;
     
-    InputConsumer.Callback mTakeInputChannelCallback;
+    InputQueue.Callback mTakeInputQueueCallback;
     
     private boolean mIsFloating;
 
@@ -255,8 +252,8 @@
         mTakeSurfaceCallback = callback;
     }
     
-    public void takeInputChannel(InputConsumer.Callback callback) {
-        mTakeInputChannelCallback = callback;
+    public void takeInputQueue(InputQueue.Callback callback) {
+        mTakeInputQueueCallback = callback;
     }
     
     @Override
@@ -2045,8 +2042,8 @@
             return mFeatureId < 0 ? mTakeSurfaceCallback : null;
         }
         
-        public InputConsumer.Callback willYouTakeTheInputConsumer() {
-            return mFeatureId < 0 ? mTakeInputChannelCallback : null;
+        public InputQueue.Callback willYouTakeTheInputQueue() {
+            return mFeatureId < 0 ? mTakeInputQueueCallback : null;
         }
         
         public void setSurfaceType(int type) {