.class public Lcom/mtv/activities/m;
.super Ljava/lang/Object;


# direct methods
.method public static a()J
    .locals 6

    const/4 v5, -0x1

    const-wide/16 v0, -0x1

    new-instance v2, Ljava/lang/String;

    const-string v3, "/proc/meminfo"

    invoke-static {v3}, Lcom/mtv/activities/m;->a(Ljava/lang/String;)[B

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/String;-><init>([B)V

    const-string v3, "MemFree"

    invoke-virtual {v2, v3}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I

    move-result v3

    if-ne v3, v5, :cond_1

    :cond_0
    :goto_0
    return-wide v0

    :cond_1
    add-int/lit8 v3, v3, 0x8

    const-string v4, "\n"

    invoke-virtual {v2, v4, v3}, Ljava/lang/String;->indexOf(Ljava/lang/String;I)I

    move-result v4

    if-eq v4, v5, :cond_0

    invoke-virtual {v2, v3, v4}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/String;->trim()Ljava/lang/String;

    move-result-object v2

    const-string v3, " "

    invoke-virtual {v2, v3}, Ljava/lang/String;->lastIndexOf(Ljava/lang/String;)I

    move-result v3

    if-eq v3, v5, :cond_0

    const/4 v0, 0x0

    invoke-virtual {v2, v0, v3}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I

    move-result v0

    add-int/lit8 v1, v3, 0x1

    invoke-virtual {v2, v1}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v1

    const-string v2, "kB"

    invoke-virtual {v1, v2}, Ljava/lang/String;->compareToIgnoreCase(Ljava/lang/String;)I

    move-result v2

    if-nez v2, :cond_3

    mul-int/lit16 v0, v0, 0x400

    :cond_2
    :goto_1
    int-to-long v0, v0

    goto :goto_0

    :cond_3
    const-string v2, "mB"

    invoke-virtual {v1, v2}, Ljava/lang/String;->compareToIgnoreCase(Ljava/lang/String;)I

    move-result v2

    if-nez v2, :cond_4

    const/high16 v1, 0x100000

    mul-int/2addr v0, v1

    goto :goto_1

    :cond_4
    const-string v2, "gB"

    invoke-virtual {v1, v2}, Ljava/lang/String;->compareToIgnoreCase(Ljava/lang/String;)I

    move-result v2

    if-nez v2, :cond_5

    const/high16 v1, 0x40000000    # 2.0f

    mul-int/2addr v0, v1

    goto :goto_1

    :cond_5
    const-string v2, "tB"

    invoke-virtual {v1, v2}, Ljava/lang/String;->compareToIgnoreCase(Ljava/lang/String;)I

    move-result v1

    if-nez v1, :cond_2

    int-to-long v0, v0

    const-wide v2, 0x10000000000L

    mul-long/2addr v0, v2

    long-to-int v0, v0

    goto :goto_1
.end method

.method public static a(Ljava/lang/String;)[B
    .locals 8

    const/4 v0, 0x0

    const/4 v2, 0x0

    const/4 v1, 0x1

    new-instance v4, Ljava/io/File;

    invoke-direct {v4, p0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v4}, Ljava/io/File;->exists()Z

    move-result v3

    if-nez v3, :cond_1

    :cond_0
    :goto_0
    return-object v0

    :cond_1
    new-instance v5, Ljava/io/ByteArrayOutputStream;

    invoke-direct {v5}, Ljava/io/ByteArrayOutputStream;-><init>()V

    :try_start_0
    new-instance v3, Ljava/io/FileInputStream;

    invoke-direct {v3, v4}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    :goto_1
    if-eqz v3, :cond_0

    const/16 v4, 0x800

    new-array v4, v4, [B

    :cond_2
    :goto_2
    :try_start_1
    invoke-virtual {v3, v4}, Ljava/io/FileInputStream;->read([B)I
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_1

    move-result v6

    const/4 v7, -0x1

    if-ne v6, v7, :cond_3

    :goto_3
    :try_start_2
    invoke-virtual {v5}, Ljava/io/ByteArrayOutputStream;->close()V
    :try_end_2
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_2

    :goto_4
    :try_start_3
    invoke-virtual {v3}, Ljava/io/FileInputStream;->close()V
    :try_end_3
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_3

    move v1, v2

    :goto_5
    if-nez v1, :cond_0

    invoke-virtual {v5}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B

    move-result-object v0

    goto :goto_0

    :catch_0
    move-exception v3

    const-string v3, "MiTV/MainActivity"

    const-string v4, "Failed to open file"

    invoke-static {v3, v4}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    move-object v3, v0

    goto :goto_1

    :catch_1
    move-exception v2

    const-string v2, "MiTV/MainActivity"

    const-string v4, "Failed to read data"

    invoke-static {v2, v4}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    move v2, v1

    goto :goto_3

    :cond_3
    if-lez v6, :cond_2

    invoke-virtual {v5, v4, v2, v6}, Ljava/io/ByteArrayOutputStream;->write([BII)V

    goto :goto_2

    :catch_2
    move-exception v2

    const-string v2, "MiTV/MainActivity"

    const-string v4, "Failed to close output buffer"

    invoke-static {v2, v4}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    move v2, v1

    goto :goto_4

    :catch_3
    move-exception v2

    const-string v2, "MiTV/MainActivity"

    const-string v3, "Failed to close file"

    invoke-static {v2, v3}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_5
.end method
