LoadCache.smali

.class public Lcom/baidu/mobstat/LoadCache;
.super Ljava/lang/Object;
.source "SourceFile"


# static fields
.field private static final a:Lcom/baidu/mobstat/LoadCache;


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

.field private volatile c:Z

.field private volatile d:Z

.field private volatile e:Z

.field private f:Landroid/os/HandlerThread;

.field private g:Landroid/os/Handler;


# direct methods
.method static constructor <clinit>()V
    .registers 1

    .prologue
    .line 22
    new-instance v0, Lcom/baidu/mobstat/LoadCache;

    invoke-direct {v0}, Lcom/baidu/mobstat/LoadCache;-><init>()V

    sput-object v0, Lcom/baidu/mobstat/LoadCache;->a:Lcom/baidu/mobstat/LoadCache;

    return-void
.end method

.method private constructor <init>()V
    .registers 2

    .prologue
    const/4 v0, 0x0

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

    .line 30
    iput-boolean v0, p0, Lcom/baidu/mobstat/LoadCache;->c:Z

    .line 31
    iput-boolean v0, p0, Lcom/baidu/mobstat/LoadCache;->d:Z

    .line 33
    iput-boolean v0, p0, Lcom/baidu/mobstat/LoadCache;->e:Z

    .line 40
    return-void
.end method

.method static synthetic a(Lcom/baidu/mobstat/LoadCache;)Landroid/content/Context;
    .registers 2

    .prologue
    .line 21
    iget-object v0, p0, Lcom/baidu/mobstat/LoadCache;->b:Landroid/content/Context;

    return-object v0
.end method

.method private a(Landroid/content/Context;Z)V
    .registers 4

    .prologue
    .line 123
    if-nez p1, :cond_3

    .line 133
    :cond_2
    :goto_2
    return-void

    .line 127
    :cond_3
    iget-boolean v0, p0, Lcom/baidu/mobstat/LoadCache;->c:Z

    if-nez v0, :cond_2

    .line 128
    invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;

    move-result-object v0

    iput-object v0, p0, Lcom/baidu/mobstat/LoadCache;->b:Landroid/content/Context;

    .line 129
    invoke-direct {p0, p2}, Lcom/baidu/mobstat/LoadCache;->a(Z)V

    .line 131
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/baidu/mobstat/LoadCache;->c:Z

    goto :goto_2
.end method

.method private declared-synchronized a(Z)V
    .registers 4

    .prologue
    .line 144
    monitor-enter p0

    :try_start_1
    new-instance v0, Lcom/baidu/mobstat/bs;

    invoke-direct {v0, p0, p1}, Lcom/baidu/mobstat/bs;-><init>(Lcom/baidu/mobstat/LoadCache;Z)V

    .line 145
    const/16 v1, 0xa

    invoke-virtual {v0, v1}, Lcom/baidu/mobstat/bs;->setPriority(I)V

    .line 146
    invoke-virtual {v0}, Lcom/baidu/mobstat/bs;->start()V
    :try_end_e
    .catchall {:try_start_1 .. :try_end_e} :catchall_10

    .line 147
    monitor-exit p0

    return-void

    .line 144
    :catchall_10
    move-exception v0

    monitor-exit p0

    throw v0
.end method

.method static synthetic a(Lcom/baidu/mobstat/LoadCache;Z)Z
    .registers 2

    .prologue
    .line 21
    iput-boolean p1, p0, Lcom/baidu/mobstat/LoadCache;->e:Z

    return p1
.end method

.method public static instance()Lcom/baidu/mobstat/LoadCache;
    .registers 1

    .prologue
    .line 25
    sget-object v0, Lcom/baidu/mobstat/LoadCache;->a:Lcom/baidu/mobstat/LoadCache;

    return-object v0
.end method


# virtual methods
.method public checkStartLoadCache(Landroid/content/Context;)V
    .registers 3

    .prologue
    .line 65
    const/4 v0, 0x0

    invoke-virtual {p0, p1, v0}, Lcom/baidu/mobstat/LoadCache;->checkStartLoadCache(Landroid/content/Context;Z)V

    .line 66
    return-void
.end method

