mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Make sure Telecom Manager is disabled
This commit is contained in:
parent
a7efacaeb6
commit
fd5f17522e
5 changed files with 5 additions and 97 deletions
|
|
@ -50,7 +50,6 @@ import org.linphone.compatibility.Compatibility
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.DialerFragmentBinding
|
||||
import org.linphone.mediastream.Version
|
||||
import org.linphone.telecom.TelecomHelper
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.DialogUtils
|
||||
import org.linphone.utils.Event
|
||||
|
|
@ -314,20 +313,6 @@ class DialerFragment : SecureFragment<DialerFragmentBinding>() {
|
|||
|
||||
@TargetApi(Version.API26_O_80)
|
||||
private fun enableTelecomManager() {
|
||||
Log.i("[Dialer] Telecom Manager permissions granted")
|
||||
if (!TelecomHelper.exists()) {
|
||||
Log.i("[Dialer] Creating Telecom Helper")
|
||||
if (Compatibility.hasTelecomManagerFeature(requireContext())) {
|
||||
TelecomHelper.create(requireContext())
|
||||
} else {
|
||||
Log.e(
|
||||
"[Dialer] Telecom Helper can't be created, device doesn't support connection service!"
|
||||
)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
Log.e("[Dialer] Telecom Manager was already created ?!")
|
||||
}
|
||||
corePreferences.useTelecomManager = true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,11 +92,6 @@ class CallSettingsFragment : GenericSettingFragment<SettingsCallFragmentBinding>
|
|||
if (Compatibility.hasTelecomManagerFeature(requireContext())) {
|
||||
if (!Compatibility.hasTelecomManagerPermissions(requireContext())) {
|
||||
Compatibility.requestTelecomManagerPermissions(requireActivity(), 1)
|
||||
} else if (!TelecomHelper.exists()) {
|
||||
corePreferences.useTelecomManager = true
|
||||
Log.w("[Telecom Helper] Doesn't exists yet, creating it")
|
||||
TelecomHelper.create(requireContext())
|
||||
updateTelecomManagerAccount()
|
||||
}
|
||||
} else {
|
||||
Log.e(
|
||||
|
|
|
|||
|
|
@ -88,15 +88,8 @@ class CallSettingsViewModel : GenericSettingsViewModel() {
|
|||
if (newValue) {
|
||||
enableTelecomManagerEvent.value = Event(true)
|
||||
} else {
|
||||
if (TelecomHelper.exists()) {
|
||||
Log.i("[Call Settings] Removing Telecom Manager account & destroying singleton")
|
||||
TelecomHelper.get().removeAccount()
|
||||
TelecomHelper.get().destroy()
|
||||
TelecomHelper.destroy()
|
||||
|
||||
Log.w("[Call Settings] Disabling Telecom Manager auto-enable")
|
||||
prefs.manuallyDisabledTelecomManager = true
|
||||
}
|
||||
Log.w("[Call Settings] Disabling Telecom Manager auto-enable")
|
||||
prefs.manuallyDisabledTelecomManager = true
|
||||
prefs.useTelecomManager = false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ import org.linphone.contact.getContactForPhoneNumberOrAddress
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.mediastream.Version
|
||||
import org.linphone.notifications.NotificationsManager
|
||||
import org.linphone.telecom.TelecomHelper
|
||||
import org.linphone.utils.*
|
||||
import org.linphone.utils.Event
|
||||
|
||||
|
|
@ -372,22 +371,7 @@ class CoreContext(
|
|||
|
||||
core.addListener(listener)
|
||||
|
||||
// CoreContext listener must be added first!
|
||||
if (Version.sdkAboveOrEqual(Version.API26_O_80) && corePreferences.useTelecomManager) {
|
||||
if (Compatibility.hasTelecomManagerPermissions(context)) {
|
||||
Log.i(
|
||||
"[Context] Creating Telecom Helper, disabling audio focus requests in AudioHelper"
|
||||
)
|
||||
core.config.setBool("audio", "android_disable_audio_focus_requests", true)
|
||||
val telecomHelper = TelecomHelper.required(context)
|
||||
Log.i(
|
||||
"[Context] Telecom Helper created, account is ${if (telecomHelper.isAccountEnabled()) "enabled" else "disabled"}"
|
||||
)
|
||||
} else {
|
||||
Log.w("[Context] Can't create Telecom Helper, permissions have been revoked")
|
||||
corePreferences.useTelecomManager = false
|
||||
}
|
||||
}
|
||||
corePreferences.useTelecomManager = false
|
||||
|
||||
configureCore()
|
||||
|
||||
|
|
@ -431,11 +415,6 @@ class CoreContext(
|
|||
}
|
||||
notificationsManager.destroy()
|
||||
contactsManager.destroy()
|
||||
if (TelecomHelper.exists()) {
|
||||
Log.i("[Context] Destroying telecom helper")
|
||||
TelecomHelper.get().destroy()
|
||||
TelecomHelper.destroy()
|
||||
}
|
||||
|
||||
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
audioManager.unregisterAudioDeviceCallback(audioDeviceCallback)
|
||||
|
|
@ -736,18 +715,7 @@ class CoreContext(
|
|||
return true
|
||||
}
|
||||
} else {
|
||||
if (TelecomHelper.exists()) {
|
||||
if (!TelecomHelper.get().isIncomingCallPermitted() ||
|
||||
TelecomHelper.get().isInManagedCall()
|
||||
) {
|
||||
Log.w(
|
||||
"[Context] Refusing the call with reason busy because Telecom Manager will reject the call"
|
||||
)
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
Log.e("[Context] Telecom Manager singleton wasn't created!")
|
||||
}
|
||||
Log.e("[Context] Telecom Manager singleton wasn't created!")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,40 +119,7 @@ class AudioRouteUtils {
|
|||
types: List<AudioDevice.Type>,
|
||||
skipTelecom: Boolean = false
|
||||
) {
|
||||
val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls.firstOrNull()
|
||||
if (currentCall != null && !skipTelecom && TelecomHelper.exists()) {
|
||||
Log.i(
|
||||
"[Audio Route Helper] Call provided & Telecom Helper exists, trying to dispatch audio route change through Telecom API"
|
||||
)
|
||||
val connection = TelecomHelper.get().findConnectionForCallId(
|
||||
currentCall.callLog.callId.orEmpty()
|
||||
)
|
||||
if (connection != null) {
|
||||
val route = when (types.first()) {
|
||||
AudioDevice.Type.Earpiece -> CallAudioState.ROUTE_EARPIECE
|
||||
AudioDevice.Type.Speaker -> CallAudioState.ROUTE_SPEAKER
|
||||
AudioDevice.Type.Headphones, AudioDevice.Type.Headset -> CallAudioState.ROUTE_WIRED_HEADSET
|
||||
AudioDevice.Type.Bluetooth, AudioDevice.Type.BluetoothA2DP, AudioDevice.Type.HearingAid -> CallAudioState.ROUTE_BLUETOOTH
|
||||
else -> CallAudioState.ROUTE_WIRED_OR_EARPIECE
|
||||
}
|
||||
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()
|
||||
// but this time with skipTelecom = true
|
||||
if (!Compatibility.changeAudioRouteForTelecomManager(connection, route)) {
|
||||
Log.w(
|
||||
"[Audio Route Helper] Connection is already using this route internally, make the change!"
|
||||
)
|
||||
applyAudioRouteChange(currentCall, types)
|
||||
}
|
||||
} else {
|
||||
Log.w("[Audio Route Helper] Telecom Helper found but no matching connection!")
|
||||
applyAudioRouteChange(currentCall, types)
|
||||
}
|
||||
} else {
|
||||
applyAudioRouteChange(call, types)
|
||||
}
|
||||
applyAudioRouteChange(call, types)
|
||||
}
|
||||
|
||||
fun routeAudioToEarpiece(call: Call? = null, skipTelecom: Boolean = false) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue