Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,119 @@
package com.facebook.internal.instrument;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import com.facebook.FacebookSdk;
import com.facebook.GraphRequest;
import com.facebook.GraphRequestBatch;
import com.facebook.GraphResponse;
import com.facebook.internal.FeatureManager;
import com.facebook.internal.Utility;
import com.facebook.internal.instrument.InstrumentData;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.StringCompanionObject;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes2.dex */
public final class ExceptionAnalyzer {
public static final ExceptionAnalyzer INSTANCE = new ExceptionAnalyzer();
private static boolean enabled;
@VisibleForTesting(otherwise = 2)
public static final boolean isDebug$facebook_core_release() {
return false;
}
private ExceptionAnalyzer() {
}
public static final void enable() {
enabled = true;
if (FacebookSdk.getAutoLogAppEventsEnabled()) {
INSTANCE.sendExceptionAnalysisReports$facebook_core_release();
}
}
public static final void execute(Throwable th) {
if (!enabled || isDebug$facebook_core_release() || th == null) {
return;
}
HashSet hashSet = new HashSet();
StackTraceElement[] stackTrace = th.getStackTrace();
Intrinsics.checkNotNullExpressionValue(stackTrace, "e.stackTrace");
for (StackTraceElement stackTraceElement : stackTrace) {
FeatureManager featureManager = FeatureManager.INSTANCE;
String className = stackTraceElement.getClassName();
Intrinsics.checkNotNullExpressionValue(className, "it.className");
FeatureManager.Feature feature = FeatureManager.getFeature(className);
if (feature != FeatureManager.Feature.Unknown) {
FeatureManager.disableFeature(feature);
hashSet.add(feature.toString());
}
}
if (FacebookSdk.getAutoLogAppEventsEnabled() && (!hashSet.isEmpty())) {
InstrumentData.Builder builder = InstrumentData.Builder.INSTANCE;
InstrumentData.Builder.build(new JSONArray((Collection) hashSet)).save();
}
}
@VisibleForTesting(otherwise = 2)
public final void sendExceptionAnalysisReports$facebook_core_release() {
if (Utility.isDataProcessingRestricted()) {
return;
}
File[] listExceptionAnalysisReportFiles = InstrumentUtility.listExceptionAnalysisReportFiles();
ArrayList arrayList = new ArrayList();
int length = listExceptionAnalysisReportFiles.length;
int i = 0;
while (i < length) {
File file = listExceptionAnalysisReportFiles[i];
i++;
final InstrumentData load = InstrumentData.Builder.load(file);
if (load.isValid()) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("crash_shield", load.toString());
GraphRequest.Companion companion = GraphRequest.Companion;
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format("%s/instruments", Arrays.copyOf(new Object[]{FacebookSdk.getApplicationId()}, 1));
Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(format, *args)");
arrayList.add(companion.newPostRequest(null, format, jSONObject, new GraphRequest.Callback() { // from class: com.facebook.internal.instrument.ExceptionAnalyzer$$ExternalSyntheticLambda0
@Override // com.facebook.GraphRequest.Callback
public final void onCompleted(GraphResponse graphResponse) {
ExceptionAnalyzer.m590sendExceptionAnalysisReports$lambda1(InstrumentData.this, graphResponse);
}
}));
} catch (JSONException unused) {
}
}
}
if (arrayList.isEmpty()) {
return;
}
new GraphRequestBatch(arrayList).executeAsync();
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: sendExceptionAnalysisReports$lambda-1, reason: not valid java name */
public static final void m590sendExceptionAnalysisReports$lambda1(InstrumentData instrumentData, GraphResponse response) {
Intrinsics.checkNotNullParameter(instrumentData, "$instrumentData");
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)) {
instrumentData.clear();
}
}
} catch (JSONException unused) {
}
}
}

View File

