297 lines
8.3 KiB
Smali
297 lines
8.3 KiB
Smali
.class public Landroidx/work/impl/utils/PreferenceUtils;
|
|
.super Ljava/lang/Object;
|
|
.source "PreferenceUtils.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 KEY_LAST_CANCEL_ALL_TIME_MS:Ljava/lang/String; = "last_cancel_all_time_ms"
|
|
|
|
.field public static final KEY_RESCHEDULE_NEEDED:Ljava/lang/String; = "reschedule_needed"
|
|
|
|
.field public static final PREFERENCES_FILE_NAME:Ljava/lang/String; = "androidx.work.util.preferences"
|
|
|
|
|
|
# instance fields
|
|
.field public 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/PreferenceUtils;->mWorkDatabase:Landroidx/work/impl/WorkDatabase;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static migrateLegacyPreferences(Landroid/content/Context;Landroidx/sqlite/db/SupportSQLiteDatabase;)V
|
|
.locals 10
|
|
.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.preferences"
|
|
|
|
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, "reschedule_needed"
|
|
|
|
invoke-interface {p0, v1}, Landroid/content/SharedPreferences;->contains(Ljava/lang/String;)Z
|
|
|
|
move-result v3
|
|
|
|
const-string v4, "last_cancel_all_time_ms"
|
|
|
|
if-nez v3, :cond_0
|
|
|
|
invoke-interface {p0, v4}, Landroid/content/SharedPreferences;->contains(Ljava/lang/String;)Z
|
|
|
|
move-result v3
|
|
|
|
if-eqz v3, :cond_2
|
|
|
|
:cond_0
|
|
const-wide/16 v5, 0x0
|
|
|
|
invoke-interface {p0, v4, v5, v6}, Landroid/content/SharedPreferences;->getLong(Ljava/lang/String;J)J
|
|
|
|
move-result-wide v7
|
|
|
|
invoke-interface {p0, v1, v2}, Landroid/content/SharedPreferences;->getBoolean(Ljava/lang/String;Z)Z
|
|
|
|
move-result v3
|
|
|
|
if-eqz v3, :cond_1
|
|
|
|
const-wide/16 v5, 0x1
|
|
|
|
:cond_1
|
|
invoke-interface {p1}, Landroidx/sqlite/db/SupportSQLiteDatabase;->beginTransaction()V
|
|
|
|
const/4 v3, 0x2
|
|
|
|
:try_start_0
|
|
new-array v9, v3, [Ljava/lang/Object;
|
|
|
|
aput-object v4, v9, v2
|
|
|
|
invoke-static {v7, v8}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
|
|
|
|
move-result-object v4
|
|
|
|
const/4 v7, 0x1
|
|
|
|
aput-object v4, v9, v7
|
|
|
|
invoke-interface {p1, v0, v9}, Landroidx/sqlite/db/SupportSQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V
|
|
|
|
new-array v3, v3, [Ljava/lang/Object;
|
|
|
|
aput-object v1, v3, v2
|
|
|
|
invoke-static {v5, v6}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
|
|
|
|
move-result-object v1
|
|
|
|
aput-object v1, v3, v7
|
|
|
|
invoke-interface {p1, v0, v3}, 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_2
|
|
return-void
|
|
|
|
:catchall_0
|
|
move-exception p0
|
|
|
|
invoke-interface {p1}, Landroidx/sqlite/db/SupportSQLiteDatabase;->endTransaction()V
|
|
|
|
throw p0
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public getLastCancelAllTimeMillis()J
|
|
.locals 2
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/PreferenceUtils;->mWorkDatabase:Landroidx/work/impl/WorkDatabase;
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkDatabase;->preferenceDao()Landroidx/work/impl/model/PreferenceDao;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "last_cancel_all_time_ms"
|
|
|
|
invoke-interface {v0, v1}, Landroidx/work/impl/model/PreferenceDao;->getLongValue(Ljava/lang/String;)Ljava/lang/Long;
|
|
|
|
move-result-object v0
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
invoke-virtual {v0}, Ljava/lang/Long;->longValue()J
|
|
|
|
move-result-wide v0
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
const-wide/16 v0, 0x0
|
|
|
|
:goto_0
|
|
return-wide v0
|
|
.end method
|
|
|
|
.method public getLastCancelAllTimeMillisLiveData()Landroidx/lifecycle/LiveData;
|
|
.locals 2
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"()",
|
|
"Landroidx/lifecycle/LiveData<",
|
|
"Ljava/lang/Long;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/PreferenceUtils;->mWorkDatabase:Landroidx/work/impl/WorkDatabase;
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkDatabase;->preferenceDao()Landroidx/work/impl/model/PreferenceDao;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "last_cancel_all_time_ms"
|
|
|
|
invoke-interface {v0, v1}, Landroidx/work/impl/model/PreferenceDao;->getObservableLongValue(Ljava/lang/String;)Landroidx/lifecycle/LiveData;
|
|
|
|
move-result-object v0
|
|
|
|
new-instance v1, Landroidx/work/impl/utils/PreferenceUtils$1;
|
|
|
|
invoke-direct {v1, p0}, Landroidx/work/impl/utils/PreferenceUtils$1;-><init>(Landroidx/work/impl/utils/PreferenceUtils;)V
|
|
|
|
invoke-static {v0, v1}, Landroidx/lifecycle/Transformations;->map(Landroidx/lifecycle/LiveData;Landroidx/arch/core/util/Function;)Landroidx/lifecycle/LiveData;
|
|
|
|
move-result-object v0
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public getNeedsReschedule()Z
|
|
.locals 5
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/PreferenceUtils;->mWorkDatabase:Landroidx/work/impl/WorkDatabase;
|
|
|
|
invoke-virtual {v0}, Landroidx/work/impl/WorkDatabase;->preferenceDao()Landroidx/work/impl/model/PreferenceDao;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "reschedule_needed"
|
|
|
|
invoke-interface {v0, v1}, Landroidx/work/impl/model/PreferenceDao;->getLongValue(Ljava/lang/String;)Ljava/lang/Long;
|
|
|
|
move-result-object v0
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
invoke-virtual {v0}, Ljava/lang/Long;->longValue()J
|
|
|
|
move-result-wide v0
|
|
|
|
const-wide/16 v2, 0x1
|
|
|
|
cmp-long v4, v0, v2
|
|
|
|
if-nez v4, :cond_0
|
|
|
|
const/4 v0, 0x1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
const/4 v0, 0x0
|
|
|
|
:goto_0
|
|
return v0
|
|
.end method
|
|
|
|
.method public setLastCancelAllTimeMillis(J)V
|
|
.locals 2
|
|
|
|
new-instance v0, Landroidx/work/impl/model/Preference;
|
|
|
|
const-string v1, "last_cancel_all_time_ms"
|
|
|
|
invoke-direct {v0, v1, p1, p2}, Landroidx/work/impl/model/Preference;-><init>(Ljava/lang/String;J)V
|
|
|
|
iget-object p1, p0, Landroidx/work/impl/utils/PreferenceUtils;->mWorkDatabase:Landroidx/work/impl/WorkDatabase;
|
|
|
|
invoke-virtual {p1}, Landroidx/work/impl/WorkDatabase;->preferenceDao()Landroidx/work/impl/model/PreferenceDao;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-interface {p1, v0}, Landroidx/work/impl/model/PreferenceDao;->insertPreference(Landroidx/work/impl/model/Preference;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public setNeedsReschedule(Z)V
|
|
.locals 2
|
|
|
|
new-instance v0, Landroidx/work/impl/model/Preference;
|
|
|
|
const-string v1, "reschedule_needed"
|
|
|
|
invoke-direct {v0, v1, p1}, Landroidx/work/impl/model/Preference;-><init>(Ljava/lang/String;Z)V
|
|
|
|
iget-object p1, p0, Landroidx/work/impl/utils/PreferenceUtils;->mWorkDatabase:Landroidx/work/impl/WorkDatabase;
|
|
|
|
invoke-virtual {p1}, Landroidx/work/impl/WorkDatabase;->preferenceDao()Landroidx/work/impl/model/PreferenceDao;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-interface {p1, v0}, Landroidx/work/impl/model/PreferenceDao;->insertPreference(Landroidx/work/impl/model/Preference;)V
|
|
|
|
return-void
|
|
.end method
|