Skip to content

Commit

Permalink
Merge pull request #2524 from square/py/no_deprecated
Browse files Browse the repository at this point in the history
Removing deprecated code
  • Loading branch information
pyricau authored May 31, 2023
2 parents 85a4420 + b172ed5 commit b463445
Show file tree
Hide file tree
Showing 76 changed files with 1,351 additions and 1,793 deletions.
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# We would like to use Kotlin recent language features but keep Kotlin 1.3 library APIs
# The benefit is that depending clients do not have to upgrade to Kotlin 1.4
kotlin = "1.8.21"
coroutines = "1.7.0"
androidXTest = "1.1.0"
androidXJunit = "1.1.3"
workManager = "2.7.0"
Expand All @@ -30,6 +31,8 @@ gradlePlugin-detekt = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plug
gradlePlugin-keeper = { module = "com.slack.keeper:keeper", version = "0.7.0" }
gradlePlugin-sqldelight = { module = "app.cash.sqldelight:gradle-plugin", version = "2.0.0-alpha05" }

coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }

kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }

Expand Down
49 changes: 12 additions & 37 deletions leakcanary/leakcanary-android-core/api/leakcanary-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ public final class leakcanary/BackgroundThreadHeapAnalyzer : leakcanary/EventLis
public fun onEvent (Lleakcanary/EventListener$Event;)V
}

public final class leakcanary/DefaultOnHeapAnalyzedListener : leakcanary/OnHeapAnalyzedListener {
public static final field Companion Lleakcanary/DefaultOnHeapAnalyzedListener$Companion;
public fun <init> (Landroid/app/Application;)V
public fun onHeapAnalyzed (Lshark/HeapAnalysis;)V
}

public final class leakcanary/DefaultOnHeapAnalyzedListener$Companion {
public final fun create ()Lleakcanary/OnHeapAnalyzedListener;
}

