e.smali

.class public Lcom/beetalk/sdk/cache/e;
.super Ljava/lang/Object;
.source "PayCachePreference.java"


# static fields
.field private static volatile a:Lcom/beetalk/sdk/cache/e;


# instance fields
.field private b:Landroid/content/SharedPreferences;

.field private c:J

.field private d:Ljava/util/Set;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Set<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method private constructor <init>(Landroid/content/Context;)V
    .registers 4

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const-string v0, "com.garena.android.msdk.PayCachePreference"

    const/4 v1, 0x0

    .line 2
    invoke-virtual {p1, v0, v1}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;

    move-result-object p1

    iput-object p1, p0, Lcom/beetalk/sdk/cache/e;->b:Landroid/content/SharedPreferences;

    return-void
.end method

.method public static a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;
    .registers 3

    .line 1
    sget-object v0, Lcom/beetalk/sdk/cache/e;->a:Lcom/beetalk/sdk/cache/e;

    if-nez v0, :cond_17

    .line 2
    const-class v0, Lcom/beetalk/sdk/cache/e;

    monitor-enter v0

    .line 3
    :try_start_7
    sget-object v1, Lcom/beetalk/sdk/cache/e;->a:Lcom/beetalk/sdk/cache/e;

    if-nez v1, :cond_12

    .line 4
    new-instance v1, Lcom/beetalk/sdk/cache/e;

    invoke-direct {v1, p0}, Lcom/beetalk/sdk/cache/e;-><init>(Landroid/content/Context;)V

    sput-object v1, Lcom/beetalk/sdk/cache/e;->a:Lcom/beetalk/sdk/cache/e;

    .line 5
    :cond_12
    monitor-exit v0

    goto :goto_17

    :catchall_14
    move-exception p0

    monitor-exit v0
    :try_end_16
    .catchall {:try_start_7 .. :try_end_16} :catchall_14

    throw p0

    .line 6
    :cond_17
    :goto_17
    sget-object p0, Lcom/beetalk/sdk/cache/e;->a:Lcom/beetalk/sdk/cache/e;

    return-object p0
.end method

