Remove InputConsumer, replacing with InputQueue.
Change-Id: Ib06907278457aaee842b123adc072840ca3602d8
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();
}