summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorYoungsang Cho <youngsang@google.com>2015-03-04 17:38:54 +0900
committerYoungsang Cho <youngsang@google.com>2015-03-25 13:44:04 +0900
commit53aa5744c9a233e54b8f8b8389a86f99abcc4244 (patch)
tree7ef61d18bf7d4c4d04ef722c13b41cc07df8f8b9 /media
parent727899fd0d6fe0de81bb329280e21b5152a1ae52 (diff)
downloadframeworks_base-53aa5744c9a233e54b8f8b8389a86f99abcc4244.zip
frameworks_base-53aa5744c9a233e54b8f8b8389a86f99abcc4244.tar.gz
frameworks_base-53aa5744c9a233e54b8f8b8389a86f99abcc4244.tar.bz2
Make TvInputService skip to dispatch media keys to an overlay view
If media keys are dispatched to an overlay view, it is always consumed because of fallback logic. Therefore, TvInputService skips to dispatch media keys to an overlay view in order to return the keys back to an application. Bug: 18195249 Change-Id: I1cb4c9de5a73bd741ab64b1b85e9c986a1a92a90
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/tv/TvInputService.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java
index f29be0d..f552a51 100644
--- a/media/java/android/media/tv/TvInputService.java
+++ b/media/java/android/media/tv/TvInputService.java
@@ -1076,12 +1076,19 @@ public abstract class TvInputService extends Service {
int dispatchInputEvent(InputEvent event, InputEventReceiver receiver) {
if (DEBUG) Log.d(TAG, "dispatchInputEvent(" + event + ")");
boolean isNavigationKey = false;
+ boolean skipDispatchToOverlayView = false;
if (event instanceof KeyEvent) {
KeyEvent keyEvent = (KeyEvent) event;
- isNavigationKey = isNavigationKey(keyEvent.getKeyCode());
if (keyEvent.dispatch(this, mDispatcherState, this)) {
return TvInputManager.Session.DISPATCH_HANDLED;
}
+ isNavigationKey = isNavigationKey(keyEvent.getKeyCode());
+ // When media keys and KEYCODE_MEDIA_AUDIO_TRACK are dispatched to ViewRootImpl,
+ // ViewRootImpl always consumes the keys. In this case, an application loses
+ // a chance to handle media keys. Therefore, media keys are not dispatched to
+ // ViewRootImpl.
+ skipDispatchToOverlayView = KeyEvent.isMediaKey(keyEvent.getKeyCode())
+ || keyEvent.getKeyCode() == KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK;
} else if (event instanceof MotionEvent) {
MotionEvent motionEvent = (MotionEvent) event;
final int source = motionEvent.getSource();
@@ -1099,7 +1106,8 @@ public abstract class TvInputService extends Service {
}
}
}
- if (mOverlayViewContainer == null || !mOverlayViewContainer.isAttachedToWindow()) {
+ if (mOverlayViewContainer == null || !mOverlayViewContainer.isAttachedToWindow()
+ || skipDispatchToOverlayView) {
return TvInputManager.Session.DISPATCH_NOT_HANDLED;
}
if (!mOverlayViewContainer.hasWindowFocus()) {