64 lines
2.6 KiB
Java
64 lines
2.6 KiB
Java
package com.squareup.leakcanary;
|
|
|
|
import java.io.Serializable;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class AnalysisResult implements Serializable {
|
|
public static final long RETAINED_HEAP_SKIPPED = -1;
|
|
public final long analysisDurationMs;
|
|
public final String className;
|
|
public final boolean excludedLeak;
|
|
public final Throwable failure;
|
|
public final boolean leakFound;
|
|
public final LeakTrace leakTrace;
|
|
public final long retainedHeapSize;
|
|
|
|
private AnalysisResult(boolean z, boolean z2, String str, LeakTrace leakTrace, Throwable th, long j, long j2) {
|
|
this.leakFound = z;
|
|
this.excludedLeak = z2;
|
|
this.className = str;
|
|
this.leakTrace = leakTrace;
|
|
this.failure = th;
|
|
this.retainedHeapSize = j;
|
|
this.analysisDurationMs = j2;
|
|
}
|
|
|
|
private String classSimpleName(String str) {
|
|
int lastIndexOf = str.lastIndexOf(46);
|
|
return lastIndexOf == -1 ? str : str.substring(lastIndexOf + 1);
|
|
}
|
|
|
|
public static AnalysisResult failure(Throwable th, long j) {
|
|
return new AnalysisResult(false, false, null, null, th, 0L, j);
|
|
}
|
|
|
|
public static AnalysisResult leakDetected(boolean z, String str, LeakTrace leakTrace, long j, long j2) {
|
|
return new AnalysisResult(true, z, str, leakTrace, null, j, j2);
|
|
}
|
|
|
|
public static AnalysisResult noLeak(String str, long j) {
|
|
return new AnalysisResult(false, false, str, null, null, 0L, j);
|
|
}
|
|
|
|
public RuntimeException leakTraceAsFakeException() {
|
|
if (!this.leakFound) {
|
|
throw new UnsupportedOperationException("leakTraceAsFakeException() can only be called when leakFound is true");
|
|
}
|
|
int i = 0;
|
|
LeakTraceElement leakTraceElement = this.leakTrace.elements.get(0);
|
|
String classSimpleName = classSimpleName(leakTraceElement.className);
|
|
RuntimeException runtimeException = new RuntimeException(classSimpleName(this.className) + " leak from " + classSimpleName + " (holder=" + leakTraceElement.holder + ", type=" + leakTraceElement.type + ")");
|
|
StackTraceElement[] stackTraceElementArr = new StackTraceElement[this.leakTrace.elements.size()];
|
|
for (LeakTraceElement leakTraceElement2 : this.leakTrace.elements) {
|
|
String str = leakTraceElement2.referenceName;
|
|
if (str == null) {
|
|
str = "leaking";
|
|
}
|
|
stackTraceElementArr[i] = new StackTraceElement(leakTraceElement2.className, str, classSimpleName(leakTraceElement2.className) + ".java", 42);
|
|
i++;
|
|
}
|
|
runtimeException.setStackTrace(stackTraceElementArr);
|
|
return runtimeException;
|
|
}
|
|
}
|