alexandroid/decompiled/jadx/sources/androidx/work/impl/utils/PreferenceUtils.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

89 lines
4.2 KiB
Java

package androidx.work.impl.utils;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.camera.core.ImageCapture$$ExternalSyntheticLambda4;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.Transformations;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.model.Preference;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes14.dex */
public class PreferenceUtils {
public static final String CREATE_PREFERENCE = "CREATE TABLE IF NOT EXISTS `Preference` (`key` TEXT NOT NULL, `long_value` INTEGER, PRIMARY KEY(`key`))";
public static final String INSERT_PREFERENCE = "INSERT OR REPLACE INTO `Preference` (`key`, `long_value`) VALUES (@key, @long_value)";
public static final String KEY_LAST_CANCEL_ALL_TIME_MS = "last_cancel_all_time_ms";
private static final String KEY_LAST_FORCE_STOP_MS = "last_force_stop_ms";
public static final String KEY_RESCHEDULE_NEEDED = "reschedule_needed";
public static final String PREFERENCES_FILE_NAME = "androidx.work.util.preferences";
private final WorkDatabase mWorkDatabase;
public PreferenceUtils(@NonNull WorkDatabase workDatabase) {
this.mWorkDatabase = workDatabase;
}
/* JADX INFO: Access modifiers changed from: private */
public static /* synthetic */ Long lambda$getLastCancelAllTimeMillisLiveData$0(Long l) {
return Long.valueOf(l != null ? l.longValue() : 0L);
}
public static void migrateLegacyPreferences(@NonNull Context context, @NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
SharedPreferences sharedPreferences = context.getSharedPreferences(PREFERENCES_FILE_NAME, 0);
if (sharedPreferences.contains(KEY_RESCHEDULE_NEEDED) || sharedPreferences.contains(KEY_LAST_CANCEL_ALL_TIME_MS)) {
long j = sharedPreferences.getLong(KEY_LAST_CANCEL_ALL_TIME_MS, 0L);
long j2 = sharedPreferences.getBoolean(KEY_RESCHEDULE_NEEDED, false) ? 1L : 0L;
supportSQLiteDatabase.beginTransaction();
try {
supportSQLiteDatabase.execSQL(INSERT_PREFERENCE, new Object[]{KEY_LAST_CANCEL_ALL_TIME_MS, Long.valueOf(j)});
supportSQLiteDatabase.execSQL(INSERT_PREFERENCE, new Object[]{KEY_RESCHEDULE_NEEDED, Long.valueOf(j2)});
sharedPreferences.edit().clear().apply();
supportSQLiteDatabase.setTransactionSuccessful();
} finally {
supportSQLiteDatabase.endTransaction();
}
}
}
public long getLastCancelAllTimeMillis() {
Long longValue = this.mWorkDatabase.preferenceDao().getLongValue(KEY_LAST_CANCEL_ALL_TIME_MS);
if (longValue != null) {
return longValue.longValue();
}
return 0L;
}
@NonNull
public LiveData<Long> getLastCancelAllTimeMillisLiveData() {
return Transformations.map(this.mWorkDatabase.preferenceDao().getObservableLongValue(KEY_LAST_CANCEL_ALL_TIME_MS), new ImageCapture$$ExternalSyntheticLambda4(5));
}
public long getLastForceStopEventMillis() {
Long longValue = this.mWorkDatabase.preferenceDao().getLongValue(KEY_LAST_FORCE_STOP_MS);
if (longValue != null) {
return longValue.longValue();
}
return 0L;
}
public boolean getNeedsReschedule() {
Long longValue = this.mWorkDatabase.preferenceDao().getLongValue(KEY_RESCHEDULE_NEEDED);
return longValue != null && longValue.longValue() == 1;
}
public void setLastCancelAllTimeMillis(long j) {
this.mWorkDatabase.preferenceDao().insertPreference(new Preference(KEY_LAST_CANCEL_ALL_TIME_MS, Long.valueOf(j)));
}
public void setLastForceStopEventMillis(long j) {
this.mWorkDatabase.preferenceDao().insertPreference(new Preference(KEY_LAST_FORCE_STOP_MS, Long.valueOf(j)));
}
public void setNeedsReschedule(boolean z) {
this.mWorkDatabase.preferenceDao().insertPreference(new Preference(KEY_RESCHEDULE_NEEDED, z));
}
}