From b4634f30e675476890e3a273ba04ed1ffb0de040 Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Thu, 21 May 2015 12:30:18 -0700 Subject: [PATCH] add dev buildType Closes #3411 // FREEBIE --- build.gradle | 18 +++++++++++++----- ...ard-testing.pro => proguard-automation.pro | 0 .../securesms/ApplicationContext.java | 19 +++++++++++++++++-- 3 files changed, 30 insertions(+), 7 deletions(-) rename proguard-testing.pro => proguard-automation.pro (100%) diff --git a/build.gradle b/build.gradle index 4eb63ee6a1..0598447389 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { } } dependencies { - classpath 'com.android.tools.build:gradle:1.0.1' + classpath 'com.android.tools.build:gradle:1.2.3' classpath files('libs/gradle-witness.jar') } } @@ -69,6 +69,8 @@ dependencies { compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' compile 'org.whispersystems:textsecure-android:1.5.0' + compile 'com.squareup.leakcanary:leakcanary-android:1.3.1' + androidTestCompile 'com.google.dexmaker:dexmaker:1.2' androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2' @@ -83,6 +85,7 @@ dependencies { exclude group: 'com.android.support', module: 'support-annotations' } androidTestCompile ('com.android.support.test.espresso:espresso-core:2.1') { + exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'javax.inject' } } @@ -135,7 +138,7 @@ dependencyVerification { android { compileSdkVersion 22 buildToolsVersion '22.0.1' - testBuildType "debugTest" + testBuildType "automation" dexOptions { javaMaxHeapSize "4g" @@ -148,6 +151,7 @@ android { testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L" buildConfigField "String", "PUSH_URL", "\"https://textsecure-service.whispersystems.org\"" + buildConfigField "boolean", "DEV_BUILD", "false" } compileOptions { @@ -190,11 +194,15 @@ android { proguardFiles = buildTypes.debug.proguardFiles signingConfig signingConfigs.release } - debugTest.initWith(buildTypes.debug) - debugTest { - proguardFile 'proguard-testing.pro' + automation.initWith(buildTypes.debug) + automation { + proguardFile 'proguard-automation.pro' buildConfigField "String", "PUSH_URL", "\"https://textsecure-service-staging.whispersystems.org\"" } + dev.initWith(buildTypes.debug) + dev { + buildConfigField "boolean", "DEV_BUILD", "true" + } } sourceSets { diff --git a/proguard-testing.pro b/proguard-automation.pro similarity index 100% rename from proguard-testing.pro rename to proguard-automation.pro diff --git a/src/org/thoughtcrime/securesms/ApplicationContext.java b/src/org/thoughtcrime/securesms/ApplicationContext.java index 447c49db27..cdd8f305a6 100644 --- a/src/org/thoughtcrime/securesms/ApplicationContext.java +++ b/src/org/thoughtcrime/securesms/ApplicationContext.java @@ -18,6 +18,11 @@ package org.thoughtcrime.securesms; import android.app.Application; import android.content.Context; +import android.os.StrictMode; +import android.os.StrictMode.ThreadPolicy; +import android.os.StrictMode.VmPolicy; + +import com.squareup.leakcanary.LeakCanary; import org.thoughtcrime.securesms.crypto.PRNGFixes; import org.thoughtcrime.securesms.dependencies.AxolotlStorageModule; @@ -34,8 +39,6 @@ import org.whispersystems.jobqueue.requirements.NetworkRequirementProvider; import org.whispersystems.libaxolotl.logging.AxolotlLoggerProvider; import org.whispersystems.libaxolotl.util.AndroidAxolotlLogger; -import java.security.Security; - import dagger.ObjectGraph; /** @@ -57,6 +60,8 @@ public class ApplicationContext extends Application implements DependencyInjecto @Override public void onCreate() { + super.onCreate(); + initializeDeveloperBuild(); initializeRandomNumberFix(); initializeLogging(); initializeDependencyInjection(); @@ -75,6 +80,16 @@ public class ApplicationContext extends Application implements DependencyInjecto return jobManager; } + private void initializeDeveloperBuild() { + if (BuildConfig.DEV_BUILD) { + LeakCanary.install(this); + StrictMode.setThreadPolicy(new ThreadPolicy.Builder().detectAll() + .penaltyLog() + .build()); + StrictMode.setVmPolicy(new VmPolicy.Builder().detectAll().penaltyLog().build()); + } + } + private void initializeRandomNumberFix() { PRNGFixes.apply(); }