summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorJoe Onorato <joeo@google.com>2010-11-08 10:59:27 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-11-08 10:59:27 -0800
commit51387974f0914a12dcf758938bbd4ffe120bdab4 (patch)
treef7faf54592578cf034731b4f2bdd79d45a7a7e62 /core/java
parentbc4119a390754505327fd2b51187d69353b239f1 (diff)
parent86f6786032b1a0380cf089aeeceef7e9d8982ef8 (diff)
downloadframeworks_base-51387974f0914a12dcf758938bbd4ffe120bdab4.zip
frameworks_base-51387974f0914a12dcf758938bbd4ffe120bdab4.tar.gz
frameworks_base-51387974f0914a12dcf758938bbd4ffe120bdab4.tar.bz2
Merge "Move the volume, media, call, camera and search key handling from PhoneWindow to a new PhoneFallbackEventHandler class that is used for all windows, not just ones with decors."
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/FallbackEventHandler.java27
-rw-r--r--core/java/android/view/ViewRoot.java11
-rw-r--r--core/java/com/android/internal/policy/IPolicy.java3
-rw-r--r--core/java/com/android/internal/policy/PolicyManager.java5
4 files changed, 46 insertions, 0 deletions
diff --git a/core/java/android/view/FallbackEventHandler.java b/core/java/android/view/FallbackEventHandler.java
new file mode 100644
index 0000000..dd68d89
--- /dev/null
+++ b/core/java/android/view/FallbackEventHandler.java
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+/**
+ * @hide
+ */
+public interface FallbackEventHandler {
+ public void setView(View v);
+ public void preDispatchKeyEvent(KeyEvent event);
+ public boolean dispatchKeyEvent(KeyEvent event);
+}
+
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index c7c2071..5b18715 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -59,6 +59,7 @@ import android.view.accessibility.AccessibilityManager;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.widget.Scroller;
+import com.android.internal.policy.PolicyManager;
import com.android.internal.view.BaseSurfaceHolder;
import com.android.internal.view.IInputMethodCallback;
import com.android.internal.view.IInputMethodSession;
@@ -160,6 +161,7 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
InputChannel mInputChannel;
InputQueue.Callback mInputQueueCallback;
InputQueue mInputQueue;
+ FallbackEventHandler mFallbackEventHandler;
final Rect mTempRect; // used in the transaction to not thrash the heap.
final Rect mVisRect; // used to retrieve visible rect of focused view.
@@ -273,6 +275,7 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
mAttachInfo = new View.AttachInfo(sWindowSession, mWindow, this, this);
mViewConfiguration = ViewConfiguration.get(context);
mDensity = context.getResources().getDisplayMetrics().densityDpi;
+ mFallbackEventHandler = PolicyManager.makeNewFallbackEventHandler(context);
}
public static void addFirstDrawHandler(Runnable callback) {
@@ -325,6 +328,7 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
synchronized (this) {
if (mView == null) {
mView = view;
+ mFallbackEventHandler.setView(view);
mWindowAttributes.copyFrom(attrs);
attrs = mWindowAttributes;
@@ -386,6 +390,7 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
mView = null;
mAttachInfo.mRootView = null;
mInputChannel = null;
+ mFallbackEventHandler.setView(null);
unscheduleTraversals();
throw new RuntimeException("Adding window failed", e);
} finally {
@@ -404,6 +409,7 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
mView = null;
mAttachInfo.mRootView = null;
mAdded = false;
+ mFallbackEventHandler.setView(null);
unscheduleTraversals();
switch (res) {
case WindowManagerImpl.ADD_BAD_APP_TOKEN:
@@ -2422,8 +2428,13 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
if (Config.LOGV) {
captureKeyLog("captureDispatchKeyEvent", event);
}
+ mFallbackEventHandler.preDispatchKeyEvent(event);
boolean keyHandled = mView.dispatchKeyEvent(event);
+ if (!keyHandled) {
+ mFallbackEventHandler.dispatchKeyEvent(event);
+ }
+
if (!keyHandled && isDown) {
int direction = 0;
switch (event.getKeyCode()) {
diff --git a/core/java/com/android/internal/policy/IPolicy.java b/core/java/com/android/internal/policy/IPolicy.java
index 73db0b7..d08b3b4 100644
--- a/core/java/com/android/internal/policy/IPolicy.java
+++ b/core/java/com/android/internal/policy/IPolicy.java
@@ -17,6 +17,7 @@
package com.android.internal.policy;
import android.content.Context;
+import android.view.FallbackEventHandler;
import android.view.LayoutInflater;
import android.view.Window;
import android.view.WindowManagerPolicy;
@@ -33,4 +34,6 @@ public interface IPolicy {
public LayoutInflater makeNewLayoutInflater(Context context);
public WindowManagerPolicy makeNewWindowManager();
+
+ public FallbackEventHandler makeNewFallbackEventHandler(Context context);
}
diff --git a/core/java/com/android/internal/policy/PolicyManager.java b/core/java/com/android/internal/policy/PolicyManager.java
index 4ed5a14..5274e54 100644
--- a/core/java/com/android/internal/policy/PolicyManager.java
+++ b/core/java/com/android/internal/policy/PolicyManager.java
@@ -17,6 +17,7 @@
package com.android.internal.policy;
import android.content.Context;
+import android.view.FallbackEventHandler;
import android.view.LayoutInflater;
import android.view.Window;
import android.view.WindowManagerPolicy;
@@ -65,4 +66,8 @@ public final class PolicyManager {
public static WindowManagerPolicy makeNewWindowManager() {
return sPolicy.makeNewWindowManager();
}
+
+ public static FallbackEventHandler makeNewFallbackEventHandler(Context context) {
+ return sPolicy.makeNewFallbackEventHandler(context);
+ }
}