@@ -0,0 +1,334 @@
package com.facebook.internal.instrument;
import android.os.Build;
import androidx.annotation.RestrictTo;
import com.facebook.internal.Utility;
import java.io.File;
import java.util.Arrays;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt__StringsJVMKt;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes2.dex */
public final class InstrumentData {
public static final Companion Companion = new Companion(null);
private static final String PARAM_APP_VERSION = "app_version";
private static final String PARAM_CALLSTACK = "callstack";
private static final String PARAM_DEVICE_MODEL = "device_model";
private static final String PARAM_DEVICE_OS = "device_os_version";
private static final String PARAM_FEATURE_NAMES = "feature_names";
private static final String PARAM_REASON = "reason";
private static final String PARAM_TIMESTAMP = "timestamp";
private static final String PARAM_TYPE = "type";
private static final String UNKNOWN = "Unknown";
private String appVersion;
private String cause;
private JSONArray featureNames;
private String filename;
private String stackTrace;
private Long timestamp;
private Type type;
public /* synthetic */ class WhenMappings {
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
static {
int[] iArr = new int[Type.valuesCustom().length];
iArr[Type.Analysis.ordinal()] = 1;
iArr[Type.AnrReport.ordinal()] = 2;
iArr[Type.CrashReport.ordinal()] = 3;
iArr[Type.CrashShield.ordinal()] = 4;
iArr[Type.ThreadCheck.ordinal()] = 5;
$EnumSwitchMapping$0 = iArr;
}
}
public /* synthetic */ InstrumentData(File file, DefaultConstructorMarker defaultConstructorMarker) {
this(file);
}
public /* synthetic */ InstrumentData(String str, String str2, DefaultConstructorMarker defaultConstructorMarker) {
this(str, str2);
}
public /* synthetic */ InstrumentData(Throwable th, Type type, DefaultConstructorMarker defaultConstructorMarker) {
this(th, type);
}
public /* synthetic */ InstrumentData(JSONArray jSONArray, DefaultConstructorMarker defaultConstructorMarker) {
this(jSONArray);
}
public enum Type {
Unknown,
Analysis,
AnrReport,
CrashReport,
CrashShield,
ThreadCheck;
public /* synthetic */ class WhenMappings {
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
static {
int[] iArr = new int[Type.valuesCustom().length];
iArr[Type.Analysis.ordinal()] = 1;
iArr[Type.AnrReport.ordinal()] = 2;
iArr[Type.CrashReport.ordinal()] = 3;
iArr[Type.CrashShield.ordinal()] = 4;
iArr[Type.ThreadCheck.ordinal()] = 5;
$EnumSwitchMapping$0 = iArr;
}
}
@Override // java.lang.Enum
public String toString() {
int i = WhenMappings.$EnumSwitchMapping$0[ordinal()];
return i != 1 ? i != 2 ? i != 3 ? i != 4 ? i != 5 ? "Unknown" : "ThreadCheck" : "CrashShield" : "CrashReport" : "AnrReport" : "Analysis";
}
public final String getLogPrefix() {
int i = WhenMappings.$EnumSwitchMapping$0[ordinal()];
return i != 1 ? i != 2 ? i != 3 ? i != 4 ? i != 5 ? "Unknown" : InstrumentUtility.THREAD_CHECK_PREFIX : InstrumentUtility.CRASH_SHIELD_PREFIX : InstrumentUtility.CRASH_REPORT_PREFIX : InstrumentUtility.ANR_REPORT_PREFIX : InstrumentUtility.ANALYSIS_REPORT_PREFIX;
}
/* renamed from: values, reason: to resolve conflict with enum method */
public static Type[] valuesCustom() {
Type[] valuesCustom = values();
return (Type[]) Arrays.copyOf(valuesCustom, valuesCustom.length);
}
}
private InstrumentData(JSONArray jSONArray) {
this.type = Type.Analysis;
this.timestamp = Long.valueOf(System.currentTimeMillis() / 1000);
this.featureNames = jSONArray;
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(InstrumentUtility.ANALYSIS_REPORT_PREFIX);
stringBuffer.append(String.valueOf(this.timestamp));
stringBuffer.append(".json");
String stringBuffer2 = stringBuffer.toString();
Intrinsics.checkNotNullExpressionValue(stringBuffer2, "StringBuffer()\n .append(InstrumentUtility.ANALYSIS_REPORT_PREFIX)\n .append(timestamp.toString())\n .append(\".json\")\n .toString()");
this.filename = stringBuffer2;
}
private InstrumentData(Throwable th, Type type) {
this.type = type;
this.appVersion = Utility.getAppVersion();
this.cause = InstrumentUtility.getCause(th);
this.stackTrace = InstrumentUtility.getStackTrace(th);
this.timestamp = Long.valueOf(System.currentTimeMillis() / 1000);
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(type.getLogPrefix());
stringBuffer.append(String.valueOf(this.timestamp));
stringBuffer.append(".json");
String stringBuffer2 = stringBuffer.toString();
Intrinsics.checkNotNullExpressionValue(stringBuffer2, "StringBuffer().append(t.logPrefix).append(timestamp.toString()).append(\".json\").toString()");
this.filename = stringBuffer2;
}
private InstrumentData(String str, String str2) {
this.type = Type.AnrReport;
this.appVersion = Utility.getAppVersion();
this.cause = str;
this.stackTrace = str2;
this.timestamp = Long.valueOf(System.currentTimeMillis() / 1000);
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(InstrumentUtility.ANR_REPORT_PREFIX);
stringBuffer.append(String.valueOf(this.timestamp));
stringBuffer.append(".json");
String stringBuffer2 = stringBuffer.toString();
Intrinsics.checkNotNullExpressionValue(stringBuffer2, "StringBuffer()\n .append(InstrumentUtility.ANR_REPORT_PREFIX)\n .append(timestamp.toString())\n .append(\".json\")\n .toString()");
this.filename = stringBuffer2;
}
private InstrumentData(File file) {
String name = file.getName();
Intrinsics.checkNotNullExpressionValue(name, "file.name");
this.filename = name;
this.type = Companion.getType(name);
InstrumentUtility instrumentUtility = InstrumentUtility.INSTANCE;
JSONObject readFile = InstrumentUtility.readFile(this.filename, true);
if (readFile != null) {
this.timestamp = Long.valueOf(readFile.optLong("timestamp", 0L));
this.appVersion = readFile.optString(PARAM_APP_VERSION, null);
this.cause = readFile.optString("reason", null);
this.stackTrace = readFile.optString(PARAM_CALLSTACK, null);
this.featureNames = readFile.optJSONArray(PARAM_FEATURE_NAMES);
}
}
public final int compareTo(InstrumentData data) {
Intrinsics.checkNotNullParameter(data, "data");
Long l = this.timestamp;
if (l == null) {
return -1;
}
long longValue = l.longValue();
Long l2 = data.timestamp;
if (l2 == null) {
return 1;
}
return Intrinsics.compare(l2.longValue(), longValue);
}
public final boolean isValid() {
Type type = this.type;
int i = type == null ? -1 : WhenMappings.$EnumSwitchMapping$0[type.ordinal()];
if (i != 1) {
if (i != 2) {
if ((i != 3 && i != 4 && i != 5) || this.stackTrace == null || this.timestamp == null) {
return false;
}
} else if (this.stackTrace == null || this.cause == null || this.timestamp == null) {
return false;
}
} else if (this.featureNames == null || this.timestamp == null) {
return false;
}
return true;
}
public final void save() {
if (isValid()) {
InstrumentUtility instrumentUtility = InstrumentUtility.INSTANCE;
InstrumentUtility.writeFile(this.filename, toString());
}
}
public final void clear() {
InstrumentUtility instrumentUtility = InstrumentUtility.INSTANCE;
InstrumentUtility.deleteFile(this.filename);
}
public String toString() {
JSONObject parameters = getParameters();
if (parameters == null) {
String jSONObject = new JSONObject().toString();
Intrinsics.checkNotNullExpressionValue(jSONObject, "JSONObject().toString()");
return jSONObject;
}
String jSONObject2 = parameters.toString();
Intrinsics.checkNotNullExpressionValue(jSONObject2, "params.toString()");
return jSONObject2;
}
private final JSONObject getParameters() {
Type type = this.type;
int i = type == null ? -1 : WhenMappings.$EnumSwitchMapping$0[type.ordinal()];
if (i == 1) {
return getAnalysisReportParameters();
}
if (i == 2 || i == 3 || i == 4 || i == 5) {
return getExceptionReportParameters();
}
return null;
}
private final JSONObject getAnalysisReportParameters() {
JSONObject jSONObject = new JSONObject();
try {
JSONArray jSONArray = this.featureNames;
if (jSONArray != null) {
jSONObject.put(PARAM_FEATURE_NAMES, jSONArray);
}
Long l = this.timestamp;
if (l != null) {
jSONObject.put("timestamp", l);
}
return jSONObject;
} catch (JSONException unused) {
return null;
}
}
private final JSONObject getExceptionReportParameters() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put(PARAM_DEVICE_OS, Build.VERSION.RELEASE);
jSONObject.put(PARAM_DEVICE_MODEL, Build.MODEL);
String str = this.appVersion;
if (str != null) {
jSONObject.put(PARAM_APP_VERSION, str);
}
Long l = this.timestamp;
if (l != null) {
jSONObject.put("timestamp", l);
}
String str2 = this.cause;
if (str2 != null) {
jSONObject.put("reason", str2);
}
String str3 = this.stackTrace;
if (str3 != null) {
jSONObject.put(PARAM_CALLSTACK, str3);
}
Type type = this.type;
if (type != null) {
jSONObject.put("type", type);
}
return jSONObject;
} catch (JSONException unused) {
return null;
}
}
public static final class Builder {
public static final Builder INSTANCE = new Builder();
private Builder() {
}
public static final InstrumentData load(File file) {
Intrinsics.checkNotNullParameter(file, "file");
return new InstrumentData(file, (DefaultConstructorMarker) null);
}
public static final InstrumentData build(Throwable th, Type t) {
Intrinsics.checkNotNullParameter(t, "t");
return new InstrumentData(th, t, (DefaultConstructorMarker) null);
}
public static final InstrumentData build(JSONArray features) {
Intrinsics.checkNotNullParameter(features, "features");
return new InstrumentData(features, (DefaultConstructorMarker) null);
}
public static final InstrumentData build(String str, String str2) {
return new InstrumentData(str, str2, (DefaultConstructorMarker) null);
}
}
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
/* JADX INFO: Access modifiers changed from: private */
public final Type getType(String str) {
if (StringsKt__StringsJVMKt.startsWith$default(str, InstrumentUtility.CRASH_REPORT_PREFIX, false, 2, null)) {
return Type.CrashReport;
}
if (StringsKt__StringsJVMKt.startsWith$default(str, InstrumentUtility.CRASH_SHIELD_PREFIX, false, 2, null)) {
return Type.CrashShield;
}
if (StringsKt__StringsJVMKt.startsWith$default(str, InstrumentUtility.THREAD_CHECK_PREFIX, false, 2, null)) {
return Type.ThreadCheck;
}
if (StringsKt__StringsJVMKt.startsWith$default(str, InstrumentUtility.ANALYSIS_REPORT_PREFIX, false, 2, null)) {
return Type.Analysis;
}
if (StringsKt__StringsJVMKt.startsWith$default(str, InstrumentUtility.ANR_REPORT_PREFIX, false, 2, null)) {
return Type.AnrReport;
}
return Type.Unknown;
}
}
}

