- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
72 lines
3.2 KiB
Java
72 lines
3.2 KiB
Java
package com.google.firebase.crashlytics.internal.common;
|
|
|
|
import com.google.firebase.crashlytics.internal.CrashlyticsNativeComponent;
|
|
import com.google.firebase.crashlytics.internal.Logger;
|
|
import com.google.firebase.crashlytics.internal.settings.SettingsProvider;
|
|
import java.lang.Thread;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class CrashlyticsUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
|
|
public final CrashListener crashListener;
|
|
public final Thread.UncaughtExceptionHandler defaultHandler;
|
|
public final AtomicBoolean isHandlingException = new AtomicBoolean(false);
|
|
public final CrashlyticsNativeComponent nativeComponent;
|
|
public final SettingsProvider settingsProvider;
|
|
|
|
public interface CrashListener {
|
|
void onUncaughtException(SettingsProvider settingsProvider, Thread thread, Throwable th);
|
|
}
|
|
|
|
public CrashlyticsUncaughtExceptionHandler(CrashListener crashListener, SettingsProvider settingsProvider, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, CrashlyticsNativeComponent crashlyticsNativeComponent) {
|
|
this.crashListener = crashListener;
|
|
this.settingsProvider = settingsProvider;
|
|
this.defaultHandler = uncaughtExceptionHandler;
|
|
this.nativeComponent = crashlyticsNativeComponent;
|
|
}
|
|
|
|
@Override // java.lang.Thread.UncaughtExceptionHandler
|
|
public void uncaughtException(Thread thread, Throwable th) {
|
|
this.isHandlingException.set(true);
|
|
try {
|
|
try {
|
|
if (shouldRecordUncaughtException(thread, th)) {
|
|
this.crashListener.onUncaughtException(this.settingsProvider, thread, th);
|
|
} else {
|
|
Logger.getLogger().d("Uncaught exception will not be recorded by Crashlytics.");
|
|
}
|
|
} catch (Exception e) {
|
|
Logger.getLogger().e("An error occurred in the uncaught exception handler", e);
|
|
}
|
|
Logger.getLogger().d("Completed exception processing. Invoking default exception handler.");
|
|
this.defaultHandler.uncaughtException(thread, th);
|
|
this.isHandlingException.set(false);
|
|
} catch (Throwable th2) {
|
|
Logger.getLogger().d("Completed exception processing. Invoking default exception handler.");
|
|
this.defaultHandler.uncaughtException(thread, th);
|
|
this.isHandlingException.set(false);
|
|
throw th2;
|
|
}
|
|
}
|
|
|
|
public boolean isHandlingException() {
|
|
return this.isHandlingException.get();
|
|
}
|
|
|
|
public final boolean shouldRecordUncaughtException(Thread thread, Throwable th) {
|
|
if (thread == null) {
|
|
Logger.getLogger().e("Crashlytics will not record uncaught exception; null thread");
|
|
return false;
|
|
}
|
|
if (th == null) {
|
|
Logger.getLogger().e("Crashlytics will not record uncaught exception; null throwable");
|
|
return false;
|
|
}
|
|
if (!this.nativeComponent.hasCrashDataForCurrentSession()) {
|
|
return true;
|
|
}
|
|
Logger.getLogger().d("Crashlytics will not record uncaught exception; native crash exists for session.");
|
|
return false;
|
|
}
|
|
}
|