RongJobIntentService.smali

.class public abstract Lio/rong/imlib/RongJobIntentService;
.super Landroid/app/Service;
.source "RongJobIntentService.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lio/rong/imlib/RongJobIntentService$CommandProcessor;,
        Lio/rong/imlib/RongJobIntentService$CompatWorkItem;,
        Lio/rong/imlib/RongJobIntentService$GenericWorkItem;,
        Lio/rong/imlib/RongJobIntentService$JobWorkEnqueuer;,
        Lio/rong/imlib/RongJobIntentService$JobServiceEngineImpl;,
        Lio/rong/imlib/RongJobIntentService$CompatWorkEnqueuer;,
        Lio/rong/imlib/RongJobIntentService$CompatJobEngine;,
        Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;
    }
.end annotation


# static fields
.field static final DEBUG:Z = false

.field static final TAG:Ljava/lang/String; = "RongJobIntentService"

.field static final sClassWorkEnqueuer:Ljava/util/HashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashMap<",
            "Landroid/content/ComponentName;",
            "Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;",
            ">;"
        }
    .end annotation
.end field

.field static final sLock:Ljava/lang/Object;


# instance fields
.field final mCompatQueue:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList<",
            "Lio/rong/imlib/RongJobIntentService$CompatWorkItem;",
            ">;"
        }
    .end annotation
.end field

.field mCompatWorkEnqueuer:Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;

.field mCurProcessor:Lio/rong/imlib/RongJobIntentService$CommandProcessor;

.field mDestroyed:Z

.field mInterruptIfStopped:Z

.field mJobImpl:Lio/rong/imlib/RongJobIntentService$CompatJobEngine;

.field mStopped:Z


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

    .line 1
    new-instance v0, Ljava/lang/Object;

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

    sput-object v0, Lio/rong/imlib/RongJobIntentService;->sLock:Ljava/lang/Object;

    .line 2
    new-instance v0, Ljava/util/HashMap;

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

    sput-object v0, Lio/rong/imlib/RongJobIntentService;->sClassWorkEnqueuer:Ljava/util/HashMap;

    return-void
.end method

.method public constructor <init>()V
    .registers 3

    .line 1
    invoke-direct {p0}, Landroid/app/Service;-><init>()V

    const/4 v0, 0x0

    .line 2
    iput-boolean v0, p0, Lio/rong/imlib/RongJobIntentService;->mInterruptIfStopped:Z

    .line 3
    iput-boolean v0, p0, Lio/rong/imlib/RongJobIntentService;->mStopped:Z

    .line 4
    iput-boolean v0, p0, Lio/rong/imlib/RongJobIntentService;->mDestroyed:Z

    .line 5
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v1, 0x1a

    if-lt v0, v1, :cond_14

    const/4 v0, 0x0

    .line 6
    iput-object v0, p0, Lio/rong/imlib/RongJobIntentService;->mCompatQueue:Ljava/util/ArrayList;

    goto :goto_1b

    .line 7
    :cond_14
    new-instance v0, Ljava/util/ArrayList;

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

    iput-object v0, p0, Lio/rong/imlib/RongJobIntentService;->mCompatQueue:Ljava/util/ArrayList;

    :goto_1b
    return-void
.end method

