From 06a814dfa29ec8aaa152cf9fe0c59a8f208e5379 Mon Sep 17 00:00:00 2001 From: Damian Kaczmarek Date: Thu, 17 Oct 2024 15:42:33 +0200 Subject: [PATCH 1/4] chore: add more debug information for sync #WPB-11603 --- .../com/wire/android/WireApplication.kt | 10 ++- .../com/wire/android/util/LifecycleLogger.kt | 65 +++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 app/src/main/kotlin/com/wire/android/util/LifecycleLogger.kt diff --git a/app/src/main/kotlin/com/wire/android/WireApplication.kt b/app/src/main/kotlin/com/wire/android/WireApplication.kt index 0b3e9f223a..da5fef76ed 100644 --- a/app/src/main/kotlin/com/wire/android/WireApplication.kt +++ b/app/src/main/kotlin/com/wire/android/WireApplication.kt @@ -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 @@ -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()) @@ -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() @@ -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) {} }) diff --git a/app/src/main/kotlin/com/wire/android/util/LifecycleLogger.kt b/app/src/main/kotlin/com/wire/android/util/LifecycleLogger.kt new file mode 100644 index 0000000000..f0ac9a51d6 --- /dev/null +++ b/app/src/main/kotlin/com/wire/android/util/LifecycleLogger.kt @@ -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" + } +} From c881cc71fd39a06aaaa177def9975c19925bdabe Mon Sep 17 00:00:00 2001 From: Damian Kaczmarek Date: Fri, 18 Oct 2024 09:27:54 +0200 Subject: [PATCH 2/4] CI Restart From 0050514eaad8ecf885c3268b76192a79287e07f0 Mon Sep 17 00:00:00 2001 From: Damian Kaczmarek Date: Fri, 18 Oct 2024 13:22:16 +0200 Subject: [PATCH 3/4] checkout kalium branch --- kalium | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kalium b/kalium index 35cfb92581..1531aa6046 160000 --- a/kalium +++ b/kalium @@ -1 +1 @@ -Subproject commit 35cfb92581fea5325e1d2a348cbe803a5b25d317 +Subproject commit 1531aa60468a47cd045cb74213e145457e8810d6 From 48da7e577d5a74aadca64c869ee9073e5d57faba Mon Sep 17 00:00:00 2001 From: Damian Kaczmarek Date: Tue, 22 Oct 2024 09:37:54 +0200 Subject: [PATCH 4/4] replace LifecycleLogger with CurrentScreenManager --- .../com/wire/android/WireApplication.kt | 10 +-- .../wire/android/util/CurrentScreenManager.kt | 24 ++++++- .../com/wire/android/util/LifecycleLogger.kt | 65 ------------------- 3 files changed, 24 insertions(+), 75 deletions(-) delete mode 100644 app/src/main/kotlin/com/wire/android/util/LifecycleLogger.kt diff --git a/app/src/main/kotlin/com/wire/android/WireApplication.kt b/app/src/main/kotlin/com/wire/android/WireApplication.kt index da5fef76ed..9b2d2823d1 100644 --- a/app/src/main/kotlin/com/wire/android/WireApplication.kt +++ b/app/src/main/kotlin/com/wire/android/WireApplication.kt @@ -39,7 +39,6 @@ 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 @@ -90,9 +89,6 @@ class WireApplication : BaseApp() { @Inject lateinit var currentScreenManager: CurrentScreenManager - @Inject - lateinit var applicationLifecycleLogger: LifecycleLogger - override val workManagerConfiguration: Configuration get() = Configuration.Builder() .setWorkerFactory(wireWorkerFactory.get()) @@ -111,9 +107,7 @@ class WireApplication : BaseApp() { appLogger.i("$TAG app lifecycle") withContext(Dispatchers.Main) { - val lifecycle = ProcessLifecycleOwner.get().lifecycle - lifecycle.addObserver(currentScreenManager) - lifecycle.addObserver(applicationLifecycleLogger) + ProcessLifecycleOwner.get().lifecycle.addObserver(currentScreenManager) } connectionPolicyManager.get().startObservingAppLifecycle() @@ -286,7 +280,7 @@ class WireApplication : BaseApp() { companion object { fun byLevel(value: Int) = - values().firstOrNull { it.level == value } ?: TRIM_MEMORY_UNKNOWN + entries.firstOrNull { it.level == value } ?: TRIM_MEMORY_UNKNOWN } } diff --git a/app/src/main/kotlin/com/wire/android/util/CurrentScreenManager.kt b/app/src/main/kotlin/com/wire/android/util/CurrentScreenManager.kt index b2b1558482..b254197dd1 100644 --- a/app/src/main/kotlin/com/wire/android/util/CurrentScreenManager.kt +++ b/app/src/main/kotlin/com/wire/android/util/CurrentScreenManager.kt @@ -104,7 +104,7 @@ class CurrentScreenManager @Inject constructor( override fun onStart(owner: LifecycleOwner) { super.onStart(owner) - appLogger.i("${TAG}: onStart called") + appLogger.i("${TAG}: app onStart called") visibilityCount.getAndUpdate { currentValue -> val newValue = maxOf(0, currentValue + 1) isApplicationVisibleFlow.value = newValue > 0 @@ -114,7 +114,7 @@ class CurrentScreenManager @Inject constructor( override fun onStop(owner: LifecycleOwner) { super.onStop(owner) - appLogger.i("${TAG}: onStop called") + appLogger.i("${TAG}: app onStop called") visibilityCount.getAndUpdate { currentValue -> val newValue = maxOf(0, currentValue - 1) isApplicationVisibleFlow.value = newValue > 0 @@ -136,6 +136,26 @@ class CurrentScreenManager @Inject constructor( AnonymousAnalyticsManagerImpl.recordView(newView) } + override fun onCreate(owner: LifecycleOwner) { + super.onCreate(owner) + appLogger.i("$TAG app onCreate called") + } + + override fun onResume(owner: LifecycleOwner) { + super.onResume(owner) + appLogger.i("$TAG app onResume called") + } + + override fun onPause(owner: LifecycleOwner) { + super.onPause(owner) + appLogger.i("$TAG app onPause called") + } + + override fun onDestroy(owner: LifecycleOwner) { + super.onDestroy(owner) + appLogger.i("$TAG app onDestroy called") + } + companion object { private const val TAG = "CurrentScreenManager" } diff --git a/app/src/main/kotlin/com/wire/android/util/LifecycleLogger.kt b/app/src/main/kotlin/com/wire/android/util/LifecycleLogger.kt deleted file mode 100644 index f0ac9a51d6..0000000000 --- a/app/src/main/kotlin/com/wire/android/util/LifecycleLogger.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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" - } -}