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 public static final QUEUE_TIME_KEY:Ljava/lang/String; = "queueTime"
# instance fields
.field private final mDoJobRunnable:Ljava/lang/Runnable;
.field public mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
.annotation build Lcom/facebook/common/internal/VisibleForTesting;
.end annotation
.end field
.field private final mExecutor:Ljava/util/concurrent/Executor;
.field private final mJobRunnable:Lcom/facebook/imagepipeline/producers/JobScheduler$JobRunnable;
.field public mJobStartTime:J
.annotation build Lcom/facebook/common/internal/VisibleForTesting;
.end annotation
.end field
.field public mJobState:Lcom/facebook/imagepipeline/producers/JobScheduler$JobState;
.annotation build Lcom/facebook/common/internal/VisibleForTesting;
.end annotation
.end field
.field public mJobSubmitTime:J
.annotation build Lcom/facebook/common/internal/VisibleForTesting;
.end annotation
.end field
.field private final mMinimumJobIntervalMs:I
.field public mStatus:I
.annotation build Lcom/facebook/common/internal/VisibleForTesting;
.end annotation
.end field
.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 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 2
iput-object p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mExecutor:Ljava/util/concurrent/Executor;
.line 3
iput-object p2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobRunnable:Lcom/facebook/imagepipeline/producers/JobScheduler$JobRunnable;
.line 4
iput p3, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mMinimumJobIntervalMs:I
.line 5
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 6
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 7
iput-object p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
const/4 p1, 0x0
.line 8
iput p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
.line 9
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 10
iput-wide p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobSubmitTime:J
.line 11
iput-wide p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobStartTime:J
return-void
.end method
.method public static INVOKEINTERFACE_com_facebook_imagepipeline_producers_JobScheduler_com_shopee_app_asm_anr_threadpool_ExecutorProxy_execute(Ljava/util/concurrent/Executor;Ljava/lang/Runnable;)V
.registers 4
.line 1
invoke-static {}, Lcom/shopee/app/asm/anr/threadpool/c;->b()Z
move-result v0
if-eqz v0, :cond_3a
invoke-static {}, Lcom/shopee/app/asm/anr/threadpool/c;->a()Z
move-result v0
if-eqz v0, :cond_3a
.line 2
:try_start_c
sget-object v0, Lcom/shopee/app/asm/anr/threadpool/c;->a:Landroid/os/HandlerThread;
.line 3
sget-object v0, Lcom/shopee/app/asm/anr/threadpool/c;->b:Landroid/os/Handler;
new-instance v1, Lcom/shopee/app/asm/anr/threadpool/a$b;
invoke-direct {v1, p0, p1}, Lcom/shopee/app/asm/anr/threadpool/a$b;-><init>(Ljava/util/concurrent/Executor;Ljava/lang/Runnable;)V
invoke-virtual {v0, v1}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
:try_end_18
.catchall {:try_start_c .. :try_end_18} :catchall_19
goto :goto_54
:catchall_19
move-exception v0
.line 4
invoke-virtual {v0}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;
sget-object v0, Lcom/shopee/app/asm/anr/threadpool/c;->a:Landroid/os/HandlerThread;
.line 5
:try_start_1f
invoke-static {p1, p0}, Lcom/shopee/app/asm/anr/threadpool/a;->a(Ljava/lang/Object;Ljava/lang/Object;)Z
move-result v0
if-eqz v0, :cond_2b
.line 6
sget-object p0, Lcom/shopee/app/asm/fix/threadpool/global/i;->e:Lcom/shopee/app/asm/fix/threadpool/global/j;
.line 7
invoke-virtual {p0, p1}, Lcom/shopee/app/asm/anr/threadpool/b;->execute(Ljava/lang/Runnable;)V
return-void
.line 8
:cond_2b
invoke-interface {p0, p1}, Ljava/util/concurrent/Executor;->execute(Ljava/lang/Runnable;)V
:try_end_2e
.catchall {:try_start_1f .. :try_end_2e} :catchall_2f
goto :goto_54
:catchall_2f
move-exception p0
.line 9
sget-object p1, Lcom/shopee/app/asm/anr/threadpool/c;->a:Landroid/os/HandlerThread;
.line 10
invoke-static {}, Lcom/shopee/app/apm/c;->d()Lcom/shopee/app/apm/nonfatal/a;
move-result-object p1
invoke-virtual {p1, p0}, Lcom/shopee/app/apm/nonfatal/a;->c(Ljava/lang/Throwable;)V
goto :goto_54
.line 11
:cond_3a
:try_start_3a
invoke-static {p1, p0}, Lcom/shopee/app/asm/anr/threadpool/a;->a(Ljava/lang/Object;Ljava/lang/Object;)Z
move-result v0
if-eqz v0, :cond_46
.line 12
sget-object p0, Lcom/shopee/app/asm/fix/threadpool/global/i;->e:Lcom/shopee/app/asm/fix/threadpool/global/j;
.line 13
invoke-virtual {p0, p1}, Lcom/shopee/app/asm/anr/threadpool/b;->execute(Ljava/lang/Runnable;)V
return-void
.line 14
:cond_46
invoke-interface {p0, p1}, Ljava/util/concurrent/Executor;->execute(Ljava/lang/Runnable;)V
:try_end_49
.catchall {:try_start_3a .. :try_end_49} :catchall_4a
goto :goto_54
:catchall_4a
move-exception p0
.line 15
sget-object p1, Lcom/shopee/app/asm/anr/threadpool/c;->a:Landroid/os/HandlerThread;
.line 16
invoke-static {}, Lcom/shopee/app/apm/c;->d()Lcom/shopee/app/apm/nonfatal/a;
move-result-object p1
invoke-virtual {p1, p0}, Lcom/shopee/app/apm/nonfatal/a;->c(Ljava/lang/Throwable;)V
:goto_54
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
.line 1
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
move-result-wide v0
.line 2
monitor-enter p0
.line 3
:try_start_5
iget-object v2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
.line 4
iget v3, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
const/4 v4, 0x0
.line 5
iput-object v4, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
const/4 v4, 0x0
.line 6
iput v4, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
.line 7
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 8
iput-wide v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobStartTime:J
.line 9
monitor-exit p0
:try_end_16
.catchall {:try_start_5 .. :try_end_16} :catchall_30
.line 10
: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 11
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 12
:cond_21
invoke-static {v2}, Lcom/facebook/imagepipeline/image/EncodedImage;->closeSafely(Lcom/facebook/imagepipeline/image/EncodedImage;)V
.line 13
invoke-direct {p0}, Lcom/facebook/imagepipeline/producers/JobScheduler;->onJobFinished()V
return-void
:catchall_28
move-exception v0
.line 14
invoke-static {v2}, Lcom/facebook/imagepipeline/image/EncodedImage;->closeSafely(Lcom/facebook/imagepipeline/image/EncodedImage;)V
.line 15
invoke-direct {p0}, Lcom/facebook/imagepipeline/producers/JobScheduler;->onJobFinished()V
.line 16
throw v0
:catchall_30
move-exception v0
.line 17
: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 1
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;
goto :goto_17
.line 2
:cond_12
iget-object p1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mSubmitJobRunnable:Ljava/lang/Runnable;
invoke-interface {p1}, Ljava/lang/Runnable;->run()V
:goto_17
return-void
.end method
.method private onJobFinished()V
.registers 7
.line 1
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
move-result-wide v0
.line 2
monitor-enter p0
.line 3
: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 4
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 5
iput-wide v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobSubmitTime:J
.line 6
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 7
: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 8
: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 9
invoke-direct {p0, v2, v3}, Lcom/facebook/imagepipeline/producers/JobScheduler;->enqueueJob(J)V
:cond_2b
return-void
:catchall_2c
move-exception v0
.line 10
: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 1
invoke-static {p1}, Lcom/facebook/imagepipeline/producers/BaseConsumer;->isLast(I)Z
move-result v0
if-nez v0, :cond_16
const/4 v0, 0x4
.line 2
invoke-static {p1, v0}, Lcom/facebook/imagepipeline/producers/BaseConsumer;->statusHasFlag(II)Z
move-result p1
if-nez p1, :cond_16
.line 3
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 3
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-static {v0, v1}, Lcom/facebook/imagepipeline/producers/JobScheduler;->INVOKEINTERFACE_com_facebook_imagepipeline_producers_JobScheduler_com_shopee_app_asm_anr_threadpool_ExecutorProxy_execute(Ljava/util/concurrent/Executor;Ljava/lang/Runnable;)V
return-void
.end method
# virtual methods
.method public clearJob()V
.registers 3
.line 1
monitor-enter p0
.line 2
:try_start_1
iget-object v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
const/4 v1, 0x0
.line 3
iput-object v1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
const/4 v1, 0x0
.line 4
iput v1, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
.line 5
monitor-exit p0
:try_end_a
.catchall {:try_start_1 .. :try_end_a} :catchall_e
.line 6
invoke-static {v0}, Lcom/facebook/imagepipeline/image/EncodedImage;->closeSafely(Lcom/facebook/imagepipeline/image/EncodedImage;)V
return-void
:catchall_e
move-exception v0
.line 7
: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
.line 1
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
move-result-wide v0
.line 2
monitor-enter p0
.line 3
: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 4
monitor-exit p0
return v3
.line 5
: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
.line 6
: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 7
: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 8
iput-wide v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mJobSubmitTime:J
.line 9
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 10
: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 11
invoke-direct {p0, v5, v6}, Lcom/facebook/imagepipeline/producers/JobScheduler;->enqueueJob(J)V
:cond_42
return v4
:catchall_43
move-exception v0
.line 12
: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 1
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 2
:cond_8
monitor-enter p0
.line 3
:try_start_9
iget-object v0, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mEncodedImage:Lcom/facebook/imagepipeline/image/EncodedImage;
.line 4
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 5
iput p2, p0, Lcom/facebook/imagepipeline/producers/JobScheduler;->mStatus:I
.line 6
monitor-exit p0
:try_end_14
.catchall {:try_start_9 .. :try_end_14} :catchall_19
.line 7
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 8
:try_start_1a
monitor-exit p0
:try_end_1b
.catchall {:try_start_1a .. :try_end_1b} :catchall_19
throw p1
.end method