summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2010-11-01 15:13:10 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-11-01 15:13:10 -0700
commitfe17625238fbf48608040619a929bdf8a04129f1 (patch)
tree89ee3554c0b5fad50222cf82bc07ede8e31f6d57 /core
parentd238beb3954b759994f6a8ceb57f74e447a021e0 (diff)
parent4d396052deb54399cbadbeb8abd873df6f3af342 (diff)
downloadframeworks_base-fe17625238fbf48608040619a929bdf8a04129f1.zip
frameworks_base-fe17625238fbf48608040619a929bdf8a04129f1.tar.gz
frameworks_base-fe17625238fbf48608040619a929bdf8a04129f1.tar.bz2
Merge "Fix policy issues when screen is off."
Diffstat (limited to 'core')
-rw-r--r--core/java/android/view/WindowManagerPolicy.java11
-rw-r--r--core/java/android/widget/MediaController.java45
-rw-r--r--core/java/android/widget/VideoView.java15
3 files changed, 48 insertions, 23 deletions
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index 1fd31a3..1a341e1 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -544,16 +544,18 @@ public interface WindowManagerPolicy {
* Generally, it's best to keep as little as possible in the queue thread
* because it's the most fragile.
* @param whenNanos The event time in uptime nanoseconds.
+ * @param action The key event action.
+ * @param flags The key event flags.
* @param keyCode The key code.
- * @param down True if the key is down.
+ * @param scanCode The key's scan code.
* @param policyFlags The policy flags associated with the key.
* @param isScreenOn True if the screen is already on
*
* @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
* {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
*/
- public int interceptKeyBeforeQueueing(long whenNanos, int keyCode, boolean down, int policyFlags,
- boolean isScreenOn);
+ public int interceptKeyBeforeQueueing(long whenNanos, int action, int flags,
+ int keyCode, int scanCode, int policyFlags, boolean isScreenOn);
/**
* Called from the input dispatcher thread before a key is dispatched to a window.
@@ -571,6 +573,7 @@ public interface WindowManagerPolicy {
* @param action The key event action.
* @param flags The key event flags.
* @param keyCode The key code.
+ * @param scanCode The key's scan code.
* @param metaState bit mask of meta keys that are held.
* @param repeatCount Number of times a key down has repeated.
* @param policyFlags The policy flags associated with the key.
@@ -578,7 +581,7 @@ public interface WindowManagerPolicy {
* not be further dispatched.
*/
public boolean interceptKeyBeforeDispatching(WindowState win, int action, int flags,
- int keyCode, int metaState, int repeatCount, int policyFlags);
+ int keyCode, int scanCode, int metaState, int repeatCount, int policyFlags);
/**
* Called when layout of the windows is about to start.
diff --git a/core/java/android/widget/MediaController.java b/core/java/android/widget/MediaController.java
index 39b1377..be1234d 100644
--- a/core/java/android/widget/MediaController.java
+++ b/core/java/android/widget/MediaController.java
@@ -413,33 +413,46 @@ public class MediaController extends FrameLayout {
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int keyCode = event.getKeyCode();
- if (event.getRepeatCount() == 0 && event.isDown() && (
- keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
- keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE ||
- keyCode == KeyEvent.KEYCODE_SPACE)) {
- doPauseResume();
- show(sDefaultTimeout);
- if (mPauseButton != null) {
- mPauseButton.requestFocus();
+ final boolean uniqueDown = event.getRepeatCount() == 0
+ && event.getAction() == KeyEvent.ACTION_DOWN;
+ if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK
+ || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
+ || keyCode == KeyEvent.KEYCODE_SPACE) {
+ if (uniqueDown) {
+ doPauseResume();
+ show(sDefaultTimeout);
+ if (mPauseButton != null) {
+ mPauseButton.requestFocus();
+ }
+ }
+ return true;
+ } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
+ if (uniqueDown && !mPlayer.isPlaying()) {
+ mPlayer.start();
+ updatePausePlay();
+ show(sDefaultTimeout);
}
return true;
- } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP) {
- if (mPlayer.isPlaying()) {
+ } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
+ || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
+ if (uniqueDown && mPlayer.isPlaying()) {
mPlayer.pause();
updatePausePlay();
+ show(sDefaultTimeout);
}
return true;
- } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
- keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
+ } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
+ || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
// don't show the controls for volume adjustment
return super.dispatchKeyEvent(event);
} else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
- hide();
-
+ if (uniqueDown) {
+ hide();
+ }
return true;
- } else {
- show(sDefaultTimeout);
}
+
+ show(sDefaultTimeout);
return super.dispatchKeyEvent(event);
}
diff --git a/core/java/android/widget/VideoView.java b/core/java/android/widget/VideoView.java
index 3d9cde4..2be7bca 100644
--- a/core/java/android/widget/VideoView.java
+++ b/core/java/android/widget/VideoView.java
@@ -529,10 +529,19 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
mMediaController.hide();
}
return true;
+ } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
+ if (mMediaPlayer.isPlaying()) {
+ start();
+ mMediaController.hide();
+ }
+ return true;
} else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
- && mMediaPlayer.isPlaying()) {
- pause();
- mMediaController.show();
+ || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
+ if (!mMediaPlayer.isPlaying()) {
+ pause();
+ mMediaController.show();
+ }
+ return true;
} else {
toggleMediaControlsVisiblity();
}