From 11c696e3b4cce3f45776e4709a2eb7cde118a122 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 23 Apr 2022 22:46:59 +0200 Subject: [PATCH] Manual install leak canary --- app/build.gradle | 2 +- app/src/debug/java/eu.faircode.email/CoalMine.java | 6 ++++++ app/src/main/java/eu/faircode/email/ApplicationEx.java | 2 ++ app/src/main/res/values/canary.xml | 4 ++++ app/src/release/java/eu.faircode.email/CoalMine.java | 4 ++++ 5 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/values/canary.xml diff --git a/app/build.gradle b/app/build.gradle index c344ef8e9f..80dae54824 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -590,5 +590,5 @@ dependencies { // https://github.com/square/leakcanary // https://square.github.io/leakcanary/getting_started/ // https://mvnrepository.com/artifact/com.squareup.leakcanary/leakcanary-android - debugImplementation "com.squareup.leakcanary:leakcanary-android-startup:$canary_version" + debugImplementation "com.squareup.leakcanary:leakcanary-android:$canary_version" } diff --git a/app/src/debug/java/eu.faircode.email/CoalMine.java b/app/src/debug/java/eu.faircode.email/CoalMine.java index b8ac658e6b..6ee662ab31 100644 --- a/app/src/debug/java/eu.faircode.email/CoalMine.java +++ b/app/src/debug/java/eu.faircode.email/CoalMine.java @@ -19,6 +19,7 @@ package eu.faircode.email; Copyright 2018-2022 by Marcel Bokhorst (M66B) */ +import android.app.Application; import android.content.Intent; import androidx.annotation.NonNull; @@ -37,6 +38,10 @@ import shark.ObjectInspector; import shark.ObjectReporter; public class CoalMine { + static void install(@NonNull Application app) { + AppWatcher.INSTANCE.manualInstall(app, 10000); + } + static void setup(boolean enabled) { List inspectors = new ArrayList<>(LeakCanary.getConfig().getObjectInspectors()); @@ -89,6 +94,7 @@ public class CoalMine { .objectInspectors(inspectors) .build(); LeakCanary.setConfig(config); + LeakCanary.INSTANCE.showLeakDisplayActivityLauncherIcon(true); } diff --git a/app/src/main/java/eu/faircode/email/ApplicationEx.java b/app/src/main/java/eu/faircode/email/ApplicationEx.java index c25db1e830..a1cb3be4c5 100644 --- a/app/src/main/java/eu/faircode/email/ApplicationEx.java +++ b/app/src/main/java/eu/faircode/email/ApplicationEx.java @@ -113,6 +113,8 @@ public class ApplicationEx extends Application " process=" + android.os.Process.myPid()); Log.logMemory(this, "App"); + CoalMine.install(this); + registerActivityLifecycleCallbacks(lifecycleCallbacks); getMainLooper().setMessageLogging(new Printer() { diff --git a/app/src/main/res/values/canary.xml b/app/src/main/res/values/canary.xml new file mode 100644 index 0000000000..6326a9f623 --- /dev/null +++ b/app/src/main/res/values/canary.xml @@ -0,0 +1,4 @@ + + + false + \ No newline at end of file diff --git a/app/src/release/java/eu.faircode.email/CoalMine.java b/app/src/release/java/eu.faircode.email/CoalMine.java index 641798d066..aaef99d4ce 100644 --- a/app/src/release/java/eu.faircode.email/CoalMine.java +++ b/app/src/release/java/eu.faircode.email/CoalMine.java @@ -19,11 +19,15 @@ package eu.faircode.email; Copyright 2018-2022 by Marcel Bokhorst (M66B) */ +import android.app.Application; import android.content.Intent; import androidx.annotation.NonNull; public class CoalMine { + static void install(@NonNull Application app) { + } + static void setup(boolean enabled) { }