[Android] disable headset detection during calls

Sébastien Toque git at videolan.org
Mon Oct 1 19:50:53 CEST 2012


vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Mon Oct  1 15:15:11 2012 +0200| [143f932c730d696f1dc7230903573c55d8fc5bfb] | committer: Sébastien Toque

disable headset detection during calls

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=143f932c730d696f1dc7230903573c55d8fc5bfb
---

 vlc-android/src/org/videolan/vlc/AudioService.java |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index 83857e0..1976dad 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -239,6 +239,8 @@ public class AudioService extends Service {
                 return;
             }
 
+            TelephonyManager telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
+
             /*
              * widget events
              */
@@ -268,7 +270,6 @@ public class AudioService extends Service {
              */
             else if (action.equalsIgnoreCase(Intent.ACTION_MEDIA_BUTTON)) {
                 KeyEvent event = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
-                TelephonyManager telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
                 if (event == null || telManager.getCallState() != TelephonyManager.CALL_STATE_IDLE)
                     return;
 
@@ -336,7 +337,7 @@ public class AudioService extends Service {
             /*
              * headset plug events
              */
-            if (mDetectHeadset) {
+            if (mDetectHeadset && telManager.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
                 if (action.equalsIgnoreCase(AudioManager.ACTION_AUDIO_BECOMING_NOISY)) {
                     Log.i(TAG, "Headset Removed.");
                     if (mLibVLC.isPlaying() && mCurrentMedia != null)



More information about the Android mailing list