mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1238066 - Add LeakCanary to local (gradle) builds. r=nalexander
This patch adds LeakCanary to gradle builds and the no-op library to mach-based builds. --HG-- extra : commitid : LKytg2xYqO extra : rebase_source : d44898c3fa57dc5cbefdf777ff5f7bbdc16dae28 extra : amend_source : 100e02a73d87297ad87f1a7514f8d142954f33b3
This commit is contained in:
parent
20d10e7380
commit
2607ce7b13
@ -122,6 +122,10 @@ dependencies {
|
||||
compile 'com.google.android.gms:play-services-gcm:8.1.0'
|
||||
}
|
||||
|
||||
// Gradle based builds include LeakCanary. Mach based builds only include the no-op version of
|
||||
// this library.
|
||||
compile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
|
||||
|
||||
compile project(':thirdparty')
|
||||
|
||||
testCompile 'junit:junit:4.12'
|
||||
|
@ -24,6 +24,8 @@ import android.content.res.Configuration;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
import com.squareup.leakcanary.LeakCanary;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class GeckoApplication extends Application
|
||||
@ -127,6 +129,8 @@ public class GeckoApplication extends Application
|
||||
public void onCreate() {
|
||||
Log.i(LOG_TAG, "zerdatime " + SystemClock.uptimeMillis() + " - Fennec application start");
|
||||
|
||||
LeakCanary.install(this);
|
||||
|
||||
final Context context = getApplicationContext();
|
||||
HardwareUtils.init(context);
|
||||
Clipboard.init(context);
|
||||
|
@ -778,6 +778,8 @@ gtjar.sources += [ thirdparty_source_dir + f for f in [
|
||||
'com/nineoldandroids/view/ViewPropertyAnimatorHC.java',
|
||||
'com/nineoldandroids/view/ViewPropertyAnimatorICS.java',
|
||||
'com/nineoldandroids/view/ViewPropertyAnimatorPreHC.java',
|
||||
'com/squareup/leakcanary/LeakCanary.java',
|
||||
'com/squareup/leakcanary/RefWatcher.java',
|
||||
'com/squareup/picasso/Action.java',
|
||||
'com/squareup/picasso/AssetBitmapHunter.java',
|
||||
'com/squareup/picasso/BitmapHunter.java',
|
||||
|
7
mobile/android/config/proguard/leakcanary-keeps.cfg
Normal file
7
mobile/android/config/proguard/leakcanary-keeps.cfg
Normal file
@ -0,0 +1,7 @@
|
||||
# LeakCanary
|
||||
-keep class org.eclipse.mat.** { *; }
|
||||
-keep class com.squareup.leakcanary.** { *; }
|
||||
-keep class com.squareup.haha.** { *; }
|
||||
|
||||
# With LeakCanary 1.4-beta1 this creates a pile of warnings
|
||||
-dontwarn com.squareup.haha.**
|
@ -247,3 +247,6 @@
|
||||
-dontnote android.support.**
|
||||
|
||||
-include "adjust-keeps.cfg"
|
||||
|
||||
-include "leakcanary-keeps.cfg"
|
||||
|
||||
|
4
mobile/android/thirdparty/build.gradle
vendored
4
mobile/android/thirdparty/build.gradle
vendored
@ -28,6 +28,10 @@ android {
|
||||
if (!mozconfig.substs.MOZ_INSTALL_TRACKING) {
|
||||
exclude 'com/adjust/**'
|
||||
}
|
||||
|
||||
// Exclude LeakCanary: It will be added again via a gradle dependency. This version
|
||||
// here is only the no-op library for mach-based builds.
|
||||
exclude 'com/squareup/leakcanary/**'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
21
mobile/android/thirdparty/com/squareup/leakcanary/LeakCanary.java
vendored
Normal file
21
mobile/android/thirdparty/com/squareup/leakcanary/LeakCanary.java
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package com.squareup.leakcanary;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
/**
|
||||
* A no-op version of {@link LeakCanary} that can be used in release builds.
|
||||
*/
|
||||
public final class LeakCanary {
|
||||
public static RefWatcher install(Application application) {
|
||||
return RefWatcher.DISABLED;
|
||||
}
|
||||
|
||||
private LeakCanary() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
20
mobile/android/thirdparty/com/squareup/leakcanary/RefWatcher.java
vendored
Normal file
20
mobile/android/thirdparty/com/squareup/leakcanary/RefWatcher.java
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package com.squareup.leakcanary;
|
||||
|
||||
/**
|
||||
* No-op implementation of {@link RefWatcher} for release builds. Please use {@link
|
||||
* RefWatcher#DISABLED}.
|
||||
*/
|
||||
public final class RefWatcher {
|
||||
public static final RefWatcher DISABLED = new RefWatcher();
|
||||
|
||||
private RefWatcher() {}
|
||||
|
||||
public void watch(Object watchedReference) {}
|
||||
|
||||
public void watch(Object watchedReference, String referenceName) {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user