View File

@@ -0,0 +1,75 @@
package com.facebook.internal.instrument;
import androidx.annotation.RestrictTo;
import com.facebook.FacebookSdk;
import com.facebook.internal.FeatureManager;
import com.facebook.internal.instrument.anrreport.ANRHandler;
import com.facebook.internal.instrument.crashreport.CrashHandler;
import com.facebook.internal.instrument.crashshield.CrashShieldHandler;
import com.facebook.internal.instrument.errorreport.ErrorReportHandler;
import com.facebook.internal.instrument.threadcheck.ThreadCheckHandler;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes2.dex */
public final class InstrumentManager {
public static final InstrumentManager INSTANCE = new InstrumentManager();
private InstrumentManager() {
}
public static final void start() {
if (FacebookSdk.getAutoLogAppEventsEnabled()) {
FeatureManager featureManager = FeatureManager.INSTANCE;
FeatureManager.checkFeature(FeatureManager.Feature.CrashReport, new FeatureManager.Callback() { // from class: com.facebook.internal.instrument.InstrumentManager$$ExternalSyntheticLambda0
@Override // com.facebook.internal.FeatureManager.Callback
public final void onCompleted(boolean z) {
InstrumentManager.m592start$lambda0(z);
}
});
FeatureManager.checkFeature(FeatureManager.Feature.ErrorReport, new FeatureManager.Callback() { // from class: com.facebook.internal.instrument.InstrumentManager$$ExternalSyntheticLambda1
@Override // com.facebook.internal.FeatureManager.Callback
public final void onCompleted(boolean z) {
InstrumentManager.m593start$lambda1(z);
}
});
FeatureManager.checkFeature(FeatureManager.Feature.AnrReport, new FeatureManager.Callback() { // from class: com.facebook.internal.instrument.InstrumentManager$$ExternalSyntheticLambda2
@Override // com.facebook.internal.FeatureManager.Callback
public final void onCompleted(boolean z) {
InstrumentManager.m594start$lambda2(z);
}
});
}
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: start$lambda-0, reason: not valid java name */
public static final void m592start$lambda0(boolean z) {
if (z) {
CrashHandler.Companion.enable();
FeatureManager featureManager = FeatureManager.INSTANCE;
if (FeatureManager.isEnabled(FeatureManager.Feature.CrashShield)) {
ExceptionAnalyzer.enable();
CrashShieldHandler.enable();
}
if (FeatureManager.isEnabled(FeatureManager.Feature.ThreadCheck)) {
ThreadCheckHandler.enable();
}
}
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: start$lambda-1, reason: not valid java name */
public static final void m593start$lambda1(boolean z) {
if (z) {
ErrorReportHandler.enable();
}
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: start$lambda-2, reason: not valid java name */
public static final void m594start$lambda2(boolean z) {
if (z) {
ANRHandler.enable();
}
}
}

View File

@@ -0,0 +1,311 @@
package com.facebook.internal.instrument;
import androidx.annotation.RestrictTo;
import com.facebook.FacebookSdk;
import com.facebook.GraphRequest;
import com.facebook.internal.Utility;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.util.Arrays;
import java.util.Iterator;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.StringCompanionObject;
import kotlin.text.Charsets;
import kotlin.text.Regex;
import kotlin.text.StringsKt__StringsJVMKt;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes2.dex */
public final class InstrumentUtility {
public static final String ANALYSIS_REPORT_PREFIX = "analysis_log_";
public static final String ANR_REPORT_PREFIX = "anr_log_";
private static final String CODELESS_PREFIX = "com.facebook.appevents.codeless";
public static final String CRASH_REPORT_PREFIX = "crash_log_";
public static final String CRASH_SHIELD_PREFIX = "shield_log_";
public static final String ERROR_REPORT_PREFIX = "error_log_";
private static final String FBSDK_PREFIX = "com.facebook";
public static final InstrumentUtility INSTANCE = new InstrumentUtility();
private static final String INSTRUMENT_DIR = "instrument";
private static final String METASDK_PREFIX = "com.meta";
private static final String SUGGESTED_EVENTS_PREFIX = "com.facebook.appevents.suggestedevents";
public static final String THREAD_CHECK_PREFIX = "thread_check_log_";
private InstrumentUtility() {
}
public static final String getCause(Throwable th) {
if (th == null) {
return null;
}
if (th.getCause() == null) {
return th.toString();
}
return String.valueOf(th.getCause());
}
public static final String getStackTrace(Throwable th) {
Throwable th2 = null;
if (th == null) {
return null;
}
JSONArray jSONArray = new JSONArray();
while (th != null && th != th2) {
StackTraceElement[] stackTrace = th.getStackTrace();
Intrinsics.checkNotNullExpressionValue(stackTrace, "t.stackTrace");
int length = stackTrace.length;
int i = 0;
while (i < length) {
StackTraceElement stackTraceElement = stackTrace[i];
i++;
jSONArray.put(stackTraceElement.toString());
}
th2 = th;
th = th.getCause();
}
return jSONArray.toString();
}
public static final String getStackTrace(Thread thread) {
Intrinsics.checkNotNullParameter(thread, "thread");
StackTraceElement[] stackTrace = thread.getStackTrace();
JSONArray jSONArray = new JSONArray();
Intrinsics.checkNotNullExpressionValue(stackTrace, "stackTrace");
int length = stackTrace.length;
int i = 0;
while (i < length) {
StackTraceElement stackTraceElement = stackTrace[i];
i++;
jSONArray.put(stackTraceElement.toString());
}
return jSONArray.toString();
}
public static final boolean isSDKRelatedException(Throwable th) {
if (th == null) {
return false;
}
Throwable th2 = null;
while (th != null && th != th2) {
StackTraceElement[] stackTrace = th.getStackTrace();
Intrinsics.checkNotNullExpressionValue(stackTrace, "t.stackTrace");
int length = stackTrace.length;
int i = 0;
while (i < length) {
StackTraceElement element = stackTrace[i];
i++;
Intrinsics.checkNotNullExpressionValue(element, "element");
if (isFromFbOrMeta(element)) {
return true;
}
}
th2 = th;
th = th.getCause();
}
return false;
}
public static final boolean isSDKRelatedThread(Thread thread) {
StackTraceElement[] stackTrace;
if (thread != null && (stackTrace = thread.getStackTrace()) != null) {
for (StackTraceElement element : stackTrace) {
Intrinsics.checkNotNullExpressionValue(element, "element");
if (isFromFbOrMeta(element)) {
String className = element.getClassName();
Intrinsics.checkNotNullExpressionValue(className, "element.className");
if (!StringsKt__StringsJVMKt.startsWith$default(className, CODELESS_PREFIX, false, 2, null)) {
String className2 = element.getClassName();
Intrinsics.checkNotNullExpressionValue(className2, "element.className");
if (!StringsKt__StringsJVMKt.startsWith$default(className2, SUGGESTED_EVENTS_PREFIX, false, 2, null)) {
return true;
}
}
String methodName = element.getMethodName();
Intrinsics.checkNotNullExpressionValue(methodName, "element.methodName");
if (StringsKt__StringsJVMKt.startsWith$default(methodName, "onClick", false, 2, null)) {
continue;
} else {
String methodName2 = element.getMethodName();
Intrinsics.checkNotNullExpressionValue(methodName2, "element.methodName");
if (StringsKt__StringsJVMKt.startsWith$default(methodName2, "onItemClick", false, 2, null)) {
continue;
} else {
String methodName3 = element.getMethodName();
Intrinsics.checkNotNullExpressionValue(methodName3, "element.methodName");
if (!StringsKt__StringsJVMKt.startsWith$default(methodName3, "onTouch", false, 2, null)) {
return true;
}
}
}
}
}
}
return false;
}
public static final File[] listAnrReportFiles() {
File instrumentReportDir = getInstrumentReportDir();
if (instrumentReportDir == null) {
return new File[0];
}
File[] listFiles = instrumentReportDir.listFiles(new FilenameFilter() { // from class: com.facebook.internal.instrument.InstrumentUtility$$ExternalSyntheticLambda2
@Override // java.io.FilenameFilter
public final boolean accept(File file, String str) {
boolean m596listAnrReportFiles$lambda1;
m596listAnrReportFiles$lambda1 = InstrumentUtility.m596listAnrReportFiles$lambda1(file, str);
return m596listAnrReportFiles$lambda1;
}
});
return listFiles == null ? new File[0] : listFiles;
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: listAnrReportFiles$lambda-1, reason: not valid java name */
public static final boolean m596listAnrReportFiles$lambda1(File file, String name) {
Intrinsics.checkNotNullExpressionValue(name, "name");
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format("^%s[0-9]+.json$", Arrays.copyOf(new Object[]{ANR_REPORT_PREFIX}, 1));
Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(format, *args)");
return new Regex(format).matches(name);
}
public static final File[] listExceptionAnalysisReportFiles() {
File instrumentReportDir = getInstrumentReportDir();
if (instrumentReportDir == null) {
return new File[0];
}
File[] listFiles = instrumentReportDir.listFiles(new FilenameFilter() { // from class: com.facebook.internal.instrument.InstrumentUtility$$ExternalSyntheticLambda1
@Override // java.io.FilenameFilter
public final boolean accept(File file, String str) {
boolean m597listExceptionAnalysisReportFiles$lambda2;
m597listExceptionAnalysisReportFiles$lambda2 = InstrumentUtility.m597listExceptionAnalysisReportFiles$lambda2(file, str);
return m597listExceptionAnalysisReportFiles$lambda2;
}
});
return listFiles == null ? new File[0] : listFiles;
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: listExceptionAnalysisReportFiles$lambda-2, reason: not valid java name */
public static final boolean m597listExceptionAnalysisReportFiles$lambda2(File file, String name) {
Intrinsics.checkNotNullExpressionValue(name, "name");
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format("^%s[0-9]+.json$", Arrays.copyOf(new Object[]{ANALYSIS_REPORT_PREFIX}, 1));
Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(format, *args)");
return new Regex(format).matches(name);
}
public static final File[] listExceptionReportFiles() {
File instrumentReportDir = getInstrumentReportDir();
if (instrumentReportDir == null) {
return new File[0];
}
File[] listFiles = instrumentReportDir.listFiles(new FilenameFilter() { // from class: com.facebook.internal.instrument.InstrumentUtility$$ExternalSyntheticLambda0
@Override // java.io.FilenameFilter
public final boolean accept(File file, String str) {
boolean m598listExceptionReportFiles$lambda3;
m598listExceptionReportFiles$lambda3 = InstrumentUtility.m598listExceptionReportFiles$lambda3(file, str);
return m598listExceptionReportFiles$lambda3;
}
});
return listFiles == null ? new File[0] : listFiles;
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: listExceptionReportFiles$lambda-3, reason: not valid java name */
public static final boolean m598listExceptionReportFiles$lambda3(File file, String name) {
Intrinsics.checkNotNullExpressionValue(name, "name");
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format("^(%s|%s|%s)[0-9]+.json$", Arrays.copyOf(new Object[]{CRASH_REPORT_PREFIX, CRASH_SHIELD_PREFIX, THREAD_CHECK_PREFIX}, 3));
Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(format, *args)");
return new Regex(format).matches(name);
}
public static final JSONObject readFile(String str, boolean z) {
File instrumentReportDir = getInstrumentReportDir();
if (instrumentReportDir != null && str != null) {
try {
return new JSONObject(Utility.readStreamToString(new FileInputStream(new File(instrumentReportDir, str))));
} catch (Exception unused) {
if (z) {
deleteFile(str);
}
}
}
return null;
}
public static final void writeFile(String str, String str2) {
File instrumentReportDir = getInstrumentReportDir();
if (instrumentReportDir == null || str == null || str2 == null) {
return;
}
try {
FileOutputStream fileOutputStream = new FileOutputStream(new File(instrumentReportDir, str));
byte[] bytes = str2.getBytes(Charsets.UTF_8);
Intrinsics.checkNotNullExpressionValue(bytes, "(this as java.lang.String).getBytes(charset)");
fileOutputStream.write(bytes);
fileOutputStream.close();
} catch (Exception unused) {
}
}
public static final boolean deleteFile(String str) {
File instrumentReportDir = getInstrumentReportDir();
if (instrumentReportDir == null || str == null) {
return false;
}
return new File(instrumentReportDir, str).delete();
}
public static final void sendReports(String str, JSONArray reports, GraphRequest.Callback callback) {
Intrinsics.checkNotNullParameter(reports, "reports");
if (reports.length() == 0) {
return;
}
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put(str, reports.toString());
JSONObject dataProcessingOptions = Utility.getDataProcessingOptions();
if (dataProcessingOptions != null) {
Iterator<String> keys = dataProcessingOptions.keys();
while (keys.hasNext()) {
String next = keys.next();
jSONObject.put(next, dataProcessingOptions.get(next));
}
}
GraphRequest.Companion companion = GraphRequest.Companion;
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format("%s/instruments", Arrays.copyOf(new Object[]{FacebookSdk.getApplicationId()}, 1));
Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(format, *args)");
companion.newPostRequest(null, format, jSONObject, callback).executeAsync();
} catch (JSONException unused) {
}
}
public static final File getInstrumentReportDir() {
File file = new File(FacebookSdk.getApplicationContext().getCacheDir(), INSTRUMENT_DIR);
if (file.exists() || file.mkdirs()) {
return file;
}
return null;
}
public static final boolean isFromFbOrMeta(StackTraceElement element) {
Intrinsics.checkNotNullParameter(element, "element");
String className = element.getClassName();
Intrinsics.checkNotNullExpressionValue(className, "element.className");
if (!StringsKt__StringsJVMKt.startsWith$default(className, "com.facebook", false, 2, null)) {
String className2 = element.getClassName();
Intrinsics.checkNotNullExpressionValue(className2, "element.className");
if (!StringsKt__StringsJVMKt.startsWith$default(className2, METASDK_PREFIX, false, 2, null)) {
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,92 @@
package com.facebook.internal.instrument.anrreport;
import android.app.ActivityManager;
import android.os.Looper;
import android.os.Process;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import com.facebook.FacebookSdk;
import com.facebook.internal.instrument.InstrumentData;
import com.facebook.internal.instrument.InstrumentUtility;
import com.facebook.internal.instrument.crashshield.CrashShieldHandler;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import kotlin.jvm.internal.Intrinsics;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes2.dex */
public final class ANRDetector {
private static final int DETECTION_INTERVAL_IN_MS = 500;
public static final ANRDetector INSTANCE = new ANRDetector();
private static final int myUid = Process.myUid();
private static final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
private static String previousStackTrace = "";
private static final Runnable anrDetectorRunnable = new Runnable() { // from class: com.facebook.internal.instrument.anrreport.ANRDetector$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
ANRDetector.m600anrDetectorRunnable$lambda0();
}
};
private ANRDetector() {
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: anrDetectorRunnable$lambda-0, reason: not valid java name */
public static final void m600anrDetectorRunnable$lambda0() {
if (CrashShieldHandler.isObjectCrashing(ANRDetector.class)) {
return;
}
try {
Object systemService = FacebookSdk.getApplicationContext().getSystemService("activity");
if (systemService == null) {
throw new NullPointerException("null cannot be cast to non-null type android.app.ActivityManager");
}
checkProcessError((ActivityManager) systemService);
} catch (Exception unused) {
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, ANRDetector.class);
}
}
@VisibleForTesting
public static final void checkProcessError(ActivityManager activityManager) {
if (CrashShieldHandler.isObjectCrashing(ANRDetector.class) || activityManager == null) {
return;
}
try {
List<ActivityManager.ProcessErrorStateInfo> processesInErrorState = activityManager.getProcessesInErrorState();
if (processesInErrorState == null) {
return;
}
for (ActivityManager.ProcessErrorStateInfo processErrorStateInfo : processesInErrorState) {
if (processErrorStateInfo.condition == 2 && processErrorStateInfo.uid == myUid) {
Thread thread = Looper.getMainLooper().getThread();
Intrinsics.checkNotNullExpressionValue(thread, "getMainLooper().thread");
String stackTrace = InstrumentUtility.getStackTrace(thread);
if (!Intrinsics.areEqual(stackTrace, previousStackTrace) && InstrumentUtility.isSDKRelatedThread(thread)) {
previousStackTrace = stackTrace;
InstrumentData.Builder builder = InstrumentData.Builder.INSTANCE;
InstrumentData.Builder.build(processErrorStateInfo.shortMsg, stackTrace).save();
}
}
}
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, ANRDetector.class);
}
}
@VisibleForTesting
public static final void start() {
if (CrashShieldHandler.isObjectCrashing(ANRDetector.class)) {
return;
}
try {
scheduledExecutorService.scheduleWithFixedDelay(anrDetectorRunnable, 0L, 500, TimeUnit.MILLISECONDS);
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, ANRDetector.class);
}
}
}

View File

@@ -0,0 +1,144 @@
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);
}
}
}

View File

@@ -0,0 +1,158 @@
package com.facebook.internal.instrument.crashreport;
import android.util.Log;
import androidx.annotation.RestrictTo;
import com.facebook.FacebookSdk;
import com.facebook.GraphRequest;
import com.facebook.GraphResponse;
import com.facebook.internal.Utility;
import com.facebook.internal.instrument.ExceptionAnalyzer;
import com.facebook.internal.instrument.InstrumentData;
import com.facebook.internal.instrument.InstrumentUtility;
import com.facebook.internal.instrument.crashreport.CrashHandler;
import java.io.File;
import java.lang.Thread;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import kotlin.collections.CollectionsKt___CollectionsKt;
import kotlin.collections.IntIterator;
import kotlin.jvm.internal.DefaultConstructorMarker;
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 CrashHandler implements Thread.UncaughtExceptionHandler {
private static final int MAX_CRASH_REPORT_NUM = 5;
private static CrashHandler instance;
private final Thread.UncaughtExceptionHandler previousHandler;
public static final Companion Companion = new Companion(null);
private static final String TAG = CrashHandler.class.getCanonicalName();
public /* synthetic */ CrashHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler, DefaultConstructorMarker defaultConstructorMarker) {
this(uncaughtExceptionHandler);
}
public static final synchronized void enable() {
synchronized (CrashHandler.class) {
Companion.enable();
}
}
private CrashHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler) {
this.previousHandler = uncaughtExceptionHandler;
}
@Override // java.lang.Thread.UncaughtExceptionHandler
public void uncaughtException(Thread t, Throwable e) {
Intrinsics.checkNotNullParameter(t, "t");
Intrinsics.checkNotNullParameter(e, "e");
if (InstrumentUtility.isSDKRelatedException(e)) {
ExceptionAnalyzer.execute(e);
InstrumentData.Builder builder = InstrumentData.Builder.INSTANCE;
InstrumentData.Builder.build(e, InstrumentData.Type.CrashReport).save();
}
Thread.UncaughtExceptionHandler uncaughtExceptionHandler = this.previousHandler;
if (uncaughtExceptionHandler == null) {
return;
}
uncaughtExceptionHandler.uncaughtException(t, e);
}
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final synchronized void enable() {
try {
if (FacebookSdk.getAutoLogAppEventsEnabled()) {
sendExceptionReports();
}
if (CrashHandler.instance != null) {
Log.w(CrashHandler.TAG, "Already enabled!");
} else {
CrashHandler.instance = new CrashHandler(Thread.getDefaultUncaughtExceptionHandler(), null);
Thread.setDefaultUncaughtExceptionHandler(CrashHandler.instance);
}
} catch (Throwable th) {
throw th;
}
}
private final void sendExceptionReports() {
final List sortedWith;
IntRange until;
if (Utility.isDataProcessingRestricted()) {
return;
}
File[] listExceptionReportFiles = InstrumentUtility.listExceptionReportFiles();
ArrayList arrayList = new ArrayList(listExceptionReportFiles.length);
for (File file : listExceptionReportFiles) {
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.crashreport.CrashHandler$Companion$$ExternalSyntheticLambda0
@Override // java.util.Comparator
public final int compare(Object obj2, Object obj3) {
int m603sendExceptionReports$lambda2;
m603sendExceptionReports$lambda2 = CrashHandler.Companion.m603sendExceptionReports$lambda2((InstrumentData) obj2, (InstrumentData) obj3);
return m603sendExceptionReports$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("crash_reports", jSONArray, new GraphRequest.Callback() { // from class: com.facebook.internal.instrument.crashreport.CrashHandler$Companion$$ExternalSyntheticLambda1
@Override // com.facebook.GraphRequest.Callback
public final void onCompleted(GraphResponse graphResponse) {
CrashHandler.Companion.m604sendExceptionReports$lambda5(sortedWith, graphResponse);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: sendExceptionReports$lambda-2, reason: not valid java name */
public static final int m603sendExceptionReports$lambda2(InstrumentData instrumentData, InstrumentData o2) {
Intrinsics.checkNotNullExpressionValue(o2, "o2");
return instrumentData.compareTo(o2);
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: sendExceptionReports$lambda-5, reason: not valid java name */
public static final void m604sendExceptionReports$lambda5(List validReports, GraphResponse response) {
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) {
}
}
}
}

View File

@@ -0,0 +1,9 @@
package com.facebook.internal.instrument.crashshield;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.CLASS)
/* loaded from: classes2.dex */
public @interface AutoHandleExceptions {
}

View File

@@ -0,0 +1,91 @@
package com.facebook.internal.instrument.crashshield;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.VisibleForTesting;
import com.facebook.FacebookSdk;
import com.facebook.internal.instrument.ExceptionAnalyzer;
import com.facebook.internal.instrument.InstrumentData;
import java.util.Collections;
import java.util.Set;
import java.util.WeakHashMap;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes2.dex */
public final class CrashShieldHandler {
public static final CrashShieldHandler INSTANCE = new CrashShieldHandler();
private static final Set<Object> crashingObjects = Collections.newSetFromMap(new WeakHashMap());
private static boolean enabled;
@VisibleForTesting
public static final void disable() {
enabled = false;
}
public static final void enable() {
enabled = true;
}
@VisibleForTesting
public static final boolean isDebug() {
return false;
}
public static final void methodFinished(Object obj) {
}
private CrashShieldHandler() {
}
public static final void handleThrowable(Throwable th, Object o) {
Intrinsics.checkNotNullParameter(o, "o");
if (enabled) {
crashingObjects.add(o);
if (FacebookSdk.getAutoLogAppEventsEnabled()) {
ExceptionAnalyzer.execute(th);
InstrumentData.Builder builder = InstrumentData.Builder.INSTANCE;
InstrumentData.Builder.build(th, InstrumentData.Type.CrashShield).save();
}
scheduleCrashInDebug(th);
}
}
public static final boolean isObjectCrashing(Object o) {
Intrinsics.checkNotNullParameter(o, "o");
return crashingObjects.contains(o);
}
public static final void reset() {
resetCrashingObjects();
}
public static final void resetCrashingObjects() {
crashingObjects.clear();
}
@VisibleForTesting
public static final void scheduleCrashInDebug(final Throwable th) {
if (isDebug()) {
new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.facebook.internal.instrument.crashshield.CrashShieldHandler$scheduleCrashInDebug$1
@Override // java.lang.Runnable
public void run() {
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
throw new RuntimeException(th);
} catch (Throwable th2) {
CrashShieldHandler.handleThrowable(th2, this);
}
} catch (Throwable th3) {
CrashShieldHandler.handleThrowable(th3, this);
}
}
});
}
}
}

