309 lines
7.9 KiB
Smali
309 lines
7.9 KiB
Smali
.class public Landroidx/work/impl/utils/IdGenerator;
|
|
.super Ljava/lang/Object;
|
|
.source "IdGenerator.java"
|
|
|
|
|
|
# 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 INITIAL_ID:I = 0x0
|
|
|
|
.field public static final NEXT_ALARM_MANAGER_ID_KEY:Ljava/lang/String; = "next_alarm_manager_id"
|
|
|
|
.field public static final NEXT_JOB_SCHEDULER_ID_KEY:Ljava/lang/String; = "next_job_scheduler_id"
|
|
|
|
.field public static final PREFERENCE_FILE_KEY:Ljava/lang/String; = "androidx.work.util.id"
|
|
|
|
|
|
# instance fields
|
|
.field private final mWorkDatabase:Landroidx/work/impl/WorkDatabase;
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>(Landroidx/work/impl/WorkDatabase;)V
|
|
.locals 0
|
|
.param p1 # Landroidx/work/impl/WorkDatabase;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
iput-object p1, p0, Landroidx/work/impl/utils/IdGenerator;->mWorkDatabase:Landroidx/work/impl/WorkDatabase;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static migrateLegacyIdGenerator(Landroid/content/Context;Landroidx/sqlite/db/SupportSQLiteDatabase;)V
|
|
.locals 8
|
|
.param p0 # Landroid/content/Context;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.param p1 # Landroidx/sqlite/db/SupportSQLiteDatabase;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
|
|
const-string v0, "INSERT OR REPLACE INTO `Preference` (`key`, `long_value`) VALUES (@key, @long_value)"
|
|
|
|
const-string v1, "androidx.work.util.id"
|
|
|
|
const/4 v2, 0x0
|
|
|
|
invoke-virtual {p0, v1, v2}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;
|
|
|
|
move-result-object p0
|
|
|
|
const-string v1, "next_job_scheduler_id"
|
|
|
|
invoke-interface {p0, v1}, Landroid/content/SharedPreferences;->contains(Ljava/lang/String;)Z
|
|
|
|
move-result v3
|
|
|
|
if-nez v3, :cond_0
|
|
|
|
invoke-interface {p0, v1}, Landroid/content/SharedPreferences;->contains(Ljava/lang/String;)Z
|
|
|
|
move-result v3
|
|
|
|
if-eqz v3, :cond_1
|
|
|
|
:cond_0
|
|
invoke-interface {p0, v1, v2}, Landroid/content/SharedPreferences;->getInt(Ljava/lang/String;I)I
|
|
|
|
move-result v3
|
|
|
|
const-string v4, "next_alarm_manager_id"
|
|
|
|
invoke-interface {p0, v4, v2}, Landroid/content/SharedPreferences;->getInt(Ljava/lang/String;I)I
|
|
|
|
move-result v5
|
|
|
|
invoke-interface {p1}, Landroidx/sqlite/db/SupportSQLiteDatabase;->beginTransaction()V
|
|
|
|
const/4 v6, 0x2
|
|
|
|
:try_start_0
|
|
new-array v7, v6, [Ljava/lang/Object;
|
|
|
|
aput-object v1, v7, v2
|
|
|
|
invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
|
|
|
|
move-result-object v1
|
|
|
|
const/4 v3, 0x1
|
|
|
|
aput-object v1, v7, v3
|
|
|
|
invoke-interface {p1, v0, v7}, Landroidx/sqlite/db/SupportSQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V
|
|
|
|
new-array v1, v6, [Ljava/lang/Object;
|
|
|
|
aput-object v4, v1, v2
|
|
|
|
invoke-static {v5}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
|
|
|
|
move-result-object v2
|
|
|
|
aput-object v2, v1, v3
|
|
|
|
invoke-interface {p1, v0, v1}, Landroidx/sqlite/db/SupportSQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V
|
|
|
|
invoke-interface {p0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-interface {p0}, Landroid/content/SharedPreferences$Editor;->clear()Landroid/content/SharedPreferences$Editor;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-interface {p0}, Landroid/content/SharedPreferences$Editor;->apply()V
|
|
|
|
invoke-interface {p1}, Landroidx/sqlite/db/SupportSQLiteDatabase;->setTransactionSuccessful()V
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
invoke-interface {p1}, Landroidx/sqlite/db/SupportSQLiteDatabase;->endTransaction()V
|
|
|
|
:cond_1
|
|
return-void
|
|
|
|
:catchall_0
|
|
move-exception p0
|
|
|
|
invoke-interface {p1}, Landroidx/sqlite/db/SupportSQLiteDatabase;->endTransaction()V
|
|
|
|
throw p0
|
|
.end method
|
|
|
|
.method private nextId(Ljava/lang/String;)I
|
|
.locals 3
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/IdGenerator;->mWorkDatabase:Landroidx/work/impl/WorkDatabase;
|
|
|
|
invoke-virtual {v0}, Landroidx/room/RoomDatabase;->beginTransaction()V
|
|
|
|
:try_start_0
|
|
iget-object v0, p0, Landroidx/work/impl/utils/IdGenerator;->mWorkDatabase:Landroidx/work/impl/WorkDatabase;
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkDatabase;->preferenceDao()Landroidx/work/impl/model/PreferenceDao;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-interface {v0, p1}, Landroidx/work/impl/model/PreferenceDao;->getLongValue(Ljava/lang/String;)Ljava/lang/Long;
|
|
|
|
move-result-object v0
|
|
|
|
const/4 v1, 0x0
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
invoke-virtual {v0}, Ljava/lang/Long;->intValue()I
|
|
|
|
move-result v0
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
const/4 v0, 0x0
|
|
|
|
:goto_0
|
|
const v2, 0x7fffffff
|
|
|
|
if-ne v0, v2, :cond_1
|
|
|
|
goto :goto_1
|
|
|
|
:cond_1
|
|
add-int/lit8 v1, v0, 0x1
|
|
|
|
:goto_1
|
|
invoke-direct {p0, p1, v1}, Landroidx/work/impl/utils/IdGenerator;->update(Ljava/lang/String;I)V
|
|
|
|
iget-object p1, p0, Landroidx/work/impl/utils/IdGenerator;->mWorkDatabase:Landroidx/work/impl/WorkDatabase;
|
|
|
|
invoke-virtual {p1}, Landroidx/room/RoomDatabase;->setTransactionSuccessful()V
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
iget-object p1, p0, Landroidx/work/impl/utils/IdGenerator;->mWorkDatabase:Landroidx/work/impl/WorkDatabase;
|
|
|
|
invoke-virtual {p1}, Landroidx/room/RoomDatabase;->endTransaction()V
|
|
|
|
return v0
|
|
|
|
:catchall_0
|
|
move-exception p1
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/IdGenerator;->mWorkDatabase:Landroidx/work/impl/WorkDatabase;
|
|
|
|
invoke-virtual {v0}, Landroidx/room/RoomDatabase;->endTransaction()V
|
|
|
|
throw p1
|
|
.end method
|
|
|
|
.method private update(Ljava/lang/String;I)V
|
|
.locals 4
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/IdGenerator;->mWorkDatabase:Landroidx/work/impl/WorkDatabase;
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkDatabase;->preferenceDao()Landroidx/work/impl/model/PreferenceDao;
|
|
|
|
move-result-object v0
|
|
|
|
new-instance v1, Landroidx/work/impl/model/Preference;
|
|
|
|
int-to-long v2, p2
|
|
|
|
invoke-direct {v1, p1, v2, v3}, Landroidx/work/impl/model/Preference;-><init>(Ljava/lang/String;J)V
|
|
|
|
invoke-interface {v0, v1}, Landroidx/work/impl/model/PreferenceDao;->insertPreference(Landroidx/work/impl/model/Preference;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public nextAlarmManagerId()I
|
|
.locals 2
|
|
|
|
const-class v0, Landroidx/work/impl/utils/IdGenerator;
|
|
|
|
monitor-enter v0
|
|
|
|
:try_start_0
|
|
const-string v1, "next_alarm_manager_id"
|
|
|
|
invoke-direct {p0, v1}, Landroidx/work/impl/utils/IdGenerator;->nextId(Ljava/lang/String;)I
|
|
|
|
move-result v1
|
|
|
|
monitor-exit v0
|
|
|
|
return v1
|
|
|
|
:catchall_0
|
|
move-exception v1
|
|
|
|
monitor-exit v0
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
throw v1
|
|
.end method
|
|
|
|
.method public nextJobSchedulerIdWithRange(II)I
|
|
.locals 2
|
|
|
|
const-class v0, Landroidx/work/impl/utils/IdGenerator;
|
|
|
|
monitor-enter v0
|
|
|
|
:try_start_0
|
|
const-string v1, "next_job_scheduler_id"
|
|
|
|
invoke-direct {p0, v1}, Landroidx/work/impl/utils/IdGenerator;->nextId(Ljava/lang/String;)I
|
|
|
|
move-result v1
|
|
|
|
if-lt v1, p1, :cond_1
|
|
|
|
if-le v1, p2, :cond_0
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
move p1, v1
|
|
|
|
goto :goto_1
|
|
|
|
:cond_1
|
|
:goto_0
|
|
const-string p2, "next_job_scheduler_id"
|
|
|
|
add-int/lit8 v1, p1, 0x1
|
|
|
|
invoke-direct {p0, p2, v1}, Landroidx/work/impl/utils/IdGenerator;->update(Ljava/lang/String;I)V
|
|
|
|
:goto_1
|
|
monitor-exit v0
|
|
|
|
return p1
|
|
|
|
:catchall_0
|
|
move-exception p1
|
|
|
|
monitor-exit v0
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
throw p1
|
|
.end method
|