.method public static enqueueWork(Landroid/content/Context;Landroid/content/ComponentName;ILandroid/content/Intent;)V
    .registers 6

    if-eqz p3, :cond_15

    .line 2
    sget-object v0, Lio/rong/imlib/RongJobIntentService;->sLock:Ljava/lang/Object;

    monitor-enter v0

    const/4 v1, 0x1

    .line 3
    :try_start_6
    invoke-static {p0, p1, v1, p2}, Lio/rong/imlib/RongJobIntentService;->getWorkEnqueuer(Landroid/content/Context;Landroid/content/ComponentName;ZI)Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;

    move-result-object p0

    .line 4
    invoke-virtual {p0, p2}, Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;->ensureJobId(I)V

    .line 5
    invoke-virtual {p0, p3}, Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;->enqueueWork(Landroid/content/Intent;)V

    .line 6
    monitor-exit v0

    return-void

    :catchall_12
    move-exception p0

    monitor-exit v0
    :try_end_14
    .catchall {:try_start_6 .. :try_end_14} :catchall_12

    throw p0

    .line 7
    :cond_15
    new-instance p0, Ljava/lang/IllegalArgumentException;

    const-string p1, "work must not be null"

    invoke-direct {p0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p0
.end method

.method public static enqueueWork(Landroid/content/Context;Ljava/lang/Class;ILandroid/content/Intent;)V
    .registers 5

    .line 1
    new-instance v0, Landroid/content/ComponentName;

    invoke-direct {v0, p0, p1}, Landroid/content/ComponentName;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    invoke-static {p0, v0, p2, p3}, Lio/rong/imlib/RongJobIntentService;->enqueueWork(Landroid/content/Context;Landroid/content/ComponentName;ILandroid/content/Intent;)V

    return-void
.end method

.method static getWorkEnqueuer(Landroid/content/Context;Landroid/content/ComponentName;ZI)Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;
    .registers 6

    .line 1
    sget-object v0, Lio/rong/imlib/RongJobIntentService;->sClassWorkEnqueuer:Ljava/util/HashMap;

    invoke-virtual {v0, p1}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;

    if-nez v0, :cond_2b

    .line 2
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v1, 0x1a

    if-lt v0, v1, :cond_20

    if-eqz p2, :cond_18

    .line 3
    new-instance p2, Lio/rong/imlib/RongJobIntentService$JobWorkEnqueuer;

    invoke-direct {p2, p0, p1, p3}, Lio/rong/imlib/RongJobIntentService$JobWorkEnqueuer;-><init>(Landroid/content/Context;Landroid/content/ComponentName;I)V

    goto :goto_25

    .line 4
    :cond_18
    new-instance p0, Ljava/lang/IllegalArgumentException;

    const-string p1, "Can\'t be here without a job id"

    invoke-direct {p0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p0

    .line 5
    :cond_20
    new-instance p2, Lio/rong/imlib/RongJobIntentService$CompatWorkEnqueuer;

    invoke-direct {p2, p0, p1}, Lio/rong/imlib/RongJobIntentService$CompatWorkEnqueuer;-><init>(Landroid/content/Context;Landroid/content/ComponentName;)V

    :goto_25
    move-object v0, p2

    .line 6
    sget-object p0, Lio/rong/imlib/RongJobIntentService;->sClassWorkEnqueuer:Ljava/util/HashMap;

    invoke-virtual {p0, p1, v0}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    :cond_2b
    return-object v0
.end method


# virtual methods
.method dequeueWork()Lio/rong/imlib/RongJobIntentService$GenericWorkItem;
    .registers 5

    .line 1
    iget-object v0, p0, Lio/rong/imlib/RongJobIntentService;->mJobImpl:Lio/rong/imlib/RongJobIntentService$CompatJobEngine;

    const/4 v1, 0x0

    if-eqz v0, :cond_13

    .line 2
    :try_start_5
    invoke-interface {v0}, Lio/rong/imlib/RongJobIntentService$CompatJobEngine;->dequeueWork()Lio/rong/imlib/RongJobIntentService$GenericWorkItem;

    move-result-object v0
    :try_end_9
    .catch Ljava/lang/SecurityException; {:try_start_5 .. :try_end_9} :catch_a

    return-object v0

    :catch_a
    move-exception v0

    const-string v2, "RongJobIntentService"

    const-string v3, "dequeueWork"

    .line 3
    invoke-static {v2, v3, v0}, Lio/rong/common/rlog/RLog;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    return-object v1

    .line 4
    :cond_13
    iget-object v0, p0, Lio/rong/imlib/RongJobIntentService;->mCompatQueue:Ljava/util/ArrayList;

    monitor-enter v0

    .line 5
    :try_start_16
    iget-object v2, p0, Lio/rong/imlib/RongJobIntentService;->mCompatQueue:Ljava/util/ArrayList;

    invoke-virtual {v2}, Ljava/util/ArrayList;->size()I

    move-result v2

    if-lez v2, :cond_29

    .line 6
    iget-object v1, p0, Lio/rong/imlib/RongJobIntentService;->mCompatQueue:Ljava/util/ArrayList;

    const/4 v2, 0x0

    invoke-virtual {v1, v2}, Ljava/util/ArrayList;->remove(I)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lio/rong/imlib/RongJobIntentService$GenericWorkItem;

    monitor-exit v0

    return-object v1

    .line 7
    :cond_29
    monitor-exit v0

    return-object v1

    :catchall_2b
    move-exception v1

    .line 8
    monitor-exit v0
    :try_end_2d
    .catchall {:try_start_16 .. :try_end_2d} :catchall_2b

    throw v1
.end method

.method doStopCurrentWork()Z
    .registers 3

    .line 1
    iget-object v0, p0, Lio/rong/imlib/RongJobIntentService;->mCurProcessor:Lio/rong/imlib/RongJobIntentService$CommandProcessor;

    if-eqz v0, :cond_9

    .line 2
    iget-boolean v1, p0, Lio/rong/imlib/RongJobIntentService;->mInterruptIfStopped:Z

    invoke-virtual {v0, v1}, Landroid/os/AsyncTask;->cancel(Z)Z

    :cond_9
    const/4 v0, 0x1

    .line 3
    iput-boolean v0, p0, Lio/rong/imlib/RongJobIntentService;->mStopped:Z

    .line 4
    invoke-virtual {p0}, Lio/rong/imlib/RongJobIntentService;->onStopCurrentWork()Z

    move-result v0

    return v0
.end method

.method ensureProcessorRunningLocked(Z)V
    .registers 4

    .line 1
    iget-object v0, p0, Lio/rong/imlib/RongJobIntentService;->mCurProcessor:Lio/rong/imlib/RongJobIntentService$CommandProcessor;

    if-nez v0, :cond_1e

    .line 2
    new-instance v0, Lio/rong/imlib/RongJobIntentService$CommandProcessor;

    invoke-direct {v0, p0}, Lio/rong/imlib/RongJobIntentService$CommandProcessor;-><init>(Lio/rong/imlib/RongJobIntentService;)V

    iput-object v0, p0, Lio/rong/imlib/RongJobIntentService;->mCurProcessor:Lio/rong/imlib/RongJobIntentService$CommandProcessor;

    .line 3
    iget-object v0, p0, Lio/rong/imlib/RongJobIntentService;->mCompatWorkEnqueuer:Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;

    if-eqz v0, :cond_14

    if-eqz p1, :cond_14

    .line 4
    invoke-virtual {v0}, Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;->serviceProcessingStarted()V

    .line 5
    :cond_14
    iget-object p1, p0, Lio/rong/imlib/RongJobIntentService;->mCurProcessor:Lio/rong/imlib/RongJobIntentService$CommandProcessor;

    sget-object v0, Landroid/os/AsyncTask;->THREAD_POOL_EXECUTOR:Ljava/util/concurrent/Executor;

    const/4 v1, 0x0

    new-array v1, v1, [Ljava/lang/Void;

    invoke-virtual {p1, v0, v1}, Landroid/os/AsyncTask;->executeOnExecutor(Ljava/util/concurrent/Executor;[Ljava/lang/Object;)Landroid/os/AsyncTask;

    :cond_1e
    return-void
.end method

.method public isStopped()Z
    .registers 2

    .line 1
    iget-boolean v0, p0, Lio/rong/imlib/RongJobIntentService;->mStopped:Z

    return v0
.end method

.method public onBind(Landroid/content/Intent;)Landroid/os/IBinder;
    .registers 2

    .line 1
    iget-object p1, p0, Lio/rong/imlib/RongJobIntentService;->mJobImpl:Lio/rong/imlib/RongJobIntentService$CompatJobEngine;

    if-eqz p1, :cond_9

    .line 2
    invoke-interface {p1}, Lio/rong/imlib/RongJobIntentService$CompatJobEngine;->compatGetBinder()Landroid/os/IBinder;

    move-result-object p1

    return-object p1

    :cond_9
    const/4 p1, 0x0

    return-object p1
.end method

.method public onCreate()V
    .registers 4

    .line 1
    invoke-super {p0}, Landroid/app/Service;->onCreate()V

    .line 2
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/4 v1, 0x0

    const/16 v2, 0x1a

    if-lt v0, v2, :cond_14

    .line 3
    new-instance v0, Lio/rong/imlib/RongJobIntentService$JobServiceEngineImpl;

    invoke-direct {v0, p0}, Lio/rong/imlib/RongJobIntentService$JobServiceEngineImpl;-><init>(Lio/rong/imlib/RongJobIntentService;)V

    iput-object v0, p0, Lio/rong/imlib/RongJobIntentService;->mJobImpl:Lio/rong/imlib/RongJobIntentService$CompatJobEngine;

    .line 4
    iput-object v1, p0, Lio/rong/imlib/RongJobIntentService;->mCompatWorkEnqueuer:Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;

    goto :goto_26

    .line 5
    :cond_14
    iput-object v1, p0, Lio/rong/imlib/RongJobIntentService;->mJobImpl:Lio/rong/imlib/RongJobIntentService$CompatJobEngine;

    .line 6
    new-instance v0, Landroid/content/ComponentName;

    invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object v1

    invoke-direct {v0, p0, v1}, Landroid/content/ComponentName;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    const/4 v1, 0x0

    .line 7
    invoke-static {p0, v0, v1, v1}, Lio/rong/imlib/RongJobIntentService;->getWorkEnqueuer(Landroid/content/Context;Landroid/content/ComponentName;ZI)Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;

    move-result-object v0

    iput-object v0, p0, Lio/rong/imlib/RongJobIntentService;->mCompatWorkEnqueuer:Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;

    :goto_26
    return-void
.end method

.method public onDestroy()V
    .registers 3

    .line 1
    invoke-super {p0}, Landroid/app/Service;->onDestroy()V

    .line 2
    iget-object v0, p0, Lio/rong/imlib/RongJobIntentService;->mCompatQueue:Ljava/util/ArrayList;

    if-eqz v0, :cond_15

    .line 3
    monitor-enter v0

    const/4 v1, 0x1

    .line 4
    :try_start_9
    iput-boolean v1, p0, Lio/rong/imlib/RongJobIntentService;->mDestroyed:Z

    .line 5
    iget-object v1, p0, Lio/rong/imlib/RongJobIntentService;->mCompatWorkEnqueuer:Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;

    invoke-virtual {v1}, Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;->serviceProcessingFinished()V

    .line 6
    monitor-exit v0

    goto :goto_15

    :catchall_12
    move-exception v1

    monitor-exit v0
    :try_end_14
    .catchall {:try_start_9 .. :try_end_14} :catchall_12

    throw v1

    :cond_15
    :goto_15
    return-void
.end method

.method protected abstract onHandleWork(Landroid/content/Intent;)V
.end method

.method public onStartCommand(Landroid/content/Intent;II)I
    .registers 6

    .line 1
    iget-object p2, p0, Lio/rong/imlib/RongJobIntentService;->mCompatQueue:Ljava/util/ArrayList;

    if-eqz p2, :cond_28

    .line 2
    iget-object p2, p0, Lio/rong/imlib/RongJobIntentService;->mCompatWorkEnqueuer:Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;

    invoke-virtual {p2}, Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;->serviceStartReceived()V

    .line 3
    iget-object p2, p0, Lio/rong/imlib/RongJobIntentService;->mCompatQueue:Ljava/util/ArrayList;

    monitor-enter p2

    .line 4
    :try_start_c
    iget-object v0, p0, Lio/rong/imlib/RongJobIntentService;->mCompatQueue:Ljava/util/ArrayList;

    new-instance v1, Lio/rong/imlib/RongJobIntentService$CompatWorkItem;

    if-eqz p1, :cond_13

    goto :goto_18

    :cond_13
    new-instance p1, Landroid/content/Intent;

    invoke-direct {p1}, Landroid/content/Intent;-><init>()V

    :goto_18
    invoke-direct {v1, p0, p1, p3}, Lio/rong/imlib/RongJobIntentService$CompatWorkItem;-><init>(Lio/rong/imlib/RongJobIntentService;Landroid/content/Intent;I)V

    invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    const/4 p1, 0x1

    .line 5
    invoke-virtual {p0, p1}, Lio/rong/imlib/RongJobIntentService;->ensureProcessorRunningLocked(Z)V

    .line 6
    monitor-exit p2

    const/4 p1, 0x3

    return p1

    :catchall_25
    move-exception p1

    monitor-exit p2
    :try_end_27
    .catchall {:try_start_c .. :try_end_27} :catchall_25

    throw p1

    :cond_28
    const/4 p1, 0x2

    return p1
.end method

.method public onStopCurrentWork()Z
    .registers 2

    const/4 v0, 0x1

    return v0
.end method

.method processorFinished()V
    .registers 3

    .line 1
    iget-object v0, p0, Lio/rong/imlib/RongJobIntentService;->mCompatQueue:Ljava/util/ArrayList;

    if-eqz v0, :cond_27

    .line 2
    monitor-enter v0

    const/4 v1, 0x0

    .line 3
    :try_start_6
    iput-object v1, p0, Lio/rong/imlib/RongJobIntentService;->mCurProcessor:Lio/rong/imlib/RongJobIntentService$CommandProcessor;

    .line 4
    iget-object v1, p0, Lio/rong/imlib/RongJobIntentService;->mCompatQueue:Ljava/util/ArrayList;

    if-eqz v1, :cond_19

    iget-object v1, p0, Lio/rong/imlib/RongJobIntentService;->mCompatQueue:Ljava/util/ArrayList;

    invoke-virtual {v1}, Ljava/util/ArrayList;->size()I

    move-result v1

    if-lez v1, :cond_19

    const/4 v1, 0x0

    .line 5
    invoke-virtual {p0, v1}, Lio/rong/imlib/RongJobIntentService;->ensureProcessorRunningLocked(Z)V

    goto :goto_22

    .line 6
    :cond_19
    iget-boolean v1, p0, Lio/rong/imlib/RongJobIntentService;->mDestroyed:Z

    if-nez v1, :cond_22

    .line 7
    iget-object v1, p0, Lio/rong/imlib/RongJobIntentService;->mCompatWorkEnqueuer:Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;

    invoke-virtual {v1}, Lio/rong/imlib/RongJobIntentService$WorkEnqueuer;->serviceProcessingFinished()V

    .line 8
    :cond_22
    :goto_22
    monitor-exit v0

    goto :goto_27

    :catchall_24
    move-exception v1

    monitor-exit v0
    :try_end_26
    .catchall {:try_start_6 .. :try_end_26} :catchall_24

    throw v1

    :cond_27
    :goto_27
    return-void
.end method

.method public setInterruptIfStopped(Z)V
    .registers 2

    .line 1
    iput-boolean p1, p0, Lio/rong/imlib/RongJobIntentService;->mInterruptIfStopped:Z

    return-void
.end method