View File

@@ -0,0 +1,9 @@
package com.facebook.internal.instrument.crashshield;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.CLASS)
/* loaded from: classes2.dex */
public @interface NoAutoExceptionHandling {
}

View File

@@ -0,0 +1,111 @@
package com.facebook.internal.instrument.errorreport;
import androidx.annotation.RestrictTo;
import com.facebook.internal.instrument.InstrumentUtility;
import java.io.File;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import org.json.JSONException;
import org.json.JSONObject;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes2.dex */
public final class ErrorReportData {
public static final Companion Companion = new Companion(null);
private static final String PARAM_TIMESTAMP = "timestamp";
private static final String PRARAM_ERROR_MESSAGE = "error_message";
private String errorMessage;
private String filename;
private Long timestamp;
public final boolean isValid() {
return (this.errorMessage == null || this.timestamp == null) ? false : true;
}
public ErrorReportData(String str) {
this.timestamp = Long.valueOf(System.currentTimeMillis() / 1000);
this.errorMessage = str;
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(InstrumentUtility.ERROR_REPORT_PREFIX);
Long l = this.timestamp;
if (l == null) {
throw new NullPointerException("null cannot be cast to non-null type kotlin.Long");
}
stringBuffer.append(l.longValue());
stringBuffer.append(".json");
String stringBuffer2 = stringBuffer.toString();
Intrinsics.checkNotNullExpressionValue(stringBuffer2, "StringBuffer()\n .append(InstrumentUtility.ERROR_REPORT_PREFIX)\n .append(timestamp as Long)\n .append(\".json\")\n .toString()");
this.filename = stringBuffer2;
}
public ErrorReportData(File file) {
Intrinsics.checkNotNullParameter(file, "file");
String name = file.getName();
Intrinsics.checkNotNullExpressionValue(name, "file.name");
this.filename = name;
JSONObject readFile = InstrumentUtility.readFile(name, true);
if (readFile != null) {
this.timestamp = Long.valueOf(readFile.optLong("timestamp", 0L));
this.errorMessage = readFile.optString("error_message", null);
}
}
public final int compareTo(ErrorReportData data) {
Intrinsics.checkNotNullParameter(data, "data");
Long l = this.timestamp;
if (l == null) {
return -1;
}
long longValue = l.longValue();
Long l2 = data.timestamp;
if (l2 == null) {
return 1;
}
return Intrinsics.compare(l2.longValue(), longValue);
}
public final void save() {
if (isValid()) {
InstrumentUtility instrumentUtility = InstrumentUtility.INSTANCE;
InstrumentUtility.writeFile(this.filename, toString());
}
}
public final void clear() {
InstrumentUtility instrumentUtility = InstrumentUtility.INSTANCE;
InstrumentUtility.deleteFile(this.filename);
}
public String toString() {
JSONObject parameters = getParameters();
if (parameters == null) {
return super.toString();
}
String jSONObject = parameters.toString();
Intrinsics.checkNotNullExpressionValue(jSONObject, "params.toString()");
return jSONObject;
}
public final JSONObject getParameters() {
JSONObject jSONObject = new JSONObject();
try {
Long l = this.timestamp;
if (l != null) {
jSONObject.put("timestamp", l);
}
jSONObject.put("error_message", this.errorMessage);
return jSONObject;
} catch (JSONException unused) {
return null;
}
}
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
}
}

