FPII-615:Can play music when a active call in DUT.
make ajudgment to know whether a call state or not at the moment.
Change-Id: I60b0829b1c32ec9e6423bdab7e978147ba3aa56a
diff --git a/src/com/android/music/MediaPlaybackService.java b/src/com/android/music/MediaPlaybackService.java
index 6057546..f0a99d7 100644
--- a/src/com/android/music/MediaPlaybackService.java
+++ b/src/com/android/music/MediaPlaybackService.java
@@ -53,7 +53,7 @@
import android.util.Log;
import android.widget.RemoteViews;
import android.widget.Toast;
-
+import android.telephony.TelephonyManager;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter;
@@ -1435,31 +1435,34 @@
* Starts playback of a previously opened file.
*/
public void play() {
- mAudioManager.requestAudioFocus(mAudioFocusListener, AudioManager.STREAM_MUSIC,
- AudioManager.AUDIOFOCUS_GAIN);
- mAudioManager.registerMediaButtonEventReceiver(new ComponentName(this.getPackageName(),
- MediaButtonIntentReceiver.class.getName()));
- mAudioManager.registerRemoteControlClient(mRemoteControlClient);
+ TelephonyManager tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
+ if (TelephonyManager.CALL_STATE_IDLE == tel.getCallState()) {
+ mAudioManager.requestAudioFocus(mAudioFocusListener, AudioManager.STREAM_MUSIC,
+ AudioManager.AUDIOFOCUS_GAIN);
+ mAudioManager.registerMediaButtonEventReceiver(new ComponentName(this.getPackageName(),
+ MediaButtonIntentReceiver.class.getName()));
+ mAudioManager.registerRemoteControlClient(mRemoteControlClient);
- if (mPlayer.isInitialized()) {
- mPlayer.start();
- // make sure we fade in, in case a previous fadein was stopped because
- // of another focus loss
- mMediaplayerHandler.removeMessages(FADEDOWN);
- mMediaplayerHandler.sendEmptyMessage(FADEUP);
+ if (mPlayer.isInitialized()) {
+ mPlayer.start();
+ // make sure we fade in, in case a previous fadein was stopped because
+ // of another focus loss
+ mMediaplayerHandler.removeMessages(FADEDOWN);
+ mMediaplayerHandler.sendEmptyMessage(FADEUP);
- updateNotification();
- if (!mIsSupposedToBePlaying) {
- mIsSupposedToBePlaying = true;
- notifyChange(PLAYSTATE_CHANGED);
- }
+ updateNotification();
+ if (!mIsSupposedToBePlaying) {
+ mIsSupposedToBePlaying = true;
+ notifyChange(PLAYSTATE_CHANGED);
+ }
- } else if (mPlayListLen <= 0) {
- // This is mostly so that if you press 'play' on a bluetooth headset
- // without every having played anything before, it will still play
- // something.
- setShuffleMode(SHUFFLE_AUTO);
- }
+ } else if (mPlayListLen <= 0) {
+ // This is mostly so that if you press 'play' on a bluetooth headset
+ // without every having played anything before, it will still play
+ // something.
+ setShuffleMode(SHUFFLE_AUTO);
+ }
+ }
}
private void updateNotification() {