Fix phone state sensor only considering 1 subscription's calls (#3803)

This commit is contained in:
Joris Pelgröm 2023-08-19 20:52:24 +02:00 committed by GitHub
parent 477c299272
commit e3ce9ed5b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,13 +84,9 @@ class PhoneStateSensorManager : SensorManager {
val telephonyManager =
context.applicationContext.getSystemService<TelephonyManager>()!!
val callState = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
telephonyManager.callStateForSubscription
} else {
@Suppress("DEPRECATION")
telephonyManager.callState
}
currentPhoneState = when (callState) {
// Deprecated function provides state for any call, not for a specific subscription only
@Suppress("DEPRECATION")
currentPhoneState = when (telephonyManager.callState) {
TelephonyManager.CALL_STATE_IDLE -> "idle"
TelephonyManager.CALL_STATE_RINGING -> "ringing"
TelephonyManager.CALL_STATE_OFFHOOK -> "offhook"