.method public checkStartLoadCache(Landroid/content/Context;Z)V
    .registers 5

    .prologue
    .line 50
    :try_start_0
    invoke-static {}, Lcom/baidu/mobstat/LoadCache;->instance()Lcom/baidu/mobstat/LoadCache;

    move-result-object v0

    invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;

    move-result-object v1

    invoke-virtual {v0, v1}, Lcom/baidu/mobstat/LoadCache;->doDataAnalyze(Landroid/content/Context;)V
    :try_end_b
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_b} :catch_13

    .line 56
    :goto_b
    invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;

    move-result-object v0

    invoke-direct {p0, v0, p2}, Lcom/baidu/mobstat/LoadCache;->a(Landroid/content/Context;Z)V

    .line 57
    return-void

    .line 52
    :catch_13
    move-exception v0

    goto :goto_b
.end method

.method public doDataAnalyze(Landroid/content/Context;)V
    .registers 6

    .prologue
    .line 69
    iget-boolean v0, p0, Lcom/baidu/mobstat/LoadCache;->e:Z

    if-eqz v0, :cond_5

    .line 115
    :cond_4
    :goto_4
    return-void

    .line 73
    :cond_5
    if-eqz p1, :cond_4

    .line 83
    iget-object v0, p0, Lcom/baidu/mobstat/LoadCache;->f:Landroid/os/HandlerThread;

    if-eqz v0, :cond_13

    iget-object v0, p0, Lcom/baidu/mobstat/LoadCache;->f:Landroid/os/HandlerThread;

    invoke-virtual {v0}, Landroid/os/HandlerThread;->isAlive()Z

    move-result v0

    if-nez v0, :cond_30

    .line 84
    :cond_13
    new-instance v0, Landroid/os/HandlerThread;

    const-string v1, "dataAnalyzeThread"

    invoke-direct {v0, v1}, Landroid/os/HandlerThread;-><init>(Ljava/lang/String;)V

    iput-object v0, p0, Lcom/baidu/mobstat/LoadCache;->f:Landroid/os/HandlerThread;

    .line 85
    iget-object v0, p0, Lcom/baidu/mobstat/LoadCache;->f:Landroid/os/HandlerThread;

    invoke-virtual {v0}, Landroid/os/HandlerThread;->start()V

    .line 87
    iget-object v0, p0, Lcom/baidu/mobstat/LoadCache;->f:Landroid/os/HandlerThread;

    invoke-virtual {v0}, Landroid/os/HandlerThread;->getLooper()Landroid/os/Looper;

    move-result-object v0

    .line 88
    if-eqz v0, :cond_30

    .line 89
    new-instance v1, Landroid/os/Handler;

    invoke-direct {v1, v0}, Landroid/os/Handler;-><init>(Landroid/os/Looper;)V

    iput-object v1, p0, Lcom/baidu/mobstat/LoadCache;->g:Landroid/os/Handler;

    .line 93
    :cond_30
    iget-object v0, p0, Lcom/baidu/mobstat/LoadCache;->g:Landroid/os/Handler;

    if-eqz v0, :cond_4

    .line 98
    iget-object v0, p0, Lcom/baidu/mobstat/LoadCache;->g:Landroid/os/Handler;

    new-instance v1, Lcom/baidu/mobstat/br;

    invoke-direct {v1, p0, p1}, Lcom/baidu/mobstat/br;-><init>(Lcom/baidu/mobstat/LoadCache;Landroid/content/Context;)V

    const-wide/16 v2, 0x1388

    invoke-virtual {v0, v1, v2, v3}, Landroid/os/Handler;->postDelayed(Ljava/lang/Runnable;J)Z

    .line 114
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/baidu/mobstat/LoadCache;->e:Z

    goto :goto_4
.end method

.method public declared-synchronized hasBeenStarted()Z
    .registers 2

    .prologue
    .line 136
    monitor-enter p0

    :try_start_1
    iget-boolean v0, p0, Lcom/baidu/mobstat/LoadCache;->c:Z
    :try_end_3
    .catchall {:try_start_1 .. :try_end_3} :catchall_5

    monitor-exit p0

    return v0

    :catchall_5
    move-exception v0

    monitor-exit p0

    throw v0
