381 lines
11 KiB
Smali
381 lines
11 KiB
Smali
.class public Landroidx/work/impl/utils/ForceStopRunnable;
|
|
.super Ljava/lang/Object;
|
|
.source "ForceStopRunnable.java"
|
|
|
|
# interfaces
|
|
.implements Ljava/lang/Runnable;
|
|
|
|
|
|
# annotations
|
|
.annotation system Ldalvik/annotation/MemberClasses;
|
|
value = {
|
|
Landroidx/work/impl/utils/ForceStopRunnable$BroadcastReceiver;
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# static fields
|
|
.field static final ACTION_FORCE_STOP_RESCHEDULE:Ljava/lang/String; = "ACTION_FORCE_STOP_RESCHEDULE"
|
|
|
|
.field private static final ALARM_ID:I = -0x1
|
|
|
|
.field private static final TAG:Ljava/lang/String;
|
|
|
|
.field private static final TEN_YEARS:J
|
|
|
|
|
|
# instance fields
|
|
.field private final mContext:Landroid/content/Context;
|
|
|
|
.field private final mWorkManager:Landroidx/work/impl/WorkManagerImpl;
|
|
|
|
|
|
# direct methods
|
|
.method static constructor <clinit>()V
|
|
.locals 3
|
|
|
|
const-string v0, "ForceStopRunnable"
|
|
|
|
invoke-static {v0}, Landroidx/work/Logger;->tagWithPrefix(Ljava/lang/String;)Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
sput-object v0, Landroidx/work/impl/utils/ForceStopRunnable;->TAG:Ljava/lang/String;
|
|
|
|
sget-object v0, Ljava/util/concurrent/TimeUnit;->DAYS:Ljava/util/concurrent/TimeUnit;
|
|
|
|
const-wide/16 v1, 0xe42
|
|
|
|
invoke-virtual {v0, v1, v2}, Ljava/util/concurrent/TimeUnit;->toMillis(J)J
|
|
|
|
move-result-wide v0
|
|
|
|
sput-wide v0, Landroidx/work/impl/utils/ForceStopRunnable;->TEN_YEARS:J
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public constructor <init>(Landroid/content/Context;Landroidx/work/impl/WorkManagerImpl;)V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;
|
|
|
|
move-result-object p1
|
|
|
|
iput-object p1, p0, Landroidx/work/impl/utils/ForceStopRunnable;->mContext:Landroid/content/Context;
|
|
|
|
iput-object p2, p0, Landroidx/work/impl/utils/ForceStopRunnable;->mWorkManager:Landroidx/work/impl/WorkManagerImpl;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method static getIntent(Landroid/content/Context;)Landroid/content/Intent;
|
|
.locals 3
|
|
|
|
new-instance v0, Landroid/content/Intent;
|
|
|
|
invoke-direct {v0}, Landroid/content/Intent;-><init>()V
|
|
|
|
new-instance v1, Landroid/content/ComponentName;
|
|
|
|
const-class v2, Landroidx/work/impl/utils/ForceStopRunnable$BroadcastReceiver;
|
|
|
|
invoke-direct {v1, p0, v2}, Landroid/content/ComponentName;-><init>(Landroid/content/Context;Ljava/lang/Class;)V
|
|
|
|
invoke-virtual {v0, v1}, Landroid/content/Intent;->setComponent(Landroid/content/ComponentName;)Landroid/content/Intent;
|
|
|
|
const-string p0, "ACTION_FORCE_STOP_RESCHEDULE"
|
|
|
|
invoke-virtual {v0, p0}, Landroid/content/Intent;->setAction(Ljava/lang/String;)Landroid/content/Intent;
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method private static getPendingIntent(Landroid/content/Context;I)Landroid/app/PendingIntent;
|
|
.locals 2
|
|
|
|
invoke-static {p0}, Landroidx/work/impl/utils/ForceStopRunnable;->getIntent(Landroid/content/Context;)Landroid/content/Intent;
|
|
|
|
move-result-object v0
|
|
|
|
const/4 v1, -0x1
|
|
|
|
invoke-static {p0, v1, v0, p1}, Landroid/app/PendingIntent;->getBroadcast(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method static setAlarm(Landroid/content/Context;)V
|
|
.locals 6
|
|
|
|
const-string v0, "alarm"
|
|
|
|
invoke-virtual {p0, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;
|
|
|
|
move-result-object v0
|
|
|
|
check-cast v0, Landroid/app/AlarmManager;
|
|
|
|
const/high16 v1, 0x8000000
|
|
|
|
invoke-static {p0, v1}, Landroidx/work/impl/utils/ForceStopRunnable;->getPendingIntent(Landroid/content/Context;I)Landroid/app/PendingIntent;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
|
|
|
|
move-result-wide v1
|
|
|
|
sget-wide v3, Landroidx/work/impl/utils/ForceStopRunnable;->TEN_YEARS:J
|
|
|
|
add-long/2addr v1, v3
|
|
|
|
if-eqz v0, :cond_1
|
|
|
|
sget v3, Landroid/os/Build$VERSION;->SDK_INT:I
|
|
|
|
const/16 v4, 0x13
|
|
|
|
const/4 v5, 0x0
|
|
|
|
if-lt v3, v4, :cond_0
|
|
|
|
invoke-virtual {v0, v5, v1, v2, p0}, Landroid/app/AlarmManager;->setExact(IJLandroid/app/PendingIntent;)V
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
invoke-virtual {v0, v5, v1, v2, p0}, Landroid/app/AlarmManager;->set(IJLandroid/app/PendingIntent;)V
|
|
|
|
:cond_1
|
|
return-void
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public isForceStopped()Z
|
|
.locals 2
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/ForceStopRunnable;->mContext:Landroid/content/Context;
|
|
|
|
const/high16 v1, 0x20000000
|
|
|
|
invoke-static {v0, v1}, Landroidx/work/impl/utils/ForceStopRunnable;->getPendingIntent(Landroid/content/Context;I)Landroid/app/PendingIntent;
|
|
|
|
move-result-object v0
|
|
|
|
if-nez v0, :cond_0
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/ForceStopRunnable;->mContext:Landroid/content/Context;
|
|
|
|
invoke-static {v0}, Landroidx/work/impl/utils/ForceStopRunnable;->setAlarm(Landroid/content/Context;)V
|
|
|
|
const/4 v0, 0x1
|
|
|
|
return v0
|
|
|
|
:cond_0
|
|
const/4 v0, 0x0
|
|
|
|
return v0
|
|
.end method
|
|
|
|
.method public run()V
|
|
.locals 8
|
|
|
|
invoke-virtual {p0}, Landroidx/work/impl/utils/ForceStopRunnable;->shouldRescheduleWorkers()Z
|
|
|
|
move-result v0
|
|
|
|
const/4 v1, 0x0
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
invoke-static {}, Landroidx/work/Logger;->get()Landroidx/work/Logger;
|
|
|
|
move-result-object v0
|
|
|
|
sget-object v2, Landroidx/work/impl/utils/ForceStopRunnable;->TAG:Ljava/lang/String;
|
|
|
|
new-array v3, v1, [Ljava/lang/Throwable;
|
|
|
|
const-string v4, "Rescheduling Workers."
|
|
|
|
invoke-virtual {v0, v2, v4, v3}, Landroidx/work/Logger;->debug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Throwable;)V
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/ForceStopRunnable;->mWorkManager:Landroidx/work/impl/WorkManagerImpl;
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkManagerImpl;->rescheduleEligibleWork()V
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/ForceStopRunnable;->mWorkManager:Landroidx/work/impl/WorkManagerImpl;
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkManagerImpl;->getPreferences()Landroidx/work/impl/utils/Preferences;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0, v1}, Landroidx/work/impl/utils/Preferences;->setNeedsReschedule(Z)V
|
|
|
|
goto/16 :goto_1
|
|
|
|
:cond_0
|
|
invoke-virtual {p0}, Landroidx/work/impl/utils/ForceStopRunnable;->isForceStopped()Z
|
|
|
|
move-result v0
|
|
|
|
if-eqz v0, :cond_1
|
|
|
|
invoke-static {}, Landroidx/work/Logger;->get()Landroidx/work/Logger;
|
|
|
|
move-result-object v0
|
|
|
|
sget-object v2, Landroidx/work/impl/utils/ForceStopRunnable;->TAG:Ljava/lang/String;
|
|
|
|
new-array v1, v1, [Ljava/lang/Throwable;
|
|
|
|
const-string v3, "Application was force-stopped, rescheduling."
|
|
|
|
invoke-virtual {v0, v2, v3, v1}, Landroidx/work/Logger;->debug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Throwable;)V
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/ForceStopRunnable;->mWorkManager:Landroidx/work/impl/WorkManagerImpl;
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkManagerImpl;->rescheduleEligibleWork()V
|
|
|
|
goto :goto_1
|
|
|
|
:cond_1
|
|
iget-object v0, p0, Landroidx/work/impl/utils/ForceStopRunnable;->mWorkManager:Landroidx/work/impl/WorkManagerImpl;
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkManagerImpl;->getWorkDatabase()Landroidx/work/impl/WorkDatabase;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkDatabase;->workSpecDao()Landroidx/work/impl/model/WorkSpecDao;
|
|
|
|
move-result-object v2
|
|
|
|
:try_start_0
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkDatabase;->beginTransaction()V
|
|
|
|
invoke-interface {v2}, Landroidx/work/impl/model/WorkSpecDao;->getEnqueuedWork()Ljava/util/List;
|
|
|
|
move-result-object v3
|
|
|
|
if-eqz v3, :cond_3
|
|
|
|
invoke-interface {v3}, Ljava/util/List;->isEmpty()Z
|
|
|
|
move-result v4
|
|
|
|
if-nez v4, :cond_3
|
|
|
|
invoke-static {}, Landroidx/work/Logger;->get()Landroidx/work/Logger;
|
|
|
|
move-result-object v4
|
|
|
|
sget-object v5, Landroidx/work/impl/utils/ForceStopRunnable;->TAG:Ljava/lang/String;
|
|
|
|
const-string v6, "Found unfinished work, scheduling it."
|
|
|
|
new-array v7, v1, [Ljava/lang/Throwable;
|
|
|
|
invoke-virtual {v4, v5, v6, v7}, Landroidx/work/Logger;->debug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Throwable;)V
|
|
|
|
invoke-interface {v3}, Ljava/util/List;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object v3
|
|
|
|
:goto_0
|
|
invoke-interface {v3}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v4
|
|
|
|
if-eqz v4, :cond_2
|
|
|
|
invoke-interface {v3}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v4
|
|
|
|
check-cast v4, Landroidx/work/impl/model/WorkSpec;
|
|
|
|
iget-object v4, v4, Landroidx/work/impl/model/WorkSpec;->id:Ljava/lang/String;
|
|
|
|
const-wide/16 v5, -0x1
|
|
|
|
invoke-interface {v2, v4, v5, v6}, Landroidx/work/impl/model/WorkSpecDao;->markWorkSpecScheduled(Ljava/lang/String;J)I
|
|
|
|
goto :goto_0
|
|
|
|
:cond_2
|
|
iget-object v2, p0, Landroidx/work/impl/utils/ForceStopRunnable;->mWorkManager:Landroidx/work/impl/WorkManagerImpl;
|
|
|
|
invoke-virtual {v2}, Landroidx/work/impl/WorkManagerImpl;->getConfiguration()Landroidx/work/Configuration;
|
|
|
|
move-result-object v2
|
|
|
|
iget-object v3, p0, Landroidx/work/impl/utils/ForceStopRunnable;->mWorkManager:Landroidx/work/impl/WorkManagerImpl;
|
|
|
|
invoke-virtual {v3}, Landroidx/work/impl/WorkManagerImpl;->getSchedulers()Ljava/util/List;
|
|
|
|
move-result-object v3
|
|
|
|
invoke-static {v2, v0, v3}, Landroidx/work/impl/Schedulers;->schedule(Landroidx/work/Configuration;Landroidx/work/impl/WorkDatabase;Ljava/util/List;)V
|
|
|
|
:cond_3
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkDatabase;->setTransactionSuccessful()V
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkDatabase;->endTransaction()V
|
|
|
|
invoke-static {}, Landroidx/work/Logger;->get()Landroidx/work/Logger;
|
|
|
|
move-result-object v0
|
|
|
|
sget-object v2, Landroidx/work/impl/utils/ForceStopRunnable;->TAG:Ljava/lang/String;
|
|
|
|
new-array v1, v1, [Ljava/lang/Throwable;
|
|
|
|
const-string v3, "Unfinished Workers exist, rescheduling."
|
|
|
|
invoke-virtual {v0, v2, v3, v1}, Landroidx/work/Logger;->debug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Throwable;)V
|
|
|
|
:goto_1
|
|
iget-object v0, p0, Landroidx/work/impl/utils/ForceStopRunnable;->mWorkManager:Landroidx/work/impl/WorkManagerImpl;
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkManagerImpl;->onForceStopRunnableCompleted()V
|
|
|
|
return-void
|
|
|
|
:catchall_0
|
|
move-exception v1
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkDatabase;->endTransaction()V
|
|
|
|
goto :goto_3
|
|
|
|
:goto_2
|
|
throw v1
|
|
|
|
:goto_3
|
|
goto :goto_2
|
|
.end method
|
|
|
|
.method shouldRescheduleWorkers()Z
|
|
.locals 1
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/ForceStopRunnable;->mWorkManager:Landroidx/work/impl/WorkManagerImpl;
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkManagerImpl;->getPreferences()Landroidx/work/impl/utils/Preferences;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/utils/Preferences;->needsReschedule()Z
|
|
|
|
move-result v0
|
|
|
|
return v0
|
|
.end method
|