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

647 lines
17 KiB
Smali

.class Lcom/bugsnag/android/DeviceData;
.super Ljava/lang/Object;
.source "DeviceData.java"
# interfaces
.implements Lcom/bugsnag/android/JsonStream$Streamable;
# static fields
.field private static final ROOT_INDICATORS:[Ljava/lang/String;
# instance fields
.field private final dpi:Ljava/lang/Integer;
.field private final id:Ljava/lang/String;
.field private final locale:Ljava/lang/String;
.field private final rooted:Ljava/lang/Boolean;
.field private final screenDensity:Ljava/lang/Float;
.field private final screenResolution:Ljava/lang/String;
.field private final totalMemory:Ljava/lang/Long;
# direct methods
.method static constructor <clinit>()V
.locals 3
.prologue
const/4 v0, 0x7
new-array v0, v0, [Ljava/lang/String;
const/4 v1, 0x0
const-string v2, "/system/xbin/su"
aput-object v2, v0, v1
const/4 v1, 0x1
const-string v2, "/system/bin/su"
aput-object v2, v0, v1
const/4 v1, 0x2
const-string v2, "/system/app/Superuser.apk"
aput-object v2, v0, v1
const/4 v1, 0x3
const-string v2, "/system/app/SuperSU.apk"
aput-object v2, v0, v1
const/4 v1, 0x4
const-string v2, "/system/app/Superuser"
aput-object v2, v0, v1
const/4 v1, 0x5
const-string v2, "/system/app/SuperSU"
aput-object v2, v0, v1
const/4 v1, 0x6
const-string v2, "/system/xbin/daemonsu"
aput-object v2, v0, v1
sput-object v0, Lcom/bugsnag/android/DeviceData;->ROOT_INDICATORS:[Ljava/lang/String;
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 {p1}, Lcom/bugsnag/android/DeviceData;->getScreenDensity(Landroid/content/Context;)Ljava/lang/Float;
move-result-object v0
iput-object v0, p0, Lcom/bugsnag/android/DeviceData;->screenDensity:Ljava/lang/Float;
invoke-static {p1}, Lcom/bugsnag/android/DeviceData;->getScreenDensityDpi(Landroid/content/Context;)Ljava/lang/Integer;
move-result-object v0
iput-object v0, p0, Lcom/bugsnag/android/DeviceData;->dpi:Ljava/lang/Integer;
invoke-static {p1}, Lcom/bugsnag/android/DeviceData;->getScreenResolution(Landroid/content/Context;)Ljava/lang/String;
move-result-object v0
iput-object v0, p0, Lcom/bugsnag/android/DeviceData;->screenResolution:Ljava/lang/String;
invoke-static {}, Lcom/bugsnag/android/DeviceData;->getTotalMemory()Ljava/lang/Long;
move-result-object v0
iput-object v0, p0, Lcom/bugsnag/android/DeviceData;->totalMemory:Ljava/lang/Long;
invoke-static {}, Lcom/bugsnag/android/DeviceData;->isRooted()Ljava/lang/Boolean;
move-result-object v0
iput-object v0, p0, Lcom/bugsnag/android/DeviceData;->rooted:Ljava/lang/Boolean;
invoke-static {}, Lcom/bugsnag/android/DeviceData;->getLocale()Ljava/lang/String;
move-result-object v0
iput-object v0, p0, Lcom/bugsnag/android/DeviceData;->locale:Ljava/lang/String;
invoke-static {p1}, Lcom/bugsnag/android/DeviceData;->getAndroidId(Landroid/content/Context;)Ljava/lang/String;
move-result-object v0
iput-object v0, p0, Lcom/bugsnag/android/DeviceData;->id:Ljava/lang/String;
return-void
.end method
.method private static getAndroidId(Landroid/content/Context;)Ljava/lang/String;
.locals 2
.param p0, "appContext" # Landroid/content/Context;
.annotation build Landroid/support/annotation/NonNull;
.end annotation
.prologue
invoke-virtual {p0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v0
.local v0, "cr":Landroid/content/ContentResolver;
const-string v1, "android_id"
invoke-static {v0, v1}, Landroid/provider/Settings$Secure;->getString(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;
move-result-object v1
return-object v1
.end method
.method private static getLocale()Ljava/lang/String;
.locals 1
.annotation build Landroid/support/annotation/NonNull;
.end annotation
.prologue
invoke-static {}, Ljava/util/Locale;->getDefault()Ljava/util/Locale;
move-result-object v0
invoke-virtual {v0}, Ljava/util/Locale;->toString()Ljava/lang/String;
move-result-object v0
return-object v0
.end method
.method private static getScreenDensity(Landroid/content/Context;)Ljava/lang/Float;
.locals 2
.param p0, "appContext" # Landroid/content/Context;
.annotation build Landroid/support/annotation/Nullable;
.end annotation
.prologue
invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
move-result-object v0
.local v0, "resources":Landroid/content/res/Resources;
if-nez v0, :cond_0
const/4 v1, 0x0
:goto_0
return-object v1
:cond_0
invoke-virtual {v0}, Landroid/content/res/Resources;->getDisplayMetrics()Landroid/util/DisplayMetrics;
move-result-object v1
iget v1, v1, Landroid/util/DisplayMetrics;->density:F
invoke-static {v1}, Ljava/lang/Float;->valueOf(F)Ljava/lang/Float;
move-result-object v1
goto :goto_0
.end method
.method private static getScreenDensityDpi(Landroid/content/Context;)Ljava/lang/Integer;
.locals 2
.param p0, "appContext" # Landroid/content/Context;
.annotation build Landroid/support/annotation/Nullable;
.end annotation
.prologue
invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
move-result-object v0
.local v0, "resources":Landroid/content/res/Resources;
if-nez v0, :cond_0
const/4 v1, 0x0
:goto_0
return-object v1
:cond_0
invoke-virtual {v0}, Landroid/content/res/Resources;->getDisplayMetrics()Landroid/util/DisplayMetrics;
move-result-object v1
iget v1, v1, Landroid/util/DisplayMetrics;->densityDpi:I
invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v1
goto :goto_0
.end method
.method private static getScreenResolution(Landroid/content/Context;)Ljava/lang/String;
.locals 8
.param p0, "appContext" # Landroid/content/Context;
.annotation build Landroid/support/annotation/Nullable;
.end annotation
.prologue
invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
move-result-object v1
.local v1, "resources":Landroid/content/res/Resources;
if-nez v1, :cond_0
const/4 v2, 0x0
:goto_0
return-object v2
:cond_0
invoke-virtual {v1}, Landroid/content/res/Resources;->getDisplayMetrics()Landroid/util/DisplayMetrics;
move-result-object v0
.local v0, "metrics":Landroid/util/DisplayMetrics;
sget-object v2, Ljava/util/Locale;->US:Ljava/util/Locale;
const-string v3, "%dx%d"
const/4 v4, 0x2
new-array v4, v4, [Ljava/lang/Object;
const/4 v5, 0x0
iget v6, v0, Landroid/util/DisplayMetrics;->widthPixels:I
iget v7, v0, Landroid/util/DisplayMetrics;->heightPixels:I
invoke-static {v6, v7}, Ljava/lang/Math;->max(II)I
move-result v6
invoke-static {v6}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v6
aput-object v6, v4, v5
const/4 v5, 0x1
iget v6, v0, Landroid/util/DisplayMetrics;->widthPixels:I
iget v7, v0, Landroid/util/DisplayMetrics;->heightPixels:I
invoke-static {v6, v7}, Ljava/lang/Math;->min(II)I
move-result v6
invoke-static {v6}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v6
aput-object v6, v4, v5
invoke-static {v2, v3, v4}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v2
goto :goto_0
.end method
.method private static getTotalMemory()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;->maxMemory()J
move-result-wide v0
const-wide v2, 0x7fffffffffffffffL
cmp-long v0, v0, v2
if-eqz v0, :cond_0
invoke-static {}, Ljava/lang/Runtime;->getRuntime()Ljava/lang/Runtime;
move-result-object v0
invoke-virtual {v0}, Ljava/lang/Runtime;->maxMemory()J
move-result-wide v0
invoke-static {v0, v1}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v0
:goto_0
return-object v0
:cond_0
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 {v0, v1}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v0
goto :goto_0
.end method
.method private static isRooted()Ljava/lang/Boolean;
.locals 7
.annotation build Landroid/support/annotation/Nullable;
.end annotation
.prologue
const/4 v5, 0x1
const/4 v3, 0x0
sget-object v2, Landroid/os/Build;->TAGS:Ljava/lang/String;
if-eqz v2, :cond_0
sget-object v2, Landroid/os/Build;->TAGS:Ljava/lang/String;
const-string v4, "test-keys"
invoke-virtual {v2, v4}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z
move-result v2
if-eqz v2, :cond_0
invoke-static {v5}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
move-result-object v2
.local v0, "candidate":Ljava/lang/String;
:goto_0
return-object v2
.end local v0 # "candidate":Ljava/lang/String;
:cond_0
:try_start_0
sget-object v4, Lcom/bugsnag/android/DeviceData;->ROOT_INDICATORS:[Ljava/lang/String;
array-length v5, v4
move v2, v3
.restart local v0 # "candidate":Ljava/lang/String;
:goto_1
if-ge v2, v5, :cond_2
aget-object v0, v4, v2
new-instance v6, Ljava/io/File;
invoke-direct {v6, v0}, Ljava/io/File;-><init>(Ljava/lang/String;)V
invoke-virtual {v6}, Ljava/io/File;->exists()Z
move-result v6
if-eqz v6, :cond_1
const/4 v2, 0x1
invoke-static {v2}, 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 v2
goto :goto_0
:cond_1
add-int/lit8 v2, v2, 0x1
goto :goto_1
:catch_0
move-exception v1
.local v1, "ignore":Ljava/lang/Exception;
const/4 v2, 0x0
goto :goto_0
.end local v1 # "ignore":Ljava/lang/Exception;
:cond_2
invoke-static {v3}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
move-result-object v2
goto :goto_0
.end method
# virtual methods
.method public getUserId()Ljava/lang/String;
.locals 1
.prologue
iget-object v0, p0, Lcom/bugsnag/android/DeviceData;->id:Ljava/lang/String;
return-object v0
.end method
.method public toStream(Lcom/bugsnag/android/JsonStream;)V
.locals 4
.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, "osName"
invoke-virtual {p1, v0}, Lcom/bugsnag/android/JsonStream;->name(Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
move-result-object v0
const-string v1, "android"
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/String;)Lcom/bugsnag/android/JsonWriter;
const-string v0, "manufacturer"
invoke-virtual {p1, v0}, Lcom/bugsnag/android/JsonStream;->name(Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
move-result-object v0
sget-object v1, Landroid/os/Build;->MANUFACTURER:Ljava/lang/String;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/String;)Lcom/bugsnag/android/JsonWriter;
const-string v0, "brand"
invoke-virtual {p1, v0}, Lcom/bugsnag/android/JsonStream;->name(Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
move-result-object v0
sget-object v1, Landroid/os/Build;->BRAND:Ljava/lang/String;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/String;)Lcom/bugsnag/android/JsonWriter;
const-string v0, "model"
invoke-virtual {p1, v0}, Lcom/bugsnag/android/JsonStream;->name(Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
move-result-object v0
sget-object v1, Landroid/os/Build;->MODEL:Ljava/lang/String;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/String;)Lcom/bugsnag/android/JsonWriter;
const-string v0, "id"
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/DeviceData;->id:Ljava/lang/String;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/String;)Lcom/bugsnag/android/JsonWriter;
const-string v0, "apiLevel"
invoke-virtual {p1, v0}, Lcom/bugsnag/android/JsonStream;->name(Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
move-result-object v0
sget v1, Landroid/os/Build$VERSION;->SDK_INT:I
int-to-long v2, v1
invoke-virtual {v0, v2, v3}, Lcom/bugsnag/android/JsonStream;->value(J)Lcom/bugsnag/android/JsonWriter;
const-string v0, "osVersion"
invoke-virtual {p1, v0}, Lcom/bugsnag/android/JsonStream;->name(Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
move-result-object v0
sget-object v1, Landroid/os/Build$VERSION;->RELEASE:Ljava/lang/String;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/String;)Lcom/bugsnag/android/JsonWriter;
const-string v0, "osBuild"
invoke-virtual {p1, v0}, Lcom/bugsnag/android/JsonStream;->name(Ljava/lang/String;)Lcom/bugsnag/android/JsonStream;
move-result-object v0
sget-object v1, Landroid/os/Build;->DISPLAY:Ljava/lang/String;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/String;)Lcom/bugsnag/android/JsonWriter;
const-string v0, "locale"
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/DeviceData;->locale:Ljava/lang/String;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/String;)Lcom/bugsnag/android/JsonWriter;
const-string v0, "totalMemory"
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/DeviceData;->totalMemory: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/DeviceData;->rooted:Ljava/lang/Boolean;
if-eqz v0, :cond_0
const-string v0, "jailbroken"
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/DeviceData;->rooted: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/DeviceData;->screenDensity:Ljava/lang/Float;
if-eqz v0, :cond_1
const-string v0, "screenDensity"
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/DeviceData;->screenDensity:Ljava/lang/Float;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/Number;)Lcom/bugsnag/android/JsonWriter;
:cond_1
iget-object v0, p0, Lcom/bugsnag/android/DeviceData;->dpi:Ljava/lang/Integer;
if-eqz v0, :cond_2
const-string v0, "dpi"
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/DeviceData;->dpi:Ljava/lang/Integer;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/Number;)Lcom/bugsnag/android/JsonWriter;
:cond_2
iget-object v0, p0, Lcom/bugsnag/android/DeviceData;->screenResolution:Ljava/lang/String;
if-eqz v0, :cond_3
const-string v0, "screenResolution"
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/DeviceData;->screenResolution:Ljava/lang/String;
invoke-virtual {v0, v1}, Lcom/bugsnag/android/JsonStream;->value(Ljava/lang/String;)Lcom/bugsnag/android/JsonWriter;
:cond_3
invoke-virtual {p1}, Lcom/bugsnag/android/JsonStream;->endObject()Lcom/bugsnag/android/JsonWriter;
return-void
.end method