mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Move LeakCanary into its own variant.
This commit is contained in:
@@ -67,11 +67,13 @@ def selectableVariants = [
|
|||||||
'nightlyPnpRelease',
|
'nightlyPnpRelease',
|
||||||
'playProdDebug',
|
'playProdDebug',
|
||||||
'playProdSpinner',
|
'playProdSpinner',
|
||||||
|
'playProdCanary',
|
||||||
'playProdPerf',
|
'playProdPerf',
|
||||||
'playProdBenchmark',
|
'playProdBenchmark',
|
||||||
'playProdInstrumentation',
|
'playProdInstrumentation',
|
||||||
'playProdRelease',
|
'playProdRelease',
|
||||||
'playStagingDebug',
|
'playStagingDebug',
|
||||||
|
'playStagingCanary',
|
||||||
'playStagingSpinner',
|
'playStagingSpinner',
|
||||||
'playStagingPerf',
|
'playStagingPerf',
|
||||||
'playStagingInstrumentation',
|
'playStagingInstrumentation',
|
||||||
@@ -318,6 +320,14 @@ android {
|
|||||||
buildConfigField "String", "BUILD_VARIANT_TYPE", "\"Benchmark\""
|
buildConfigField "String", "BUILD_VARIANT_TYPE", "\"Benchmark\""
|
||||||
buildConfigField "boolean", "TRACING_ENABLED", "true"
|
buildConfigField "boolean", "TRACING_ENABLED", "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canary {
|
||||||
|
initWith debug
|
||||||
|
isDefault false
|
||||||
|
minifyEnabled false
|
||||||
|
matchingFallbacks = ['debug']
|
||||||
|
buildConfigField "String", "BUILD_VARIANT_TYPE", "\"Canary\""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
productFlavors {
|
productFlavors {
|
||||||
@@ -559,7 +569,8 @@ dependencies {
|
|||||||
implementation libs.kotlinx.collections.immutable
|
implementation libs.kotlinx.collections.immutable
|
||||||
|
|
||||||
spinnerImplementation project(":spinner")
|
spinnerImplementation project(":spinner")
|
||||||
spinnerImplementation libs.square.leakcanary
|
|
||||||
|
canaryImplementation libs.square.leakcanary
|
||||||
|
|
||||||
testImplementation testLibs.junit.junit
|
testImplementation testLibs.junit.junit
|
||||||
testImplementation testLibs.assertj.core
|
testImplementation testLibs.assertj.core
|
||||||
|
|||||||
9
app/src/canary/AndroidManifest.xml
Normal file
9
app/src/canary/AndroidManifest.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:name=".CanaryApplicationContext"
|
||||||
|
tools:replace="android:name" />
|
||||||
|
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package org.thoughtcrime.securesms
|
||||||
|
|
||||||
|
import android.os.StrictMode
|
||||||
|
import android.os.StrictMode.ThreadPolicy
|
||||||
|
import leakcanary.LeakCanary
|
||||||
|
import shark.AndroidReferenceMatchers
|
||||||
|
|
||||||
|
class CanaryApplicationContext : ApplicationContext() {
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
|
|
||||||
|
StrictMode.setThreadPolicy(
|
||||||
|
ThreadPolicy.Builder()
|
||||||
|
.detectDiskReads()
|
||||||
|
.detectDiskWrites()
|
||||||
|
.detectNetwork()
|
||||||
|
.penaltyLog()
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
Class.forName("dalvik.system.CloseGuard")
|
||||||
|
.getMethod("setEnabled", Boolean::class.javaPrimitiveType)
|
||||||
|
.invoke(null, true)
|
||||||
|
} catch (e: ReflectiveOperationException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
LeakCanary.config = LeakCanary.config.copy(
|
||||||
|
referenceMatchers = AndroidReferenceMatchers.appDefaults +
|
||||||
|
AndroidReferenceMatchers.ignoredInstanceField(
|
||||||
|
className = "android.service.media.MediaBrowserService\$ServiceBinder",
|
||||||
|
fieldName = "this\$0"
|
||||||
|
) +
|
||||||
|
AndroidReferenceMatchers.ignoredInstanceField(
|
||||||
|
className = "androidx.media.MediaBrowserServiceCompat\$MediaBrowserServiceImplApi26\$MediaBrowserServiceApi26",
|
||||||
|
fieldName = "mBase"
|
||||||
|
) +
|
||||||
|
AndroidReferenceMatchers.ignoredInstanceField(
|
||||||
|
className = "android.support.v4.media.MediaBrowserCompat",
|
||||||
|
fieldName = "mImpl"
|
||||||
|
) +
|
||||||
|
AndroidReferenceMatchers.ignoredInstanceField(
|
||||||
|
className = "android.support.v4.media.session.MediaControllerCompat",
|
||||||
|
fieldName = "mToken"
|
||||||
|
) +
|
||||||
|
AndroidReferenceMatchers.ignoredInstanceField(
|
||||||
|
className = "android.support.v4.media.session.MediaControllerCompat",
|
||||||
|
fieldName = "mImpl"
|
||||||
|
) +
|
||||||
|
AndroidReferenceMatchers.ignoredInstanceField(
|
||||||
|
className = "org.thoughtcrime.securesms.components.voice.VoiceNotePlaybackService",
|
||||||
|
fieldName = "mApplication"
|
||||||
|
) +
|
||||||
|
AndroidReferenceMatchers.ignoredInstanceField(
|
||||||
|
className = "org.thoughtcrime.securesms.service.GenericForegroundService\$LocalBinder",
|
||||||
|
fieldName = "this\$0"
|
||||||
|
) +
|
||||||
|
AndroidReferenceMatchers.ignoredInstanceField(
|
||||||
|
className = "org.thoughtcrime.securesms.contacts.ContactsSyncAdapter",
|
||||||
|
fieldName = "mContext"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,6 @@ package org.thoughtcrime.securesms
|
|||||||
|
|
||||||
import android.content.ContentValues
|
import android.content.ContentValues
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.StrictMode
|
|
||||||
import android.os.StrictMode.ThreadPolicy
|
|
||||||
import leakcanary.LeakCanary
|
|
||||||
import org.signal.spinner.Spinner
|
import org.signal.spinner.Spinner
|
||||||
import org.signal.spinner.Spinner.DatabaseConfig
|
import org.signal.spinner.Spinner.DatabaseConfig
|
||||||
import org.thoughtcrime.securesms.database.DatabaseMonitor
|
import org.thoughtcrime.securesms.database.DatabaseMonitor
|
||||||
@@ -24,22 +21,12 @@ import org.thoughtcrime.securesms.database.TimestampTransformer
|
|||||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.util.AppSignatureUtil
|
import org.thoughtcrime.securesms.util.AppSignatureUtil
|
||||||
import shark.AndroidReferenceMatchers
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
class SpinnerApplicationContext : ApplicationContext() {
|
class SpinnerApplicationContext : ApplicationContext() {
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
|
||||||
StrictMode.setThreadPolicy(
|
|
||||||
ThreadPolicy.Builder()
|
|
||||||
.detectDiskReads()
|
|
||||||
.detectDiskWrites()
|
|
||||||
.detectNetwork()
|
|
||||||
.penaltyLog()
|
|
||||||
.build()
|
|
||||||
)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName("dalvik.system.CloseGuard")
|
Class.forName("dalvik.system.CloseGuard")
|
||||||
.getMethod("setEnabled", Boolean::class.javaPrimitiveType)
|
.getMethod("setEnabled", Boolean::class.javaPrimitiveType)
|
||||||
@@ -93,41 +80,5 @@ class SpinnerApplicationContext : ApplicationContext() {
|
|||||||
Spinner.onUpdate("signal", table, values, selection, args)
|
Spinner.onUpdate("signal", table, values, selection, args)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
LeakCanary.config = LeakCanary.config.copy(
|
|
||||||
referenceMatchers = AndroidReferenceMatchers.appDefaults +
|
|
||||||
AndroidReferenceMatchers.ignoredInstanceField(
|
|
||||||
className = "android.service.media.MediaBrowserService\$ServiceBinder",
|
|
||||||
fieldName = "this\$0"
|
|
||||||
) +
|
|
||||||
AndroidReferenceMatchers.ignoredInstanceField(
|
|
||||||
className = "androidx.media.MediaBrowserServiceCompat\$MediaBrowserServiceImplApi26\$MediaBrowserServiceApi26",
|
|
||||||
fieldName = "mBase"
|
|
||||||
) +
|
|
||||||
AndroidReferenceMatchers.ignoredInstanceField(
|
|
||||||
className = "android.support.v4.media.MediaBrowserCompat",
|
|
||||||
fieldName = "mImpl"
|
|
||||||
) +
|
|
||||||
AndroidReferenceMatchers.ignoredInstanceField(
|
|
||||||
className = "android.support.v4.media.session.MediaControllerCompat",
|
|
||||||
fieldName = "mToken"
|
|
||||||
) +
|
|
||||||
AndroidReferenceMatchers.ignoredInstanceField(
|
|
||||||
className = "android.support.v4.media.session.MediaControllerCompat",
|
|
||||||
fieldName = "mImpl"
|
|
||||||
) +
|
|
||||||
AndroidReferenceMatchers.ignoredInstanceField(
|
|
||||||
className = "org.thoughtcrime.securesms.components.voice.VoiceNotePlaybackService",
|
|
||||||
fieldName = "mApplication"
|
|
||||||
) +
|
|
||||||
AndroidReferenceMatchers.ignoredInstanceField(
|
|
||||||
className = "org.thoughtcrime.securesms.service.GenericForegroundService\$LocalBinder",
|
|
||||||
fieldName = "this\$0"
|
|
||||||
) +
|
|
||||||
AndroidReferenceMatchers.ignoredInstanceField(
|
|
||||||
className = "org.thoughtcrime.securesms.contacts.ContactsSyncAdapter",
|
|
||||||
fieldName = "mContext"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user