Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add more debug information for sync #WPB-11603 #3523

Open
wants to merge 2 commits into
base: release/candidate
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/src/main/kotlin/com/wire/android/WireApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.wire.android.feature.analytics.model.AnalyticsSettings
import com.wire.android.util.AppNameUtil
import com.wire.android.util.CurrentScreenManager
import com.wire.android.util.DataDogLogger
import com.wire.android.util.LifecycleLogger
import com.wire.android.util.LogFileWriter
import com.wire.android.util.getGitBuildId
import com.wire.android.util.lifecycle.ConnectionPolicyManager
Expand Down Expand Up @@ -89,6 +90,9 @@ class WireApplication : BaseApp() {
@Inject
lateinit var currentScreenManager: CurrentScreenManager

@Inject
lateinit var applicationLifecycleLogger: LifecycleLogger

override val workManagerConfiguration: Configuration
get() = Configuration.Builder()
.setWorkerFactory(wireWorkerFactory.get())
Expand All @@ -107,7 +111,9 @@ class WireApplication : BaseApp() {

appLogger.i("$TAG app lifecycle")
withContext(Dispatchers.Main) {
ProcessLifecycleOwner.get().lifecycle.addObserver(currentScreenManager)
val lifecycle = ProcessLifecycleOwner.get().lifecycle
lifecycle.addObserver(currentScreenManager)
lifecycle.addObserver(applicationLifecycleLogger)
}
connectionPolicyManager.get().startObservingAppLifecycle()

Expand Down Expand Up @@ -148,11 +154,13 @@ class WireApplication : BaseApp() {
override fun onActivityStarted(activity: Activity) {
globalAnalyticsManager.onStart(activity)
}

override fun onActivityResumed(activity: Activity) {}
override fun onActivityPaused(activity: Activity) {}
override fun onActivityStopped(activity: Activity) {
globalAnalyticsManager.onStop(activity)
}

override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
override fun onActivityDestroyed(activity: Activity) {}
})
Expand Down
65 changes: 65 additions & 0 deletions app/src/main/kotlin/com/wire/android/util/LifecycleLogger.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/

@file:Suppress("StringTemplate")

package com.wire.android.util

import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import com.wire.android.appLogger

import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class LifecycleLogger @Inject constructor() : DefaultLifecycleObserver {
override fun onCreate(owner: LifecycleOwner) {
super.onCreate(owner)
appLogger.i("$TAG app onCreate")
}

override fun onStart(owner: LifecycleOwner) {
super.onStart(owner)
appLogger.i("$TAG app onStart")
}

override fun onResume(owner: LifecycleOwner) {
super.onResume(owner)
appLogger.i("$TAG app onResume")
}

override fun onPause(owner: LifecycleOwner) {
super.onPause(owner)
appLogger.i("$TAG app onPause")
}

override fun onStop(owner: LifecycleOwner) {
super.onStop(owner)
appLogger.i("$TAG app onStop")
}

override fun onDestroy(owner: LifecycleOwner) {
super.onDestroy(owner)
appLogger.i("$TAG app onDestroy")
}

private companion object {
const val TAG = "LifecycleLogger"
}
}
Loading