summaryrefslogtreecommitdiffstats
path: root/media/java
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2010-06-14 09:53:30 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2010-08-09 11:48:20 -0700
commite73131a68408a0495ba96a4d5a60799ba293c176 (patch)
tree6136d90535e14cd6c7519b35c57657b24915c853 /media/java
parent8fb2e6e4720385961083a150a3e848ccaef544ae (diff)
downloadframeworks_base-e73131a68408a0495ba96a4d5a60799ba293c176.zip
frameworks_base-e73131a68408a0495ba96a4d5a60799ba293c176.tar.gz
frameworks_base-e73131a68408a0495ba96a4d5a60799ba293c176.tar.bz2
Fix bug 2684341 Don't steal the media button event from the phone
app is the phone is ringing, even in silent mode. Use the PhoneStateListener to know whether the phone is ringing, as the mode is not MODE_RINGTONE when ringing in silent mode. Change-Id: Iede350cecde0b663d50f9b4a57f9a9ef08066c0d
Diffstat (limited to 'media/java')
-rw-r--r--media/java/android/media/AudioService.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 9212708..41d2cc5 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -239,6 +239,9 @@ public class AudioService extends IAudioService.Stub {
// independently change its priority)
private final BroadcastReceiver mMediaButtonReceiver = new MediaButtonBroadcastReceiver();
+ // Used to alter media button redirection when the phone is ringing.
+ private boolean mIsRinging = false;
+
// Devices currently connected
private HashMap <Integer, String> mConnectedDevices = new HashMap <Integer, String>();
@@ -1956,11 +1959,16 @@ public class AudioService extends IAudioService.Stub {
private final static Object mAudioFocusLock = new Object();
+ private final static Object mRingingLock = new Object();
+
private PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (state == TelephonyManager.CALL_STATE_RINGING) {
//Log.v(TAG, " CALL_STATE_RINGING");
+ synchronized(mRingingLock) {
+ mIsRinging = true;
+ }
int ringVolume = AudioService.this.getStreamVolume(AudioManager.STREAM_RING);
if (ringVolume > 0) {
requestAudioFocus(AudioManager.STREAM_RING,
@@ -1970,12 +1978,18 @@ public class AudioService extends IAudioService.Stub {
}
} else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
//Log.v(TAG, " CALL_STATE_OFFHOOK");
+ synchronized(mRingingLock) {
+ mIsRinging = false;
+ }
requestAudioFocus(AudioManager.STREAM_RING,
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT,
null, null /* both allowed to be null only for this clientId */,
IN_VOICE_COMM_FOCUS_ID /*clientId*/);
} else if (state == TelephonyManager.CALL_STATE_IDLE) {
//Log.v(TAG, " CALL_STATE_IDLE");
+ synchronized(mRingingLock) {
+ mIsRinging = false;
+ }
abandonAudioFocus(null, IN_VOICE_COMM_FOCUS_ID);
}
}
@@ -2243,9 +2257,11 @@ public class AudioService extends IAudioService.Stub {
// if in a call or ringing, do not break the current phone app behavior
// TODO modify this to let the phone app specifically get the RC focus
// add modify the phone app to take advantage of the new API
- if ((getMode() == AudioSystem.MODE_IN_CALL) ||
- (getMode() == AudioSystem.MODE_RINGTONE)) {
- return;
+ synchronized(mRingingLock) {
+ if (mIsRinging || (getMode() == AudioSystem.MODE_IN_CALL) ||
+ (getMode() == AudioSystem.MODE_RINGTONE) ) {
+ return;
+ }
}
synchronized(mRCStack) {
if (!mRCStack.empty()) {