.class public Landroidx/work/impl/background/systemalarm/d;
.super Ljava/lang/Object;
.source ""

# interfaces
.implements Lm1/a;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Landroidx/work/impl/background/systemalarm/d$c;,
        Landroidx/work/impl/background/systemalarm/d$b;,
        Landroidx/work/impl/background/systemalarm/d$d;
    }
.end annotation


# static fields
.field public static final B:Ljava/lang/String;


# instance fields
.field public A:Landroidx/work/impl/background/systemalarm/d$c;

.field public final r:Landroid/content/Context;

.field public final s:Lx1/a;

.field public final t:Lv1/r;

.field public final u:Lm1/c;

.field public final v:Lm1/j;

.field public final w:Landroidx/work/impl/background/systemalarm/a;

.field public final x:Landroid/os/Handler;

.field public final y:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List<",
            "Landroid/content/Intent;",
            ">;"
        }
    .end annotation
.end field

.field public z:Landroid/content/Intent;


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

    const-string v0, "SystemAlarmDispatcher"

    invoke-static {v0}, Ll1/i;->e(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    sput-object v0, Landroidx/work/impl/background/systemalarm/d;->B:Ljava/lang/String;

    return-void
.end method

.method public constructor <init>(Landroid/content/Context;)V
    .registers 4

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

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

    move-result-object v0

    iput-object v0, p0, Landroidx/work/impl/background/systemalarm/d;->r:Landroid/content/Context;

    new-instance v1, Landroidx/work/impl/background/systemalarm/a;

    invoke-direct {v1, v0}, Landroidx/work/impl/background/systemalarm/a;-><init>(Landroid/content/Context;)V

    iput-object v1, p0, Landroidx/work/impl/background/systemalarm/d;->w:Landroidx/work/impl/background/systemalarm/a;

    new-instance v0, Lv1/r;

    invoke-direct {v0}, Lv1/r;-><init>()V

    iput-object v0, p0, Landroidx/work/impl/background/systemalarm/d;->t:Lv1/r;

    invoke-static {p1}, Lm1/j;->b(Landroid/content/Context;)Lm1/j;

    move-result-object p1

    iput-object p1, p0, Landroidx/work/impl/background/systemalarm/d;->v:Lm1/j;

    .line 2
    iget-object v0, p1, Lm1/j;->f:Lm1/c;

    .line 3
    iput-object v0, p0, Landroidx/work/impl/background/systemalarm/d;->u:Lm1/c;

    .line 4
    iget-object p1, p1, Lm1/j;->d:Lx1/a;

    .line 5
    iput-object p1, p0, Landroidx/work/impl/background/systemalarm/d;->s:Lx1/a;

    invoke-virtual {v0, p0}, Lm1/c;->b(Lm1/a;)V

    new-instance p1, Ljava/util/ArrayList;

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

    iput-object p1, p0, Landroidx/work/impl/background/systemalarm/d;->y:Ljava/util/List;

    const/4 p1, 0x0

    iput-object p1, p0, Landroidx/work/impl/background/systemalarm/d;->z:Landroid/content/Intent;

    new-instance p1, Landroid/os/Handler;

    invoke-static {}, Landroid/os/Looper;->getMainLooper()Landroid/os/Looper;

    move-result-object v0

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

    iput-object p1, p0, Landroidx/work/impl/background/systemalarm/d;->x:Landroid/os/Handler;

    return-void
.end method


# virtual methods
.method public a(Ljava/lang/String;Z)V
    .registers 7

    new-instance v0, Landroidx/work/impl/background/systemalarm/d$b;

    iget-object v1, p0, Landroidx/work/impl/background/systemalarm/d;->r:Landroid/content/Context;

    sget-object v2, Landroidx/work/impl/background/systemalarm/a;->u:Ljava/lang/String;

    .line 1
    new-instance v2, Landroid/content/Intent;

    const-class v3, Landroidx/work/impl/background/systemalarm/SystemAlarmService;

    invoke-direct {v2, v1, v3}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    const-string v1, "ACTION_EXECUTION_COMPLETED"

    invoke-virtual {v2, v1}, Landroid/content/Intent;->setAction(Ljava/lang/String;)Landroid/content/Intent;

    const-string v1, "KEY_WORKSPEC_ID"

    invoke-virtual {v2, v1, p1}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    const-string p1, "KEY_NEEDS_RESCHEDULE"

    invoke-virtual {v2, p1, p2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Z)Landroid/content/Intent;

    const/4 p1, 0x0

    .line 2
    invoke-direct {v0, p0, v2, p1}, Landroidx/work/impl/background/systemalarm/d$b;-><init>(Landroidx/work/impl/background/systemalarm/d;Landroid/content/Intent;I)V

    .line 3
    iget-object p1, p0, Landroidx/work/impl/background/systemalarm/d;->x:Landroid/os/Handler;

    invoke-virtual {p1, v0}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    return-void
.end method

.method public b(Landroid/content/Intent;I)Z
    .registers 10

    invoke-static {}, Ll1/i;->c()Ll1/i;

    move-result-object v0

    sget-object v1, Landroidx/work/impl/background/systemalarm/d;->B:Ljava/lang/String;

    const-string v2, "Adding command %s (%s)"

    const/4 v3, 0x2

    new-array v3, v3, [Ljava/lang/Object;

    const/4 v4, 0x0

    aput-object p1, v3, v4

    invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v5

    const/4 v6, 0x1

    aput-object v5, v3, v6

    invoke-static {v2, v3}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    new-array v3, v4, [Ljava/lang/Throwable;

    invoke-virtual {v0, v1, v2, v3}, Ll1/i;->a(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Throwable;)V

    invoke-virtual {p0}, Landroidx/work/impl/background/systemalarm/d;->c()V

    invoke-virtual {p1}, Landroid/content/Intent;->getAction()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v2

    if-eqz v2, :cond_37

    invoke-static {}, Ll1/i;->c()Ll1/i;

    move-result-object p1

    const-string p2, "Unknown command. Ignoring"

    new-array v0, v4, [Ljava/lang/Throwable;

    invoke-virtual {p1, v1, p2, v0}, Ll1/i;->f(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Throwable;)V

    return v4

    :cond_37
    const-string v1, "ACTION_CONSTRAINTS_CHANGED"

    invoke-virtual {v1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_6e

    const-string v0, "ACTION_CONSTRAINTS_CHANGED"

    .line 1
    invoke-virtual {p0}, Landroidx/work/impl/background/systemalarm/d;->c()V

    iget-object v1, p0, Landroidx/work/impl/background/systemalarm/d;->y:Ljava/util/List;

    monitor-enter v1

    :try_start_47
    iget-object v2, p0, Landroidx/work/impl/background/systemalarm/d;->y:Ljava/util/List;

    invoke-interface {v2}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v2

    :cond_4d
    invoke-interface {v2}, Ljava/util/Iterator;->hasNext()Z

    move-result v3

    if-eqz v3, :cond_66

    invoke-interface {v2}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Landroid/content/Intent;

    invoke-virtual {v3}, Landroid/content/Intent;->getAction()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v0, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    if-eqz v3, :cond_4d

    monitor-exit v1

    move v0, v6

    goto :goto_68

    :cond_66
    monitor-exit v1

    move v0, v4

    :goto_68
    if-eqz v0, :cond_6e

    return v4

    :catchall_6b
    move-exception p1

    monitor-exit v1
    :try_end_6d
    .catchall {:try_start_47 .. :try_end_6d} :catchall_6b

    throw p1

    :cond_6e
    const-string v0, "KEY_START_ID"

    .line 2
    invoke-virtual {p1, v0, p2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;I)Landroid/content/Intent;

    iget-object p2, p0, Landroidx/work/impl/background/systemalarm/d;->y:Ljava/util/List;

    monitor-enter p2

    :try_start_76
    iget-object v0, p0, Landroidx/work/impl/background/systemalarm/d;->y:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->isEmpty()Z

    move-result v0

    if-nez v0, :cond_7f

    move v4, v6

    :cond_7f
    iget-object v0, p0, Landroidx/work/impl/background/systemalarm/d;->y:Ljava/util/List;

    invoke-interface {v0, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    if-nez v4, :cond_89

    invoke-virtual {p0}, Landroidx/work/impl/background/systemalarm/d;->e()V

    :cond_89
    monitor-exit p2

    return v6

    :catchall_8b
    move-exception p1

    monitor-exit p2
    :try_end_8d
    .catchall {:try_start_76 .. :try_end_8d} :catchall_8b

    throw p1
.end method

.method public final c()V
    .registers 3

    iget-object v0, p0, Landroidx/work/impl/background/systemalarm/d;->x:Landroid/os/Handler;

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

    move-result-object v0

    invoke-virtual {v0}, Landroid/os/Looper;->getThread()Ljava/lang/Thread;

    move-result-object v0

    invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;

    move-result-object v1

    if-ne v0, v1, :cond_11

    return-void

    :cond_11
    new-instance v0, Ljava/lang/IllegalStateException;

    const-string v1, "Needs to be invoked on the main thread."

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

    throw v0
.end method

.method public d()V
    .registers 5

    invoke-static {}, Ll1/i;->c()Ll1/i;

    move-result-object v0

    sget-object v1, Landroidx/work/impl/background/systemalarm/d;->B:Ljava/lang/String;

    const/4 v2, 0x0

    new-array v2, v2, [Ljava/lang/Throwable;

    const-string v3, "Destroying SystemAlarmDispatcher"

    invoke-virtual {v0, v1, v3, v2}, Ll1/i;->a(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Throwable;)V

    iget-object v0, p0, Landroidx/work/impl/background/systemalarm/d;->u:Lm1/c;

    invoke-virtual {v0, p0}, Lm1/c;->e(Lm1/a;)V

    iget-object v0, p0, Landroidx/work/impl/background/systemalarm/d;->t:Lv1/r;

    .line 1
    iget-object v1, v0, Lv1/r;->a:Ljava/util/concurrent/ScheduledExecutorService;

    invoke-interface {v1}, Ljava/util/concurrent/ScheduledExecutorService;->isShutdown()Z

    move-result v1

    if-nez v1, :cond_22

    iget-object v0, v0, Lv1/r;->a:Ljava/util/concurrent/ScheduledExecutorService;

    invoke-interface {v0}, Ljava/util/concurrent/ScheduledExecutorService;->shutdownNow()Ljava/util/List;

    :cond_22
    const/4 v0, 0x0

    .line 2
    iput-object v0, p0, Landroidx/work/impl/background/systemalarm/d;->A:Landroidx/work/impl/background/systemalarm/d$c;

    return-void
.end method

.method public final e()V
    .registers 4

    invoke-virtual {p0}, Landroidx/work/impl/background/systemalarm/d;->c()V

    iget-object v0, p0, Landroidx/work/impl/background/systemalarm/d;->r:Landroid/content/Context;

    const-string v1, "ProcessCommand"

    invoke-static {v0, v1}, Lv1/m;->a(Landroid/content/Context;Ljava/lang/String;)Landroid/os/PowerManager$WakeLock;

    move-result-object v0

    :try_start_b
    invoke-virtual {v0}, Landroid/os/PowerManager$WakeLock;->acquire()V

    iget-object v1, p0, Landroidx/work/impl/background/systemalarm/d;->v:Lm1/j;

    .line 1
    iget-object v1, v1, Lm1/j;->d:Lx1/a;

    .line 2
    new-instance v2, Landroidx/work/impl/background/systemalarm/d$a;

    invoke-direct {v2, p0}, Landroidx/work/impl/background/systemalarm/d$a;-><init>(Landroidx/work/impl/background/systemalarm/d;)V

    check-cast v1, Lx1/b;

    .line 3
    iget-object v1, v1, Lx1/b;->a:Lv1/j;

    invoke-virtual {v1, v2}, Lv1/j;->execute(Ljava/lang/Runnable;)V
    :try_end_1e
    .catchall {:try_start_b .. :try_end_1e} :catchall_22

    .line 4
    invoke-virtual {v0}, Landroid/os/PowerManager$WakeLock;->release()V

    return-void

    :catchall_22
    move-exception v1

    invoke-virtual {v0}, Landroid/os/PowerManager$WakeLock;->release()V

    throw v1
.end method
