apkfuckery/com.discord/smali/com/bugsnag/android/AppState.smali

469 lines
14 KiB
Smali
Raw Normal View History

2019-02-04 20:05:16 +00:00
.class Lcom/bugsnag/android/AppState;
.super Ljava/lang/Object;
.source "AppState.java"
# interfaces
.implements Lcom/bugsnag/android/JsonStream$Streamable;
# static fields
.field private static final startTime:Ljava/lang/Long;
# instance fields
.field private final activeScreen:Ljava/lang/String;
.field private final duration:Ljava/lang/Long;
.field private final inForeground:Ljava/lang/Boolean;
.field private final lowMemory:Ljava/lang/Boolean;
.field private final memoryUsage:Ljava/lang/Long;
# direct methods
.method static constructor <clinit>()V
.locals 2
.prologue
invoke-static {}, Landroid/os/SystemClock;->elapsedRealtime()J
move-result-wide v0
invoke-static {v0, v1}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v0
sput-object v0, Lcom/bugsnag/android/AppState;->startTime:Ljava/lang/Long;
return-void
.end method
.method constructor <init>(Landroid/content/Context;)V
.locals 1
.param p1, "appContext" # Landroid/content/Context;
.annotation build Landroid/support/annotation/NonNull;
.end annotation
.end param
.prologue
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
invoke-static {}, Lcom/bugsnag/android/AppState;->getDuration()Ljava/lang/Long;
move-result-object v0
iput-object v0, p0, Lcom/bugsnag/android/AppState;->duration:Ljava/lang/Long;
invoke-static {p1}, Lcom/bugsnag/android/AppState;->isInForeground(Landroid/content/Context;)Ljava/lang/Boolean;
move-result-object v0
iput-object v0, p0, Lcom/bugsnag/android/AppState;->inForeground:Ljava/lang/Boolean;
invoke-static {p1}, Lcom/bugsnag/android/AppState;->getActiveScreen(Landroid/content/Context;)Ljava/lang/String;
move-result-object v0
iput-object v0, p0, Lcom/bugsnag/android/AppState;->activeScreen:Ljava/lang/String;
invoke-static {}, Lcom/bugsnag/android/AppState;->getMemoryUsage()Ljava/lang/Long;
move-result-object v0
iput-object v0, p0, Lcom/bugsnag/android/AppState;->memoryUsage:Ljava/lang/Long;
invoke-static {p1}, Lcom/bugsnag/android/AppState;->isLowMemory(Landroid/content/Context;)Ljava/lang/Boolean;
move-result-object v0
iput-object v0, p0, Lcom/bugsnag/android/AppState;->lowMemory:Ljava/lang/Boolean;
return-void
.end method
.method private static getActiveScreen(Landroid/content/Context;)Ljava/lang/String;
.locals 5
.param p0, "appContext" # Landroid/content/Context;
.annotation build Landroid/support/annotation/Nullable;
.end annotation
.prologue
:try_start_0
const-string v4, "activity"
invoke-virtual {p0, v4}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroid/app/ActivityManager;
.local v0, "activityManager":Landroid/app/ActivityManager;
const/4 v4, 0x1
invoke-virtual {v0, v4}, Landroid/app/ActivityManager;->getRunningTasks(I)Ljava/util/List;
move-result-object v3
.local v3, "tasks":Ljava/util/List;, "Ljava/util/List<Landroid/app/ActivityManager$RunningTaskInfo;>;"
const/4 v4, 0x0
invoke-interface {v3, v4}, Ljava/util/List;->get(I)Ljava/lang/Object;
move-result-object v2
check-cast v2, Landroid/app/ActivityManager$RunningTaskInfo;
.local v2, "runningTask":Landroid/app/ActivityManager$RunningTaskInfo;
iget-object v4, v2, Landroid/app/ActivityManager$RunningTaskInfo;->topActivity:Landroid/content/ComponentName;
invoke-virtual {v4}, Landroid/content/ComponentName;->getClassName()Ljava/lang/String;
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
move-result-object v4
.end local v0 # "activityManager":Landroid/app/ActivityManager;
.end local v2 # "runningTask":Landroid/app/ActivityManager$RunningTaskInfo;
.end local v3 # "tasks":Ljava/util/List;, "Ljava/util/List<Landroid/app/ActivityManager$RunningTaskInfo;>;"
:goto_0
return-object v4
:catch_0
move-exception v1
.local v1, "e":Ljava/lang/Exception;
const-string v4, "Could not get active screen information, we recommend granting the \'android.permission.GET_TASKS\' permission"
invoke-static {v4}, Lcom/bugsnag/android/Logger;->warn(Ljava/lang/String;)V
const/4 v4, 0x0
goto :goto_0
.end method
.method public static getActiveScreenClass(Ljava/lang/String;)Ljava/lang/String;
.locals 1
.param p0, "activeScreen" # Ljava/lang/String;
.annotation build Landroid/support/annotation/Nullable;
.end annotation
.end param
.annotation build Landroid/support/annotation/Nullable;
.end annotation
.prologue
if-eqz p0, :cond_0
const/16 v0, 0x2e
invoke-virtual {p0, v0}, Ljava/lang/String;->lastIndexOf(I)I
move-result v0
add-int/lit8 v0, v0, 0x1
invoke-virtual {p0, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String;
move-result-object v0
:goto_0
return-object v0
:cond_0
const/4 v0, 0x0
goto :goto_0
.end method
.method private static getDuration()Ljava/lang/Long;
.locals 4
.annotation build Landroid/support/annotation/NonNull;
.end annotation
.prologue
invoke-static {}, Landroid/os/SystemClock;->elapsedRealtime()J
move-result-wide v0
sget-object v2, Lcom/bugsnag/android/AppState;->startTime:Ljava/lang/Long;
invoke-virtual {v2}, Ljava/lang/Long;->longValue()J
move-result-wide v2
sub-long/2addr v0, v2
invoke-static {v0, v1}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v0
return-object v0
.end method
.method private static getMemoryUsage()Ljava/lang/Long;
.locals 4
.annotation build Landroid/support/annotation/NonNull;
.end annotation
.prologue
invoke-static {}, Ljava/lang/Runtime;->getRuntime()Ljava/lang/Runtime;
move-result-object v0
invoke-virtual {v0}, Ljava/lang/Runtime;->totalMemory()J
move-result-wide v0
invoke-static {}, Ljava/lang/Runtime;->getRuntime()Ljava/lang/Runtime;
move-result-object v2
invoke-virtual {v2}, Ljava/lang/Runtime;->freeMemory()J
move-result-wide v2
sub-long/2addr v0, v2
invoke-static {v0, v1}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v0
return-object v0
.end method
.method static init()V
.locals 0
.prologue
return-void
.end method
.method private static isInForeground(Landroid/content/Context;)Ljava/lang/Boolean;
.locals 6
.param p0, "appContext" # Landroid/content/Context;
.annotation build Landroid/support/annotation/Nullable;
.end annotation
.prologue
:try_start_0
const-string v4, "activity"
invoke-virtual {p0, v4}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroid/app/ActivityManager;
.local v0, "activityManager":Landroid/app/ActivityManager;
const/4 v4, 0x1
invoke-virtual {v0, v4}, Landroid/app/ActivityManager;->getRunningTasks(I)Ljava/util/List;
move-result-object v3
.local v3, "tasks":Ljava/util/List;, "Ljava/util/List<Landroid/app/ActivityManager$RunningTaskInfo;>;"
invoke-interface {v3}, Ljava/util/List;->isEmpty()Z
move-result v4
if-eqz v4, :cond_0
const/4 v4, 0x0
invoke-static {v4}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
move-result-object v4
.end local v0 # "activityManager":Landroid/app/ActivityManager;
.end local v3 # "tasks":Ljava/util/List;, "Ljava/util/List<Landroid/app/ActivityManager$RunningTaskInfo;>;"
:goto_0
return-object v4
.restart local v0 # "activityManager":Landroid/app/ActivityManager;
.restart local v3 # "tasks":Ljava/util/List;, "Ljava/util/List<Landroid/app/ActivityManager$RunningTaskInfo;>;"
:cond_0
const/4 v4, 0x0
invoke-interface {v3, v4}, Ljava/util/List;->get(I)Ljava/lang/Object;
move-result-object v2
check-cast v2, Landroid/app/ActivityManager$RunningTaskInfo;
.local v2, "runningTask":Landroid/app/ActivityManager$RunningTaskInfo;
iget-object v4, v2, Landroid/app/ActivityManager$RunningTaskInfo;->topActivity:Landroid/content/ComponentName;
invoke-virtual {v4}, Landroid/content/ComponentName;->getPackageName()Ljava/lang/String;
move-result-object v4
invoke-virtual {p0}, Landroid/content/Context;->getPackageName()Ljava/lang/String;
move-result-object v5
invoke-virtual {v4, v5}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
move-result v4
invoke-static {v4}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
move-result-object v4
goto :goto_0
.end local v0 # "activityManager":Landroid/app/ActivityManager;
.end local v2 # "runningTask":Landroid/app/ActivityManager$RunningTaskInfo;
.end local v3 # "tasks":Ljava/util/List;, "Ljava/util/List<Landroid/app/ActivityManager$RunningTaskInfo;>;"
:catch_0
move-exception v1
.local v1, "e":Ljava/lang/Exception;
const-string v4, "Could not check if app is in the foreground, we recommend granting the \'android.permission.GET_TASKS\' permission"
invoke-static {v4}, Lcom/bugsnag/android/Logger;->warn(Ljava/lang/String;)V
const/4 v4, 0x0
goto :goto_0
.end method
.method private static isLowMemory(Landroid/content/Context;)Ljava/lang/Boolean;
.locals 4
.param p0, "appContext" # Landroid/content/Context;
.annotation build Landroid/support/annotation/Nullable;
.end annotation
.prologue
:try_start_0
const-string v3, "activity"
invoke-virtual {p0, v3}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroid/app/ActivityManager;
.local v0, "activityManager":Landroid/app/ActivityManager;
new-instance v2, Landroid/app/ActivityManager$MemoryInfo;
invoke-direct {v2}, Landroid/app/ActivityManager$MemoryInfo;-><init>()V
.local v2, "memInfo":Landroid/app/ActivityManager$MemoryInfo;
invoke-virtual {v0, v2}, Landroid/app/ActivityManager;->getMemoryInfo(Landroid/app/ActivityManager$MemoryInfo;)V
iget-boolean v3, v2, Landroid/app/ActivityManager$MemoryInfo;->lowMemory:Z
invoke-static {v3}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
move-result-object v3
.end local v0 # "activityManager":Landroid/app/ActivityManager;
.end local v2 # "memInfo":Landroid/app/ActivityManager$MemoryInfo;
:goto_0
return-object v3
:catch_0
move-exception v1
.local v1, "e":Ljava/lang/Exception;
const-string v3, "Could not check lowMemory status"
invoke-static {v3}, Lcom/bugsnag/android/Logger;->warn(Ljava/lang/String;)V
const/4 v3, 0x0
goto :goto_0
.end method
# virtual methods
.method public toStream(Lcom/bugsnag/android/JsonStream;)V
.locals 2
.param p1, "writer" # Lcom/bugsnag/android/JsonStream;
.annotation build Landroid/support/annotation/NonNull;
.end annotation
.end param
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.prologue
invoke-virtual {p1}, Lcom/bugsnag/android/JsonStream;->beginObject()Lcom/bugsnag/android/JsonWriter;
const-string v0, "duration"
invoke-virtual {p1, v0}, Lcom/bugsnag/android/JsonStream;->name(Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
move-result-object v0
iget-object v1, p0, Lcom/bugsnag/android/AppState;->duration:Ljava/lang/Long;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/Number;)Lcom/bugsnag/android/JsonWriter;
iget-object v0, p0, Lcom/bugsnag/android/AppState;->inForeground:Ljava/lang/Boolean;
if-eqz v0, :cond_0
const-string v0, "inForeground"
invoke-virtual {p1, v0}, Lcom/bugsnag/android/JsonStream;->name(Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
move-result-object v0
iget-object v1, p0, Lcom/bugsnag/android/AppState;->inForeground:Ljava/lang/Boolean;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/Boolean;)V
:cond_0
iget-object v0, p0, Lcom/bugsnag/android/AppState;->activeScreen:Ljava/lang/String;
if-eqz v0, :cond_1
const-string v0, "activeScreen"
invoke-virtual {p1, v0}, Lcom/bugsnag/android/JsonStream;->name(Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
move-result-object v0
iget-object v1, p0, Lcom/bugsnag/android/AppState;->activeScreen:Ljava/lang/String;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/String;)Lcom/bugsnag/android/JsonWriter;
:cond_1
const-string v0, "memoryUsage"
invoke-virtual {p1, v0}, Lcom/bugsnag/android/JsonStream;->name(Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
move-result-object v0
iget-object v1, p0, Lcom/bugsnag/android/AppState;->memoryUsage:Ljava/lang/Long;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/Number;)Lcom/bugsnag/android/JsonWriter;
iget-object v0, p0, Lcom/bugsnag/android/AppState;->lowMemory:Ljava/lang/Boolean;
if-eqz v0, :cond_2
const-string v0, "lowMemory"
invoke-virtual {p1, v0}, Lcom/bugsnag/android/JsonStream;->name(Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
move-result-object v0
iget-object v1, p0, Lcom/bugsnag/android/AppState;->lowMemory:Ljava/lang/Boolean;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/Boolean;)V
:cond_2
invoke-virtual {p1}, Lcom/bugsnag/android/JsonStream;->endObject()Lcom/bugsnag/android/JsonWriter;
return-void
.end method