summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/ViewRootImpl.java
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2015-05-14 13:31:24 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-14 13:31:29 +0000
commit07b83f1c9e8a7692a985aa2d13ac13fc5521aa4b (patch)
tree057cd12608c83a809c155a1b3b7469f39b2e26ef /core/java/android/view/ViewRootImpl.java
parentbe752b1f28f1f3724b235e3f0a77b4c07c40e631 (diff)
parentec0ce51b733f10c620cb9447b074f022d042e31d (diff)
downloadframeworks_base-07b83f1c9e8a7692a985aa2d13ac13fc5521aa4b.zip
frameworks_base-07b83f1c9e8a7692a985aa2d13ac13fc5521aa4b.tar.gz
frameworks_base-07b83f1c9e8a7692a985aa2d13ac13fc5521aa4b.tar.bz2
Merge "Add new MotionEvent actions for button press and release." into mnc-dev
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
-rw-r--r--core/java/android/view/ViewRootImpl.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 7c635b9..1cbd886 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -40,6 +40,7 @@ import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
import android.media.AudioManager;
import android.os.Binder;
+import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
@@ -5352,7 +5353,7 @@ public final class ViewRootImpl implements ViewParent,
//Log.d(TAG, ">>>>>> CALLING relayout");
if (params != null && mOrigWindowType != params.type) {
// For compatibility with old apps, don't crash here.
- if (mTargetSdkVersion < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ if (mTargetSdkVersion < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
Slog.w(TAG, "Window type can not be changed after "
+ "the window is added; ignoring change of " + mView);
params.type = mOrigWindowType;
@@ -5777,6 +5778,7 @@ public final class ViewRootImpl implements ViewParent,
void enqueueInputEvent(InputEvent event,
InputEventReceiver receiver, int flags, boolean processImmediately) {
+ adjustInputEventForCompatibility(event);
QueuedInputEvent q = obtainQueuedInputEvent(event, receiver, flags);
// Always enqueue the input event in order, regardless of its time stamp.
@@ -5882,6 +5884,19 @@ public final class ViewRootImpl implements ViewParent,
recycleQueuedInputEvent(q);
}
+ private void adjustInputEventForCompatibility(InputEvent e) {
+ if (mTargetSdkVersion < Build.VERSION_CODES.MNC && e instanceof MotionEvent) {
+ MotionEvent motion = (MotionEvent) e;
+ final int mask =
+ MotionEvent.BUTTON_STYLUS_PRIMARY | MotionEvent.BUTTON_STYLUS_SECONDARY;
+ final int buttonState = motion.getButtonState();
+ final int compatButtonState = (buttonState & mask) >> 4;
+ if (compatButtonState != 0) {
+ motion.setButtonState(buttonState | compatButtonState);
+ }
+ }
+ }
+
static boolean isTerminalInputEvent(InputEvent event) {
if (event instanceof KeyEvent) {
final KeyEvent keyEvent = (KeyEvent)event;