.end method

.method public declared-synchronized hasFinished()Z
    .registers 2

    .prologue
    .line 140
    monitor-enter p0

    :try_start_1
    iget-boolean v0, p0, Lcom/baidu/mobstat/LoadCache;->d:Z
    :try_end_3
    .catchall {:try_start_1 .. :try_end_3} :catchall_5

    monitor-exit p0

    return v0

    :catchall_5
    move-exception v0

    monitor-exit p0

    throw v0
.end method

.method public initNeededData(Landroid/content/Context;ZZ)V
    .registers 6

    .prologue
    const/4 v1, 0x1

    .line 180
    iget-boolean v0, p0, Lcom/baidu/mobstat/LoadCache;->d:Z

    if-eqz v0, :cond_6

    .line 203
    :goto_5
    return-void

    .line 184
    :cond_6
    invoke-static {p1}, Lcom/baidu/mobstat/PrefOperate;->loadMetaDataConfig(Landroid/content/Context;)V

    .line 191
    invoke-static {}, Lcom/baidu/mobstat/DataCore;->instance()Lcom/baidu/mobstat/DataCore;

    move-result-object v0

    invoke-virtual {v0, p1}, Lcom/baidu/mobstat/DataCore;->loadStatData(Landroid/content/Context;)V

    .line 193
    invoke-static {}, Lcom/baidu/mobstat/DataCore;->instance()Lcom/baidu/mobstat/DataCore;

    move-result-object v0

    invoke-virtual {v0, p1}, Lcom/baidu/mobstat/DataCore;->loadLastSession(Landroid/content/Context;)V

    .line 195
    invoke-static {}, Lcom/baidu/mobstat/DataCore;->instance()Lcom/baidu/mobstat/DataCore;

    move-result-object v0

    invoke-virtual {v0, p1}, Lcom/baidu/mobstat/DataCore;->installHeader(Landroid/content/Context;)V

    .line 197
    if-eqz p2, :cond_27

    .line 199
    invoke-static {}, Lcom/baidu/mobstat/DataCore;->instance()Lcom/baidu/mobstat/DataCore;

    move-result-object v0

    invoke-virtual {v0, p1, v1, p3}, Lcom/baidu/mobstat/DataCore;->saveLogDataToSend(Landroid/content/Context;ZZ)V

    .line 202
    :cond_27
    iput-boolean v1, p0, Lcom/baidu/mobstat/LoadCache;->d:Z

    goto :goto_5
.end method

.method public waitForLoadCache()V
    .registers 3

    .prologue
    .line 152
    iget-boolean v0, p0, Lcom/baidu/mobstat/LoadCache;->d:Z

    if-nez v0, :cond_1c

    .line 153
    monitor-enter p0

    .line 154
    :goto_5
    :try_start_5
    iget-boolean v0, p0, Lcom/baidu/mobstat/LoadCache;->d:Z
    :try_end_7
    .catchall {:try_start_5 .. :try_end_7} :catchall_18

    if-nez v0, :cond_1b

    .line 156
    const-wide/16 v0, 0x32

    :try_start_b
    invoke-virtual {p0, v0, v1}, Ljava/lang/Object;->wait(J)V
    :try_end_e
    .catch Ljava/lang/InterruptedException; {:try_start_b .. :try_end_e} :catch_f
    .catchall {:try_start_b .. :try_end_e} :catchall_18

    goto :goto_5

    .line 157
    :catch_f
    move-exception v0

    .line 158
    :try_start_10
    invoke-virtual {v0}, Ljava/lang/InterruptedException;->getMessage()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Lcom/baidu/mobstat/cw;->b(Ljava/lang/String;)V

    goto :goto_5

    .line 161
    :catchall_18
    move-exception v0

    monitor-exit p0
    :try_end_1a
    .catchall {:try_start_10 .. :try_end_1a} :catchall_18

    throw v0

    :cond_1b
    :try_start_1b
    monitor-exit p0
    :try_end_1c
    .catchall {:try_start_1b .. :try_end_1c} :catchall_18

    .line 163
    :cond_1c
    return-void
.end method