Added SDK logs to crashlytics reports
This commit is contained in:
parent
0f55be3a1b
commit
cc5e3dd164
2 changed files with 36 additions and 0 deletions
|
@ -145,6 +145,8 @@ android {
|
|||
if (!firebaseEnabled()) {
|
||||
resValue "string", "gcm_defaultSenderId", "none"
|
||||
}
|
||||
|
||||
resValue "bool", "crashlytics_enabled", "false"
|
||||
}
|
||||
|
||||
releaseAppBundle {
|
||||
|
@ -167,11 +169,15 @@ android {
|
|||
}
|
||||
|
||||
if (crashlyticsEnabled()) {
|
||||
resValue "bool", "crashlytics_enabled", "true"
|
||||
|
||||
firebaseCrashlytics {
|
||||
nativeSymbolUploadEnabled true
|
||||
strippedNativeLibsDir file(LinphoneSdkBuildDir + '/libs/').toString()
|
||||
unstrippedNativeLibsDir file(LinphoneSdkBuildDir + '/libs-debug/').toString()
|
||||
}
|
||||
} else {
|
||||
resValue "bool", "crashlytics_enabled", "false"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,6 +235,8 @@ dependencies {
|
|||
implementation platform('com.google.firebase:firebase-bom:26.4.0')
|
||||
if (crashlyticsEnabled()) {
|
||||
implementation 'com.google.firebase:firebase-crashlytics-ndk'
|
||||
} else {
|
||||
compileOnly 'com.google.firebase:firebase-crashlytics-ndk'
|
||||
}
|
||||
if (firebaseEnabled()) {
|
||||
implementation 'com.google.firebase:firebase-messaging'
|
||||
|
|
|
@ -32,6 +32,7 @@ import android.view.*
|
|||
import androidx.emoji.bundled.BundledEmojiCompatConfig
|
||||
import androidx.emoji.text.EmojiCompat
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import java.io.File
|
||||
import kotlin.math.abs
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
|
@ -79,6 +80,8 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
MutableLiveData<Event<Int>>()
|
||||
}
|
||||
|
||||
private val loggingService = Factory.instance().loggingService
|
||||
|
||||
private var gsmCallActive = false
|
||||
private val phoneStateListener = object : PhoneStateListener() {
|
||||
override fun onCallStateChanged(state: Int, phoneNumber: String?) {
|
||||
|
@ -214,8 +217,32 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
}
|
||||
}
|
||||
|
||||
private val loggingServiceListener = object : LoggingServiceListenerStub() {
|
||||
override fun onLogMessageWritten(
|
||||
logService: LoggingService,
|
||||
domain: String,
|
||||
level: LogLevel,
|
||||
message: String
|
||||
) {
|
||||
when (level) {
|
||||
LogLevel.Error -> android.util.Log.e(domain, message)
|
||||
LogLevel.Warning -> android.util.Log.w(domain, message)
|
||||
LogLevel.Message -> android.util.Log.i(domain, message)
|
||||
LogLevel.Fatal -> android.util.Log.wtf(domain, message)
|
||||
else -> android.util.Log.d(domain, message)
|
||||
}
|
||||
FirebaseCrashlytics.getInstance().log("[$domain] [${level.name}] $message")
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
if (context.resources.getBoolean(R.bool.crashlytics_enabled)) {
|
||||
loggingService.addListener(loggingServiceListener)
|
||||
Log.i("[Context] Crashlytics enabled, register logging service listener")
|
||||
}
|
||||
|
||||
core = Factory.instance().createCoreWithConfig(coreConfig, context)
|
||||
|
||||
stopped = false
|
||||
Log.i("[Context] Ready")
|
||||
}
|
||||
|
@ -256,6 +283,7 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
core.stop()
|
||||
core.removeListener(listener)
|
||||
stopped = true
|
||||
loggingService.removeListener(loggingServiceListener)
|
||||
}
|
||||
|
||||
private fun configureCore() {
|
||||
|
|
Loading…
Reference in a new issue