JobScheduler.smali
.class public Lcom/facebook/imagepipeline/producers/JobScheduler;
.super Ljava/lang/Object;
.source "SourceFile"
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;,
Lcom/facebook/imagepipeline/producers/JobScheduler$JobRunnable;,
Lcom/facebook/imagepipeline/producers/JobScheduler$JobStartExecutorSupplier;
}
.end annotation
# static fields
.field static final QUEUE_TIME_KEY:Ljava/lang/String; = "queueTime"
# instance fields
.field private final mDoJobRunnable:Ljava/lang/Runnable;
.field mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
.field private final mExecutor:Ljava/util/concurrent/Executor;
.field private final mJobRunnable:Lcom/facebook/imagepipeline/producers/JobScheduler$JobRunnable;
.field mJobStartTime:J
.field mJobState:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
.field mJobSubmitTime:J
.field private final mMinimumJobIntervalMs:I
.field mStatus:I
.field private final mSubmitJobRunnable:Ljava/lang/Runnable;
# direct methods
.method public constructor <init>(Ljava/util/concurrent/Executor;Lcom/facebook/imagepipeline/producers/JobScheduler$JobRunnable;I)V
.registers 4
.line 66
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 67
iput-object p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mExecutor:Ljava/util/concurrent/Executor;
.line 68
iput-object p2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobRunnable:Lcom/facebook/imagepipeline/producers/JobScheduler$JobRunnable;
.line 69
iput p3, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mMinimumJobIntervalMs:I
.line 70
new-instance p1, Lcom/facebook/imagepipeline/producers/JobScheduler$1;
invoke-direct {p1, p0}, Lcom/facebook/imagepipeline/producers/JobScheduler$1;-><init>(Lcom/facebook/imagepipeline/producers/JobScheduler;)V
iput-object p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mDoJobRunnable:Ljava/lang/Runnable;
.line 76
new-instance p1, Lcom/facebook/imagepipeline/producers/JobScheduler$2;
invoke-direct {p1, p0}, Lcom/facebook/imagepipeline/producers/JobScheduler$2;-><init>(Lcom/facebook/imagepipeline/producers/JobScheduler;)V
iput-object p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mSubmitJobRunnable:Ljava/lang/Runnable;
const/4 p1, 0x0
.line 82
iput-object p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
const/4 p1, 0x0
.line 83
iput p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
.line 84
sget-object p1, Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;->IDLE:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
iput-object p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobState:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
const-wide/16 p1, 0x0
.line 85
iput-wide p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobSubmitTime:J
.line 86
iput-wide p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobStartTime:J
return-void
.end method
.method static synthetic access$000(Lcom/facebook/imagepipeline/producers/JobScheduler;)V
.registers 1
.line 22
invoke-direct {p0}, Lcom/facebook/imagepipeline/producers/JobScheduler;->doJob()V
return-void
.end method
.method static synthetic access$100(Lcom/facebook/imagepipeline/producers/JobScheduler;)V
.registers 1
.line 22
invoke-direct {p0}, Lcom/facebook/imagepipeline/producers/JobScheduler;->submitJob()V
return-void
.end method
.method private doJob()V
.registers 6
.line 187
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
move-result-wide v0
.line 190
monitor-enter p0
.line 191
:try_start_5
iget-object v2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
.line 192
iget v3, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
const/4 v4, 0x0
.line 193
iput-object v4, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
const/4 v4, 0x0
.line 194
iput v4, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
.line 195
sget-object v4, Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;->RUNNING:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
iput-object v4, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobState:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
.line 196
iput-wide v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobStartTime:J
.line 197
monitor-exit p0
:try_end_16
.catchall {:try_start_5 .. :try_end_16} :catchall_30
.line 201
:try_start_16
invoke-static {v2, v3}, Lcom/facebook/imagepipeline/producers/JobScheduler;->shouldProcess(Lcom/facebook/imagepipeline/image/EncodedImage;I)Z
move-result v0
if-eqz v0, :cond_21
.line 202
iget-object v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobRunnable:Lcom/facebook/imagepipeline/producers/JobScheduler$JobRunnable;
invoke-interface {v0, v2, v3}, Lcom/facebook/imagepipeline/producers/JobScheduler$JobRunnable;->run(Lcom/facebook/imagepipeline/image/EncodedImage;I)V
:try_end_21
.catchall {:try_start_16 .. :try_end_21} :catchall_28
.line 205
:cond_21
invoke-static {v2}, Lcom/facebook/imagepipeline/image/EncodedImage;->closeSafely(Lcom/facebook/imagepipeline/image/EncodedImage;)V
.line 206
invoke-direct {p0}, Lcom/facebook/imagepipeline/producers/JobScheduler;->onJobFinished()V
return-void
:catchall_28
move-exception v0
.line 205
invoke-static {v2}, Lcom/facebook/imagepipeline/image/EncodedImage;->closeSafely(Lcom/facebook/imagepipeline/image/EncodedImage;)V
.line 206
invoke-direct {p0}, Lcom/facebook/imagepipeline/producers/JobScheduler;->onJobFinished()V
throw v0
:catchall_30
move-exception v0
.line 197
:try_start_31
monitor-exit p0
:try_end_32
.catchall {:try_start_31 .. :try_end_32} :catchall_30
throw v0
.end method
.method private enqueueJob(J)V
.registers 6
const-wide/16 v0, 0x0
cmp-long v2, p1, v0
if-lez v2, :cond_12
.line 176
invoke-static {}, Lcom/facebook/imagepipeline/producers/JobScheduler$JobStartExecutorSupplier;->get()Ljava/util/concurrent/ScheduledExecutorService;
move-result-object v0
iget-object v1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mSubmitJobRunnable:Ljava/lang/Runnable;
sget-object v2, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
invoke-interface {v0, v1, p1, p2, v2}, Ljava/util/concurrent/ScheduledExecutorService;->schedule(Ljava/lang/Runnable;JLjava/util/concurrent/TimeUnit;)Ljava/util/concurrent/ScheduledFuture;
return-void
.line 178
:cond_12
iget-object p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mSubmitJobRunnable:Ljava/lang/Runnable;
invoke-interface {p1}, Ljava/lang/Runnable;->run()V
return-void
.end method
.method private onJobFinished()V
.registers 7
.line 211
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
move-result-wide v0
.line 214
monitor-enter p0
.line 215
:try_start_5
iget-object v2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobState:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
sget-object v3, Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;->RUNNING_AND_PENDING:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
if-ne v2, v3, :cond_1d
.line 216
iget-wide v2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobStartTime:J
iget v4, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mMinimumJobIntervalMs:I
int-to-long v4, v4
add-long/2addr v2, v4
invoke-static {v2, v3, v0, v1}, Ljava/lang/Math;->max(JJ)J
move-result-wide v2
const/4 v4, 0x1
.line 218
iput-wide v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobSubmitTime:J
.line 219
sget-object v5, Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;->QUEUED:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
iput-object v5, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobState:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
goto :goto_24
.line 221
:cond_1d
sget-object v2, Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;->IDLE:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
iput-object v2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobState:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
const-wide/16 v2, 0x0
const/4 v4, 0x0
.line 223
:goto_24
monitor-exit p0
:try_end_25
.catchall {:try_start_5 .. :try_end_25} :catchall_2c
if-eqz v4, :cond_2b
sub-long/2addr v2, v0
.line 225
invoke-direct {p0, v2, v3}, Lcom/facebook/imagepipeline/producers/JobScheduler;->enqueueJob(J)V
:cond_2b
return-void
:catchall_2c
move-exception v0
.line 223
:try_start_2d
monitor-exit p0
:try_end_2e
.catchall {:try_start_2d .. :try_end_2e} :catchall_2c
throw v0
.end method
.method private static shouldProcess(Lcom/facebook/imagepipeline/image/EncodedImage;I)Z
.registers 3
.line 232
invoke-static {p1}, Lcom/facebook/imagepipeline/producers/BaseConsumer;->isLast(I)Z
move-result v0
if-nez v0, :cond_16
const/4 v0, 0x4
.line 233
invoke-static {p1, v0}, Lcom/facebook/imagepipeline/producers/BaseConsumer;->statusHasFlag(II)Z
move-result p1
if-nez p1, :cond_16
.line 234
invoke-static {p0}, Lcom/facebook/imagepipeline/image/EncodedImage;->isValid(Lcom/facebook/imagepipeline/image/EncodedImage;)Z
move-result p0
if-eqz p0, :cond_14
goto :goto_16
:cond_14
const/4 p0, 0x0
return p0
:cond_16
:goto_16
const/4 p0, 0x1
return p0
.end method
.method private submitJob()V
.registers 3
.line 183
iget-object v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mExecutor:Ljava/util/concurrent/Executor;
iget-object v1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mDoJobRunnable:Ljava/lang/Runnable;
invoke-interface {v0, v1}, Ljava/util/concurrent/Executor;->execute(Ljava/lang/Runnable;)V
return-void
.end method
# virtual methods
.method public clearJob()V
.registers 3
.line 97
monitor-enter p0
.line 98
:try_start_1
iget-object v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
const/4 v1, 0x0
.line 99
iput-object v1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
const/4 v1, 0x0
.line 100
iput v1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
.line 101
monitor-exit p0
:try_end_a
.catchall {:try_start_1 .. :try_end_a} :catchall_e
.line 102
invoke-static {v0}, Lcom/facebook/imagepipeline/image/EncodedImage;->closeSafely(Lcom/facebook/imagepipeline/image/EncodedImage;)V
return-void
:catchall_e
move-exception v0
.line 101
:try_start_f
monitor-exit p0
:try_end_10
.catchall {:try_start_f .. :try_end_10} :catchall_e
throw v0
.end method
.method public declared-synchronized getQueuedTime()J
.registers 5
monitor-enter p0
.line 243
:try_start_1
iget-wide v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobStartTime:J
iget-wide v2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobSubmitTime:J
:try_end_5
.catchall {:try_start_1 .. :try_end_5} :catchall_8
sub-long/2addr v0, v2
monitor-exit p0
return-wide v0
:catchall_8
move-exception v0
monitor-exit p0
throw v0
.end method
.method public scheduleJob()Z
.registers 8
.line 140
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
move-result-wide v0
.line 143
monitor-enter p0
.line 144
:try_start_5
iget-object v2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
iget v3, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
invoke-static {v2, v3}, Lcom/facebook/imagepipeline/producers/JobScheduler;->shouldProcess(Lcom/facebook/imagepipeline/image/EncodedImage;I)Z
move-result v2
const/4 v3, 0x0
if-nez v2, :cond_12
.line 145
monitor-exit p0
return v3
.line 147
:cond_12
sget-object v2, Lcom/facebook/imagepipeline/producers/JobScheduler$3;->$SwitchMap$com$facebook$imagepipeline$producers$JobScheduler$JobState:[I
iget-object v4, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobState:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
invoke-virtual {v4}, Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;->ordinal()I
move-result v4
aget v2, v2, v4
const/4 v4, 0x1
if-eq v2, v4, :cond_2a
const/4 v5, 0x3
if-eq v2, v5, :cond_23
goto :goto_27
.line 158
:cond_23
sget-object v2, Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;->RUNNING_AND_PENDING:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
iput-object v2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobState:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
:goto_27
const-wide/16 v5, 0x0
goto :goto_3b
.line 149
:cond_2a
iget-wide v2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobStartTime:J
iget v5, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mMinimumJobIntervalMs:I
int-to-long v5, v5
add-long/2addr v2, v5
invoke-static {v2, v3, v0, v1}, Ljava/lang/Math;->max(JJ)J
move-result-wide v5
.line 151
iput-wide v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobSubmitTime:J
.line 152
sget-object v2, Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;->QUEUED:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
iput-object v2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobState:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
const/4 v3, 0x1
.line 164
:goto_3b
monitor-exit p0
:try_end_3c
.catchall {:try_start_5 .. :try_end_3c} :catchall_43
if-eqz v3, :cond_42
sub-long/2addr v5, v0
.line 166
invoke-direct {p0, v5, v6}, Lcom/facebook/imagepipeline/producers/JobScheduler;->enqueueJob(J)V
:cond_42
return v4
:catchall_43
move-exception v0
.line 164
:try_start_44
monitor-exit p0
:try_end_45
.catchall {:try_start_44 .. :try_end_45} :catchall_43
throw v0
.end method
.method public updateJob(Lcom/facebook/imagepipeline/image/EncodedImage;I)Z
.registers 4
.line 115
invoke-static {p1, p2}, Lcom/facebook/imagepipeline/producers/JobScheduler;->shouldProcess(Lcom/facebook/imagepipeline/image/EncodedImage;I)Z
move-result v0
if-nez v0, :cond_8
const/4 p1, 0x0
return p1
.line 119
:cond_8
monitor-enter p0
.line 120
:try_start_9
iget-object v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
.line 121
invoke-static {p1}, Lcom/facebook/imagepipeline/image/EncodedImage;->cloneOrNull(Lcom/facebook/imagepipeline/image/EncodedImage;)Lcom/facebook/imagepipeline/image/EncodedImage;
move-result-object p1
iput-object p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
.line 122
iput p2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
.line 123
monitor-exit p0
:try_end_14
.catchall {:try_start_9 .. :try_end_14} :catchall_19
.line 124
invoke-static {v0}, Lcom/facebook/imagepipeline/image/EncodedImage;->closeSafely(Lcom/facebook/imagepipeline/image/EncodedImage;)V
const/4 p1, 0x1
return p1
:catchall_19
move-exception p1
.line 123
:try_start_1a
monitor-exit p0
:try_end_1b
.catchall {:try_start_1a .. :try_end_1b} :catchall_19
throw p1
.end method