[Android] Replace the call to the TelephonyManager to avoid a crash

Nicolas Pomepuy git at videolan.org
Wed Sep 21 13:28:48 UTC 2022


vlc-android | branch: 3.5.x | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Sep 21 11:44:43 2022 +0200| [31987d0991d438a3fab5a92b4ba81ae7b8c2f6cb] | committer: Duncan McNamara

Replace the call to the TelephonyManager to avoid a crash

> https://code.videolan.org/videolan/vlc-android/commit/31987d0991d438a3fab5a92b4ba81ae7b8c2f6cb
---

 application/vlc-android/src/org/videolan/vlc/PlaybackService.kt | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index fd6a78df6..84b404719 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -33,7 +33,6 @@ import android.support.v4.media.MediaDescriptionCompat
 import android.support.v4.media.MediaMetadataCompat
 import android.support.v4.media.session.MediaSessionCompat
 import android.support.v4.media.session.PlaybackStateCompat
-import android.telephony.TelephonyManager
 import android.util.Log
 import android.view.View
 import android.widget.TextView
@@ -140,8 +139,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
             val state = intent.getIntExtra("state", 0)
 
             // skip all headsets events if there is a call
-            val telManager = applicationContext.getSystemService<TelephonyManager>()
-            if (telManager?.callState != TelephonyManager.CALL_STATE_IDLE) return
+            if ((context.getSystemService(AUDIO_SERVICE) as AudioManager).mode == AudioManager.MODE_IN_CALL) return
 
             /*
              * Launch the activity if needed



More information about the Android mailing list