Fixed issue with headset audio routing when connecting it during call
This commit is contained in:
parent
101d9aa931
commit
b30f5baef6
3 changed files with 15 additions and 4 deletions
|
@ -257,8 +257,14 @@ class Api26Compatibility {
|
||||||
vibrator.vibrate(effect, audioAttrs)
|
vibrator.vibrate(effect, audioAttrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun changeAudioRouteForTelecomManager(connection: NativeCallWrapper, route: Int) {
|
fun changeAudioRouteForTelecomManager(connection: NativeCallWrapper, route: Int): Boolean {
|
||||||
|
Log.i("[Telecom Helper] Changing audio route [$route] on connection ${connection.callId}")
|
||||||
|
if (connection.callAudioState.route == route) {
|
||||||
|
Log.w("[Telecom Helper] Connection is already using this route")
|
||||||
|
return false
|
||||||
|
}
|
||||||
connection.setAudioRoute(route)
|
connection.setAudioRoute(route)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun requestTelecomManagerPermission(activity: Activity, code: Int) {
|
fun requestTelecomManagerPermission(activity: Activity, code: Int) {
|
||||||
|
|
|
@ -232,10 +232,11 @@ class Compatibility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun changeAudioRouteForTelecomManager(connection: NativeCallWrapper, route: Int) {
|
fun changeAudioRouteForTelecomManager(connection: NativeCallWrapper, route: Int): Boolean {
|
||||||
if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
||||||
Api26Compatibility.changeAudioRouteForTelecomManager(connection, route)
|
return Api26Compatibility.changeAudioRouteForTelecomManager(connection, route)
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Contacts */
|
/* Contacts */
|
||||||
|
|
|
@ -112,7 +112,11 @@ class AudioRouteUtils {
|
||||||
Log.i("[Audio Route Helper] Telecom Helper & matching connection found, dispatching audio route change through it")
|
Log.i("[Audio Route Helper] Telecom Helper & matching connection found, dispatching audio route change through it")
|
||||||
// We will be called here again by NativeCallWrapper.onCallAudioStateChanged()
|
// We will be called here again by NativeCallWrapper.onCallAudioStateChanged()
|
||||||
// but this time with skipTelecom = true
|
// but this time with skipTelecom = true
|
||||||
Compatibility.changeAudioRouteForTelecomManager(connection, route)
|
if (!Compatibility.changeAudioRouteForTelecomManager(connection, route)) {
|
||||||
|
Log.w("[Audio Route Helper] Connection is already using this route internally, make the change!")
|
||||||
|
applyAudioRouteChange(callToUse, types)
|
||||||
|
changeCaptureDeviceToMatchAudioRoute(callToUse, types)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.w("[Audio Route Helper] Telecom Helper found but no matching connection!")
|
Log.w("[Audio Route Helper] Telecom Helper found but no matching connection!")
|
||||||
applyAudioRouteChange(callToUse, types)
|
applyAudioRouteChange(callToUse, types)
|
||||||
|
|
Loading…
Reference in a new issue