.method public static a(Landroid/content/Context;Lcom/android/billingclient/api/Purchase;)V
    .registers 4

    if-nez p1, :cond_3

    return-void

    .line 7
    :cond_3
    invoke-virtual {p1}, Lcom/android/billingclient/api/Purchase;->getSku()Ljava/lang/String;

    move-result-object v0

    const-string v1, "9999"

    invoke-virtual {v1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-nez v0, :cond_3a

    .line 8
    invoke-virtual {p1}, Lcom/android/billingclient/api/Purchase;->getSku()Ljava/lang/String;

    move-result-object v0

    const-string v1, "android.test.purchased"

    invoke-virtual {v1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_1c

    goto :goto_3a

    .line 9
    :cond_1c
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->b(Landroid/content/Context;)Z

    move-result v0

    if-eqz v0, :cond_25

    .line 10
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->f(Landroid/content/Context;)V

    .line 11
    :cond_25
    invoke-virtual {p1}, Lcom/android/billingclient/api/Purchase;->getPurchaseToken()Ljava/lang/String;

    move-result-object p1

    .line 12
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->c(Landroid/content/Context;)Ljava/util/Set;

    move-result-object v0

    .line 13
    invoke-interface {v0, p1}, Ljava/util/Set;->contains(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_34

    return-void

    .line 14
    :cond_34
    invoke-interface {v0, p1}, Ljava/util/Set;->add(Ljava/lang/Object;)Z

    .line 15
    invoke-static {p0, v0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;Ljava/util/Set;)V

    :cond_3a
    :goto_3a
    return-void
.end method

.method private static a(Landroid/content/Context;Ljava/util/Set;)V
    .registers 6
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Landroid/content/Context;",
            "Ljava/util/Set<",
            "Ljava/lang/String;",
            ">;)V"
        }
    .end annotation

    .line 16
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object v0

    iget-object v0, v0, Lcom/beetalk/sdk/cache/e;->b:Landroid/content/SharedPreferences;

    invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object v0

    .line 17
    new-instance v1, Lorg/json/JSONArray;

    invoke-direct {v1}, Lorg/json/JSONArray;-><init>()V

    .line 18
    invoke-interface {p1}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v2

    :goto_13
    invoke-interface {v2}, Ljava/util/Iterator;->hasNext()Z

    move-result v3

    if-eqz v3, :cond_23

    invoke-interface {v2}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/lang/String;

    .line 19
    invoke-virtual {v1, v3}, Lorg/json/JSONArray;->put(Ljava/lang/Object;)Lorg/json/JSONArray;

    goto :goto_13

    .line 20
    :cond_23
    invoke-virtual {v1}, Lorg/json/JSONArray;->toString()Ljava/lang/String;

    move-result-object v1

    const-string v2, "COMMIT_CACHE"

    invoke-interface {v0, v2, v1}, Landroid/content/SharedPreferences$Editor;->putString(Ljava/lang/String;Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 21
    invoke-interface {v0}, Landroid/content/SharedPreferences$Editor;->apply()V

    .line 22
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object p0

    iput-object p1, p0, Lcom/beetalk/sdk/cache/e;->d:Ljava/util/Set;

    return-void
.end method

.method private static b(Landroid/content/Context;)Z
    .registers 4

    .line 5
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->d(Landroid/content/Context;)Z

    move-result v0

    if-eqz v0, :cond_27

    .line 6
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object v0

    const-wide/16 v1, 0x0

    iput-wide v1, v0, Lcom/beetalk/sdk/cache/e;->c:J

    .line 7
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object v0

    const/4 v1, 0x0

    iput-object v1, v0, Lcom/beetalk/sdk/cache/e;->d:Ljava/util/Set;

    .line 8
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object p0

    iget-object p0, p0, Lcom/beetalk/sdk/cache/e;->b:Landroid/content/SharedPreferences;

    invoke-interface {p0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object p0

    .line 9
    invoke-interface {p0}, Landroid/content/SharedPreferences$Editor;->clear()Landroid/content/SharedPreferences$Editor;

    .line 10
    invoke-interface {p0}, Landroid/content/SharedPreferences$Editor;->apply()V

    const/4 p0, 0x1

    return p0

    :cond_27
    const/4 p0, 0x0

    return p0
.end method

.method public static b(Landroid/content/Context;Lcom/android/billingclient/api/Purchase;)Z
    .registers 4

    const/4 v0, 0x0

    if-nez p1, :cond_4

    return v0

    .line 1
    :cond_4
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->b(Landroid/content/Context;)Z

    move-result v1

    if-eqz v1, :cond_b

    return v0

    .line 2
    :cond_b
    invoke-virtual {p1}, Lcom/android/billingclient/api/Purchase;->getPurchaseToken()Ljava/lang/String;

    move-result-object p1

    .line 3
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->c(Landroid/content/Context;)Ljava/util/Set;

    move-result-object p0

    .line 4
    invoke-interface {p0, p1}, Ljava/util/Set;->contains(Ljava/lang/Object;)Z

    move-result p0

    return p0
.end method

.method private static c(Landroid/content/Context;)Ljava/util/Set;
    .registers 5
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Landroid/content/Context;",
            ")",
            "Ljava/util/Set<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation

    .line 1
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object v0

    iget-object v0, v0, Lcom/beetalk/sdk/cache/e;->d:Ljava/util/Set;

    if-eqz v0, :cond_1b

    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object v0

    iget-object v0, v0, Lcom/beetalk/sdk/cache/e;->d:Ljava/util/Set;

    invoke-interface {v0}, Ljava/util/Set;->isEmpty()Z

    move-result v0

    if-nez v0, :cond_1b

    .line 2
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object p0

    iget-object p0, p0, Lcom/beetalk/sdk/cache/e;->d:Ljava/util/Set;

    return-object p0

    .line 3
    :cond_1b
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object v0

    iget-object v0, v0, Lcom/beetalk/sdk/cache/e;->b:Landroid/content/SharedPreferences;

    const-string v1, "COMMIT_CACHE"

    const-string v2, "[]"

    .line 4
    invoke-interface {v0, v1, v2}, Landroid/content/SharedPreferences;->getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    const/4 v1, 0x0

    .line 5
    :try_start_2a
    new-instance v2, Lorg/json/JSONArray;

    invoke-direct {v2, v0}, Lorg/json/JSONArray;-><init>(Ljava/lang/String;)V
    :try_end_2f
    .catch Lorg/json/JSONException; {:try_start_2a .. :try_end_2f} :catch_31

    move-object v1, v2

    goto :goto_35

    :catch_31
    move-exception v0

    .line 6
    invoke-static {v0}, Lcom/beetalk/sdk/b/a;->a(Ljava/lang/Exception;)V

    .line 7
    :goto_35
    new-instance v0, Ljava/util/HashSet;

    invoke-direct {v0}, Ljava/util/HashSet;-><init>()V

    if-eqz v1, :cond_4d

    const/4 v2, 0x0

    .line 8
    :goto_3d
    invoke-virtual {v1}, Lorg/json/JSONArray;->length()I

    move-result v3

    if-ge v2, v3, :cond_4d

    .line 9
    invoke-virtual {v1, v2}, Lorg/json/JSONArray;->optString(I)Ljava/lang/String;

    move-result-object v3

    invoke-interface {v0, v3}, Ljava/util/Set;->add(Ljava/lang/Object;)Z

    add-int/lit8 v2, v2, 0x1

    goto :goto_3d

    .line 10
    :cond_4d
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object p0

    iput-object v0, p0, Lcom/beetalk/sdk/cache/e;->d:Ljava/util/Set;

    return-object v0
.end method

.method private static d(Landroid/content/Context;)Z
    .registers 5

    .line 1
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v0

    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->e(Landroid/content/Context;)J

    move-result-wide v2

    sub-long/2addr v0, v2

    invoke-static {}, Lcom/beetalk/sdk/SDKConstants;->m()J

    move-result-wide v2

    cmp-long p0, v0, v2

    if-lez p0, :cond_13

    const/4 p0, 0x1

    goto :goto_14

    :cond_13
    const/4 p0, 0x0

    :goto_14
    return p0
.end method

.method private static e(Landroid/content/Context;)J
    .registers 6

    .line 1
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object v0

    iget-wide v0, v0, Lcom/beetalk/sdk/cache/e;->c:J

    const-wide/16 v2, 0x0

    cmp-long v4, v0, v2

    if-lez v4, :cond_d

    return-wide v0

    .line 2
    :cond_d
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object v0

    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object v1

    iget-object v1, v1, Lcom/beetalk/sdk/cache/e;->b:Landroid/content/SharedPreferences;

    const-string v4, "TIME_CREATED"

    invoke-interface {v1, v4, v2, v3}, Landroid/content/SharedPreferences;->getLong(Ljava/lang/String;J)J

    move-result-wide v1

    iput-wide v1, v0, Lcom/beetalk/sdk/cache/e;->c:J

    .line 3
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object p0

    iget-wide v0, p0, Lcom/beetalk/sdk/cache/e;->c:J

    return-wide v0
.end method

.method private static f(Landroid/content/Context;)V
    .registers 5

    .line 1
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v0

    .line 2
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object v2

    iget-object v2, v2, Lcom/beetalk/sdk/cache/e;->b:Landroid/content/SharedPreferences;

    invoke-interface {v2}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object v2

    const-string v3, "TIME_CREATED"

    .line 3
    invoke-interface {v2, v3, v0, v1}, Landroid/content/SharedPreferences$Editor;->putLong(Ljava/lang/String;J)Landroid/content/SharedPreferences$Editor;

    .line 4
    invoke-interface {v2}, Landroid/content/SharedPreferences$Editor;->apply()V

    .line 5
    invoke-static {p0}, Lcom/beetalk/sdk/cache/e;->a(Landroid/content/Context;)Lcom/beetalk/sdk/cache/e;

    move-result-object p0

    iput-wide v0, p0, Lcom/beetalk/sdk/cache/e;->c:J

    return-void
.end method