[Android] Replace the call to the TelephonyManager to avoid a crash
Nicolas Pomepuy
git at videolan.org
Wed Sep 21 11:42:43 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Sep 21 11:44:43 2022 +0200| [135a2f058ba448a2b5f6ec051f215bd1b6805464] | committer: Duncan McNamara
Replace the call to the TelephonyManager to avoid a crash
> https://code.videolan.org/videolan/vlc-android/commit/135a2f058ba448a2b5f6ec051f215bd1b6805464
---
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