apkfuckery/com.discord/smali/com/bugsnag/android/ExceptionHandler.smali
2019-02-04 21:05:16 +01:00

203 lines
6.2 KiB
Smali

.class Lcom/bugsnag/android/ExceptionHandler;
.super Ljava/lang/Object;
.source "ExceptionHandler.java"
# interfaces
.implements Ljava/lang/Thread$UncaughtExceptionHandler;
# instance fields
.field final clientMap:Ljava/util/WeakHashMap;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/WeakHashMap",
"<",
"Lcom/bugsnag/android/Client;",
"Ljava/lang/Boolean;",
">;"
}
.end annotation
.end field
.field private final originalHandler:Ljava/lang/Thread$UncaughtExceptionHandler;
# direct methods
.method public constructor <init>(Ljava/lang/Thread$UncaughtExceptionHandler;)V
.locals 1
.param p1, "originalHandler" # Ljava/lang/Thread$UncaughtExceptionHandler;
.prologue
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
new-instance v0, Ljava/util/WeakHashMap;
invoke-direct {v0}, Ljava/util/WeakHashMap;-><init>()V
iput-object v0, p0, Lcom/bugsnag/android/ExceptionHandler;->clientMap:Ljava/util/WeakHashMap;
iput-object p1, p0, Lcom/bugsnag/android/ExceptionHandler;->originalHandler:Ljava/lang/Thread$UncaughtExceptionHandler;
return-void
.end method
.method static disable(Lcom/bugsnag/android/Client;)V
.locals 3
.param p0, "client" # Lcom/bugsnag/android/Client;
.prologue
invoke-static {}, Ljava/lang/Thread;->getDefaultUncaughtExceptionHandler()Ljava/lang/Thread$UncaughtExceptionHandler;
move-result-object v1
.local v1, "currentHandler":Ljava/lang/Thread$UncaughtExceptionHandler;
instance-of v2, v1, Lcom/bugsnag/android/ExceptionHandler;
if-eqz v2, :cond_0
move-object v0, v1
check-cast v0, Lcom/bugsnag/android/ExceptionHandler;
.local v0, "bugsnagHandler":Lcom/bugsnag/android/ExceptionHandler;
iget-object v2, v0, Lcom/bugsnag/android/ExceptionHandler;->clientMap:Ljava/util/WeakHashMap;
invoke-virtual {v2, p0}, Ljava/util/WeakHashMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;
iget-object v2, v0, Lcom/bugsnag/android/ExceptionHandler;->clientMap:Ljava/util/WeakHashMap;
invoke-virtual {v2}, Ljava/util/WeakHashMap;->size()I
move-result v2
if-nez v2, :cond_0
iget-object v2, v0, Lcom/bugsnag/android/ExceptionHandler;->originalHandler:Ljava/lang/Thread$UncaughtExceptionHandler;
invoke-static {v2}, Ljava/lang/Thread;->setDefaultUncaughtExceptionHandler(Ljava/lang/Thread$UncaughtExceptionHandler;)V
.end local v0 # "bugsnagHandler":Lcom/bugsnag/android/ExceptionHandler;
:cond_0
return-void
.end method
.method static enable(Lcom/bugsnag/android/Client;)V
.locals 4
.param p0, "client" # Lcom/bugsnag/android/Client;
.prologue
invoke-static {}, Ljava/lang/Thread;->getDefaultUncaughtExceptionHandler()Ljava/lang/Thread$UncaughtExceptionHandler;
move-result-object v1
.local v1, "currentHandler":Ljava/lang/Thread$UncaughtExceptionHandler;
instance-of v2, v1, Lcom/bugsnag/android/ExceptionHandler;
if-eqz v2, :cond_0
move-object v0, v1
check-cast v0, Lcom/bugsnag/android/ExceptionHandler;
.local v0, "bugsnagHandler":Lcom/bugsnag/android/ExceptionHandler;
:goto_0
iget-object v2, v0, Lcom/bugsnag/android/ExceptionHandler;->clientMap:Ljava/util/WeakHashMap;
const/4 v3, 0x1
invoke-static {v3}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
move-result-object v3
invoke-virtual {v2, p0, v3}, Ljava/util/WeakHashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
return-void
.end local v0 # "bugsnagHandler":Lcom/bugsnag/android/ExceptionHandler;
:cond_0
new-instance v0, Lcom/bugsnag/android/ExceptionHandler;
invoke-direct {v0, v1}, Lcom/bugsnag/android/ExceptionHandler;-><init>(Ljava/lang/Thread$UncaughtExceptionHandler;)V
.restart local v0 # "bugsnagHandler":Lcom/bugsnag/android/ExceptionHandler;
invoke-static {v0}, Ljava/lang/Thread;->setDefaultUncaughtExceptionHandler(Ljava/lang/Thread$UncaughtExceptionHandler;)V
goto :goto_0
.end method
# virtual methods
.method public uncaughtException(Ljava/lang/Thread;Ljava/lang/Throwable;)V
.locals 6
.param p1, "t" # Ljava/lang/Thread;
.param p2, "e" # Ljava/lang/Throwable;
.prologue
iget-object v1, p0, Lcom/bugsnag/android/ExceptionHandler;->clientMap:Ljava/util/WeakHashMap;
invoke-virtual {v1}, Ljava/util/WeakHashMap;->keySet()Ljava/util/Set;
move-result-object v1
invoke-interface {v1}, Ljava/util/Set;->iterator()Ljava/util/Iterator;
move-result-object v1
:goto_0
invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z
move-result v2
if-eqz v2, :cond_0
invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v0
check-cast v0, Lcom/bugsnag/android/Client;
.local v0, "client":Lcom/bugsnag/android/Client;
sget-object v2, Lcom/bugsnag/android/Severity;->ERROR:Lcom/bugsnag/android/Severity;
invoke-virtual {v0, p2, v2}, Lcom/bugsnag/android/Client;->notify(Ljava/lang/Throwable;Lcom/bugsnag/android/Severity;)V
goto :goto_0
.end local v0 # "client":Lcom/bugsnag/android/Client;
:cond_0
iget-object v1, p0, Lcom/bugsnag/android/ExceptionHandler;->originalHandler:Ljava/lang/Thread$UncaughtExceptionHandler;
if-eqz v1, :cond_1
iget-object v1, p0, Lcom/bugsnag/android/ExceptionHandler;->originalHandler:Ljava/lang/Thread$UncaughtExceptionHandler;
invoke-interface {v1, p1, p2}, Ljava/lang/Thread$UncaughtExceptionHandler;->uncaughtException(Ljava/lang/Thread;Ljava/lang/Throwable;)V
:goto_1
return-void
:cond_1
sget-object v1, Ljava/lang/System;->err:Ljava/io/PrintStream;
const-string v2, "Exception in thread \"%s\" "
const/4 v3, 0x1
new-array v3, v3, [Ljava/lang/Object;
const/4 v4, 0x0
invoke-virtual {p1}, Ljava/lang/Thread;->getName()Ljava/lang/String;
move-result-object v5
aput-object v5, v3, v4
invoke-virtual {v1, v2, v3}, Ljava/io/PrintStream;->printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
sget-object v1, Ljava/lang/System;->err:Ljava/io/PrintStream;
invoke-virtual {p2, v1}, Ljava/lang/Throwable;->printStackTrace(Ljava/io/PrintStream;)V
goto :goto_1
.end method