From 498b9aed2645f183620de28bfd986ea79149771a Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sun, 19 Jan 2025 13:18:19 +0200 Subject: [PATCH] Track services using LeakCanary --- .../org/koitharu/kotatsu/core/ui/BaseService.kt | 15 +++++++++++++++ .../org/koitharu/kotatsu/core/ui/BaseService.kt | 0 .../org/koitharu/kotatsu/core/ui/BaseService.kt | 5 +++++ 3 files changed, 20 insertions(+) create mode 100644 app/src/debug/kotlin/org/koitharu/kotatsu/core/ui/BaseService.kt rename app/src/{main => nightly}/kotlin/org/koitharu/kotatsu/core/ui/BaseService.kt (100%) create mode 100644 app/src/release/kotlin/org/koitharu/kotatsu/core/ui/BaseService.kt diff --git a/app/src/debug/kotlin/org/koitharu/kotatsu/core/ui/BaseService.kt b/app/src/debug/kotlin/org/koitharu/kotatsu/core/ui/BaseService.kt new file mode 100644 index 000000000..6453ac7fe --- /dev/null +++ b/app/src/debug/kotlin/org/koitharu/kotatsu/core/ui/BaseService.kt @@ -0,0 +1,15 @@ +package org.koitharu.kotatsu.core.ui + +import androidx.lifecycle.LifecycleService +import leakcanary.AppWatcher + +abstract class BaseService : LifecycleService() { + + override fun onDestroy() { + super.onDestroy() + AppWatcher.objectWatcher.watch( + watchedObject = this, + description = "${javaClass.simpleName} service received Service#onDestroy() callback", + ) + } +} diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/BaseService.kt b/app/src/nightly/kotlin/org/koitharu/kotatsu/core/ui/BaseService.kt similarity index 100% rename from app/src/main/kotlin/org/koitharu/kotatsu/core/ui/BaseService.kt rename to app/src/nightly/kotlin/org/koitharu/kotatsu/core/ui/BaseService.kt diff --git a/app/src/release/kotlin/org/koitharu/kotatsu/core/ui/BaseService.kt b/app/src/release/kotlin/org/koitharu/kotatsu/core/ui/BaseService.kt new file mode 100644 index 000000000..7a8f1463c --- /dev/null +++ b/app/src/release/kotlin/org/koitharu/kotatsu/core/ui/BaseService.kt @@ -0,0 +1,5 @@ +package org.koitharu.kotatsu.core.ui + +import androidx.lifecycle.LifecycleService + +abstract class BaseService : LifecycleService()