public abstract interface class leakcanary/EventListener {
public abstract fun onEvent (Lleakcanary/EventListener$Event;)V
}
Expand Down Expand Up @@ -94,25 +84,23 @@ public final class leakcanary/LeakCanary {

public final class leakcanary/LeakCanary$Config {
public fun <init> ()V
public fun <init> (ZZILjava/util/List;Ljava/util/List;Lleakcanary/OnHeapAnalyzedListener;Lshark/MetadataExtractor;ZIZLshark/LeakingObjectFinder;Lleakcanary/HeapDumper;Ljava/util/List;ZZ)V
public synthetic fun <init> (ZZILjava/util/List;Ljava/util/List;Lleakcanary/OnHeapAnalyzedListener;Lshark/MetadataExtractor;ZIZLshark/LeakingObjectFinder;Lleakcanary/HeapDumper;Ljava/util/List;ZZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (ZZILjava/util/List;Ljava/util/List;Lshark/MetadataExtractor;ZIZLshark/LeakingObjectFinder;Lleakcanary/HeapDumper;Ljava/util/List;Z)V
public synthetic fun <init> (ZZILjava/util/List;Ljava/util/List;Lshark/MetadataExtractor;ZIZLshark/LeakingObjectFinder;Lleakcanary/HeapDumper;Ljava/util/List;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Z
public final fun component10 ()Z
public final fun component11 ()Lshark/LeakingObjectFinder;
public final fun component12 ()Lleakcanary/HeapDumper;
public final fun component13 ()Ljava/util/List;
public final fun component14 ()Z
public final fun component15 ()Z
public final fun component10 ()Lshark/LeakingObjectFinder;
public final fun component11 ()Lleakcanary/HeapDumper;
public final fun component12 ()Ljava/util/List;
public final fun component13 ()Z
public final fun component2 ()Z
public final fun component3 ()I
public final fun component4 ()Ljava/util/List;
public final fun component5 ()Ljava/util/List;
public final fun component6 ()Lleakcanary/OnHeapAnalyzedListener;
public final fun component7 ()Lshark/MetadataExtractor;
public final fun component8 ()Z
public final fun component9 ()I
public final fun copy (ZZILjava/util/List;Ljava/util/List;Lleakcanary/OnHeapAnalyzedListener;Lshark/MetadataExtractor;ZIZLshark/LeakingObjectFinder;Lleakcanary/HeapDumper;Ljava/util/List;ZZ)Lleakcanary/LeakCanary$Config;
public static synthetic fun copy$default (Lleakcanary/LeakCanary$Config;ZZILjava/util/List;Ljava/util/List;Lleakcanary/OnHeapAnalyzedListener;Lshark/MetadataExtractor;ZIZLshark/LeakingObjectFinder;Lleakcanary/HeapDumper;Ljava/util/List;ZZILjava/lang/Object;)Lleakcanary/LeakCanary$Config;
public final fun component6 ()Lshark/MetadataExtractor;
public final fun component7 ()Z
public final fun component8 ()I
public final fun component9 ()Z
public final fun copy (ZZILjava/util/List;Ljava/util/List;Lshark/MetadataExtractor;ZIZLshark/LeakingObjectFinder;Lleakcanary/HeapDumper;Ljava/util/List;Z)Lleakcanary/LeakCanary$Config;
public static synthetic fun copy$default (Lleakcanary/LeakCanary$Config;ZZILjava/util/List;Ljava/util/List;Lshark/MetadataExtractor;ZIZLshark/LeakingObjectFinder;Lleakcanary/HeapDumper;Ljava/util/List;ZILjava/lang/Object;)Lleakcanary/LeakCanary$Config;
public fun equals (Ljava/lang/Object;)Z
public final fun getComputeRetainedHeapSize ()Z
public final fun getDumpHeap ()Z
Expand All @@ -123,12 +111,10 @@ public final class leakcanary/LeakCanary$Config {
public final fun getMaxStoredHeapDumps ()I
public final fun getMetadataExtractor ()Lshark/MetadataExtractor;
public final fun getObjectInspectors ()Ljava/util/List;
public final fun getOnHeapAnalyzedListener ()Lleakcanary/OnHeapAnalyzedListener;
public final fun getReferenceMatchers ()Ljava/util/List;
public final fun getRequestWriteExternalStoragePermission ()Z
public final fun getRetainedVisibleThreshold ()I
public final fun getShowNotifications ()Z
public final fun getUseExperimentalLeakFinders ()Z
public fun hashCode ()I
public final fun newBuilder ()Lleakcanary/LeakCanary$Config$Builder;
public fun toString ()Ljava/lang/String;
Expand All @@ -145,12 +131,10 @@ public final class leakcanary/LeakCanary$Config$Builder {
public final fun maxStoredHeapDumps (I)Lleakcanary/LeakCanary$Config$Builder;
public final fun metadataExtractor (Lshark/MetadataExtractor;)Lleakcanary/LeakCanary$Config$Builder;
public final fun objectInspectors (Ljava/util/List;)Lleakcanary/LeakCanary$Config$Builder;
public final fun onHeapAnalyzedListener (Lleakcanary/OnHeapAnalyzedListener;)Lleakcanary/LeakCanary$Config$Builder;
public final fun referenceMatchers (Ljava/util/List;)Lleakcanary/LeakCanary$Config$Builder;
public final fun requestWriteExternalStoragePermission (Z)Lleakcanary/LeakCanary$Config$Builder;
public final fun retainedVisibleThreshold (I)Lleakcanary/LeakCanary$Config$Builder;
public final fun showNotifications (Z)Lleakcanary/LeakCanary$Config$Builder;
public final fun useExperimentalLeakFinders (Z)Lleakcanary/LeakCanary$Config$Builder;
}

public final class leakcanary/LogcatEventListener : leakcanary/EventListener {
Expand All @@ -163,15 +147,6 @@ public final class leakcanary/NotificationEventListener : leakcanary/EventListen
public fun onEvent (Lleakcanary/EventListener$Event;)V
}

public abstract interface class leakcanary/OnHeapAnalyzedListener {
public static final field Companion Lleakcanary/OnHeapAnalyzedListener$Companion;
public abstract fun onHeapAnalyzed (Lshark/HeapAnalysis;)V
}

public final class leakcanary/OnHeapAnalyzedListener$Companion {
public final fun invoke (Lkotlin/jvm/functions/Function1;)Lleakcanary/OnHeapAnalyzedListener;
}

public final class leakcanary/RemoteWorkManagerHeapAnalyzer : leakcanary/EventListener {
public static final field INSTANCE Lleakcanary/RemoteWorkManagerHeapAnalyzer;
public fun onEvent (Lleakcanary/EventListener$Event;)V
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,6 @@ object LeakCanary {
*/
val objectInspectors: List<ObjectInspector> = AndroidObjectInspectors.appDefaults,

/**
* Deprecated, add to LeakCanary.config.eventListeners instead.
* Called on a background thread when the heap analysis is complete.
* If you want leaks to be added to the activity that lists leaks, make sure to delegate
* calls to a [DefaultOnHeapAnalyzedListener].
*
* Defaults to [DefaultOnHeapAnalyzedListener]
*/
@Deprecated(message = "Add to LeakCanary.config.eventListeners instead")
val onHeapAnalyzedListener: OnHeapAnalyzedListener = DefaultOnHeapAnalyzedListener.create(),

/**
* Extracts metadata from a hprof to be reported in [HeapAnalysisSuccess.metadata].
* Called on a background thread during heap analysis.
Expand Down Expand Up @@ -216,12 +205,6 @@ object LeakCanary {
* Defaults to true.
*/
val showNotifications: Boolean = true,

/**
* Deprecated: This is a no-op, set a custom [leakingObjectFinder] instead.
*/
@Deprecated("This is a no-op, set a custom leakingObjectFinder instead")
val useExperimentalLeakFinders: Boolean = false
) {

/**
Expand Down Expand Up @@ -255,7 +238,6 @@ object LeakCanary {
private var retainedVisibleThreshold = config.retainedVisibleThreshold
private var referenceMatchers = config.referenceMatchers
private var objectInspectors = config.objectInspectors
private var onHeapAnalyzedListener = config.onHeapAnalyzedListener
private var metadataExtractor = config.metadataExtractor
private var computeRetainedHeapSize = config.computeRetainedHeapSize
private var maxStoredHeapDumps = config.maxStoredHeapDumps
Expand All @@ -264,7 +246,6 @@ object LeakCanary {
private var leakingObjectFinder = config.leakingObjectFinder
private var heapDumper = config.heapDumper
private var eventListeners = config.eventListeners
private var useExperimentalLeakFinders = config.useExperimentalLeakFinders
private var showNotifications = config.showNotifications

/** @see [LeakCanary.Config.dumpHeap] */
Expand All @@ -287,11 +268,6 @@ object LeakCanary {
fun objectInspectors(objectInspectors: List<ObjectInspector>) =
apply { this.objectInspectors = objectInspectors }

/** @see [LeakCanary.Config.onHeapAnalyzedListener] */
@Deprecated(message = "Add to LeakCanary.config.eventListeners instead")
fun onHeapAnalyzedListener(onHeapAnalyzedListener: OnHeapAnalyzedListener) =
apply { this.onHeapAnalyzedListener = onHeapAnalyzedListener }

/** @see [LeakCanary.Config.metadataExtractor] */
fun metadataExtractor(metadataExtractor: MetadataExtractor) =
apply { this.metadataExtractor = metadataExtractor }
Expand Down Expand Up @@ -320,11 +296,6 @@ object LeakCanary {
fun eventListeners(eventListeners: List<EventListener>) =
apply { this.eventListeners = eventListeners }

/** @see [LeakCanary.Config.useExperimentalLeakFinders] */
@Deprecated("Set a custom leakingObjectFinder instead")
fun useExperimentalLeakFinders(useExperimentalLeakFinders: Boolean) =
apply { this.useExperimentalLeakFinders = useExperimentalLeakFinders }

/** @see [LeakCanary.Config.showNotifications] */
fun showNotifications(showNotifications: Boolean) =
apply { this.showNotifications = showNotifications }
Expand All @@ -336,15 +307,13 @@ object LeakCanary {
retainedVisibleThreshold = retainedVisibleThreshold,
referenceMatchers = referenceMatchers,
objectInspectors = objectInspectors,
onHeapAnalyzedListener = onHeapAnalyzedListener,
metadataExtractor = metadataExtractor,
computeRetainedHeapSize = computeRetainedHeapSize,
maxStoredHeapDumps = maxStoredHeapDumps,
requestWriteExternalStoragePermission = requestWriteExternalStoragePermission,
leakingObjectFinder = leakingObjectFinder,
heapDumper = heapDumper,
eventListeners = eventListeners,
useExperimentalLeakFinders = useExperimentalLeakFinders,
showNotifications = showNotifications,
)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ internal object AndroidDebugHeapAnalyzer {
}
}
}
LeakCanary.config.onHeapAnalyzedListener.onHeapAnalyzed(fullHeapAnalysis)
return analysisDoneEvent
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,6 @@ public abstract interface class leakcanary/HeapAnalysisReporter {
public abstract fun reportHeapAnalysis (Lshark/HeapAnalysis;)V
}

public final class leakcanary/InstrumentationLeakDetector {
public static final field Companion Lleakcanary/InstrumentationLeakDetector$Companion;
public fun <init> ()V
public final fun detectLeaks ()Lleakcanary/InstrumentationLeakDetector$Result;
}

public final class leakcanary/InstrumentationLeakDetector$Companion {
public final fun updateConfig ()V
}

public abstract class leakcanary/InstrumentationLeakDetector$Result {
}

public final class leakcanary/InstrumentationLeakDetector$Result$AnalysisPerformed : leakcanary/InstrumentationLeakDetector$Result {
public fun <init> (Lshark/HeapAnalysis;)V
public final fun getHeapAnalysis ()Lshark/HeapAnalysis;
}

public final class leakcanary/InstrumentationLeakDetector$Result$NoAnalysis : leakcanary/InstrumentationLeakDetector$Result {
public fun <init> (Ljava/lang/String;)V
public final fun getReason ()Ljava/lang/String;
}

public final class leakcanary/LeakAssertions {
public static final field INSTANCE Lleakcanary/LeakAssertions;
public static final field NO_TAG Ljava/lang/String;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import org.junit.Test
import java.util.Date

/**
* Tests that the [InstrumentationLeakDetector] can detect leaks
* Tests that the [AndroidDetectLeaksAssert] can detect leaks
* in instrumentation tests
*/
class InstrumentationLeakDetectorTest {
class AndroidDetectLeaksAssertTest {

@Before fun setUp() {
AppWatcher.objectWatcher
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package leakcanary

import android.os.SystemClock
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Test
import shark.Hprof
import shark.HprofHeapGraph
import shark.SharkLog
import java.io.File
import java.io.FileOutputStream
import leakcanary.internal.friendly.measureDurationMillis
import org.junit.Test
import shark.FileSourceProvider
import shark.HprofHeader
import shark.HprofIndex
import shark.SharkLog

class IndexingTest {

Expand All @@ -18,13 +19,17 @@ class IndexingTest {
val heapDumpFile = File(context.filesDir, "AnalysisDurationTest.hprof")
context.assets.open("large-dump.hprof").copyTo(FileOutputStream(heapDumpFile))

Hprof.open(heapDumpFile).use { hprof ->
SharkLog.d { "Start indexing" }
val before = SystemClock.uptimeMillis()
HprofHeapGraph.indexHprof(hprof)
val durationMs = (SystemClock.uptimeMillis() - before)
SharkLog.d { "Indexing took $durationMs ms" }
val sourceProvider = FileSourceProvider(heapDumpFile)
val parsedHeaders = HprofHeader.parseHeaderOf(heapDumpFile)

SharkLog.d { "Start indexing" }
val durationMs = measureDurationMillis {
HprofIndex.indexRecordsOf(
hprofSourceProvider = sourceProvider,
hprofHeader = parsedHeaders
)
}
SharkLog.d { "Indexing took $durationMs ms" }
}
}

Loading

0 comments on commit b463445

Please sign in to comment.