JobScheduler.smali
.class public Lcom/facebook/imagepipeline/producers/JobScheduler;
.super Ljava/lang/Object;
.source "JobScheduler.java"
# 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 public static final QUEUE_TIME_KEY:Ljava/lang/String; = "queueTime"
# instance fields
.field public final mDoJobRunnable:Ljava/lang/Runnable;
.field public mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
.annotation build Lcom/facebook/common/internal/VisibleForTesting;
.end annotation
.annotation build Ljavax/annotation/concurrent/GuardedBy;
value = "this"
.end annotation
.end field
.field public final mExecutor:Ljava/util/concurrent/Executor;
.field public final mJobRunnable:Lcom/facebook/imagepipeline/producers/JobScheduler$JobRunnable;
.field public mJobStartTime:J
.annotation build Lcom/facebook/common/internal/VisibleForTesting;
.end annotation
.annotation build Ljavax/annotation/concurrent/GuardedBy;
value = "this"
.end annotation
.end field
.field public mJobState:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
.annotation build Lcom/facebook/common/internal/VisibleForTesting;
.end annotation
.annotation build Ljavax/annotation/concurrent/GuardedBy;
value = "this"
.end annotation
.end field
.field public mJobSubmitTime:J
.annotation build Lcom/facebook/common/internal/VisibleForTesting;
.end annotation
.annotation build Ljavax/annotation/concurrent/GuardedBy;
value = "this"
.end annotation
.end field
.field public final mMinimumJobIntervalMs:I
.field public mStatus:I
.annotation build Lcom/facebook/common/internal/VisibleForTesting;
.end annotation
.annotation build Ljavax/annotation/concurrent/GuardedBy;
value = "this"
.end annotation
.end field
.field public final mSubmitJobRunnable:Ljava/lang/Runnable;
# direct methods
.method static constructor <clinit>()V
.registers 1
return-void
.end method
.method public constructor <init>(Ljava/util/concurrent/Executor;Lcom/facebook/imagepipeline/producers/JobScheduler$JobRunnable;I)V
.registers 4
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
iput-object p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mExecutor:Ljava/util/concurrent/Executor;
iput-object p2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobRunnable:Lcom/facebook/imagepipeline/producers/JobScheduler$JobRunnable;
iput p3, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mMinimumJobIntervalMs:I
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;
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
iput-object p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
const/4 p1, 0x0
iput p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
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
iput-wide p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobSubmitTime:J
iput-wide p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobStartTime:J
return-void
.end method
.method public static synthetic access$000(Lcom/facebook/imagepipeline/producers/JobScheduler;)V
.registers 1
invoke-direct {p0}, Lcom/facebook/imagepipeline/producers/JobScheduler;->doJob()V
return-void
.end method
.method public static synthetic access$100(Lcom/facebook/imagepipeline/producers/JobScheduler;)V
.registers 1
invoke-direct {p0}, Lcom/facebook/imagepipeline/producers/JobScheduler;->submitJob()V
return-void
.end method
.method private doJob()V
.registers 6
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
move-result-wide v0
monitor-enter p0
: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
const/4 v4, 0x0
iput-object v4, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
const/4 v4, 0x0
iput v4, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
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;
iput-wide v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobStartTime:J
monitor-exit p0
:try_end_16
.catchall {:try_start_5 .. :try_end_16} :catchall_30
: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
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
:cond_21
invoke-static {v2}, Lcom/facebook/imagepipeline/image/EncodedImage;->closeSafely(Lcom/facebook/imagepipeline/image/EncodedImage;)V
invoke-direct {p0}, Lcom/facebook/imagepipeline/producers/JobScheduler;->onJobFinished()V
return-void
:catchall_28
move-exception v0
invoke-static {v2}, Lcom/facebook/imagepipeline/image/EncodedImage;->closeSafely(Lcom/facebook/imagepipeline/image/EncodedImage;)V
invoke-direct {p0}, Lcom/facebook/imagepipeline/producers/JobScheduler;->onJobFinished()V
throw v0
:catchall_30
move-exception v0
: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 7
iget-object v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mSubmitJobRunnable:Ljava/lang/Runnable;
const-string v1, "JobScheduler_enqueueJob"
invoke-static {v0, v1}, Lcom/facebook/imagepipeline/instrumentation/FrescoInstrumenter;->decorateRunnable(Ljava/lang/Runnable;Ljava/lang/String;)Ljava/lang/Runnable;
move-result-object v0
const-wide/16 v1, 0x0
cmp-long v3, p1, v1
if-lez v3, :cond_18
invoke-static {}, Lcom/facebook/imagepipeline/producers/JobScheduler$JobStartExecutorSupplier;->get()Ljava/util/concurrent/ScheduledExecutorService;
move-result-object v1
sget-object v2, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
invoke-interface {v1, v0, p1, p2, v2}, Ljava/util/concurrent/ScheduledExecutorService;->schedule(Ljava/lang/Runnable;JLjava/util/concurrent/TimeUnit;)Ljava/util/concurrent/ScheduledFuture;
goto :goto_1b
:cond_18
invoke-interface {v0}, Ljava/lang/Runnable;->run()V
:goto_1b
return-void
.end method
.method private onJobFinished()V
.registers 7
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
move-result-wide v0
monitor-enter p0
: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
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
iput-wide v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobSubmitTime:J
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
: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
: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
invoke-direct {p0, v2, v3}, Lcom/facebook/imagepipeline/producers/JobScheduler;->enqueueJob(J)V
:cond_2b
return-void
:catchall_2c
move-exception v0
:try_start_2d
monitor-exit p0
:try_end_2e
.catchall {:try_start_2d .. :try_end_2e} :catchall_2c
throw v0
.end method
.method public static shouldProcess(Lcom/facebook/imagepipeline/image/EncodedImage;I)Z
.registers 3
invoke-static {p1}, Lcom/facebook/imagepipeline/producers/BaseConsumer;->isLast(I)Z
move-result v0
if-nez v0, :cond_16
const/4 v0, 0x4
invoke-static {p1, v0}, Lcom/facebook/imagepipeline/producers/BaseConsumer;->statusHasFlag(II)Z
move-result p1
if-nez p1, :cond_16
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
goto :goto_17
:cond_16
:goto_16
const/4 p0, 0x1
:goto_17
return p0
.end method
.method private submitJob()V
.registers 4
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;
const-string v2, "JobScheduler_submitJob"
invoke-static {v1, v2}, Lcom/facebook/imagepipeline/instrumentation/FrescoInstrumenter;->decorateRunnable(Ljava/lang/Runnable;Ljava/lang/String;)Ljava/lang/Runnable;
move-result-object v1
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
monitor-enter p0
:try_start_1
iget-object v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
const/4 v1, 0x0
iput-object v1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
const/4 v1, 0x0
iput v1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
monitor-exit p0
:try_end_a
.catchall {:try_start_1 .. :try_end_a} :catchall_e
invoke-static {v0}, Lcom/facebook/imagepipeline/image/EncodedImage;->closeSafely(Lcom/facebook/imagepipeline/image/EncodedImage;)V
return-void
:catchall_e
move-exception v0
: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
: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
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
move-result-wide v0
monitor-enter p0
: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
monitor-exit p0
return v3
: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}, Ljava/lang/Enum;->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
: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
: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
iput-wide v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobSubmitTime:J
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
: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
invoke-direct {p0, v5, v6}, Lcom/facebook/imagepipeline/producers/JobScheduler;->enqueueJob(J)V
:cond_42
return v4
:catchall_43
move-exception v0
: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
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
:cond_8
monitor-enter p0
:try_start_9
iget-object v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
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;
iput p2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
monitor-exit p0
:try_end_14
.catchall {:try_start_9 .. :try_end_14} :catchall_19
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
:try_start_1a
monitor-exit p0
:try_end_1b
.catchall {:try_start_1a .. :try_end_1b} :catchall_19
throw p1
.end method