.class public Landroidx/work/impl/foreground/SystemForegroundService;
.super Landroidx/lifecycle/q;
.source ""

# interfaces
.implements Landroidx/work/impl/foreground/a$a;


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


# instance fields
.field public s:Landroid/os/Handler;

.field public t:Z

.field public u:Landroidx/work/impl/foreground/a;

.field public v:Landroid/app/NotificationManager;


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

    const-string v0, "SystemFgService"

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

    move-result-object v0

    sput-object v0, Landroidx/work/impl/foreground/SystemForegroundService;->w:Ljava/lang/String;

    return-void
.end method

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

    invoke-direct {p0}, Landroidx/lifecycle/q;-><init>()V

    return-void
.end method


# virtual methods
.method public final b()V
    .registers 5

    new-instance v0, Landroid/os/Handler;

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

    move-result-object v1

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

    iput-object v0, p0, Landroidx/work/impl/foreground/SystemForegroundService;->s:Landroid/os/Handler;

    invoke-virtual {p0}, Landroid/app/Service;->getApplicationContext()Landroid/content/Context;

    move-result-object v0

    const-string v1, "notification"

    invoke-virtual {v0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/app/NotificationManager;

    iput-object v0, p0, Landroidx/work/impl/foreground/SystemForegroundService;->v:Landroid/app/NotificationManager;

    new-instance v0, Landroidx/work/impl/foreground/a;

    invoke-virtual {p0}, Landroid/app/Service;->getApplicationContext()Landroid/content/Context;

    move-result-object v1

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

    iput-object v0, p0, Landroidx/work/impl/foreground/SystemForegroundService;->u:Landroidx/work/impl/foreground/a;

    .line 1
    iget-object v1, v0, Landroidx/work/impl/foreground/a;->A:Landroidx/work/impl/foreground/a$a;

    if-eqz v1, :cond_37

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

    move-result-object v0

    sget-object v1, Landroidx/work/impl/foreground/a;->B:Ljava/lang/String;

    const/4 v2, 0x0

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

    const-string v3, "A callback already exists."

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

    goto :goto_39

    :cond_37
    iput-object p0, v0, Landroidx/work/impl/foreground/a;->A:Landroidx/work/impl/foreground/a$a;

    :goto_39
    return-void
.end method

.method public e(IILandroid/app/Notification;)V
    .registers 6

    iget-object v0, p0, Landroidx/work/impl/foreground/SystemForegroundService;->s:Landroid/os/Handler;

    new-instance v1, Landroidx/work/impl/foreground/SystemForegroundService$a;

    invoke-direct {v1, p0, p1, p3, p2}, Landroidx/work/impl/foreground/SystemForegroundService$a;-><init>(Landroidx/work/impl/foreground/SystemForegroundService;ILandroid/app/Notification;I)V

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

    return-void
.end method

.method public onCreate()V
    .registers 1

    invoke-super {p0}, Landroidx/lifecycle/q;->onCreate()V

    invoke-virtual {p0}, Landroidx/work/impl/foreground/SystemForegroundService;->b()V

    return-void
.end method

.method public onDestroy()V
    .registers 2

    invoke-super {p0}, Landroidx/lifecycle/q;->onDestroy()V

    iget-object v0, p0, Landroidx/work/impl/foreground/SystemForegroundService;->u:Landroidx/work/impl/foreground/a;

    invoke-virtual {v0}, Landroidx/work/impl/foreground/a;->g()V

    return-void
.end method

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

    invoke-super {p0, p1, p2, p3}, Landroidx/lifecycle/q;->onStartCommand(Landroid/content/Intent;II)I

    iget-boolean p2, p0, Landroidx/work/impl/foreground/SystemForegroundService;->t:Z

    const/4 p3, 0x0

    if-eqz p2, :cond_1f

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

    move-result-object p2

    sget-object v0, Landroidx/work/impl/foreground/SystemForegroundService;->w:Ljava/lang/String;

    new-array v1, p3, [Ljava/lang/Throwable;

    const-string v2, "Re-initializing SystemForegroundService after a request to shut-down."

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

    iget-object p2, p0, Landroidx/work/impl/foreground/SystemForegroundService;->u:Landroidx/work/impl/foreground/a;

    invoke-virtual {p2}, Landroidx/work/impl/foreground/a;->g()V

    invoke-virtual {p0}, Landroidx/work/impl/foreground/SystemForegroundService;->b()V

    iput-boolean p3, p0, Landroidx/work/impl/foreground/SystemForegroundService;->t:Z

    :cond_1f
    if-eqz p1, :cond_e5

    iget-object p2, p0, Landroidx/work/impl/foreground/SystemForegroundService;->u:Landroidx/work/impl/foreground/a;

    invoke-static {p2}, Ljava/util/Objects;->requireNonNull(Ljava/lang/Object;)Ljava/lang/Object;

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

    move-result-object v0

    const-string v1, "ACTION_START_FOREGROUND"

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

    move-result v1

    const-string v2, "KEY_WORKSPEC_ID"

    const/4 v3, 0x1

    if-eqz v1, :cond_61

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

    move-result-object v0

    sget-object v1, Landroidx/work/impl/foreground/a;->B:Ljava/lang/String;

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

    aput-object p1, v3, p3

    const-string v4, "Started foreground service %s"

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

    move-result-object v3

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

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

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

    move-result-object p3

    iget-object v0, p2, Landroidx/work/impl/foreground/a;->s:Lm1/j;

    .line 3
    iget-object v0, v0, Lm1/j;->c:Landroidx/work/impl/WorkDatabase;

    .line 4
    iget-object v1, p2, Landroidx/work/impl/foreground/a;->t:Lx1/a;

    new-instance v2, Lt1/b;

    invoke-direct {v2, p2, v0, p3}, Lt1/b;-><init>(Landroidx/work/impl/foreground/a;Landroidx/work/impl/WorkDatabase;Ljava/lang/String;)V

    check-cast v1, Lx1/b;

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

    invoke-virtual {p3, v2}, Lv1/j;->execute(Ljava/lang/Runnable;)V

    goto :goto_69

    :cond_61
    const-string v1, "ACTION_NOTIFY"

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

    move-result v1

    if-eqz v1, :cond_6e

    :goto_69
    invoke-virtual {p2, p1}, Landroidx/work/impl/foreground/a;->f(Landroid/content/Intent;)V

    goto/16 :goto_e5

    :cond_6e
    const-string v1, "ACTION_CANCEL_WORK"

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

    move-result v1

    if-eqz v1, :cond_af

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

    move-result-object v0

    sget-object v1, Landroidx/work/impl/foreground/a;->B:Ljava/lang/String;

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

    aput-object p1, v3, p3

    const-string v4, "Stopping foreground work for %s"

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

    move-result-object v3

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

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

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

    move-result-object p1

    if-eqz p1, :cond_e5

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

    move-result p3

    if-nez p3, :cond_e5

    iget-object p2, p2, Landroidx/work/impl/foreground/a;->s:Lm1/j;

    invoke-static {p1}, Ljava/util/UUID;->fromString(Ljava/lang/String;)Ljava/util/UUID;

    move-result-object p1

    invoke-static {p2}, Ljava/util/Objects;->requireNonNull(Ljava/lang/Object;)Ljava/lang/Object;

    .line 8
    new-instance p3, Lv1/a;

    invoke-direct {p3, p2, p1}, Lv1/a;-><init>(Lm1/j;Ljava/util/UUID;)V

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

    check-cast p1, Lx1/b;

    .line 10
    iget-object p1, p1, Lx1/b;->a:Lv1/j;

    invoke-virtual {p1, p3}, Lv1/j;->execute(Ljava/lang/Runnable;)V

    goto :goto_e5

    :cond_af
    const-string p1, "ACTION_STOP_FOREGROUND"

    .line 11
    invoke-virtual {p1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result p1

    if-eqz p1, :cond_e5

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

    move-result-object p1

    sget-object v0, Landroidx/work/impl/foreground/a;->B:Ljava/lang/String;

    new-array v1, p3, [Ljava/lang/Throwable;

    const-string v2, "Stopping foreground service"

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

    iget-object p1, p2, Landroidx/work/impl/foreground/a;->A:Landroidx/work/impl/foreground/a$a;

    if-eqz p1, :cond_e5

    check-cast p1, Landroidx/work/impl/foreground/SystemForegroundService;

    .line 13
    iput-boolean v3, p1, Landroidx/work/impl/foreground/SystemForegroundService;->t:Z

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

    move-result-object p2

    sget-object v0, Landroidx/work/impl/foreground/SystemForegroundService;->w:Ljava/lang/String;

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

    const-string v1, "All commands completed."

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

    sget p2, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 p3, 0x1a

    if-lt p2, p3, :cond_e2

    invoke-virtual {p1, v3}, Landroid/app/Service;->stopForeground(Z)V

    :cond_e2
    invoke-virtual {p1}, Landroid/app/Service;->stopSelf()V

    :cond_e5
    :goto_e5
    const/4 p1, 0x3

    return p1
.end method
