- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
145 lines
5.9 KiB
Java
145 lines
5.9 KiB
Java
package com.facebook.internal.instrument.anrreport;
|
|
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import com.facebook.FacebookSdk;
|
|
import com.facebook.GraphRequest;
|
|
import com.facebook.GraphResponse;
|
|
import com.facebook.internal.Utility;
|
|
import com.facebook.internal.instrument.InstrumentData;
|
|
import com.facebook.internal.instrument.InstrumentUtility;
|
|
import com.facebook.internal.instrument.crashshield.CrashShieldHandler;
|
|
import java.io.File;
|
|
import java.util.ArrayList;
|
|
import java.util.Comparator;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import kotlin.collections.CollectionsKt___CollectionsKt;
|
|
import kotlin.collections.IntIterator;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.ranges.IntRange;
|
|
import kotlin.ranges.RangesKt___RangesKt;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
/* loaded from: classes2.dex */
|
|
public final class ANRHandler {
|
|
private static final int MAX_ANR_REPORT_NUM = 5;
|
|
public static final ANRHandler INSTANCE = new ANRHandler();
|
|
private static final AtomicBoolean enabled = new AtomicBoolean(false);
|
|
|
|
private ANRHandler() {
|
|
}
|
|
|
|
public static final synchronized void enable() {
|
|
synchronized (ANRHandler.class) {
|
|
if (CrashShieldHandler.isObjectCrashing(ANRHandler.class)) {
|
|
return;
|
|
}
|
|
try {
|
|
if (enabled.getAndSet(true)) {
|
|
return;
|
|
}
|
|
if (FacebookSdk.getAutoLogAppEventsEnabled()) {
|
|
sendANRReports();
|
|
}
|
|
ANRDetector.start();
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, ANRHandler.class);
|
|
}
|
|
}
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public static final void sendANRReports() {
|
|
final List sortedWith;
|
|
IntRange until;
|
|
if (CrashShieldHandler.isObjectCrashing(ANRHandler.class)) {
|
|
return;
|
|
}
|
|
try {
|
|
if (Utility.isDataProcessingRestricted()) {
|
|
return;
|
|
}
|
|
File[] listAnrReportFiles = InstrumentUtility.listAnrReportFiles();
|
|
ArrayList arrayList = new ArrayList(listAnrReportFiles.length);
|
|
for (File file : listAnrReportFiles) {
|
|
arrayList.add(InstrumentData.Builder.load(file));
|
|
}
|
|
ArrayList arrayList2 = new ArrayList();
|
|
for (Object obj : arrayList) {
|
|
if (((InstrumentData) obj).isValid()) {
|
|
arrayList2.add(obj);
|
|
}
|
|
}
|
|
sortedWith = CollectionsKt___CollectionsKt.sortedWith(arrayList2, new Comparator() { // from class: com.facebook.internal.instrument.anrreport.ANRHandler$$ExternalSyntheticLambda0
|
|
@Override // java.util.Comparator
|
|
public final int compare(Object obj2, Object obj3) {
|
|
int m601sendANRReports$lambda2;
|
|
m601sendANRReports$lambda2 = ANRHandler.m601sendANRReports$lambda2((InstrumentData) obj2, (InstrumentData) obj3);
|
|
return m601sendANRReports$lambda2;
|
|
}
|
|
});
|
|
JSONArray jSONArray = new JSONArray();
|
|
until = RangesKt___RangesKt.until(0, Math.min(sortedWith.size(), 5));
|
|
Iterator it = until.iterator();
|
|
while (it.hasNext()) {
|
|
jSONArray.put(sortedWith.get(((IntIterator) it).nextInt()));
|
|
}
|
|
InstrumentUtility instrumentUtility = InstrumentUtility.INSTANCE;
|
|
InstrumentUtility.sendReports("anr_reports", jSONArray, new GraphRequest.Callback() { // from class: com.facebook.internal.instrument.anrreport.ANRHandler$$ExternalSyntheticLambda1
|
|
@Override // com.facebook.GraphRequest.Callback
|
|
public final void onCompleted(GraphResponse graphResponse) {
|
|
ANRHandler.m602sendANRReports$lambda5(sortedWith, graphResponse);
|
|
}
|
|
});
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, ANRHandler.class);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* renamed from: sendANRReports$lambda-2, reason: not valid java name */
|
|
public static final int m601sendANRReports$lambda2(InstrumentData instrumentData, InstrumentData o2) {
|
|
if (CrashShieldHandler.isObjectCrashing(ANRHandler.class)) {
|
|
return 0;
|
|
}
|
|
try {
|
|
Intrinsics.checkNotNullExpressionValue(o2, "o2");
|
|
return instrumentData.compareTo(o2);
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, ANRHandler.class);
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* renamed from: sendANRReports$lambda-5, reason: not valid java name */
|
|
public static final void m602sendANRReports$lambda5(List validReports, GraphResponse response) {
|
|
if (CrashShieldHandler.isObjectCrashing(ANRHandler.class)) {
|
|
return;
|
|
}
|
|
try {
|
|
Intrinsics.checkNotNullParameter(validReports, "$validReports");
|
|
Intrinsics.checkNotNullParameter(response, "response");
|
|
try {
|
|
if (response.getError() == null) {
|
|
JSONObject jsonObject = response.getJsonObject();
|
|
if (Intrinsics.areEqual(jsonObject == null ? null : Boolean.valueOf(jsonObject.getBoolean("success")), Boolean.TRUE)) {
|
|
Iterator it = validReports.iterator();
|
|
while (it.hasNext()) {
|
|
((InstrumentData) it.next()).clear();
|
|
}
|
|
}
|
|
}
|
|
} catch (JSONException unused) {
|
|
}
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, ANRHandler.class);
|
|
}
|
|
}
|
|
}
|