294 lines
9.6 KiB
Smali
294 lines
9.6 KiB
Smali
.class public Landroidx/work/impl/foreground/SystemForegroundService;
|
|
.super Landroidx/lifecycle/LifecycleService;
|
|
.source "SystemForegroundService.java"
|
|
|
|
# interfaces
|
|
.implements Landroidx/work/impl/foreground/SystemForegroundDispatcher$Callback;
|
|
|
|
|
|
# annotations
|
|
.annotation build Landroidx/annotation/RestrictTo;
|
|
value = {
|
|
.enum Landroidx/annotation/RestrictTo$Scope;->LIBRARY_GROUP:Landroidx/annotation/RestrictTo$Scope;
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# static fields
|
|
.field public static final TAG:Ljava/lang/String;
|
|
|
|
.field public static sForegroundService:Landroidx/work/impl/foreground/SystemForegroundService;
|
|
.annotation build Landroidx/annotation/Nullable;
|
|
.end annotation
|
|
.end field
|
|
|
|
|
|
# instance fields
|
|
.field public mDispatcher:Landroidx/work/impl/foreground/SystemForegroundDispatcher;
|
|
|
|
.field public mHandler:Landroid/os/Handler;
|
|
|
|
.field public mIsShutdown:Z
|
|
|
|
.field public mNotificationManager:Landroid/app/NotificationManager;
|
|
|
|
|
|
# direct methods
|
|
.method public static constructor <clinit>()V
|
|
.locals 1
|
|
|
|
const-string v0, "SystemFgService"
|
|
|
|
invoke-static {v0}, Landroidx/work/Logger;->tagWithPrefix(Ljava/lang/String;)Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
sput-object v0, Landroidx/work/impl/foreground/SystemForegroundService;->TAG:Ljava/lang/String;
|
|
|
|
const/4 v0, 0x0
|
|
|
|
sput-object v0, Landroidx/work/impl/foreground/SystemForegroundService;->sForegroundService:Landroidx/work/impl/foreground/SystemForegroundService;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public constructor <init>()V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Landroidx/lifecycle/LifecycleService;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static getInstance()Landroidx/work/impl/foreground/SystemForegroundService;
|
|
.locals 1
|
|
.annotation build Landroidx/annotation/Nullable;
|
|
.end annotation
|
|
|
|
sget-object v0, Landroidx/work/impl/foreground/SystemForegroundService;->sForegroundService:Landroidx/work/impl/foreground/SystemForegroundService;
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method private initializeDispatcher()V
|
|
.locals 2
|
|
.annotation build Landroidx/annotation/MainThread;
|
|
.end annotation
|
|
|
|
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;->mHandler: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;->mNotificationManager:Landroid/app/NotificationManager;
|
|
|
|
new-instance v0, Landroidx/work/impl/foreground/SystemForegroundDispatcher;
|
|
|
|
invoke-virtual {p0}, Landroid/app/Service;->getApplicationContext()Landroid/content/Context;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-direct {v0, v1}, Landroidx/work/impl/foreground/SystemForegroundDispatcher;-><init>(Landroid/content/Context;)V
|
|
|
|
iput-object v0, p0, Landroidx/work/impl/foreground/SystemForegroundService;->mDispatcher:Landroidx/work/impl/foreground/SystemForegroundDispatcher;
|
|
|
|
invoke-virtual {v0, p0}, Landroidx/work/impl/foreground/SystemForegroundDispatcher;->setCallback(Landroidx/work/impl/foreground/SystemForegroundDispatcher$Callback;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public cancelNotification(I)V
|
|
.locals 2
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/foreground/SystemForegroundService;->mHandler:Landroid/os/Handler;
|
|
|
|
new-instance v1, Landroidx/work/impl/foreground/SystemForegroundService$4;
|
|
|
|
invoke-direct {v1, p0, p1}, Landroidx/work/impl/foreground/SystemForegroundService$4;-><init>(Landroidx/work/impl/foreground/SystemForegroundService;I)V
|
|
|
|
invoke-virtual {v0, v1}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public notify(ILandroid/app/Notification;)V
|
|
.locals 2
|
|
.param p2 # Landroid/app/Notification;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/foreground/SystemForegroundService;->mHandler:Landroid/os/Handler;
|
|
|
|
new-instance v1, Landroidx/work/impl/foreground/SystemForegroundService$3;
|
|
|
|
invoke-direct {v1, p0, p1, p2}, Landroidx/work/impl/foreground/SystemForegroundService$3;-><init>(Landroidx/work/impl/foreground/SystemForegroundService;ILandroid/app/Notification;)V
|
|
|
|
invoke-virtual {v0, v1}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public onCreate()V
|
|
.locals 0
|
|
|
|
invoke-super {p0}, Landroidx/lifecycle/LifecycleService;->onCreate()V
|
|
|
|
sput-object p0, Landroidx/work/impl/foreground/SystemForegroundService;->sForegroundService:Landroidx/work/impl/foreground/SystemForegroundService;
|
|
|
|
invoke-direct {p0}, Landroidx/work/impl/foreground/SystemForegroundService;->initializeDispatcher()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public onDestroy()V
|
|
.locals 1
|
|
|
|
invoke-super {p0}, Landroidx/lifecycle/LifecycleService;->onDestroy()V
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/foreground/SystemForegroundService;->mDispatcher:Landroidx/work/impl/foreground/SystemForegroundDispatcher;
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/foreground/SystemForegroundDispatcher;->onDestroy()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public onStartCommand(Landroid/content/Intent;II)I
|
|
.locals 3
|
|
.param p1 # Landroid/content/Intent;
|
|
.annotation build Landroidx/annotation/Nullable;
|
|
.end annotation
|
|
.end param
|
|
|
|
invoke-super {p0, p1, p2, p3}, Landroidx/lifecycle/LifecycleService;->onStartCommand(Landroid/content/Intent;II)I
|
|
|
|
iget-boolean p2, p0, Landroidx/work/impl/foreground/SystemForegroundService;->mIsShutdown:Z
|
|
|
|
if-eqz p2, :cond_0
|
|
|
|
invoke-static {}, Landroidx/work/Logger;->get()Landroidx/work/Logger;
|
|
|
|
move-result-object p2
|
|
|
|
sget-object p3, Landroidx/work/impl/foreground/SystemForegroundService;->TAG:Ljava/lang/String;
|
|
|
|
const/4 v0, 0x0
|
|
|
|
new-array v1, v0, [Ljava/lang/Throwable;
|
|
|
|
const-string v2, "Re-initializing SystemForegroundService after a request to shut-down."
|
|
|
|
invoke-virtual {p2, p3, v2, v1}, Landroidx/work/Logger;->info(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Throwable;)V
|
|
|
|
iget-object p2, p0, Landroidx/work/impl/foreground/SystemForegroundService;->mDispatcher:Landroidx/work/impl/foreground/SystemForegroundDispatcher;
|
|
|
|
invoke-virtual {p2}, Landroidx/work/impl/foreground/SystemForegroundDispatcher;->onDestroy()V
|
|
|
|
invoke-direct {p0}, Landroidx/work/impl/foreground/SystemForegroundService;->initializeDispatcher()V
|
|
|
|
iput-boolean v0, p0, Landroidx/work/impl/foreground/SystemForegroundService;->mIsShutdown:Z
|
|
|
|
:cond_0
|
|
if-eqz p1, :cond_1
|
|
|
|
iget-object p2, p0, Landroidx/work/impl/foreground/SystemForegroundService;->mDispatcher:Landroidx/work/impl/foreground/SystemForegroundDispatcher;
|
|
|
|
invoke-virtual {p2, p1}, Landroidx/work/impl/foreground/SystemForegroundDispatcher;->onStartCommand(Landroid/content/Intent;)V
|
|
|
|
:cond_1
|
|
const/4 p1, 0x3
|
|
|
|
return p1
|
|
.end method
|
|
|
|
.method public startForeground(IILandroid/app/Notification;)V
|
|
.locals 2
|
|
.param p3 # Landroid/app/Notification;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/foreground/SystemForegroundService;->mHandler:Landroid/os/Handler;
|
|
|
|
new-instance v1, Landroidx/work/impl/foreground/SystemForegroundService$2;
|
|
|
|
invoke-direct {v1, p0, p1, p3, p2}, Landroidx/work/impl/foreground/SystemForegroundService$2;-><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 stop()V
|
|
.locals 5
|
|
.annotation build Landroidx/annotation/MainThread;
|
|
.end annotation
|
|
|
|
const/4 v0, 0x1
|
|
|
|
iput-boolean v0, p0, Landroidx/work/impl/foreground/SystemForegroundService;->mIsShutdown:Z
|
|
|
|
invoke-static {}, Landroidx/work/Logger;->get()Landroidx/work/Logger;
|
|
|
|
move-result-object v1
|
|
|
|
sget-object v2, Landroidx/work/impl/foreground/SystemForegroundService;->TAG:Ljava/lang/String;
|
|
|
|
const/4 v3, 0x0
|
|
|
|
new-array v3, v3, [Ljava/lang/Throwable;
|
|
|
|
const-string v4, "All commands completed."
|
|
|
|
invoke-virtual {v1, v2, v4, v3}, Landroidx/work/Logger;->debug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Throwable;)V
|
|
|
|
sget v1, Landroid/os/Build$VERSION;->SDK_INT:I
|
|
|
|
const/16 v2, 0x1a
|
|
|
|
if-lt v1, v2, :cond_0
|
|
|
|
invoke-virtual {p0, v0}, Landroid/app/Service;->stopForeground(Z)V
|
|
|
|
:cond_0
|
|
const/4 v0, 0x0
|
|
|
|
sput-object v0, Landroidx/work/impl/foreground/SystemForegroundService;->sForegroundService:Landroidx/work/impl/foreground/SystemForegroundService;
|
|
|
|
invoke-virtual {p0}, Landroid/app/Service;->stopSelf()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public stopForegroundService()V
|
|
.locals 2
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/foreground/SystemForegroundService;->mHandler:Landroid/os/Handler;
|
|
|
|
new-instance v1, Landroidx/work/impl/foreground/SystemForegroundService$1;
|
|
|
|
invoke-direct {v1, p0}, Landroidx/work/impl/foreground/SystemForegroundService$1;-><init>(Landroidx/work/impl/foreground/SystemForegroundService;)V
|
|
|
|
invoke-virtual {v0, v1}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
|
|
|
|
return-void
|
|
.end method
|