View File

@@ -0,0 +1,134 @@
package com.facebook.internal.instrument.errorreport;
import androidx.annotation.RestrictTo;
import com.facebook.FacebookSdk;
import com.facebook.GraphRequest;
import com.facebook.GraphResponse;
import com.facebook.internal.Utility;
import com.facebook.internal.instrument.InstrumentUtility;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
import kotlin.collections.CollectionsKt__MutableCollectionsJVMKt;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.StringCompanionObject;
import kotlin.text.Regex;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes2.dex */
public final class ErrorReportHandler {
public static final ErrorReportHandler INSTANCE = new ErrorReportHandler();
private static final int MAX_ERROR_REPORT_NUM = 1000;
private ErrorReportHandler() {
}
public static final void save(String str) {
try {
new ErrorReportData(str).save();
} catch (Exception unused) {
}
}
public static final void enable() {
if (FacebookSdk.getAutoLogAppEventsEnabled()) {
sendErrorReports();
}
}
public static final void sendErrorReports() {
if (Utility.isDataProcessingRestricted()) {
return;
}
File[] listErrorReportFiles = listErrorReportFiles();
final ArrayList arrayList = new ArrayList();
int length = listErrorReportFiles.length;
int i = 0;
while (i < length) {
File file = listErrorReportFiles[i];
i++;
ErrorReportData errorReportData = new ErrorReportData(file);
if (errorReportData.isValid()) {
arrayList.add(errorReportData);
}
}
CollectionsKt__MutableCollectionsJVMKt.sortWith(arrayList, new Comparator() { // from class: com.facebook.internal.instrument.errorreport.ErrorReportHandler$$ExternalSyntheticLambda0
@Override // java.util.Comparator
public final int compare(Object obj, Object obj2) {
int m607sendErrorReports$lambda0;
m607sendErrorReports$lambda0 = ErrorReportHandler.m607sendErrorReports$lambda0((ErrorReportData) obj, (ErrorReportData) obj2);
return m607sendErrorReports$lambda0;
}
});
JSONArray jSONArray = new JSONArray();
for (int i2 = 0; i2 < arrayList.size() && i2 < 1000; i2++) {
jSONArray.put(arrayList.get(i2));
}
InstrumentUtility instrumentUtility = InstrumentUtility.INSTANCE;
InstrumentUtility.sendReports("error_reports", jSONArray, new GraphRequest.Callback() { // from class: com.facebook.internal.instrument.errorreport.ErrorReportHandler$$ExternalSyntheticLambda1
@Override // com.facebook.GraphRequest.Callback
public final void onCompleted(GraphResponse graphResponse) {
ErrorReportHandler.m608sendErrorReports$lambda2(arrayList, graphResponse);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: sendErrorReports$lambda-0, reason: not valid java name */
public static final int m607sendErrorReports$lambda0(ErrorReportData errorReportData, ErrorReportData o2) {
Intrinsics.checkNotNullExpressionValue(o2, "o2");
return errorReportData.compareTo(o2);
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: sendErrorReports$lambda-2, reason: not valid java name */
public static final void m608sendErrorReports$lambda2(ArrayList validReports, GraphResponse response) {
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()) {
((ErrorReportData) it.next()).clear();
}
}
}
} catch (JSONException unused) {
}
}
public static final File[] listErrorReportFiles() {
File instrumentReportDir = InstrumentUtility.getInstrumentReportDir();
if (instrumentReportDir == null) {
return new File[0];
}
File[] listFiles = instrumentReportDir.listFiles(new FilenameFilter() { // from class: com.facebook.internal.instrument.errorreport.ErrorReportHandler$$ExternalSyntheticLambda2
@Override // java.io.FilenameFilter
public final boolean accept(File file, String str) {
boolean m606listErrorReportFiles$lambda3;
m606listErrorReportFiles$lambda3 = ErrorReportHandler.m606listErrorReportFiles$lambda3(file, str);
return m606listErrorReportFiles$lambda3;
}
});
Intrinsics.checkNotNullExpressionValue(listFiles, "reportDir.listFiles { dir, name ->\n name.matches(Regex(String.format(\"^%s[0-9]+.json$\", InstrumentUtility.ERROR_REPORT_PREFIX)))\n }");
return listFiles;
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: listErrorReportFiles$lambda-3, reason: not valid java name */
public static final boolean m606listErrorReportFiles$lambda3(File file, String name) {
Intrinsics.checkNotNullExpressionValue(name, "name");
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format("^%s[0-9]+.json$", Arrays.copyOf(new Object[]{InstrumentUtility.ERROR_REPORT_PREFIX}, 1));
Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(format, *args)");
return new Regex(format).matches(name);
}
}

View File

@@ -0,0 +1,51 @@
package com.facebook.internal.instrument.threadcheck;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.RestrictTo;
import com.facebook.internal.instrument.InstrumentData;
import java.util.Arrays;
import java.util.Locale;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.StringCompanionObject;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes2.dex */
public final class ThreadCheckHandler {
public static final ThreadCheckHandler INSTANCE = new ThreadCheckHandler();
private static final String TAG = ThreadCheckHandler.class.getCanonicalName();
private static boolean enabled;
public static final void enable() {
enabled = true;
}
private ThreadCheckHandler() {
}
public static final void uiThreadViolationDetected(Class<?> clazz, String methodName, String methodDesc) {
Intrinsics.checkNotNullParameter(clazz, "clazz");
Intrinsics.checkNotNullParameter(methodName, "methodName");
Intrinsics.checkNotNullParameter(methodDesc, "methodDesc");
INSTANCE.log("@UiThread", clazz, methodName, methodDesc);
}
public static final void workerThreadViolationDetected(Class<?> clazz, String methodName, String methodDesc) {
Intrinsics.checkNotNullParameter(clazz, "clazz");
Intrinsics.checkNotNullParameter(methodName, "methodName");
Intrinsics.checkNotNullParameter(methodDesc, "methodDesc");
INSTANCE.log("@WorkerThread", clazz, methodName, methodDesc);
}
private final void log(String str, Class<?> cls, String str2, String str3) {
if (enabled) {
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format(Locale.US, "%s annotation violation detected in %s.%s%s. Current looper is %s and main looper is %s.", Arrays.copyOf(new Object[]{str, cls.getName(), str2, str3, Looper.myLooper(), Looper.getMainLooper()}, 6));
Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(locale, format, *args)");
Exception exc = new Exception();
Log.e(TAG, format, exc);
InstrumentData.Builder builder = InstrumentData.Builder.INSTANCE;
InstrumentData.Builder.build(exc, InstrumentData.Type.ThreadCheck).save();
}
}
}