- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
92 lines
4.2 KiB
Java
92 lines
4.2 KiB
Java
package androidx.work.impl;
|
|
|
|
import android.content.Context;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.work.Logger;
|
|
import java.io.File;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Map;
|
|
import kotlin.Pair;
|
|
import kotlin.TuplesKt;
|
|
import kotlin.collections.MapsKt__MapsJVMKt;
|
|
import kotlin.collections.MapsKt__MapsKt;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.jvm.internal.SourceDebugExtension;
|
|
import kotlin.ranges.RangesKt___RangesKt;
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
@SourceDebugExtension({"SMAP\nWorkDatabasePathHelper.kt\nKotlin\n*S Kotlin\n*F\n+ 1 WorkDatabasePathHelper.kt\nandroidx/work/impl/WorkDatabasePathHelper\n+ 2 _Maps.kt\nkotlin/collections/MapsKt___MapsKt\n+ 3 _Arrays.kt\nkotlin/collections/ArraysKt___ArraysKt\n*L\n1#1,122:1\n215#2,2:123\n8676#3,2:125\n9358#3,4:127\n*S KotlinDebug\n*F\n+ 1 WorkDatabasePathHelper.kt\nandroidx/work/impl/WorkDatabasePathHelper\n*L\n46#1:123,2\n75#1:125,2\n75#1:127,4\n*E\n"})
|
|
/* loaded from: classes.dex */
|
|
public final class WorkDatabasePathHelper {
|
|
public static final WorkDatabasePathHelper INSTANCE = new WorkDatabasePathHelper();
|
|
|
|
private WorkDatabasePathHelper() {
|
|
}
|
|
|
|
public static final void migrateDatabase(Context context) {
|
|
String str;
|
|
String str2;
|
|
String str3;
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
WorkDatabasePathHelper workDatabasePathHelper = INSTANCE;
|
|
if (workDatabasePathHelper.getDefaultDatabasePath(context).exists()) {
|
|
Logger logger = Logger.get();
|
|
str = WorkDatabasePathHelperKt.TAG;
|
|
logger.debug(str, "Migrating WorkDatabase to the no-backup directory");
|
|
for (Map.Entry<File, File> entry : workDatabasePathHelper.migrationPaths(context).entrySet()) {
|
|
File key = entry.getKey();
|
|
File value = entry.getValue();
|
|
if (key.exists()) {
|
|
if (value.exists()) {
|
|
Logger logger2 = Logger.get();
|
|
str3 = WorkDatabasePathHelperKt.TAG;
|
|
logger2.warning(str3, "Over-writing contents of " + value);
|
|
}
|
|
String str4 = key.renameTo(value) ? "Migrated " + key + "to " + value : "Renaming " + key + " to " + value + " failed";
|
|
Logger logger3 = Logger.get();
|
|
str2 = WorkDatabasePathHelperKt.TAG;
|
|
logger3.debug(str2, str4);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public final Map<File, File> migrationPaths(Context context) {
|
|
String[] strArr;
|
|
int mapCapacity;
|
|
int coerceAtLeast;
|
|
Map<File, File> plus;
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
File defaultDatabasePath = getDefaultDatabasePath(context);
|
|
File databasePath = getDatabasePath(context);
|
|
strArr = WorkDatabasePathHelperKt.DATABASE_EXTRA_FILES;
|
|
mapCapacity = MapsKt__MapsJVMKt.mapCapacity(strArr.length);
|
|
coerceAtLeast = RangesKt___RangesKt.coerceAtLeast(mapCapacity, 16);
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap(coerceAtLeast);
|
|
for (String str : strArr) {
|
|
Pair pair = TuplesKt.to(new File(defaultDatabasePath.getPath() + str), new File(databasePath.getPath() + str));
|
|
linkedHashMap.put(pair.getFirst(), pair.getSecond());
|
|
}
|
|
plus = MapsKt__MapsKt.plus(linkedHashMap, TuplesKt.to(defaultDatabasePath, databasePath));
|
|
return plus;
|
|
}
|
|
|
|
public final File getDefaultDatabasePath(Context context) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
File databasePath = context.getDatabasePath(WorkDatabasePathHelperKt.WORK_DATABASE_NAME);
|
|
Intrinsics.checkNotNullExpressionValue(databasePath, "context.getDatabasePath(WORK_DATABASE_NAME)");
|
|
return databasePath;
|
|
}
|
|
|
|
public final File getDatabasePath(Context context) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
return getNoBackupPath(context);
|
|
}
|
|
|
|
@RequiresApi(23)
|
|
private final File getNoBackupPath(Context context) {
|
|
return new File(Api21Impl.INSTANCE.getNoBackupFilesDir(context), WorkDatabasePathHelperKt.WORK_DATABASE_NAME);
|
|
}
|
|
}
|