summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorYoungsang Cho <youngsang@google.com>2014-06-26 01:08:08 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-06-24 01:52:26 +0000
commit6d8a7d7009c12660dc4d6f7f188e366b9b813c98 (patch)
treee83178e387351bf069a5a41bec2ba778542afcff /media
parentb32d9e53c2fa938498268649f4539f345680dd7d (diff)
parent44fbbca35459ee756a531661eba53ec33419790a (diff)
downloadframeworks_base-6d8a7d7009c12660dc4d6f7f188e366b9b813c98.zip
frameworks_base-6d8a7d7009c12660dc4d6f7f188e366b9b813c98.tar.gz
frameworks_base-6d8a7d7009c12660dc4d6f7f188e366b9b813c98.tar.bz2
Merge "Properly handle navigation keys in TIS"
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/tv/TvInputService.java39
1 files changed, 36 insertions, 3 deletions
diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java
index 409a33c..0f4a930 100644
--- a/media/java/android/media/tv/TvInputService.java
+++ b/media/java/android/media/tv/TvInputService.java
@@ -560,8 +560,11 @@ public abstract class TvInputService extends Service {
*/
int dispatchInputEvent(InputEvent event, InputEventReceiver receiver) {
if (DEBUG) Log.d(TAG, "dispatchInputEvent(" + event + ")");
+ boolean isNavigationKey = false;
if (event instanceof KeyEvent) {
- if (((KeyEvent) event).dispatch(this, mDispatcherState, this)) {
+ KeyEvent keyEvent = (KeyEvent) event;
+ isNavigationKey = isNavigationKey(keyEvent.getKeyCode());
+ if (keyEvent.dispatch(this, mDispatcherState, this)) {
return TvInputManager.Session.DISPATCH_HANDLED;
}
} else if (event instanceof MotionEvent) {
@@ -587,8 +590,18 @@ public abstract class TvInputService extends Service {
if (!mOverlayView.hasWindowFocus()) {
mOverlayView.getViewRootImpl().windowFocusChanged(true, true);
}
- mOverlayView.getViewRootImpl().dispatchInputEvent(event, receiver);
- return TvInputManager.Session.DISPATCH_IN_PROGRESS;
+ if (isNavigationKey && mOverlayView.hasFocusable()) {
+ // If mOverlayView has focusable views, navigation key events should be always
+ // handled. If not, it can make the application UI navigation messed up.
+ // For example, in the case that the left-most view is focused, a left key event
+ // will not be handled in ViewRootImpl. Then, the left key event will be handled in
+ // the application during the UI navigation of the TV input.
+ mOverlayView.getViewRootImpl().dispatchInputEvent(event);
+ return TvInputManager.Session.DISPATCH_HANDLED;
+ } else {
+ mOverlayView.getViewRootImpl().dispatchInputEvent(event, receiver);
+ return TvInputManager.Session.DISPATCH_IN_PROGRESS;
+ }
}
private void setSessionCallback(ITvInputSessionCallback callback) {
@@ -596,6 +609,26 @@ public abstract class TvInputService extends Service {
}
}
+ /** @hide */
+ public static boolean isNavigationKey(int keyCode) {
+ switch (keyCode) {
+ case KeyEvent.KEYCODE_DPAD_LEFT:
+ case KeyEvent.KEYCODE_DPAD_RIGHT:
+ case KeyEvent.KEYCODE_DPAD_UP:
+ case KeyEvent.KEYCODE_DPAD_DOWN:
+ case KeyEvent.KEYCODE_DPAD_CENTER:
+ case KeyEvent.KEYCODE_PAGE_UP:
+ case KeyEvent.KEYCODE_PAGE_DOWN:
+ case KeyEvent.KEYCODE_MOVE_HOME:
+ case KeyEvent.KEYCODE_MOVE_END:
+ case KeyEvent.KEYCODE_TAB:
+ case KeyEvent.KEYCODE_SPACE:
+ case KeyEvent.KEYCODE_ENTER:
+ return true;
+ }
+ return false;
+ }
+
private final class ServiceHandler extends Handler {
private static final int DO_CREATE_SESSION = 1;
private static final int DO_BROADCAST_AVAILABILITY_CHANGE = 2;