Skip to content

Commit

Permalink
Merge pull request #26 from voximplant/separate_audioCallManager
Browse files Browse the repository at this point in the history
Separate AudioCallManager
  • Loading branch information
jedi1150 authored Jan 18, 2024
2 parents d482d9b + 7df991b commit dd52544
Show file tree
Hide file tree
Showing 17 changed files with 362 additions and 244 deletions.
4 changes: 2 additions & 2 deletions audiocall/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ android {

defaultConfig {
applicationId "com.voximplant.demos.kotlin.audio_call"
minSdk 26
minSdk 21
targetSdk 33
multiDexEnabled true
versionCode 1
versionName "1.4.0"
versionName "1.5.0"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*
* Copyright (c) 2011 - 2021, Zingaya, Inc. All rights reserved.
* Copyright (c) 2011 - 2024, Zingaya, Inc. All rights reserved.
*/

package com.voximplant.demos.kotlin.audio_call

import android.Manifest
import android.annotation.SuppressLint
import android.app.NotificationManager
import android.content.pm.PackageManager
import android.os.Build
import android.util.Log
import androidx.lifecycle.Lifecycle
Expand All @@ -16,7 +17,8 @@ import androidx.lifecycle.ProcessLifecycleOwner
import androidx.multidex.MultiDexApplication
import com.google.firebase.FirebaseApp
import com.voximplant.demos.kotlin.audio_call.services.AudioCallManager
import com.voximplant.demos.kotlin.audio_call.services.TelecomManager
import com.voximplant.demos.kotlin.audio_call.services.AudioCallManagerDefault
import com.voximplant.demos.kotlin.audio_call.services.AudioCallManagerTelecom
import com.voximplant.demos.kotlin.services.AuthService
import com.voximplant.demos.kotlin.utils.*
import com.voximplant.sdk.Voximplant
Expand All @@ -25,10 +27,9 @@ import java.util.concurrent.Executors

@SuppressLint("StaticFieldLeak")
lateinit var permissionsHelper: PermissionsHelper
lateinit var audioCallManager: AudioCallManager

@SuppressLint("StaticFieldLeak")
lateinit var telecomManager: TelecomManager
lateinit var audioCallManager: AudioCallManager

class AudioCallApplication : MultiDexApplication(), LifecycleObserver {
override fun onCreate() {
Expand All @@ -47,12 +48,13 @@ class AudioCallApplication : MultiDexApplication(), LifecycleObserver {
arrayOf(Manifest.permission.RECORD_AUDIO, Manifest.permission.MANAGE_OWN_CALLS, Manifest.permission.BLUETOOTH_CONNECT, Manifest.permission.POST_NOTIFICATIONS)
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
arrayOf(Manifest.permission.RECORD_AUDIO, Manifest.permission.MANAGE_OWN_CALLS, Manifest.permission.BLUETOOTH_CONNECT)
} else {
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
arrayOf(Manifest.permission.RECORD_AUDIO, Manifest.permission.MANAGE_OWN_CALLS)
} else {
arrayOf(Manifest.permission.RECORD_AUDIO)
}

permissionsHelper = PermissionsHelper(applicationContext, requiredPermissions)
telecomManager = TelecomManager(applicationContext).apply { registerAccount() }

Shared.notificationHelper =
NotificationHelper(
Expand All @@ -62,10 +64,11 @@ class AudioCallApplication : MultiDexApplication(), LifecycleObserver {
)
Shared.fileLogger = FileLogger(this)
Shared.authService = AuthService(client, applicationContext)
audioCallManager = AudioCallManager(
applicationContext,
client,
)
audioCallManager = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && (applicationContext.packageManager.hasSystemFeature(PackageManager.FEATURE_TELECOM) || applicationContext.packageManager.hasSystemFeature(PackageManager.FEATURE_CONNECTION_SERVICE))) {
AudioCallManagerTelecom(applicationContext, client)
} else {
AudioCallManagerDefault(applicationContext, client)
}
Shared.shareHelper = ShareHelper.also {
it.init(
this,
Expand Down
Loading

0 comments on commit dd52544

Please sign in to comment.