diff options
| author | Joe Onorato <joeo@google.com> | 2010-11-05 18:57:34 -0700 |
|---|---|---|
| committer | Joe Onorato <joeo@google.com> | 2010-11-05 18:58:29 -0700 |
| commit | 86f6786032b1a0380cf089aeeceef7e9d8982ef8 (patch) | |
| tree | 663485aedd29b4397504c055e3dfef007bcbd76c /core/java | |
| parent | f3e5fcc91734d8e39b396f1b70b9903a6b3dd2c0 (diff) | |
| download | frameworks_base-86f6786032b1a0380cf089aeeceef7e9d8982ef8.zip frameworks_base-86f6786032b1a0380cf089aeeceef7e9d8982ef8.tar.gz frameworks_base-86f6786032b1a0380cf089aeeceef7e9d8982ef8.tar.bz2 | |
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.
Bug: 3155146
Change-Id: Ib070fa3e523e3564b225bca576c08012fef4f416
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/view/FallbackEventHandler.java | 27 | ||||
| -rw-r--r-- | core/java/android/view/ViewRoot.java | 11 | ||||
| -rw-r--r-- | core/java/com/android/internal/policy/IPolicy.java | 3 | ||||
| -rw-r--r-- | core/java/com/android/internal/policy/PolicyManager.java | 5 |
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); + } } |
