Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package androidx.work.impl;
import android.content.Context;
import androidx.annotation.RequiresApi;
import java.io.File;
import kotlin.jvm.internal.Intrinsics;
@RequiresApi(21)
/* loaded from: classes.dex */
public final class Api21Impl {
public static final Api21Impl INSTANCE = new Api21Impl();
private Api21Impl() {
}
public final File getNoBackupFilesDir(Context context) {
Intrinsics.checkNotNullParameter(context, "context");
File noBackupFilesDir = context.getNoBackupFilesDir();
Intrinsics.checkNotNullExpressionValue(noBackupFilesDir, "context.noBackupFilesDir");
return noBackupFilesDir;
}
}

View File

@@ -0,0 +1,20 @@
package androidx.work.impl;
import android.content.ContentValues;
import androidx.room.RenameColumn;
import androidx.room.migration.AutoMigrationSpec;
import androidx.sqlite.db.SupportSQLiteDatabase;
import kotlin.jvm.internal.Intrinsics;
@RenameColumn(fromColumnName = "period_start_time", tableName = "WorkSpec", toColumnName = "last_enqueue_time")
/* loaded from: classes.dex */
public final class AutoMigration_14_15 implements AutoMigrationSpec {
@Override // androidx.room.migration.AutoMigrationSpec
public void onPostMigrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
db.execSQL("UPDATE workspec SET period_count = 1 WHERE last_enqueue_time <> 0 AND interval_duration <> 0");
ContentValues contentValues = new ContentValues(1);
contentValues.put("last_enqueue_time", Long.valueOf(System.currentTimeMillis()));
db.update("WorkSpec", 3, contentValues, "last_enqueue_time = 0 AND interval_duration <> 0 ", new Object[0]);
}
}

View File

@@ -0,0 +1,14 @@
package androidx.work.impl;
import androidx.room.migration.AutoMigrationSpec;
import androidx.sqlite.db.SupportSQLiteDatabase;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class AutoMigration_19_20 implements AutoMigrationSpec {
@Override // androidx.room.migration.AutoMigrationSpec
public void onPostMigrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
db.execSQL("UPDATE WorkSpec SET `last_enqueue_time` = -1 WHERE `last_enqueue_time` = 0");
}
}

View File

@@ -0,0 +1,41 @@
package androidx.work.impl;
import androidx.room.RoomDatabase;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.work.Clock;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class CleanupCallback extends RoomDatabase.Callback {
private final Clock clock;
public final Clock getClock() {
return this.clock;
}
public CleanupCallback(Clock clock) {
Intrinsics.checkNotNullParameter(clock, "clock");
this.clock = clock;
}
private final String getPruneSQL() {
return "DELETE FROM workspec WHERE state IN (2, 3, 5) AND (last_enqueue_time + minimum_retention_duration) < " + getPruneDate() + " AND (SELECT COUNT(*)=0 FROM dependency WHERE prerequisite_id=id AND work_spec_id NOT IN (SELECT id FROM workspec WHERE state IN (2, 3, 5)))";
}
private final long getPruneDate() {
return this.clock.currentTimeMillis() - WorkDatabaseKt.PRUNE_THRESHOLD_MILLIS;
}
@Override // androidx.room.RoomDatabase.Callback
public void onOpen(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
super.onOpen(db);
db.beginTransaction();
try {
db.execSQL(getPruneSQL());
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
}

View File

@@ -0,0 +1,29 @@
package androidx.work.impl;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.core.os.HandlerCompat;
import androidx.work.RunnableScheduler;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class DefaultRunnableScheduler implements RunnableScheduler {
private final Handler mHandler = HandlerCompat.createAsync(Looper.getMainLooper());
@NonNull
public Handler getHandler() {
return this.mHandler;
}
@Override // androidx.work.RunnableScheduler
public void scheduleWithDelay(long j, @NonNull Runnable runnable) {
this.mHandler.postDelayed(runnable, j);
}
@Override // androidx.work.RunnableScheduler
public void cancel(@NonNull Runnable runnable) {
this.mHandler.removeCallbacks(runnable);
}
}

View File

@@ -0,0 +1,11 @@
package androidx.work.impl;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.work.impl.model.WorkGenerationalId;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public interface ExecutionListener {
void onExecuted(@NonNull WorkGenerationalId workGenerationalId, boolean z);
}

View File

@@ -0,0 +1,20 @@
package androidx.work.impl;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class Migration_11_12 extends Migration {
public static final Migration_11_12 INSTANCE = new Migration_11_12();
private Migration_11_12() {
super(11, 12);
}
@Override // androidx.room.migration.Migration
public void migrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
db.execSQL("ALTER TABLE workspec ADD COLUMN `out_of_quota_policy` INTEGER NOT NULL DEFAULT 0");
}
}

View File

@@ -0,0 +1,21 @@
package androidx.work.impl;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class Migration_12_13 extends Migration {
public static final Migration_12_13 INSTANCE = new Migration_12_13();
private Migration_12_13() {
super(12, 13);
}
@Override // androidx.room.migration.Migration
public void migrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
db.execSQL("UPDATE workspec SET required_network_type = 0 WHERE required_network_type IS NULL ");
db.execSQL("UPDATE workspec SET content_uri_triggers = x'' WHERE content_uri_triggers is NULL");
}
}

View File

@@ -0,0 +1,25 @@
package androidx.work.impl;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class Migration_15_16 extends Migration {
public static final Migration_15_16 INSTANCE = new Migration_15_16();
private Migration_15_16() {
super(15, 16);
}
@Override // androidx.room.migration.Migration
public void migrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
db.execSQL("DELETE FROM SystemIdInfo WHERE work_spec_id IN (SELECT work_spec_id FROM SystemIdInfo LEFT JOIN WorkSpec ON work_spec_id = id WHERE WorkSpec.id IS NULL)");
db.execSQL("ALTER TABLE `WorkSpec` ADD COLUMN `generation` INTEGER NOT NULL DEFAULT 0");
db.execSQL("CREATE TABLE IF NOT EXISTS `_new_SystemIdInfo` (\n `work_spec_id` TEXT NOT NULL, \n `generation` INTEGER NOT NULL DEFAULT 0, \n `system_id` INTEGER NOT NULL, \n PRIMARY KEY(`work_spec_id`, `generation`), \n FOREIGN KEY(`work_spec_id`) REFERENCES `WorkSpec`(`id`) \n ON UPDATE CASCADE ON DELETE CASCADE )");
db.execSQL("INSERT INTO `_new_SystemIdInfo` (`work_spec_id`,`system_id`) SELECT `work_spec_id`,`system_id` FROM `SystemIdInfo`");
db.execSQL("DROP TABLE `SystemIdInfo`");
db.execSQL("ALTER TABLE `_new_SystemIdInfo` RENAME TO `SystemIdInfo`");
}
}

View File

@@ -0,0 +1,30 @@
package androidx.work.impl;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.work.OverwritingInputMerger;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt__IndentKt;
/* loaded from: classes.dex */
public final class Migration_16_17 extends Migration {
public static final Migration_16_17 INSTANCE = new Migration_16_17();
private Migration_16_17() {
super(16, 17);
}
@Override // androidx.room.migration.Migration
public void migrate(SupportSQLiteDatabase db) {
String trimIndent;
Intrinsics.checkNotNullParameter(db, "db");
trimIndent = StringsKt__IndentKt.trimIndent("UPDATE WorkSpec\n SET input_merger_class_name = '" + OverwritingInputMerger.class.getName() + "'\n WHERE input_merger_class_name IS NULL\n ");
db.execSQL(trimIndent);
db.execSQL("CREATE TABLE IF NOT EXISTS `_new_WorkSpec` (\n `id` TEXT NOT NULL,\n `state` INTEGER NOT NULL,\n `worker_class_name` TEXT NOT NULL,\n `input_merger_class_name` TEXT NOT NULL,\n `input` BLOB NOT NULL,\n `output` BLOB NOT NULL,\n `initial_delay` INTEGER NOT NULL,\n `interval_duration` INTEGER NOT NULL,\n `flex_duration` INTEGER NOT NULL,\n `run_attempt_count` INTEGER NOT NULL,\n `backoff_policy` INTEGER NOT NULL,\n `backoff_delay_duration` INTEGER NOT NULL,\n `last_enqueue_time` INTEGER NOT NULL,\n `minimum_retention_duration` INTEGER NOT NULL,\n `schedule_requested_at` INTEGER NOT NULL,\n `run_in_foreground` INTEGER NOT NULL,\n `out_of_quota_policy` INTEGER NOT NULL,\n `period_count` INTEGER NOT NULL DEFAULT 0,\n `generation` INTEGER NOT NULL DEFAULT 0,\n `required_network_type` INTEGER NOT NULL,\n `requires_charging` INTEGER NOT NULL,\n `requires_device_idle` INTEGER NOT NULL,\n `requires_battery_not_low` INTEGER NOT NULL,\n `requires_storage_not_low` INTEGER NOT NULL,\n `trigger_content_update_delay` INTEGER NOT NULL,\n `trigger_max_content_delay` INTEGER NOT NULL,\n `content_uri_triggers` BLOB NOT NULL,\n PRIMARY KEY(`id`)\n )");
db.execSQL("INSERT INTO `_new_WorkSpec` (\n `id`,\n `state`,\n `worker_class_name`,\n `input_merger_class_name`,\n `input`,\n `output`,\n `initial_delay`,\n `interval_duration`,\n `flex_duration`,\n `run_attempt_count`,\n `backoff_policy`,\n `backoff_delay_duration`,\n `last_enqueue_time`,\n `minimum_retention_duration`,\n `schedule_requested_at`,\n `run_in_foreground`,\n `out_of_quota_policy`,\n `period_count`,\n `generation`,\n `required_network_type`,\n `requires_charging`,\n `requires_device_idle`,\n `requires_battery_not_low`,\n `requires_storage_not_low`,\n `trigger_content_update_delay`,\n `trigger_max_content_delay`,\n `content_uri_triggers`\n ) SELECT\n `id`,\n `state`,\n `worker_class_name`,\n `input_merger_class_name`,\n `input`,\n `output`,\n `initial_delay`,\n `interval_duration`,\n `flex_duration`,\n `run_attempt_count`,\n `backoff_policy`,\n `backoff_delay_duration`,\n `last_enqueue_time`,\n `minimum_retention_duration`,\n `schedule_requested_at`,\n `run_in_foreground`,\n `out_of_quota_policy`,\n `period_count`,\n `generation`,\n `required_network_type`,\n `requires_charging`,\n `requires_device_idle`,\n `requires_battery_not_low`,\n `requires_storage_not_low`,\n `trigger_content_update_delay`,\n `trigger_max_content_delay`,\n `content_uri_triggers`\n FROM `WorkSpec`");
db.execSQL("DROP TABLE `WorkSpec`");
db.execSQL("ALTER TABLE `_new_WorkSpec` RENAME TO `WorkSpec`");
db.execSQL("CREATE INDEX IF NOT EXISTS `index_WorkSpec_schedule_requested_at`ON `WorkSpec` (`schedule_requested_at`)");
db.execSQL("CREATE INDEX IF NOT EXISTS `index_WorkSpec_last_enqueue_time` ON`WorkSpec` (`last_enqueue_time`)");
}
}

View File

@@ -0,0 +1,23 @@
package androidx.work.impl;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class Migration_1_2 extends Migration {
public static final Migration_1_2 INSTANCE = new Migration_1_2();
private Migration_1_2() {
super(1, 2);
}
@Override // androidx.room.migration.Migration
public void migrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
db.execSQL("\n CREATE TABLE IF NOT EXISTS `SystemIdInfo` (`work_spec_id` TEXT NOT NULL, `system_id`\n INTEGER NOT NULL, PRIMARY KEY(`work_spec_id`), FOREIGN KEY(`work_spec_id`)\n REFERENCES `WorkSpec`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )\n ");
db.execSQL("\n INSERT INTO SystemIdInfo(work_spec_id, system_id)\n SELECT work_spec_id, alarm_id AS system_id FROM alarmInfo\n ");
db.execSQL("DROP TABLE IF EXISTS alarmInfo");
db.execSQL("\n INSERT OR IGNORE INTO worktag(tag, work_spec_id)\n SELECT worker_class_name AS tag, id AS work_spec_id FROM workspec\n ");
}
}

View File

@@ -0,0 +1,20 @@
package androidx.work.impl;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class Migration_3_4 extends Migration {
public static final Migration_3_4 INSTANCE = new Migration_3_4();
private Migration_3_4() {
super(3, 4);
}
@Override // androidx.room.migration.Migration
public void migrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
db.execSQL("\n UPDATE workspec SET schedule_requested_at = 0\n WHERE state NOT IN (2, 3, 5)\n AND schedule_requested_at = -1\n AND interval_duration <> 0\n ");
}
}

View File

@@ -0,0 +1,21 @@
package androidx.work.impl;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class Migration_4_5 extends Migration {
public static final Migration_4_5 INSTANCE = new Migration_4_5();
private Migration_4_5() {
super(4, 5);
}
@Override // androidx.room.migration.Migration
public void migrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
db.execSQL("ALTER TABLE workspec ADD COLUMN `trigger_content_update_delay` INTEGER NOT NULL DEFAULT -1");
db.execSQL("ALTER TABLE workspec ADD COLUMN `trigger_max_content_delay` INTEGER NOT NULL DEFAULT -1");
}
}

View File

@@ -0,0 +1,20 @@
package androidx.work.impl;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class Migration_6_7 extends Migration {
public static final Migration_6_7 INSTANCE = new Migration_6_7();
private Migration_6_7() {
super(6, 7);
}
@Override // androidx.room.migration.Migration
public void migrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
db.execSQL("\n CREATE TABLE IF NOT EXISTS `WorkProgress` (`work_spec_id` TEXT NOT NULL, `progress`\n BLOB NOT NULL, PRIMARY KEY(`work_spec_id`), FOREIGN KEY(`work_spec_id`)\n REFERENCES `WorkSpec`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )\n ");
}
}

View File

@@ -0,0 +1,20 @@
package androidx.work.impl;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class Migration_7_8 extends Migration {
public static final Migration_7_8 INSTANCE = new Migration_7_8();
private Migration_7_8() {
super(7, 8);
}
@Override // androidx.room.migration.Migration
public void migrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
db.execSQL("\n CREATE INDEX IF NOT EXISTS `index_WorkSpec_period_start_time` ON `workspec`(`period_start_time`)\n ");
}
}

View File

@@ -0,0 +1,20 @@
package androidx.work.impl;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class Migration_8_9 extends Migration {
public static final Migration_8_9 INSTANCE = new Migration_8_9();
private Migration_8_9() {
super(8, 9);
}
@Override // androidx.room.migration.Migration
public void migrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
db.execSQL("ALTER TABLE workspec ADD COLUMN `run_in_foreground` INTEGER NOT NULL DEFAULT 0");
}
}

View File

@@ -0,0 +1,335 @@
package androidx.work.impl;
import android.content.Context;
import android.os.PowerManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.core.content.ContextCompat;
import androidx.work.Configuration;
import androidx.work.ForegroundInfo;
import androidx.work.Logger;
import androidx.work.WorkerParameters;
import androidx.work.impl.WorkerWrapper;
import androidx.work.impl.foreground.ForegroundProcessor;
import androidx.work.impl.foreground.SystemForegroundDispatcher;
import androidx.work.impl.model.WorkGenerationalId;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.utils.WakeLocks;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class Processor implements ForegroundProcessor {
private static final String FOREGROUND_WAKELOCK_TAG = "ProcessorForegroundLck";
private static final String TAG = Logger.tagWithPrefix("Processor");
private Context mAppContext;
private Configuration mConfiguration;
private WorkDatabase mWorkDatabase;
private TaskExecutor mWorkTaskExecutor;
private Map<String, WorkerWrapper> mEnqueuedWorkMap = new HashMap();
private Map<String, WorkerWrapper> mForegroundWorkMap = new HashMap();
private Set<String> mCancelledIds = new HashSet();
private final List<ExecutionListener> mOuterListeners = new ArrayList();
@Nullable
private PowerManager.WakeLock mForegroundLock = null;
private final Object mLock = new Object();
private Map<String, Set<StartStopToken>> mWorkRuns = new HashMap();
public Processor(@NonNull Context context, @NonNull Configuration configuration, @NonNull TaskExecutor taskExecutor, @NonNull WorkDatabase workDatabase) {
this.mAppContext = context;
this.mConfiguration = configuration;
this.mWorkTaskExecutor = taskExecutor;
this.mWorkDatabase = workDatabase;
}
public boolean startWork(@NonNull StartStopToken startStopToken) {
return startWork(startStopToken, null);
}
public boolean startWork(@NonNull StartStopToken startStopToken, @Nullable WorkerParameters.RuntimeExtras runtimeExtras) {
WorkGenerationalId id = startStopToken.getId();
final String workSpecId = id.getWorkSpecId();
final ArrayList arrayList = new ArrayList();
WorkSpec workSpec = (WorkSpec) this.mWorkDatabase.runInTransaction(new Callable() { // from class: androidx.work.impl.Processor$$ExternalSyntheticLambda0
@Override // java.util.concurrent.Callable
public final Object call() {
WorkSpec lambda$startWork$0;
lambda$startWork$0 = Processor.this.lambda$startWork$0(arrayList, workSpecId);
return lambda$startWork$0;
}
});
if (workSpec == null) {
Logger.get().warning(TAG, "Didn't find WorkSpec for id " + id);
runOnExecuted(id, false);
return false;
}
synchronized (this.mLock) {
try {
if (isEnqueued(workSpecId)) {
Set<StartStopToken> set = this.mWorkRuns.get(workSpecId);
if (set.iterator().next().getId().getGeneration() == id.getGeneration()) {
set.add(startStopToken);
Logger.get().debug(TAG, "Work " + id + " is already enqueued for processing");
} else {
runOnExecuted(id, false);
}
return false;
}
if (workSpec.getGeneration() != id.getGeneration()) {
runOnExecuted(id, false);
return false;
}
final WorkerWrapper build = new WorkerWrapper.Builder(this.mAppContext, this.mConfiguration, this.mWorkTaskExecutor, this, this.mWorkDatabase, workSpec, arrayList).withRuntimeExtras(runtimeExtras).build();
final ListenableFuture launch = build.launch();
launch.addListener(new Runnable() { // from class: androidx.work.impl.Processor$$ExternalSyntheticLambda1
@Override // java.lang.Runnable
public final void run() {
Processor.this.lambda$startWork$1(launch, build);
}
}, this.mWorkTaskExecutor.getMainThreadExecutor());
this.mEnqueuedWorkMap.put(workSpecId, build);
HashSet hashSet = new HashSet();
hashSet.add(startStopToken);
this.mWorkRuns.put(workSpecId, hashSet);
Logger.get().debug(TAG, getClass().getSimpleName() + ": processing " + id);
return true;
} catch (Throwable th) {
throw th;
}
}
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ WorkSpec lambda$startWork$0(ArrayList arrayList, String str) throws Exception {
arrayList.addAll(this.mWorkDatabase.workTagDao().getTagsForWorkSpecId(str));
return this.mWorkDatabase.workSpecDao().getWorkSpec(str);
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ void lambda$startWork$1(ListenableFuture listenableFuture, WorkerWrapper workerWrapper) {
boolean z;
try {
z = ((Boolean) listenableFuture.get()).booleanValue();
} catch (InterruptedException | ExecutionException unused) {
z = true;
}
onExecuted(workerWrapper, z);
}
@Override // androidx.work.impl.foreground.ForegroundProcessor
public void startForeground(@NonNull String str, @NonNull ForegroundInfo foregroundInfo) {
synchronized (this.mLock) {
try {
Logger.get().info(TAG, "Moving WorkSpec (" + str + ") to the foreground");
WorkerWrapper remove = this.mEnqueuedWorkMap.remove(str);
if (remove != null) {
if (this.mForegroundLock == null) {
PowerManager.WakeLock newWakeLock = WakeLocks.newWakeLock(this.mAppContext, FOREGROUND_WAKELOCK_TAG);
this.mForegroundLock = newWakeLock;
newWakeLock.acquire();
}
this.mForegroundWorkMap.put(str, remove);
ContextCompat.startForegroundService(this.mAppContext, SystemForegroundDispatcher.createStartForegroundIntent(this.mAppContext, remove.getWorkGenerationalId(), foregroundInfo));
}
} catch (Throwable th) {
throw th;
}
}
}
public boolean stopForegroundWork(@NonNull StartStopToken startStopToken, int i) {
WorkerWrapper cleanUpWorkerUnsafe;
String workSpecId = startStopToken.getId().getWorkSpecId();
synchronized (this.mLock) {
cleanUpWorkerUnsafe = cleanUpWorkerUnsafe(workSpecId);
}
return interrupt(workSpecId, cleanUpWorkerUnsafe, i);
}
public boolean stopWork(@NonNull StartStopToken startStopToken, int i) {
String workSpecId = startStopToken.getId().getWorkSpecId();
synchronized (this.mLock) {
try {
if (this.mForegroundWorkMap.get(workSpecId) != null) {
Logger.get().debug(TAG, "Ignored stopWork. WorkerWrapper " + workSpecId + " is in foreground");
return false;
}
Set<StartStopToken> set = this.mWorkRuns.get(workSpecId);
if (set != null && set.contains(startStopToken)) {
return interrupt(workSpecId, cleanUpWorkerUnsafe(workSpecId), i);
}
return false;
} finally {
}
}
}
public boolean stopAndCancelWork(@NonNull String str, int i) {
WorkerWrapper cleanUpWorkerUnsafe;
synchronized (this.mLock) {
Logger.get().debug(TAG, "Processor cancelling " + str);
this.mCancelledIds.add(str);
cleanUpWorkerUnsafe = cleanUpWorkerUnsafe(str);
}
return interrupt(str, cleanUpWorkerUnsafe, i);
}
public boolean isCancelled(@NonNull String str) {
boolean contains;
synchronized (this.mLock) {
contains = this.mCancelledIds.contains(str);
}
return contains;
}
public boolean hasWork() {
boolean z;
synchronized (this.mLock) {
try {
z = (this.mEnqueuedWorkMap.isEmpty() && this.mForegroundWorkMap.isEmpty()) ? false : true;
} finally {
}
}
return z;
}
public boolean isEnqueued(@NonNull String str) {
boolean z;
synchronized (this.mLock) {
z = getWorkerWrapperUnsafe(str) != null;
}
return z;
}
public void addExecutionListener(@NonNull ExecutionListener executionListener) {
synchronized (this.mLock) {
this.mOuterListeners.add(executionListener);
}
}
public void removeExecutionListener(@NonNull ExecutionListener executionListener) {
synchronized (this.mLock) {
this.mOuterListeners.remove(executionListener);
}
}
private void onExecuted(@NonNull WorkerWrapper workerWrapper, boolean z) {
synchronized (this.mLock) {
try {
WorkGenerationalId workGenerationalId = workerWrapper.getWorkGenerationalId();
String workSpecId = workGenerationalId.getWorkSpecId();
if (getWorkerWrapperUnsafe(workSpecId) == workerWrapper) {
cleanUpWorkerUnsafe(workSpecId);
}
Logger.get().debug(TAG, getClass().getSimpleName() + " " + workSpecId + " executed; reschedule = " + z);
Iterator<ExecutionListener> it = this.mOuterListeners.iterator();
while (it.hasNext()) {
it.next().onExecuted(workGenerationalId, z);
}
} catch (Throwable th) {
throw th;
}
}
}
@Nullable
private WorkerWrapper getWorkerWrapperUnsafe(@NonNull String str) {
WorkerWrapper workerWrapper = this.mForegroundWorkMap.get(str);
return workerWrapper == null ? this.mEnqueuedWorkMap.get(str) : workerWrapper;
}
@Nullable
public WorkSpec getRunningWorkSpec(@NonNull String str) {
synchronized (this.mLock) {
try {
WorkerWrapper workerWrapperUnsafe = getWorkerWrapperUnsafe(str);
if (workerWrapperUnsafe == null) {
return null;
}
return workerWrapperUnsafe.getWorkSpec();
} catch (Throwable th) {
throw th;
}
}
}
private void runOnExecuted(@NonNull final WorkGenerationalId workGenerationalId, final boolean z) {
this.mWorkTaskExecutor.getMainThreadExecutor().execute(new Runnable() { // from class: androidx.work.impl.Processor$$ExternalSyntheticLambda2
@Override // java.lang.Runnable
public final void run() {
Processor.this.lambda$runOnExecuted$2(workGenerationalId, z);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ void lambda$runOnExecuted$2(WorkGenerationalId workGenerationalId, boolean z) {
synchronized (this.mLock) {
try {
Iterator<ExecutionListener> it = this.mOuterListeners.iterator();
while (it.hasNext()) {
it.next().onExecuted(workGenerationalId, z);
}
} catch (Throwable th) {
throw th;
}
}
}
private void stopForegroundService() {
synchronized (this.mLock) {
try {
if (!(!this.mForegroundWorkMap.isEmpty())) {
try {
this.mAppContext.startService(SystemForegroundDispatcher.createStopForegroundIntent(this.mAppContext));
} catch (Throwable th) {
Logger.get().error(TAG, "Unable to stop foreground service", th);
}
PowerManager.WakeLock wakeLock = this.mForegroundLock;
if (wakeLock != null) {
wakeLock.release();
this.mForegroundLock = null;
}
}
} catch (Throwable th2) {
throw th2;
}
}
}
@Nullable
private WorkerWrapper cleanUpWorkerUnsafe(@NonNull String str) {
WorkerWrapper remove = this.mForegroundWorkMap.remove(str);
boolean z = remove != null;
if (!z) {
remove = this.mEnqueuedWorkMap.remove(str);
}
this.mWorkRuns.remove(str);
if (z) {
stopForegroundService();
}
return remove;
}
private static boolean interrupt(@NonNull String str, @Nullable WorkerWrapper workerWrapper, int i) {
if (workerWrapper != null) {
workerWrapper.interrupt(i);
Logger.get().debug(TAG, "WorkerWrapper interrupted for " + str);
return true;
}
Logger.get().debug(TAG, "WorkerWrapper could not be found for " + str);
return false;
}
}

View File

@@ -0,0 +1,33 @@
package androidx.work.impl;
import android.content.Context;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.work.impl.utils.PreferenceUtils;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class RescheduleMigration extends Migration {
private final Context mContext;
public final Context getMContext() {
return this.mContext;
}
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public RescheduleMigration(Context mContext, int i, int i2) {
super(i, i2);
Intrinsics.checkNotNullParameter(mContext, "mContext");
this.mContext = mContext;
}
@Override // androidx.room.migration.Migration
public void migrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
if (this.endVersion >= 10) {
db.execSQL(PreferenceUtils.INSERT_PREFERENCE, new Object[]{PreferenceUtils.KEY_RESCHEDULE_NEEDED, 1});
} else {
this.mContext.getSharedPreferences(PreferenceUtils.PREFERENCES_FILE_NAME, 0).edit().putBoolean(PreferenceUtils.KEY_RESCHEDULE_NEEDED, true).apply();
}
}
}

View File

@@ -0,0 +1,18 @@
package androidx.work.impl;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.work.impl.model.WorkSpec;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public interface Scheduler {
public static final int MAX_GREEDY_SCHEDULER_LIMIT = 200;
public static final int MAX_SCHEDULER_LIMIT = 50;
void cancel(@NonNull String str);
boolean hasLimitedSchedulingSlots();
void schedule(@NonNull WorkSpec... workSpecArr);
}

View File

@@ -0,0 +1,125 @@
package androidx.work.impl;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.work.Clock;
import androidx.work.Configuration;
import androidx.work.Logger;
import androidx.work.impl.background.systemjob.SystemJobScheduler;
import androidx.work.impl.background.systemjob.SystemJobService;
import androidx.work.impl.model.WorkGenerationalId;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.model.WorkSpecDao;
import androidx.work.impl.utils.PackageManagerHelper;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Executor;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class Schedulers {
public static final String GCM_SCHEDULER = "androidx.work.impl.background.gcm.GcmScheduler";
private static final String TAG = Logger.tagWithPrefix("Schedulers");
public static void registerRescheduling(@NonNull final List<Scheduler> list, @NonNull Processor processor, @NonNull final Executor executor, @NonNull final WorkDatabase workDatabase, @NonNull final Configuration configuration) {
processor.addExecutionListener(new ExecutionListener() { // from class: androidx.work.impl.Schedulers$$ExternalSyntheticLambda1
@Override // androidx.work.impl.ExecutionListener
public final void onExecuted(WorkGenerationalId workGenerationalId, boolean z) {
Schedulers.lambda$registerRescheduling$1(executor, list, configuration, workDatabase, workGenerationalId, z);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public static /* synthetic */ void lambda$registerRescheduling$1(Executor executor, final List list, final Configuration configuration, final WorkDatabase workDatabase, final WorkGenerationalId workGenerationalId, boolean z) {
executor.execute(new Runnable() { // from class: androidx.work.impl.Schedulers$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
Schedulers.lambda$registerRescheduling$0(list, workGenerationalId, configuration, workDatabase);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public static /* synthetic */ void lambda$registerRescheduling$0(List list, WorkGenerationalId workGenerationalId, Configuration configuration, WorkDatabase workDatabase) {
Iterator it = list.iterator();
while (it.hasNext()) {
((Scheduler) it.next()).cancel(workGenerationalId.getWorkSpecId());
}
schedule(configuration, workDatabase, list);
}
public static void schedule(@NonNull Configuration configuration, @NonNull WorkDatabase workDatabase, @Nullable List<Scheduler> list) {
if (list == null || list.size() == 0) {
return;
}
WorkSpecDao workSpecDao = workDatabase.workSpecDao();
workDatabase.beginTransaction();
try {
List<WorkSpec> eligibleWorkForSchedulingWithContentUris = workSpecDao.getEligibleWorkForSchedulingWithContentUris();
markScheduled(workSpecDao, configuration.getClock(), eligibleWorkForSchedulingWithContentUris);
List<WorkSpec> eligibleWorkForScheduling = workSpecDao.getEligibleWorkForScheduling(configuration.getMaxSchedulerLimit());
markScheduled(workSpecDao, configuration.getClock(), eligibleWorkForScheduling);
if (eligibleWorkForSchedulingWithContentUris != null) {
eligibleWorkForScheduling.addAll(eligibleWorkForSchedulingWithContentUris);
}
List<WorkSpec> allEligibleWorkSpecsForScheduling = workSpecDao.getAllEligibleWorkSpecsForScheduling(200);
workDatabase.setTransactionSuccessful();
workDatabase.endTransaction();
if (eligibleWorkForScheduling.size() > 0) {
WorkSpec[] workSpecArr = (WorkSpec[]) eligibleWorkForScheduling.toArray(new WorkSpec[eligibleWorkForScheduling.size()]);
for (Scheduler scheduler : list) {
if (scheduler.hasLimitedSchedulingSlots()) {
scheduler.schedule(workSpecArr);
}
}
}
if (allEligibleWorkSpecsForScheduling.size() > 0) {
WorkSpec[] workSpecArr2 = (WorkSpec[]) allEligibleWorkSpecsForScheduling.toArray(new WorkSpec[allEligibleWorkSpecsForScheduling.size()]);
for (Scheduler scheduler2 : list) {
if (!scheduler2.hasLimitedSchedulingSlots()) {
scheduler2.schedule(workSpecArr2);
}
}
}
} catch (Throwable th) {
workDatabase.endTransaction();
throw th;
}
}
@NonNull
public static Scheduler createBestAvailableBackgroundScheduler(@NonNull Context context, @NonNull WorkDatabase workDatabase, Configuration configuration) {
SystemJobScheduler systemJobScheduler = new SystemJobScheduler(context, workDatabase, configuration);
PackageManagerHelper.setComponentEnabled(context, SystemJobService.class, true);
Logger.get().debug(TAG, "Created SystemJobScheduler and enabled SystemJobService");
return systemJobScheduler;
}
@Nullable
private static Scheduler tryCreateGcmBasedScheduler(@NonNull Context context, Clock clock) {
try {
Scheduler scheduler = (Scheduler) Class.forName(GCM_SCHEDULER).getConstructor(Context.class, Clock.class).newInstance(context, clock);
Logger.get().debug(TAG, "Created androidx.work.impl.background.gcm.GcmScheduler");
return scheduler;
} catch (Throwable th) {
Logger.get().debug(TAG, "Unable to create GCM Scheduler", th);
return null;
}
}
private Schedulers() {
}
private static void markScheduled(WorkSpecDao workSpecDao, Clock clock, List<WorkSpec> list) {
if (list.size() > 0) {
long currentTimeMillis = clock.currentTimeMillis();
Iterator<WorkSpec> it = list.iterator();
while (it.hasNext()) {
workSpecDao.markWorkSpecScheduled(it.next().id, currentTimeMillis);
}
}
}
}

View File

@@ -0,0 +1,18 @@
package androidx.work.impl;
import androidx.work.impl.model.WorkGenerationalId;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class StartStopToken {
private final WorkGenerationalId id;
public final WorkGenerationalId getId() {
return this.id;
}
public StartStopToken(WorkGenerationalId id) {
Intrinsics.checkNotNullParameter(id, "id");
this.id = id;
}
}

View File

@@ -0,0 +1,61 @@
package androidx.work.impl;
import androidx.work.impl.model.WorkGenerationalId;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.model.WorkSpecKt;
import java.util.List;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public interface StartStopTokens {
public static final Companion Companion = Companion.$$INSTANCE;
static StartStopTokens create() {
return Companion.create();
}
static StartStopTokens create(boolean z) {
return Companion.create(z);
}
boolean contains(WorkGenerationalId workGenerationalId);
StartStopToken remove(WorkGenerationalId workGenerationalId);
List<StartStopToken> remove(String str);
StartStopToken tokenFor(WorkGenerationalId workGenerationalId);
default StartStopToken tokenFor(WorkSpec spec) {
Intrinsics.checkNotNullParameter(spec, "spec");
return tokenFor(WorkSpecKt.generationalId(spec));
}
default StartStopToken remove(WorkSpec spec) {
Intrinsics.checkNotNullParameter(spec, "spec");
return remove(WorkSpecKt.generationalId(spec));
}
public static final class Companion {
static final /* synthetic */ Companion $$INSTANCE = new Companion();
public final StartStopTokens create() {
return create$default(this, false, 1, null);
}
private Companion() {
}
public static /* synthetic */ StartStopTokens create$default(Companion companion, boolean z, int i, Object obj) {
if ((i & 1) != 0) {
z = true;
}
return companion.create(z);
}
public final StartStopTokens create(boolean z) {
StartStopTokensImpl startStopTokensImpl = new StartStopTokensImpl();
return z ? new SynchronizedStartStopTokensImpl(startStopTokensImpl) : startStopTokensImpl;
}
}
}

View File

@@ -0,0 +1,57 @@
package androidx.work.impl;
import androidx.work.impl.model.WorkGenerationalId;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import kotlin.collections.CollectionsKt___CollectionsKt;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
@SourceDebugExtension({"SMAP\nStartStopToken.kt\nKotlin\n*S Kotlin\n*F\n+ 1 StartStopToken.kt\nandroidx/work/impl/StartStopTokensImpl\n+ 2 Maps.kt\nkotlin/collections/MapsKt__MapsKt\n+ 3 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n*L\n1#1,104:1\n361#2,7:105\n467#2,7:112\n1855#3,2:119\n*S KotlinDebug\n*F\n+ 1 StartStopToken.kt\nandroidx/work/impl/StartStopTokensImpl\n*L\n65#1:105,7\n73#1:112,7\n74#1:119,2\n*E\n"})
/* loaded from: classes.dex */
final class StartStopTokensImpl implements StartStopTokens {
private final Map<WorkGenerationalId, StartStopToken> runs = new LinkedHashMap();
@Override // androidx.work.impl.StartStopTokens
public StartStopToken remove(WorkGenerationalId id) {
Intrinsics.checkNotNullParameter(id, "id");
return this.runs.remove(id);
}
@Override // androidx.work.impl.StartStopTokens
public boolean contains(WorkGenerationalId id) {
Intrinsics.checkNotNullParameter(id, "id");
return this.runs.containsKey(id);
}
@Override // androidx.work.impl.StartStopTokens
public StartStopToken tokenFor(WorkGenerationalId id) {
Intrinsics.checkNotNullParameter(id, "id");
Map<WorkGenerationalId, StartStopToken> map = this.runs;
StartStopToken startStopToken = map.get(id);
if (startStopToken == null) {
startStopToken = new StartStopToken(id);
map.put(id, startStopToken);
}
return startStopToken;
}
@Override // androidx.work.impl.StartStopTokens
public List<StartStopToken> remove(String workSpecId) {
Intrinsics.checkNotNullParameter(workSpecId, "workSpecId");
Map<WorkGenerationalId, StartStopToken> map = this.runs;
LinkedHashMap linkedHashMap = new LinkedHashMap();
for (Map.Entry<WorkGenerationalId, StartStopToken> entry : map.entrySet()) {
if (Intrinsics.areEqual(entry.getKey().getWorkSpecId(), workSpecId)) {
linkedHashMap.put(entry.getKey(), entry.getValue());
}
}
Iterator it = linkedHashMap.keySet().iterator();
while (it.hasNext()) {
this.runs.remove((WorkGenerationalId) it.next());
}
return CollectionsKt___CollectionsKt.toList(linkedHashMap.values());
}
}

View File

@@ -0,0 +1,59 @@
package androidx.work.impl;
import androidx.work.impl.model.WorkGenerationalId;
import java.util.List;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
@SourceDebugExtension({"SMAP\nStartStopToken.kt\nKotlin\n*S Kotlin\n*F\n+ 1 StartStopToken.kt\nandroidx/work/impl/SynchronizedStartStopTokensImpl\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,104:1\n1#2:105\n*E\n"})
/* loaded from: classes.dex */
final class SynchronizedStartStopTokensImpl implements StartStopTokens {
private final StartStopTokens delegate;
private final Object lock;
public SynchronizedStartStopTokensImpl(StartStopTokens delegate) {
Intrinsics.checkNotNullParameter(delegate, "delegate");
this.delegate = delegate;
this.lock = new Object();
}
@Override // androidx.work.impl.StartStopTokens
public StartStopToken tokenFor(WorkGenerationalId id) {
StartStopToken startStopToken;
Intrinsics.checkNotNullParameter(id, "id");
synchronized (this.lock) {
startStopToken = this.delegate.tokenFor(id);
}
return startStopToken;
}
@Override // androidx.work.impl.StartStopTokens
public StartStopToken remove(WorkGenerationalId id) {
StartStopToken remove;
Intrinsics.checkNotNullParameter(id, "id");
synchronized (this.lock) {
remove = this.delegate.remove(id);
}
return remove;
}
@Override // androidx.work.impl.StartStopTokens
public List<StartStopToken> remove(String workSpecId) {
List<StartStopToken> remove;
Intrinsics.checkNotNullParameter(workSpecId, "workSpecId");
synchronized (this.lock) {
remove = this.delegate.remove(workSpecId);
}
return remove;
}
@Override // androidx.work.impl.StartStopTokens
public boolean contains(WorkGenerationalId id) {
boolean contains;
Intrinsics.checkNotNullParameter(id, "id");
synchronized (this.lock) {
contains = this.delegate.contains(id);
}
return contains;
}
}

View File

@@ -0,0 +1,50 @@
package androidx.work.impl;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.ExecutionException;
import kotlin.Result;
import kotlin.ResultKt;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.CancellableContinuation;
/* loaded from: classes.dex */
final class ToContinuation<T> implements Runnable {
private final CancellableContinuation continuation;
private final ListenableFuture futureToObserve;
public final CancellableContinuation getContinuation() {
return this.continuation;
}
public final ListenableFuture getFutureToObserve() {
return this.futureToObserve;
}
public ToContinuation(ListenableFuture futureToObserve, CancellableContinuation continuation) {
Intrinsics.checkNotNullParameter(futureToObserve, "futureToObserve");
Intrinsics.checkNotNullParameter(continuation, "continuation");
this.futureToObserve = futureToObserve;
this.continuation = continuation;
}
@Override // java.lang.Runnable
public void run() {
Throwable nonNullCause;
Object uninterruptibly;
if (this.futureToObserve.isCancelled()) {
CancellableContinuation.DefaultImpls.cancel$default(this.continuation, null, 1, null);
return;
}
try {
CancellableContinuation cancellableContinuation = this.continuation;
Result.Companion companion = Result.Companion;
uninterruptibly = WorkerWrapperKt.getUninterruptibly(this.futureToObserve);
cancellableContinuation.resumeWith(Result.m4060constructorimpl(uninterruptibly));
} catch (ExecutionException e) {
CancellableContinuation cancellableContinuation2 = this.continuation;
Result.Companion companion2 = Result.Companion;
nonNullCause = WorkerWrapperKt.nonNullCause(e);
cancellableContinuation2.resumeWith(Result.m4060constructorimpl(ResultKt.createFailure(nonNullCause)));
}
}
}

View File

@@ -0,0 +1,67 @@
package androidx.work.impl;
import androidx.work.Logger;
import com.fyber.inneractive.sdk.bidder.TokenParametersOuterClass$TokenParameters;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.Boxing;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function4;
import kotlinx.coroutines.DelayKt;
import kotlinx.coroutines.flow.FlowCollector;
@DebugMetadata(c = "androidx.work.impl.UnfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$1", f = "UnfinishedWorkListener.kt", l = {TokenParametersOuterClass$TokenParameters.PRIORCLICKS_FIELD_NUMBER}, m = "invokeSuspend")
/* loaded from: classes.dex */
public final class UnfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$1 extends SuspendLambda implements Function4 {
/* synthetic */ long J$0;
/* synthetic */ Object L$0;
int label;
public UnfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$1(Continuation continuation) {
super(4, continuation);
}
@Override // kotlin.jvm.functions.Function4
public /* bridge */ /* synthetic */ Object invoke(Object obj, Object obj2, Object obj3, Object obj4) {
return invoke((FlowCollector) obj, (Throwable) obj2, ((Number) obj3).longValue(), (Continuation) obj4);
}
public final Object invoke(FlowCollector flowCollector, Throwable th, long j, Continuation continuation) {
UnfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$1 unfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$1 = new UnfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$1(continuation);
unfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$1.L$0 = th;
unfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$1.J$0 = j;
return unfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$1.invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
String str;
long j;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
Throwable th = (Throwable) this.L$0;
long j2 = this.J$0;
Logger logger = Logger.get();
str = UnfinishedWorkListenerKt.TAG;
logger.error(str, "Cannot check for unfinished work", th);
j = UnfinishedWorkListenerKt.MAX_DELAY_MS;
long min = Math.min(j2 * 30000, j);
this.label = 1;
if (DelayKt.delay(min, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
return Boxing.boxBoolean(true);
}
}

View File

@@ -0,0 +1,53 @@
package androidx.work.impl;
import android.content.Context;
import androidx.work.impl.background.systemalarm.RescheduleReceiver;
import androidx.work.impl.utils.PackageManagerHelper;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
@DebugMetadata(c = "androidx.work.impl.UnfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$2", f = "UnfinishedWorkListener.kt", l = {}, m = "invokeSuspend")
/* loaded from: classes.dex */
public final class UnfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$2 extends SuspendLambda implements Function2 {
final /* synthetic */ Context $appContext;
/* synthetic */ boolean Z$0;
int label;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public UnfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$2(Context context, Continuation continuation) {
super(2, continuation);
this.$appContext = context;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
UnfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$2 unfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$2 = new UnfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$2(this.$appContext, continuation);
unfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$2.Z$0 = ((Boolean) obj).booleanValue();
return unfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$2;
}
@Override // kotlin.jvm.functions.Function2
public /* bridge */ /* synthetic */ Object invoke(Object obj, Object obj2) {
return invoke(((Boolean) obj).booleanValue(), (Continuation) obj2);
}
public final Object invoke(boolean z, Continuation continuation) {
return ((UnfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$2) create(Boolean.valueOf(z), continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
if (this.label == 0) {
ResultKt.throwOnFailure(obj);
PackageManagerHelper.setComponentEnabled(this.$appContext, RescheduleReceiver.class, this.Z$0);
return Unit.INSTANCE;
}
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
}

View File

@@ -0,0 +1,34 @@
package androidx.work.impl;
import android.content.Context;
import androidx.work.Configuration;
import androidx.work.Logger;
import androidx.work.impl.utils.ProcessUtils;
import java.util.concurrent.TimeUnit;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.flow.FlowKt;
/* loaded from: classes.dex */
public final class UnfinishedWorkListenerKt {
private static final int DELAY_MS = 30000;
private static final long MAX_DELAY_MS;
private static final String TAG;
static {
String tagWithPrefix = Logger.tagWithPrefix("UnfinishedWorkListener");
Intrinsics.checkNotNullExpressionValue(tagWithPrefix, "tagWithPrefix(\"UnfinishedWorkListener\")");
TAG = tagWithPrefix;
MAX_DELAY_MS = TimeUnit.HOURS.toMillis(1L);
}
public static final void maybeLaunchUnfinishedWorkListener(CoroutineScope coroutineScope, Context appContext, Configuration configuration, WorkDatabase db) {
Intrinsics.checkNotNullParameter(coroutineScope, "<this>");
Intrinsics.checkNotNullParameter(appContext, "appContext");
Intrinsics.checkNotNullParameter(configuration, "configuration");
Intrinsics.checkNotNullParameter(db, "db");
if (ProcessUtils.isDefaultProcess(appContext, configuration)) {
FlowKt.launchIn(FlowKt.onEach(FlowKt.distinctUntilChanged(FlowKt.conflate(FlowKt.retryWhen(db.workSpecDao().hasUnfinishedWorkFlow(), new UnfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$1(null)))), new UnfinishedWorkListenerKt$maybeLaunchUnfinishedWorkListener$2(appContext, null)), coroutineScope);
}
}
}

View File

@@ -0,0 +1,215 @@
package androidx.work.impl;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.lifecycle.LiveData;
import androidx.work.ArrayCreatingInputMerger;
import androidx.work.ExistingWorkPolicy;
import androidx.work.ListenableWorker;
import androidx.work.Logger;
import androidx.work.OneTimeWorkRequest;
import androidx.work.Operation;
import androidx.work.OperationKt;
import androidx.work.WorkContinuation;
import androidx.work.WorkInfo;
import androidx.work.WorkRequest;
import androidx.work.impl.utils.EnqueueRunnable;
import androidx.work.impl.utils.StatusRunnable;
import androidx.work.impl.workers.CombineContinuationsWorker;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class WorkContinuationImpl extends WorkContinuation {
private static final String TAG = Logger.tagWithPrefix("WorkContinuationImpl");
private final List<String> mAllIds;
private boolean mEnqueued;
private final ExistingWorkPolicy mExistingWorkPolicy;
private final List<String> mIds;
private final String mName;
private Operation mOperation;
private final List<WorkContinuationImpl> mParents;
private final List<? extends WorkRequest> mWork;
private final WorkManagerImpl mWorkManagerImpl;
@NonNull
public List<String> getAllIds() {
return this.mAllIds;
}
@NonNull
public ExistingWorkPolicy getExistingWorkPolicy() {
return this.mExistingWorkPolicy;
}
@NonNull
public List<String> getIds() {
return this.mIds;
}
@Nullable
public String getName() {
return this.mName;
}
@Nullable
public List<WorkContinuationImpl> getParents() {
return this.mParents;
}
@NonNull
public List<? extends WorkRequest> getWork() {
return this.mWork;
}
@NonNull
public WorkManagerImpl getWorkManagerImpl() {
return this.mWorkManagerImpl;
}
public boolean isEnqueued() {
return this.mEnqueued;
}
public void markEnqueued() {
this.mEnqueued = true;
}
public WorkContinuationImpl(@NonNull WorkManagerImpl workManagerImpl, @NonNull List<? extends WorkRequest> list) {
this(workManagerImpl, null, ExistingWorkPolicy.KEEP, list, null);
}
public WorkContinuationImpl(@NonNull WorkManagerImpl workManagerImpl, @Nullable String str, @NonNull ExistingWorkPolicy existingWorkPolicy, @NonNull List<? extends WorkRequest> list) {
this(workManagerImpl, str, existingWorkPolicy, list, null);
}
public WorkContinuationImpl(@NonNull WorkManagerImpl workManagerImpl, @Nullable String str, @NonNull ExistingWorkPolicy existingWorkPolicy, @NonNull List<? extends WorkRequest> list, @Nullable List<WorkContinuationImpl> list2) {
this.mWorkManagerImpl = workManagerImpl;
this.mName = str;
this.mExistingWorkPolicy = existingWorkPolicy;
this.mWork = list;
this.mParents = list2;
this.mIds = new ArrayList(list.size());
this.mAllIds = new ArrayList();
if (list2 != null) {
Iterator<WorkContinuationImpl> it = list2.iterator();
while (it.hasNext()) {
this.mAllIds.addAll(it.next().mAllIds);
}
}
for (int i = 0; i < list.size(); i++) {
if (existingWorkPolicy == ExistingWorkPolicy.REPLACE && list.get(i).getWorkSpec().getNextScheduleTimeOverride() != Long.MAX_VALUE) {
throw new IllegalArgumentException("Next Schedule Time Override must be used with ExistingPeriodicWorkPolicyUPDATE (preferably) or KEEP");
}
String stringId = list.get(i).getStringId();
this.mIds.add(stringId);
this.mAllIds.add(stringId);
}
}
@Override // androidx.work.WorkContinuation
@NonNull
public WorkContinuation then(@NonNull List<OneTimeWorkRequest> list) {
return list.isEmpty() ? this : new WorkContinuationImpl(this.mWorkManagerImpl, this.mName, ExistingWorkPolicy.KEEP, list, Collections.singletonList(this));
}
@Override // androidx.work.WorkContinuation
@NonNull
public LiveData<List<WorkInfo>> getWorkInfosLiveData() {
return this.mWorkManagerImpl.getWorkInfosById(this.mAllIds);
}
@Override // androidx.work.WorkContinuation
@NonNull
public ListenableFuture getWorkInfos() {
return StatusRunnable.forStringIds(this.mWorkManagerImpl.getWorkDatabase(), this.mWorkManagerImpl.getWorkTaskExecutor(), this.mAllIds);
}
@Override // androidx.work.WorkContinuation
@NonNull
public Operation enqueue() {
if (!this.mEnqueued) {
this.mOperation = OperationKt.launchOperation(this.mWorkManagerImpl.getConfiguration().getTracer(), "EnqueueRunnable_" + getExistingWorkPolicy().name(), this.mWorkManagerImpl.getWorkTaskExecutor().getSerialTaskExecutor(), new Function0() { // from class: androidx.work.impl.WorkContinuationImpl$$ExternalSyntheticLambda0
@Override // kotlin.jvm.functions.Function0
public final Object invoke() {
Unit lambda$enqueue$0;
lambda$enqueue$0 = WorkContinuationImpl.this.lambda$enqueue$0();
return lambda$enqueue$0;
}
});
} else {
Logger.get().warning(TAG, "Already enqueued work ids (" + TextUtils.join(", ", this.mIds) + ")");
}
return this.mOperation;
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ Unit lambda$enqueue$0() {
EnqueueRunnable.enqueue(this);
return Unit.INSTANCE;
}
@Override // androidx.work.WorkContinuation
@NonNull
public WorkContinuation combineInternal(@NonNull List<WorkContinuation> list) {
OneTimeWorkRequest build = new OneTimeWorkRequest.Builder((Class<? extends ListenableWorker>) CombineContinuationsWorker.class).setInputMerger(ArrayCreatingInputMerger.class).build();
ArrayList arrayList = new ArrayList(list.size());
Iterator<WorkContinuation> it = list.iterator();
while (it.hasNext()) {
arrayList.add((WorkContinuationImpl) it.next());
}
return new WorkContinuationImpl(this.mWorkManagerImpl, null, ExistingWorkPolicy.KEEP, Collections.singletonList(build), arrayList);
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public boolean hasCycles() {
return hasCycles(this, new HashSet());
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
private static boolean hasCycles(@NonNull WorkContinuationImpl workContinuationImpl, @NonNull Set<String> set) {
set.addAll(workContinuationImpl.getIds());
Set<String> prerequisitesFor = prerequisitesFor(workContinuationImpl);
Iterator<String> it = set.iterator();
while (it.hasNext()) {
if (prerequisitesFor.contains(it.next())) {
return true;
}
}
List<WorkContinuationImpl> parents = workContinuationImpl.getParents();
if (parents != null && !parents.isEmpty()) {
Iterator<WorkContinuationImpl> it2 = parents.iterator();
while (it2.hasNext()) {
if (hasCycles(it2.next(), set)) {
return true;
}
}
}
set.removeAll(workContinuationImpl.getIds());
return false;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static Set<String> prerequisitesFor(@NonNull WorkContinuationImpl workContinuationImpl) {
HashSet hashSet = new HashSet();
List<WorkContinuationImpl> parents = workContinuationImpl.getParents();
if (parents != null && !parents.isEmpty()) {
Iterator<WorkContinuationImpl> it = parents.iterator();
while (it.hasNext()) {
hashSet.addAll(it.next().getIds());
}
}
return hashSet;
}
}

View File

@@ -0,0 +1,98 @@
package androidx.work.impl;
import android.content.Context;
import androidx.annotation.RestrictTo;
import androidx.room.AutoMigration;
import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.TypeConverters;
import androidx.sqlite.db.SupportSQLiteOpenHelper;
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory;
import androidx.work.Clock;
import androidx.work.Data;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.model.Dependency;
import androidx.work.impl.model.DependencyDao;
import androidx.work.impl.model.Preference;
import androidx.work.impl.model.PreferenceDao;
import androidx.work.impl.model.RawWorkInfoDao;
import androidx.work.impl.model.SystemIdInfo;
import androidx.work.impl.model.SystemIdInfoDao;
import androidx.work.impl.model.WorkName;
import androidx.work.impl.model.WorkNameDao;
import androidx.work.impl.model.WorkProgress;
import androidx.work.impl.model.WorkProgressDao;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.model.WorkSpecDao;
import androidx.work.impl.model.WorkTag;
import androidx.work.impl.model.WorkTagDao;
import androidx.work.impl.model.WorkTypeConverters;
import java.util.concurrent.Executor;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
@TypeConverters({Data.class, WorkTypeConverters.class})
@Database(autoMigrations = {@AutoMigration(from = 13, to = 14), @AutoMigration(from = 14, spec = AutoMigration_14_15.class, to = 15), @AutoMigration(from = 16, to = 17), @AutoMigration(from = 17, to = 18), @AutoMigration(from = 18, to = 19), @AutoMigration(from = 19, spec = AutoMigration_19_20.class, to = 20), @AutoMigration(from = 20, to = 21), @AutoMigration(from = 22, to = 23)}, entities = {Dependency.class, WorkSpec.class, WorkTag.class, SystemIdInfo.class, WorkName.class, WorkProgress.class, Preference.class}, version = 23)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public abstract class WorkDatabase extends RoomDatabase {
public static final Companion Companion = new Companion(null);
public static final WorkDatabase create(Context context, Executor executor, Clock clock, boolean z) {
return Companion.create(context, executor, clock, z);
}
public abstract DependencyDao dependencyDao();
public abstract PreferenceDao preferenceDao();
public abstract RawWorkInfoDao rawWorkInfoDao();
public abstract SystemIdInfoDao systemIdInfoDao();
public abstract WorkNameDao workNameDao();
public abstract WorkProgressDao workProgressDao();
public abstract WorkSpecDao workSpecDao();
public abstract WorkTagDao workTagDao();
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final WorkDatabase create(final Context context, Executor queryExecutor, Clock clock, boolean z) {
RoomDatabase.Builder openHelperFactory;
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(queryExecutor, "queryExecutor");
Intrinsics.checkNotNullParameter(clock, "clock");
if (z) {
openHelperFactory = Room.inMemoryDatabaseBuilder(context, WorkDatabase.class).allowMainThreadQueries();
} else {
openHelperFactory = Room.databaseBuilder(context, WorkDatabase.class, WorkDatabasePathHelperKt.WORK_DATABASE_NAME).openHelperFactory(new SupportSQLiteOpenHelper.Factory() { // from class: androidx.work.impl.WorkDatabase$Companion$$ExternalSyntheticLambda0
@Override // androidx.sqlite.db.SupportSQLiteOpenHelper.Factory
public final SupportSQLiteOpenHelper create(SupportSQLiteOpenHelper.Configuration configuration) {
SupportSQLiteOpenHelper create$lambda$0;
create$lambda$0 = WorkDatabase.Companion.create$lambda$0(context, configuration);
return create$lambda$0;
}
});
}
return (WorkDatabase) openHelperFactory.setQueryExecutor(queryExecutor).addCallback(new CleanupCallback(clock)).addMigrations(Migration_1_2.INSTANCE).addMigrations(new RescheduleMigration(context, 2, 3)).addMigrations(Migration_3_4.INSTANCE).addMigrations(Migration_4_5.INSTANCE).addMigrations(new RescheduleMigration(context, 5, 6)).addMigrations(Migration_6_7.INSTANCE).addMigrations(Migration_7_8.INSTANCE).addMigrations(Migration_8_9.INSTANCE).addMigrations(new WorkMigration9To10(context)).addMigrations(new RescheduleMigration(context, 10, 11)).addMigrations(Migration_11_12.INSTANCE).addMigrations(Migration_12_13.INSTANCE).addMigrations(Migration_15_16.INSTANCE).addMigrations(Migration_16_17.INSTANCE).addMigrations(new RescheduleMigration(context, 21, 22)).fallbackToDestructiveMigration().build();
}
/* JADX INFO: Access modifiers changed from: private */
public static final SupportSQLiteOpenHelper create$lambda$0(Context context, SupportSQLiteOpenHelper.Configuration configuration) {
Intrinsics.checkNotNullParameter(configuration, "configuration");
SupportSQLiteOpenHelper.Configuration.Builder builder = SupportSQLiteOpenHelper.Configuration.Companion.builder(context);
builder.name(configuration.name).callback(configuration.callback).noBackupDirectory(true).allowDataLossOnRecovery(true);
return new FrameworkSQLiteOpenHelperFactory().create(builder.build());
}
}
}

View File

@@ -0,0 +1,10 @@
package androidx.work.impl;
import java.util.concurrent.TimeUnit;
/* loaded from: classes.dex */
public final class WorkDatabaseKt {
private static final String PRUNE_SQL_FORMAT_PREFIX = "DELETE FROM workspec WHERE state IN (2, 3, 5) AND (last_enqueue_time + minimum_retention_duration) < ";
private static final String PRUNE_SQL_FORMAT_SUFFIX = " AND (SELECT COUNT(*)=0 FROM dependency WHERE prerequisite_id=id AND work_spec_id NOT IN (SELECT id FROM workspec WHERE state IN (2, 3, 5)))";
public static final long PRUNE_THRESHOLD_MILLIS = TimeUnit.DAYS.toMillis(1);
}

View File

@@ -0,0 +1,18 @@
package androidx.work.impl;
/* loaded from: classes.dex */
public final class WorkDatabaseMigrationsKt {
private static final String CREATE_INDEX_PERIOD_START_TIME = "\n CREATE INDEX IF NOT EXISTS `index_WorkSpec_period_start_time` ON `workspec`(`period_start_time`)\n ";
private static final String CREATE_OUT_OF_QUOTA_POLICY = "ALTER TABLE workspec ADD COLUMN `out_of_quota_policy` INTEGER NOT NULL DEFAULT 0";
private static final String CREATE_RUN_IN_FOREGROUND = "ALTER TABLE workspec ADD COLUMN `run_in_foreground` INTEGER NOT NULL DEFAULT 0";
private static final String CREATE_SYSTEM_ID_INFO = "\n CREATE TABLE IF NOT EXISTS `SystemIdInfo` (`work_spec_id` TEXT NOT NULL, `system_id`\n INTEGER NOT NULL, PRIMARY KEY(`work_spec_id`), FOREIGN KEY(`work_spec_id`)\n REFERENCES `WorkSpec`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )\n ";
private static final String CREATE_WORK_PROGRESS = "\n CREATE TABLE IF NOT EXISTS `WorkProgress` (`work_spec_id` TEXT NOT NULL, `progress`\n BLOB NOT NULL, PRIMARY KEY(`work_spec_id`), FOREIGN KEY(`work_spec_id`)\n REFERENCES `WorkSpec`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )\n ";
private static final String INITIALIZE_PERIOD_COUNTER = "UPDATE workspec SET period_count = 1 WHERE last_enqueue_time <> 0 AND interval_duration <> 0";
private static final String MIGRATE_ALARM_INFO_TO_SYSTEM_ID_INFO = "\n INSERT INTO SystemIdInfo(work_spec_id, system_id)\n SELECT work_spec_id, alarm_id AS system_id FROM alarmInfo\n ";
private static final String PERIODIC_WORK_SET_SCHEDULE_REQUESTED_AT = "\n UPDATE workspec SET schedule_requested_at = 0\n WHERE state NOT IN (2, 3, 5)\n AND schedule_requested_at = -1\n AND interval_duration <> 0\n ";
private static final String REMOVE_ALARM_INFO = "DROP TABLE IF EXISTS alarmInfo";
private static final String SET_DEFAULT_CONTENT_URI_TRIGGERS = "UPDATE workspec SET content_uri_triggers = x'' WHERE content_uri_triggers is NULL";
private static final String SET_DEFAULT_NETWORK_TYPE = "UPDATE workspec SET required_network_type = 0 WHERE required_network_type IS NULL ";
private static final String WORKSPEC_ADD_TRIGGER_MAX_CONTENT_DELAY = "ALTER TABLE workspec ADD COLUMN `trigger_max_content_delay` INTEGER NOT NULL DEFAULT -1";
private static final String WORKSPEC_ADD_TRIGGER_UPDATE_DELAY = "ALTER TABLE workspec ADD COLUMN `trigger_content_update_delay` INTEGER NOT NULL DEFAULT -1";
}

View File

@@ -0,0 +1,91 @@
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);
}
}

View File

@@ -0,0 +1,18 @@
package androidx.work.impl;
import androidx.work.Logger;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class WorkDatabasePathHelperKt {
private static final String[] DATABASE_EXTRA_FILES;
private static final String TAG;
public static final String WORK_DATABASE_NAME = "androidx.work.workdb";
static {
String tagWithPrefix = Logger.tagWithPrefix("WrkDbPathHelper");
Intrinsics.checkNotNullExpressionValue(tagWithPrefix, "tagWithPrefix(\"WrkDbPathHelper\")");
TAG = tagWithPrefix;
DATABASE_EXTRA_FILES = new String[]{"-journal", "-shm", "-wal"};
}
}

View File

@@ -0,0 +1,34 @@
package androidx.work.impl;
/* loaded from: classes.dex */
public final class WorkDatabaseVersions {
public static final WorkDatabaseVersions INSTANCE = new WorkDatabaseVersions();
public static final int VERSION_1 = 1;
public static final int VERSION_10 = 10;
public static final int VERSION_11 = 11;
public static final int VERSION_12 = 12;
public static final int VERSION_13 = 13;
public static final int VERSION_14 = 14;
public static final int VERSION_15 = 15;
public static final int VERSION_16 = 16;
public static final int VERSION_17 = 17;
public static final int VERSION_18 = 18;
public static final int VERSION_19 = 19;
public static final int VERSION_2 = 2;
public static final int VERSION_20 = 20;
public static final int VERSION_21 = 21;
public static final int VERSION_22 = 22;
public static final int VERSION_3 = 3;
public static final int VERSION_4 = 4;
public static final int VERSION_5 = 5;
public static final int VERSION_6 = 6;
public static final int VERSION_7 = 7;
public static final int VERSION_8 = 8;
public static final int VERSION_9 = 9;
public static /* synthetic */ void getVERSION_18$annotations() {
}
private WorkDatabaseVersions() {
}
}

View File

@@ -0,0 +1,22 @@
package androidx.work.impl;
import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/* loaded from: classes.dex */
final class WorkDatabase_AutoMigration_13_14_Impl extends Migration {
public WorkDatabase_AutoMigration_13_14_Impl() {
super(13, 14);
}
@Override // androidx.room.migration.Migration
public void migrate(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
supportSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS `_new_WorkSpec` (`id` TEXT NOT NULL, `state` INTEGER NOT NULL, `worker_class_name` TEXT NOT NULL, `input_merger_class_name` TEXT, `input` BLOB NOT NULL, `output` BLOB NOT NULL, `initial_delay` INTEGER NOT NULL, `interval_duration` INTEGER NOT NULL, `flex_duration` INTEGER NOT NULL, `run_attempt_count` INTEGER NOT NULL, `backoff_policy` INTEGER NOT NULL, `backoff_delay_duration` INTEGER NOT NULL, `period_start_time` INTEGER NOT NULL, `minimum_retention_duration` INTEGER NOT NULL, `schedule_requested_at` INTEGER NOT NULL, `run_in_foreground` INTEGER NOT NULL, `out_of_quota_policy` INTEGER NOT NULL, `required_network_type` INTEGER NOT NULL, `requires_charging` INTEGER NOT NULL, `requires_device_idle` INTEGER NOT NULL, `requires_battery_not_low` INTEGER NOT NULL, `requires_storage_not_low` INTEGER NOT NULL, `trigger_content_update_delay` INTEGER NOT NULL, `trigger_max_content_delay` INTEGER NOT NULL, `content_uri_triggers` BLOB NOT NULL, PRIMARY KEY(`id`))");
supportSQLiteDatabase.execSQL("INSERT INTO `_new_WorkSpec` (`id`,`state`,`worker_class_name`,`input_merger_class_name`,`input`,`output`,`initial_delay`,`interval_duration`,`flex_duration`,`run_attempt_count`,`backoff_policy`,`backoff_delay_duration`,`period_start_time`,`minimum_retention_duration`,`schedule_requested_at`,`run_in_foreground`,`out_of_quota_policy`,`required_network_type`,`requires_charging`,`requires_device_idle`,`requires_battery_not_low`,`requires_storage_not_low`,`trigger_content_update_delay`,`trigger_max_content_delay`,`content_uri_triggers`) SELECT `id`,`state`,`worker_class_name`,`input_merger_class_name`,`input`,`output`,`initial_delay`,`interval_duration`,`flex_duration`,`run_attempt_count`,`backoff_policy`,`backoff_delay_duration`,`period_start_time`,`minimum_retention_duration`,`schedule_requested_at`,`run_in_foreground`,`out_of_quota_policy`,`required_network_type`,`requires_charging`,`requires_device_idle`,`requires_battery_not_low`,`requires_storage_not_low`,`trigger_content_update_delay`,`trigger_max_content_delay`,`content_uri_triggers` FROM `WorkSpec`");
supportSQLiteDatabase.execSQL("DROP TABLE `WorkSpec`");
supportSQLiteDatabase.execSQL("ALTER TABLE `_new_WorkSpec` RENAME TO `WorkSpec`");
supportSQLiteDatabase.execSQL("CREATE INDEX IF NOT EXISTS `index_WorkSpec_schedule_requested_at` ON `WorkSpec` (`schedule_requested_at`)");
supportSQLiteDatabase.execSQL("CREATE INDEX IF NOT EXISTS `index_WorkSpec_period_start_time` ON `WorkSpec` (`period_start_time`)");
}
}

View File

@@ -0,0 +1,27 @@
package androidx.work.impl;
import androidx.annotation.NonNull;
import androidx.room.migration.AutoMigrationSpec;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/* loaded from: classes.dex */
final class WorkDatabase_AutoMigration_14_15_Impl extends Migration {
private final AutoMigrationSpec callback;
public WorkDatabase_AutoMigration_14_15_Impl() {
super(14, 15);
this.callback = new AutoMigration_14_15();
}
@Override // androidx.room.migration.Migration
public void migrate(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
supportSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS `_new_WorkSpec` (`id` TEXT NOT NULL, `state` INTEGER NOT NULL, `worker_class_name` TEXT NOT NULL, `input_merger_class_name` TEXT, `input` BLOB NOT NULL, `output` BLOB NOT NULL, `initial_delay` INTEGER NOT NULL, `interval_duration` INTEGER NOT NULL, `flex_duration` INTEGER NOT NULL, `run_attempt_count` INTEGER NOT NULL, `backoff_policy` INTEGER NOT NULL, `backoff_delay_duration` INTEGER NOT NULL, `last_enqueue_time` INTEGER NOT NULL, `minimum_retention_duration` INTEGER NOT NULL, `schedule_requested_at` INTEGER NOT NULL, `run_in_foreground` INTEGER NOT NULL, `out_of_quota_policy` INTEGER NOT NULL, `period_count` INTEGER NOT NULL DEFAULT 0, `required_network_type` INTEGER NOT NULL, `requires_charging` INTEGER NOT NULL, `requires_device_idle` INTEGER NOT NULL, `requires_battery_not_low` INTEGER NOT NULL, `requires_storage_not_low` INTEGER NOT NULL, `trigger_content_update_delay` INTEGER NOT NULL, `trigger_max_content_delay` INTEGER NOT NULL, `content_uri_triggers` BLOB NOT NULL, PRIMARY KEY(`id`))");
supportSQLiteDatabase.execSQL("INSERT INTO `_new_WorkSpec` (`id`,`state`,`worker_class_name`,`input_merger_class_name`,`input`,`output`,`initial_delay`,`interval_duration`,`flex_duration`,`run_attempt_count`,`backoff_policy`,`backoff_delay_duration`,`last_enqueue_time`,`minimum_retention_duration`,`schedule_requested_at`,`run_in_foreground`,`out_of_quota_policy`,`required_network_type`,`requires_charging`,`requires_device_idle`,`requires_battery_not_low`,`requires_storage_not_low`,`trigger_content_update_delay`,`trigger_max_content_delay`,`content_uri_triggers`) SELECT `id`,`state`,`worker_class_name`,`input_merger_class_name`,`input`,`output`,`initial_delay`,`interval_duration`,`flex_duration`,`run_attempt_count`,`backoff_policy`,`backoff_delay_duration`,`period_start_time`,`minimum_retention_duration`,`schedule_requested_at`,`run_in_foreground`,`out_of_quota_policy`,`required_network_type`,`requires_charging`,`requires_device_idle`,`requires_battery_not_low`,`requires_storage_not_low`,`trigger_content_update_delay`,`trigger_max_content_delay`,`content_uri_triggers` FROM `WorkSpec`");
supportSQLiteDatabase.execSQL("DROP TABLE `WorkSpec`");
supportSQLiteDatabase.execSQL("ALTER TABLE `_new_WorkSpec` RENAME TO `WorkSpec`");
supportSQLiteDatabase.execSQL("CREATE INDEX IF NOT EXISTS `index_WorkSpec_schedule_requested_at` ON `WorkSpec` (`schedule_requested_at`)");
supportSQLiteDatabase.execSQL("CREATE INDEX IF NOT EXISTS `index_WorkSpec_last_enqueue_time` ON `WorkSpec` (`last_enqueue_time`)");
this.callback.onPostMigrate(supportSQLiteDatabase);
}
}

View File

@@ -0,0 +1,22 @@
package androidx.work.impl;
import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/* loaded from: classes.dex */
final class WorkDatabase_AutoMigration_16_17_Impl extends Migration {
public WorkDatabase_AutoMigration_16_17_Impl() {
super(16, 17);
}
@Override // androidx.room.migration.Migration
public void migrate(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
supportSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS `_new_WorkSpec` (`id` TEXT NOT NULL, `state` INTEGER NOT NULL, `worker_class_name` TEXT NOT NULL, `input_merger_class_name` TEXT NOT NULL, `input` BLOB NOT NULL, `output` BLOB NOT NULL, `initial_delay` INTEGER NOT NULL, `interval_duration` INTEGER NOT NULL, `flex_duration` INTEGER NOT NULL, `run_attempt_count` INTEGER NOT NULL, `backoff_policy` INTEGER NOT NULL, `backoff_delay_duration` INTEGER NOT NULL, `last_enqueue_time` INTEGER NOT NULL, `minimum_retention_duration` INTEGER NOT NULL, `schedule_requested_at` INTEGER NOT NULL, `run_in_foreground` INTEGER NOT NULL, `out_of_quota_policy` INTEGER NOT NULL, `period_count` INTEGER NOT NULL DEFAULT 0, `generation` INTEGER NOT NULL DEFAULT 0, `required_network_type` INTEGER NOT NULL, `requires_charging` INTEGER NOT NULL, `requires_device_idle` INTEGER NOT NULL, `requires_battery_not_low` INTEGER NOT NULL, `requires_storage_not_low` INTEGER NOT NULL, `trigger_content_update_delay` INTEGER NOT NULL, `trigger_max_content_delay` INTEGER NOT NULL, `content_uri_triggers` BLOB NOT NULL, PRIMARY KEY(`id`))");
supportSQLiteDatabase.execSQL("INSERT INTO `_new_WorkSpec` (`id`,`state`,`worker_class_name`,`input_merger_class_name`,`input`,`output`,`initial_delay`,`interval_duration`,`flex_duration`,`run_attempt_count`,`backoff_policy`,`backoff_delay_duration`,`last_enqueue_time`,`minimum_retention_duration`,`schedule_requested_at`,`run_in_foreground`,`out_of_quota_policy`,`period_count`,`generation`,`required_network_type`,`requires_charging`,`requires_device_idle`,`requires_battery_not_low`,`requires_storage_not_low`,`trigger_content_update_delay`,`trigger_max_content_delay`,`content_uri_triggers`) SELECT `id`,`state`,`worker_class_name`,`input_merger_class_name`,`input`,`output`,`initial_delay`,`interval_duration`,`flex_duration`,`run_attempt_count`,`backoff_policy`,`backoff_delay_duration`,`last_enqueue_time`,`minimum_retention_duration`,`schedule_requested_at`,`run_in_foreground`,`out_of_quota_policy`,`period_count`,`generation`,`required_network_type`,`requires_charging`,`requires_device_idle`,`requires_battery_not_low`,`requires_storage_not_low`,`trigger_content_update_delay`,`trigger_max_content_delay`,`content_uri_triggers` FROM `WorkSpec`");
supportSQLiteDatabase.execSQL("DROP TABLE `WorkSpec`");
supportSQLiteDatabase.execSQL("ALTER TABLE `_new_WorkSpec` RENAME TO `WorkSpec`");
supportSQLiteDatabase.execSQL("CREATE INDEX IF NOT EXISTS `index_WorkSpec_schedule_requested_at` ON `WorkSpec` (`schedule_requested_at`)");
supportSQLiteDatabase.execSQL("CREATE INDEX IF NOT EXISTS `index_WorkSpec_last_enqueue_time` ON `WorkSpec` (`last_enqueue_time`)");
}
}

View File

@@ -0,0 +1,18 @@
package androidx.work.impl;
import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/* loaded from: classes.dex */
final class WorkDatabase_AutoMigration_17_18_Impl extends Migration {
public WorkDatabase_AutoMigration_17_18_Impl() {
super(17, 18);
}
@Override // androidx.room.migration.Migration
public void migrate(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
supportSQLiteDatabase.execSQL("ALTER TABLE `WorkSpec` ADD COLUMN `next_schedule_time_override` INTEGER NOT NULL DEFAULT 9223372036854775807");
supportSQLiteDatabase.execSQL("ALTER TABLE `WorkSpec` ADD COLUMN `next_schedule_time_override_generation` INTEGER NOT NULL DEFAULT 0");
}
}

View File

@@ -0,0 +1,17 @@
package androidx.work.impl;
import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/* loaded from: classes.dex */
final class WorkDatabase_AutoMigration_18_19_Impl extends Migration {
public WorkDatabase_AutoMigration_18_19_Impl() {
super(18, 19);
}
@Override // androidx.room.migration.Migration
public void migrate(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
supportSQLiteDatabase.execSQL("ALTER TABLE `WorkSpec` ADD COLUMN `stop_reason` INTEGER NOT NULL DEFAULT -256");
}
}

View File

@@ -0,0 +1,27 @@
package androidx.work.impl;
import androidx.annotation.NonNull;
import androidx.room.migration.AutoMigrationSpec;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/* loaded from: classes.dex */
final class WorkDatabase_AutoMigration_19_20_Impl extends Migration {
private final AutoMigrationSpec callback;
public WorkDatabase_AutoMigration_19_20_Impl() {
super(19, 20);
this.callback = new AutoMigration_19_20();
}
@Override // androidx.room.migration.Migration
public void migrate(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
supportSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS `_new_WorkSpec` (`id` TEXT NOT NULL, `state` INTEGER NOT NULL, `worker_class_name` TEXT NOT NULL, `input_merger_class_name` TEXT NOT NULL, `input` BLOB NOT NULL, `output` BLOB NOT NULL, `initial_delay` INTEGER NOT NULL, `interval_duration` INTEGER NOT NULL, `flex_duration` INTEGER NOT NULL, `run_attempt_count` INTEGER NOT NULL, `backoff_policy` INTEGER NOT NULL, `backoff_delay_duration` INTEGER NOT NULL, `last_enqueue_time` INTEGER NOT NULL DEFAULT -1, `minimum_retention_duration` INTEGER NOT NULL, `schedule_requested_at` INTEGER NOT NULL, `run_in_foreground` INTEGER NOT NULL, `out_of_quota_policy` INTEGER NOT NULL, `period_count` INTEGER NOT NULL DEFAULT 0, `generation` INTEGER NOT NULL DEFAULT 0, `next_schedule_time_override` INTEGER NOT NULL DEFAULT 9223372036854775807, `next_schedule_time_override_generation` INTEGER NOT NULL DEFAULT 0, `stop_reason` INTEGER NOT NULL DEFAULT -256, `required_network_type` INTEGER NOT NULL, `requires_charging` INTEGER NOT NULL, `requires_device_idle` INTEGER NOT NULL, `requires_battery_not_low` INTEGER NOT NULL, `requires_storage_not_low` INTEGER NOT NULL, `trigger_content_update_delay` INTEGER NOT NULL, `trigger_max_content_delay` INTEGER NOT NULL, `content_uri_triggers` BLOB NOT NULL, PRIMARY KEY(`id`))");
supportSQLiteDatabase.execSQL("INSERT INTO `_new_WorkSpec` (`id`,`state`,`worker_class_name`,`input_merger_class_name`,`input`,`output`,`initial_delay`,`interval_duration`,`flex_duration`,`run_attempt_count`,`backoff_policy`,`backoff_delay_duration`,`last_enqueue_time`,`minimum_retention_duration`,`schedule_requested_at`,`run_in_foreground`,`out_of_quota_policy`,`period_count`,`generation`,`next_schedule_time_override`,`next_schedule_time_override_generation`,`stop_reason`,`required_network_type`,`requires_charging`,`requires_device_idle`,`requires_battery_not_low`,`requires_storage_not_low`,`trigger_content_update_delay`,`trigger_max_content_delay`,`content_uri_triggers`) SELECT `id`,`state`,`worker_class_name`,`input_merger_class_name`,`input`,`output`,`initial_delay`,`interval_duration`,`flex_duration`,`run_attempt_count`,`backoff_policy`,`backoff_delay_duration`,`last_enqueue_time`,`minimum_retention_duration`,`schedule_requested_at`,`run_in_foreground`,`out_of_quota_policy`,`period_count`,`generation`,`next_schedule_time_override`,`next_schedule_time_override_generation`,`stop_reason`,`required_network_type`,`requires_charging`,`requires_device_idle`,`requires_battery_not_low`,`requires_storage_not_low`,`trigger_content_update_delay`,`trigger_max_content_delay`,`content_uri_triggers` FROM `WorkSpec`");
supportSQLiteDatabase.execSQL("DROP TABLE `WorkSpec`");
supportSQLiteDatabase.execSQL("ALTER TABLE `_new_WorkSpec` RENAME TO `WorkSpec`");
supportSQLiteDatabase.execSQL("CREATE INDEX IF NOT EXISTS `index_WorkSpec_schedule_requested_at` ON `WorkSpec` (`schedule_requested_at`)");
supportSQLiteDatabase.execSQL("CREATE INDEX IF NOT EXISTS `index_WorkSpec_last_enqueue_time` ON `WorkSpec` (`last_enqueue_time`)");
this.callback.onPostMigrate(supportSQLiteDatabase);
}
}

View File

@@ -0,0 +1,17 @@
package androidx.work.impl;
import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/* loaded from: classes.dex */
final class WorkDatabase_AutoMigration_20_21_Impl extends Migration {
public WorkDatabase_AutoMigration_20_21_Impl() {
super(20, 21);
}
@Override // androidx.room.migration.Migration
public void migrate(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
supportSQLiteDatabase.execSQL("ALTER TABLE `WorkSpec` ADD COLUMN `required_network_request` BLOB NOT NULL DEFAULT x''");
}
}

View File

@@ -0,0 +1,17 @@
package androidx.work.impl;
import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/* loaded from: classes.dex */
final class WorkDatabase_AutoMigration_22_23_Impl extends Migration {
public WorkDatabase_AutoMigration_22_23_Impl() {
super(22, 23);
}
@Override // androidx.room.migration.Migration
public void migrate(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
supportSQLiteDatabase.execSQL("ALTER TABLE `WorkSpec` ADD COLUMN `trace_tag` TEXT DEFAULT NULL");
}
}

View File

@@ -0,0 +1,462 @@
package androidx.work.impl;
import androidx.annotation.NonNull;
import androidx.core.app.NotificationCompat;
import androidx.room.DatabaseConfiguration;
import androidx.room.InvalidationTracker;
import androidx.room.RoomDatabase;
import androidx.room.RoomMasterTable;
import androidx.room.RoomOpenHelper;
import androidx.room.migration.AutoMigrationSpec;
import androidx.room.migration.Migration;
import androidx.room.util.DBUtil;
import androidx.room.util.TableInfo;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.sqlite.db.SupportSQLiteOpenHelper;
import androidx.work.impl.model.DependencyDao;
import androidx.work.impl.model.DependencyDao_Impl;
import androidx.work.impl.model.PreferenceDao;
import androidx.work.impl.model.PreferenceDao_Impl;
import androidx.work.impl.model.RawWorkInfoDao;
import androidx.work.impl.model.RawWorkInfoDao_Impl;
import androidx.work.impl.model.SystemIdInfoDao;
import androidx.work.impl.model.SystemIdInfoDao_Impl;
import androidx.work.impl.model.WorkNameDao;
import androidx.work.impl.model.WorkNameDao_Impl;
import androidx.work.impl.model.WorkProgressDao;
import androidx.work.impl.model.WorkProgressDao_Impl;
import androidx.work.impl.model.WorkSpecDao;
import androidx.work.impl.model.WorkSpecDao_Impl;
import androidx.work.impl.model.WorkTagDao;
import androidx.work.impl.model.WorkTagDao_Impl;
import androidx.work.impl.utils.PreferenceUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/* loaded from: classes.dex */
public final class WorkDatabase_Impl extends WorkDatabase {
private volatile DependencyDao _dependencyDao;
private volatile PreferenceDao _preferenceDao;
private volatile RawWorkInfoDao _rawWorkInfoDao;
private volatile SystemIdInfoDao _systemIdInfoDao;
private volatile WorkNameDao _workNameDao;
private volatile WorkProgressDao _workProgressDao;
private volatile WorkSpecDao _workSpecDao;
private volatile WorkTagDao _workTagDao;
@Override // androidx.room.RoomDatabase
@NonNull
public SupportSQLiteOpenHelper createOpenHelper(@NonNull DatabaseConfiguration databaseConfiguration) {
return databaseConfiguration.sqliteOpenHelperFactory.create(SupportSQLiteOpenHelper.Configuration.builder(databaseConfiguration.context).name(databaseConfiguration.name).callback(new RoomOpenHelper(databaseConfiguration, new RoomOpenHelper.Delegate(23) { // from class: androidx.work.impl.WorkDatabase_Impl.1
@Override // androidx.room.RoomOpenHelper.Delegate
public void onPostMigrate(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
}
@Override // androidx.room.RoomOpenHelper.Delegate
public void createAllTables(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
supportSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS `Dependency` (`work_spec_id` TEXT NOT NULL, `prerequisite_id` TEXT NOT NULL, PRIMARY KEY(`work_spec_id`, `prerequisite_id`), FOREIGN KEY(`work_spec_id`) REFERENCES `WorkSpec`(`id`) ON UPDATE CASCADE ON DELETE CASCADE , FOREIGN KEY(`prerequisite_id`) REFERENCES `WorkSpec`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )");
supportSQLiteDatabase.execSQL("CREATE INDEX IF NOT EXISTS `index_Dependency_work_spec_id` ON `Dependency` (`work_spec_id`)");
supportSQLiteDatabase.execSQL("CREATE INDEX IF NOT EXISTS `index_Dependency_prerequisite_id` ON `Dependency` (`prerequisite_id`)");
supportSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS `WorkSpec` (`id` TEXT NOT NULL, `state` INTEGER NOT NULL, `worker_class_name` TEXT NOT NULL, `input_merger_class_name` TEXT NOT NULL, `input` BLOB NOT NULL, `output` BLOB NOT NULL, `initial_delay` INTEGER NOT NULL, `interval_duration` INTEGER NOT NULL, `flex_duration` INTEGER NOT NULL, `run_attempt_count` INTEGER NOT NULL, `backoff_policy` INTEGER NOT NULL, `backoff_delay_duration` INTEGER NOT NULL, `last_enqueue_time` INTEGER NOT NULL DEFAULT -1, `minimum_retention_duration` INTEGER NOT NULL, `schedule_requested_at` INTEGER NOT NULL, `run_in_foreground` INTEGER NOT NULL, `out_of_quota_policy` INTEGER NOT NULL, `period_count` INTEGER NOT NULL DEFAULT 0, `generation` INTEGER NOT NULL DEFAULT 0, `next_schedule_time_override` INTEGER NOT NULL DEFAULT 9223372036854775807, `next_schedule_time_override_generation` INTEGER NOT NULL DEFAULT 0, `stop_reason` INTEGER NOT NULL DEFAULT -256, `trace_tag` TEXT, `required_network_type` INTEGER NOT NULL, `required_network_request` BLOB NOT NULL DEFAULT x'', `requires_charging` INTEGER NOT NULL, `requires_device_idle` INTEGER NOT NULL, `requires_battery_not_low` INTEGER NOT NULL, `requires_storage_not_low` INTEGER NOT NULL, `trigger_content_update_delay` INTEGER NOT NULL, `trigger_max_content_delay` INTEGER NOT NULL, `content_uri_triggers` BLOB NOT NULL, PRIMARY KEY(`id`))");
supportSQLiteDatabase.execSQL("CREATE INDEX IF NOT EXISTS `index_WorkSpec_schedule_requested_at` ON `WorkSpec` (`schedule_requested_at`)");
supportSQLiteDatabase.execSQL("CREATE INDEX IF NOT EXISTS `index_WorkSpec_last_enqueue_time` ON `WorkSpec` (`last_enqueue_time`)");
supportSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS `WorkTag` (`tag` TEXT NOT NULL, `work_spec_id` TEXT NOT NULL, PRIMARY KEY(`tag`, `work_spec_id`), FOREIGN KEY(`work_spec_id`) REFERENCES `WorkSpec`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )");
supportSQLiteDatabase.execSQL("CREATE INDEX IF NOT EXISTS `index_WorkTag_work_spec_id` ON `WorkTag` (`work_spec_id`)");
supportSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS `SystemIdInfo` (`work_spec_id` TEXT NOT NULL, `generation` INTEGER NOT NULL DEFAULT 0, `system_id` INTEGER NOT NULL, PRIMARY KEY(`work_spec_id`, `generation`), FOREIGN KEY(`work_spec_id`) REFERENCES `WorkSpec`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )");
supportSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS `WorkName` (`name` TEXT NOT NULL, `work_spec_id` TEXT NOT NULL, PRIMARY KEY(`name`, `work_spec_id`), FOREIGN KEY(`work_spec_id`) REFERENCES `WorkSpec`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )");
supportSQLiteDatabase.execSQL("CREATE INDEX IF NOT EXISTS `index_WorkName_work_spec_id` ON `WorkName` (`work_spec_id`)");
supportSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS `WorkProgress` (`work_spec_id` TEXT NOT NULL, `progress` BLOB NOT NULL, PRIMARY KEY(`work_spec_id`), FOREIGN KEY(`work_spec_id`) REFERENCES `WorkSpec`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )");
supportSQLiteDatabase.execSQL(PreferenceUtils.CREATE_PREFERENCE);
supportSQLiteDatabase.execSQL(RoomMasterTable.CREATE_QUERY);
supportSQLiteDatabase.execSQL("INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '86254750241babac4b8d52996a675549')");
}
@Override // androidx.room.RoomOpenHelper.Delegate
public void dropAllTables(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
supportSQLiteDatabase.execSQL("DROP TABLE IF EXISTS `Dependency`");
supportSQLiteDatabase.execSQL("DROP TABLE IF EXISTS `WorkSpec`");
supportSQLiteDatabase.execSQL("DROP TABLE IF EXISTS `WorkTag`");
supportSQLiteDatabase.execSQL("DROP TABLE IF EXISTS `SystemIdInfo`");
supportSQLiteDatabase.execSQL("DROP TABLE IF EXISTS `WorkName`");
supportSQLiteDatabase.execSQL("DROP TABLE IF EXISTS `WorkProgress`");
supportSQLiteDatabase.execSQL("DROP TABLE IF EXISTS `Preference`");
List list = ((RoomDatabase) WorkDatabase_Impl.this).mCallbacks;
if (list != null) {
Iterator it = list.iterator();
while (it.hasNext()) {
((RoomDatabase.Callback) it.next()).onDestructiveMigration(supportSQLiteDatabase);
}
}
}
@Override // androidx.room.RoomOpenHelper.Delegate
public void onCreate(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
List list = ((RoomDatabase) WorkDatabase_Impl.this).mCallbacks;
if (list != null) {
Iterator it = list.iterator();
while (it.hasNext()) {
((RoomDatabase.Callback) it.next()).onCreate(supportSQLiteDatabase);
}
}
}
@Override // androidx.room.RoomOpenHelper.Delegate
public void onOpen(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
((RoomDatabase) WorkDatabase_Impl.this).mDatabase = supportSQLiteDatabase;
supportSQLiteDatabase.execSQL("PRAGMA foreign_keys = ON");
WorkDatabase_Impl.this.internalInitInvalidationTracker(supportSQLiteDatabase);
List list = ((RoomDatabase) WorkDatabase_Impl.this).mCallbacks;
if (list != null) {
Iterator it = list.iterator();
while (it.hasNext()) {
((RoomDatabase.Callback) it.next()).onOpen(supportSQLiteDatabase);
}
}
}
@Override // androidx.room.RoomOpenHelper.Delegate
public void onPreMigrate(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
DBUtil.dropFtsSyncTriggers(supportSQLiteDatabase);
}
@Override // androidx.room.RoomOpenHelper.Delegate
@NonNull
public RoomOpenHelper.ValidationResult onValidateSchema(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
HashMap hashMap = new HashMap(2);
hashMap.put("work_spec_id", new TableInfo.Column("work_spec_id", "TEXT", true, 1, null, 1));
hashMap.put("prerequisite_id", new TableInfo.Column("prerequisite_id", "TEXT", true, 2, null, 1));
HashSet hashSet = new HashSet(2);
hashSet.add(new TableInfo.ForeignKey("WorkSpec", "CASCADE", "CASCADE", Arrays.asList("work_spec_id"), Arrays.asList("id")));
hashSet.add(new TableInfo.ForeignKey("WorkSpec", "CASCADE", "CASCADE", Arrays.asList("prerequisite_id"), Arrays.asList("id")));
HashSet hashSet2 = new HashSet(2);
hashSet2.add(new TableInfo.Index("index_Dependency_work_spec_id", false, Arrays.asList("work_spec_id"), Arrays.asList("ASC")));
hashSet2.add(new TableInfo.Index("index_Dependency_prerequisite_id", false, Arrays.asList("prerequisite_id"), Arrays.asList("ASC")));
TableInfo tableInfo = new TableInfo("Dependency", hashMap, hashSet, hashSet2);
TableInfo read = TableInfo.read(supportSQLiteDatabase, "Dependency");
if (!tableInfo.equals(read)) {
return new RoomOpenHelper.ValidationResult(false, "Dependency(androidx.work.impl.model.Dependency).\n Expected:\n" + tableInfo + "\n Found:\n" + read);
}
HashMap hashMap2 = new HashMap(32);
hashMap2.put("id", new TableInfo.Column("id", "TEXT", true, 1, null, 1));
hashMap2.put("state", new TableInfo.Column("state", "INTEGER", true, 0, null, 1));
hashMap2.put("worker_class_name", new TableInfo.Column("worker_class_name", "TEXT", true, 0, null, 1));
hashMap2.put("input_merger_class_name", new TableInfo.Column("input_merger_class_name", "TEXT", true, 0, null, 1));
hashMap2.put("input", new TableInfo.Column("input", "BLOB", true, 0, null, 1));
hashMap2.put("output", new TableInfo.Column("output", "BLOB", true, 0, null, 1));
hashMap2.put("initial_delay", new TableInfo.Column("initial_delay", "INTEGER", true, 0, null, 1));
hashMap2.put("interval_duration", new TableInfo.Column("interval_duration", "INTEGER", true, 0, null, 1));
hashMap2.put("flex_duration", new TableInfo.Column("flex_duration", "INTEGER", true, 0, null, 1));
hashMap2.put("run_attempt_count", new TableInfo.Column("run_attempt_count", "INTEGER", true, 0, null, 1));
hashMap2.put("backoff_policy", new TableInfo.Column("backoff_policy", "INTEGER", true, 0, null, 1));
hashMap2.put("backoff_delay_duration", new TableInfo.Column("backoff_delay_duration", "INTEGER", true, 0, null, 1));
hashMap2.put("last_enqueue_time", new TableInfo.Column("last_enqueue_time", "INTEGER", true, 0, "-1", 1));
hashMap2.put("minimum_retention_duration", new TableInfo.Column("minimum_retention_duration", "INTEGER", true, 0, null, 1));
hashMap2.put("schedule_requested_at", new TableInfo.Column("schedule_requested_at", "INTEGER", true, 0, null, 1));
hashMap2.put("run_in_foreground", new TableInfo.Column("run_in_foreground", "INTEGER", true, 0, null, 1));
hashMap2.put("out_of_quota_policy", new TableInfo.Column("out_of_quota_policy", "INTEGER", true, 0, null, 1));
hashMap2.put("period_count", new TableInfo.Column("period_count", "INTEGER", true, 0, "0", 1));
hashMap2.put("generation", new TableInfo.Column("generation", "INTEGER", true, 0, "0", 1));
hashMap2.put("next_schedule_time_override", new TableInfo.Column("next_schedule_time_override", "INTEGER", true, 0, "9223372036854775807", 1));
hashMap2.put("next_schedule_time_override_generation", new TableInfo.Column("next_schedule_time_override_generation", "INTEGER", true, 0, "0", 1));
hashMap2.put("stop_reason", new TableInfo.Column("stop_reason", "INTEGER", true, 0, "-256", 1));
hashMap2.put("trace_tag", new TableInfo.Column("trace_tag", "TEXT", false, 0, null, 1));
hashMap2.put("required_network_type", new TableInfo.Column("required_network_type", "INTEGER", true, 0, null, 1));
hashMap2.put("required_network_request", new TableInfo.Column("required_network_request", "BLOB", true, 0, "x''", 1));
hashMap2.put("requires_charging", new TableInfo.Column("requires_charging", "INTEGER", true, 0, null, 1));
hashMap2.put("requires_device_idle", new TableInfo.Column("requires_device_idle", "INTEGER", true, 0, null, 1));
hashMap2.put("requires_battery_not_low", new TableInfo.Column("requires_battery_not_low", "INTEGER", true, 0, null, 1));
hashMap2.put("requires_storage_not_low", new TableInfo.Column("requires_storage_not_low", "INTEGER", true, 0, null, 1));
hashMap2.put("trigger_content_update_delay", new TableInfo.Column("trigger_content_update_delay", "INTEGER", true, 0, null, 1));
hashMap2.put("trigger_max_content_delay", new TableInfo.Column("trigger_max_content_delay", "INTEGER", true, 0, null, 1));
hashMap2.put("content_uri_triggers", new TableInfo.Column("content_uri_triggers", "BLOB", true, 0, null, 1));
HashSet hashSet3 = new HashSet(0);
HashSet hashSet4 = new HashSet(2);
hashSet4.add(new TableInfo.Index("index_WorkSpec_schedule_requested_at", false, Arrays.asList("schedule_requested_at"), Arrays.asList("ASC")));
hashSet4.add(new TableInfo.Index("index_WorkSpec_last_enqueue_time", false, Arrays.asList("last_enqueue_time"), Arrays.asList("ASC")));
TableInfo tableInfo2 = new TableInfo("WorkSpec", hashMap2, hashSet3, hashSet4);
TableInfo read2 = TableInfo.read(supportSQLiteDatabase, "WorkSpec");
if (!tableInfo2.equals(read2)) {
return new RoomOpenHelper.ValidationResult(false, "WorkSpec(androidx.work.impl.model.WorkSpec).\n Expected:\n" + tableInfo2 + "\n Found:\n" + read2);
}
HashMap hashMap3 = new HashMap(2);
hashMap3.put("tag", new TableInfo.Column("tag", "TEXT", true, 1, null, 1));
hashMap3.put("work_spec_id", new TableInfo.Column("work_spec_id", "TEXT", true, 2, null, 1));
HashSet hashSet5 = new HashSet(1);
hashSet5.add(new TableInfo.ForeignKey("WorkSpec", "CASCADE", "CASCADE", Arrays.asList("work_spec_id"), Arrays.asList("id")));
HashSet hashSet6 = new HashSet(1);
hashSet6.add(new TableInfo.Index("index_WorkTag_work_spec_id", false, Arrays.asList("work_spec_id"), Arrays.asList("ASC")));
TableInfo tableInfo3 = new TableInfo("WorkTag", hashMap3, hashSet5, hashSet6);
TableInfo read3 = TableInfo.read(supportSQLiteDatabase, "WorkTag");
if (!tableInfo3.equals(read3)) {
return new RoomOpenHelper.ValidationResult(false, "WorkTag(androidx.work.impl.model.WorkTag).\n Expected:\n" + tableInfo3 + "\n Found:\n" + read3);
}
HashMap hashMap4 = new HashMap(3);
hashMap4.put("work_spec_id", new TableInfo.Column("work_spec_id", "TEXT", true, 1, null, 1));
hashMap4.put("generation", new TableInfo.Column("generation", "INTEGER", true, 2, "0", 1));
hashMap4.put("system_id", new TableInfo.Column("system_id", "INTEGER", true, 0, null, 1));
HashSet hashSet7 = new HashSet(1);
hashSet7.add(new TableInfo.ForeignKey("WorkSpec", "CASCADE", "CASCADE", Arrays.asList("work_spec_id"), Arrays.asList("id")));
TableInfo tableInfo4 = new TableInfo("SystemIdInfo", hashMap4, hashSet7, new HashSet(0));
TableInfo read4 = TableInfo.read(supportSQLiteDatabase, "SystemIdInfo");
if (!tableInfo4.equals(read4)) {
return new RoomOpenHelper.ValidationResult(false, "SystemIdInfo(androidx.work.impl.model.SystemIdInfo).\n Expected:\n" + tableInfo4 + "\n Found:\n" + read4);
}
HashMap hashMap5 = new HashMap(2);
hashMap5.put("name", new TableInfo.Column("name", "TEXT", true, 1, null, 1));
hashMap5.put("work_spec_id", new TableInfo.Column("work_spec_id", "TEXT", true, 2, null, 1));
HashSet hashSet8 = new HashSet(1);
hashSet8.add(new TableInfo.ForeignKey("WorkSpec", "CASCADE", "CASCADE", Arrays.asList("work_spec_id"), Arrays.asList("id")));
HashSet hashSet9 = new HashSet(1);
hashSet9.add(new TableInfo.Index("index_WorkName_work_spec_id", false, Arrays.asList("work_spec_id"), Arrays.asList("ASC")));
TableInfo tableInfo5 = new TableInfo("WorkName", hashMap5, hashSet8, hashSet9);
TableInfo read5 = TableInfo.read(supportSQLiteDatabase, "WorkName");
if (!tableInfo5.equals(read5)) {
return new RoomOpenHelper.ValidationResult(false, "WorkName(androidx.work.impl.model.WorkName).\n Expected:\n" + tableInfo5 + "\n Found:\n" + read5);
}
HashMap hashMap6 = new HashMap(2);
hashMap6.put("work_spec_id", new TableInfo.Column("work_spec_id", "TEXT", true, 1, null, 1));
hashMap6.put(NotificationCompat.CATEGORY_PROGRESS, new TableInfo.Column(NotificationCompat.CATEGORY_PROGRESS, "BLOB", true, 0, null, 1));
HashSet hashSet10 = new HashSet(1);
hashSet10.add(new TableInfo.ForeignKey("WorkSpec", "CASCADE", "CASCADE", Arrays.asList("work_spec_id"), Arrays.asList("id")));
TableInfo tableInfo6 = new TableInfo("WorkProgress", hashMap6, hashSet10, new HashSet(0));
TableInfo read6 = TableInfo.read(supportSQLiteDatabase, "WorkProgress");
if (!tableInfo6.equals(read6)) {
return new RoomOpenHelper.ValidationResult(false, "WorkProgress(androidx.work.impl.model.WorkProgress).\n Expected:\n" + tableInfo6 + "\n Found:\n" + read6);
}
HashMap hashMap7 = new HashMap(2);
hashMap7.put("key", new TableInfo.Column("key", "TEXT", true, 1, null, 1));
hashMap7.put("long_value", new TableInfo.Column("long_value", "INTEGER", false, 0, null, 1));
TableInfo tableInfo7 = new TableInfo("Preference", hashMap7, new HashSet(0), new HashSet(0));
TableInfo read7 = TableInfo.read(supportSQLiteDatabase, "Preference");
if (!tableInfo7.equals(read7)) {
return new RoomOpenHelper.ValidationResult(false, "Preference(androidx.work.impl.model.Preference).\n Expected:\n" + tableInfo7 + "\n Found:\n" + read7);
}
return new RoomOpenHelper.ValidationResult(true, null);
}
}, "86254750241babac4b8d52996a675549", "1cbd3130fa23b59692c061c594c16cc0")).build());
}
@Override // androidx.room.RoomDatabase
@NonNull
public InvalidationTracker createInvalidationTracker() {
return new InvalidationTracker(this, new HashMap(0), new HashMap(0), "Dependency", "WorkSpec", "WorkTag", "SystemIdInfo", "WorkName", "WorkProgress", "Preference");
}
@Override // androidx.room.RoomDatabase
public void clearAllTables() {
super.assertNotMainThread();
SupportSQLiteDatabase writableDatabase = super.getOpenHelper().getWritableDatabase();
try {
super.beginTransaction();
writableDatabase.execSQL("PRAGMA defer_foreign_keys = TRUE");
writableDatabase.execSQL("DELETE FROM `Dependency`");
writableDatabase.execSQL("DELETE FROM `WorkSpec`");
writableDatabase.execSQL("DELETE FROM `WorkTag`");
writableDatabase.execSQL("DELETE FROM `SystemIdInfo`");
writableDatabase.execSQL("DELETE FROM `WorkName`");
writableDatabase.execSQL("DELETE FROM `WorkProgress`");
writableDatabase.execSQL("DELETE FROM `Preference`");
super.setTransactionSuccessful();
} finally {
super.endTransaction();
writableDatabase.query("PRAGMA wal_checkpoint(FULL)").close();
if (!writableDatabase.inTransaction()) {
writableDatabase.execSQL("VACUUM");
}
}
}
@Override // androidx.room.RoomDatabase
@NonNull
public Map<Class<?>, List<Class<?>>> getRequiredTypeConverters() {
HashMap hashMap = new HashMap();
hashMap.put(WorkSpecDao.class, WorkSpecDao_Impl.getRequiredConverters());
hashMap.put(DependencyDao.class, DependencyDao_Impl.getRequiredConverters());
hashMap.put(WorkTagDao.class, WorkTagDao_Impl.getRequiredConverters());
hashMap.put(SystemIdInfoDao.class, SystemIdInfoDao_Impl.getRequiredConverters());
hashMap.put(WorkNameDao.class, WorkNameDao_Impl.getRequiredConverters());
hashMap.put(WorkProgressDao.class, WorkProgressDao_Impl.getRequiredConverters());
hashMap.put(PreferenceDao.class, PreferenceDao_Impl.getRequiredConverters());
hashMap.put(RawWorkInfoDao.class, RawWorkInfoDao_Impl.getRequiredConverters());
return hashMap;
}
@Override // androidx.room.RoomDatabase
@NonNull
public Set<Class<? extends AutoMigrationSpec>> getRequiredAutoMigrationSpecs() {
return new HashSet();
}
@Override // androidx.room.RoomDatabase
@NonNull
public List<Migration> getAutoMigrations(@NonNull Map<Class<? extends AutoMigrationSpec>, AutoMigrationSpec> map) {
ArrayList arrayList = new ArrayList();
arrayList.add(new WorkDatabase_AutoMigration_13_14_Impl());
arrayList.add(new WorkDatabase_AutoMigration_14_15_Impl());
arrayList.add(new WorkDatabase_AutoMigration_16_17_Impl());
arrayList.add(new WorkDatabase_AutoMigration_17_18_Impl());
arrayList.add(new WorkDatabase_AutoMigration_18_19_Impl());
arrayList.add(new WorkDatabase_AutoMigration_19_20_Impl());
arrayList.add(new WorkDatabase_AutoMigration_20_21_Impl());
arrayList.add(new WorkDatabase_AutoMigration_22_23_Impl());
return arrayList;
}
@Override // androidx.work.impl.WorkDatabase
public WorkSpecDao workSpecDao() {
WorkSpecDao workSpecDao;
if (this._workSpecDao != null) {
return this._workSpecDao;
}
synchronized (this) {
try {
if (this._workSpecDao == null) {
this._workSpecDao = new WorkSpecDao_Impl(this);
}
workSpecDao = this._workSpecDao;
} catch (Throwable th) {
throw th;
}
}
return workSpecDao;
}
@Override // androidx.work.impl.WorkDatabase
public DependencyDao dependencyDao() {
DependencyDao dependencyDao;
if (this._dependencyDao != null) {
return this._dependencyDao;
}
synchronized (this) {
try {
if (this._dependencyDao == null) {
this._dependencyDao = new DependencyDao_Impl(this);
}
dependencyDao = this._dependencyDao;
} catch (Throwable th) {
throw th;
}
}
return dependencyDao;
}
@Override // androidx.work.impl.WorkDatabase
public WorkTagDao workTagDao() {
WorkTagDao workTagDao;
if (this._workTagDao != null) {
return this._workTagDao;
}
synchronized (this) {
try {
if (this._workTagDao == null) {
this._workTagDao = new WorkTagDao_Impl(this);
}
workTagDao = this._workTagDao;
} catch (Throwable th) {
throw th;
}
}
return workTagDao;
}
@Override // androidx.work.impl.WorkDatabase
public SystemIdInfoDao systemIdInfoDao() {
SystemIdInfoDao systemIdInfoDao;
if (this._systemIdInfoDao != null) {
return this._systemIdInfoDao;
}
synchronized (this) {
try {
if (this._systemIdInfoDao == null) {
this._systemIdInfoDao = new SystemIdInfoDao_Impl(this);
}
systemIdInfoDao = this._systemIdInfoDao;
} catch (Throwable th) {
throw th;
}
}
return systemIdInfoDao;
}
@Override // androidx.work.impl.WorkDatabase
public WorkNameDao workNameDao() {
WorkNameDao workNameDao;
if (this._workNameDao != null) {
return this._workNameDao;
}
synchronized (this) {
try {
if (this._workNameDao == null) {
this._workNameDao = new WorkNameDao_Impl(this);
}
workNameDao = this._workNameDao;
} catch (Throwable th) {
throw th;
}
}
return workNameDao;
}
@Override // androidx.work.impl.WorkDatabase
public WorkProgressDao workProgressDao() {
WorkProgressDao workProgressDao;
if (this._workProgressDao != null) {
return this._workProgressDao;
}
synchronized (this) {
try {
if (this._workProgressDao == null) {
this._workProgressDao = new WorkProgressDao_Impl(this);
}
workProgressDao = this._workProgressDao;
} catch (Throwable th) {
throw th;
}
}
return workProgressDao;
}
@Override // androidx.work.impl.WorkDatabase
public PreferenceDao preferenceDao() {
PreferenceDao preferenceDao;
if (this._preferenceDao != null) {
return this._preferenceDao;
}
synchronized (this) {
try {
if (this._preferenceDao == null) {
this._preferenceDao = new PreferenceDao_Impl(this);
}
preferenceDao = this._preferenceDao;
} catch (Throwable th) {
throw th;
}
}
return preferenceDao;
}
@Override // androidx.work.impl.WorkDatabase
public RawWorkInfoDao rawWorkInfoDao() {
RawWorkInfoDao rawWorkInfoDao;
if (this._rawWorkInfoDao != null) {
return this._rawWorkInfoDao;
}
synchronized (this) {
try {
if (this._rawWorkInfoDao == null) {
this._rawWorkInfoDao = new RawWorkInfoDao_Impl(this);
}
rawWorkInfoDao = this._rawWorkInfoDao;
} catch (Throwable th) {
throw th;
}
}
return rawWorkInfoDao;
}
}

View File

@@ -0,0 +1,27 @@
package androidx.work.impl;
import androidx.work.WorkInfo;
import androidx.work.WorkerParameters;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public interface WorkLauncher {
void startWork(StartStopToken startStopToken, WorkerParameters.RuntimeExtras runtimeExtras);
void stopWork(StartStopToken startStopToken, int i);
default void startWork(StartStopToken workSpecId) {
Intrinsics.checkNotNullParameter(workSpecId, "workSpecId");
startWork(workSpecId, null);
}
default void stopWork(StartStopToken workSpecId) {
Intrinsics.checkNotNullParameter(workSpecId, "workSpecId");
stopWork(workSpecId, WorkInfo.STOP_REASON_UNKNOWN);
}
default void stopWorkWithReason(StartStopToken workSpecId, int i) {
Intrinsics.checkNotNullParameter(workSpecId, "workSpecId");
stopWork(workSpecId, i);
}
}

View File

@@ -0,0 +1,49 @@
package androidx.work.impl;
import androidx.work.WorkerParameters;
import androidx.work.impl.utils.StopWorkRunnable;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class WorkLauncherImpl implements WorkLauncher {
private final Processor processor;
private final TaskExecutor workTaskExecutor;
public final Processor getProcessor() {
return this.processor;
}
public final TaskExecutor getWorkTaskExecutor() {
return this.workTaskExecutor;
}
public WorkLauncherImpl(Processor processor, TaskExecutor workTaskExecutor) {
Intrinsics.checkNotNullParameter(processor, "processor");
Intrinsics.checkNotNullParameter(workTaskExecutor, "workTaskExecutor");
this.processor = processor;
this.workTaskExecutor = workTaskExecutor;
}
/* JADX INFO: Access modifiers changed from: private */
public static final void startWork$lambda$0(WorkLauncherImpl workLauncherImpl, StartStopToken startStopToken, WorkerParameters.RuntimeExtras runtimeExtras) {
workLauncherImpl.processor.startWork(startStopToken, runtimeExtras);
}
@Override // androidx.work.impl.WorkLauncher
public void startWork(final StartStopToken workSpecId, final WorkerParameters.RuntimeExtras runtimeExtras) {
Intrinsics.checkNotNullParameter(workSpecId, "workSpecId");
this.workTaskExecutor.executeOnTaskThread(new Runnable() { // from class: androidx.work.impl.WorkLauncherImpl$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
WorkLauncherImpl.startWork$lambda$0(WorkLauncherImpl.this, workSpecId, runtimeExtras);
}
});
}
@Override // androidx.work.impl.WorkLauncher
public void stopWork(StartStopToken workSpecId, int i) {
Intrinsics.checkNotNullParameter(workSpecId, "workSpecId");
this.workTaskExecutor.executeOnTaskThread(new StopWorkRunnable(this.processor, workSpecId, false, i));
}
}

View File

@@ -0,0 +1,564 @@
package androidx.work.impl;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.arch.core.util.Function;
import androidx.lifecycle.LiveData;
import androidx.work.Configuration;
import androidx.work.ExistingPeriodicWorkPolicy;
import androidx.work.ExistingWorkPolicy;
import androidx.work.ListenableFutureKt;
import androidx.work.Logger;
import androidx.work.OneTimeWorkRequest;
import androidx.work.Operation;
import androidx.work.PeriodicWorkRequest;
import androidx.work.TracerKt;
import androidx.work.WorkContinuation;
import androidx.work.WorkInfo;
import androidx.work.WorkManager;
import androidx.work.WorkQuery;
import androidx.work.WorkRequest;
import androidx.work.impl.background.systemjob.SystemJobScheduler;
import androidx.work.impl.constraints.trackers.Trackers;
import androidx.work.impl.foreground.SystemForegroundDispatcher;
import androidx.work.impl.model.RawWorkInfoDaoKt;
import androidx.work.impl.model.WorkGenerationalId;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.model.WorkSpecDaoKt;
import androidx.work.impl.utils.CancelWorkRunnable;
import androidx.work.impl.utils.ForceStopRunnable;
import androidx.work.impl.utils.LiveDataUtils;
import androidx.work.impl.utils.PreferenceUtils;
import androidx.work.impl.utils.PruneWorkRunnableKt;
import androidx.work.impl.utils.RawQueries;
import androidx.work.impl.utils.StatusRunnable;
import androidx.work.impl.utils.StopWorkRunnable;
import androidx.work.impl.utils.taskexecutor.SerialExecutor;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import androidx.work.multiprocess.RemoteWorkManager;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.flow.Flow;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class WorkManagerImpl extends WorkManager {
public static final int CONTENT_URI_TRIGGER_API_LEVEL = 24;
public static final int MAX_PRE_JOB_SCHEDULER_API_LEVEL = 22;
public static final int MIN_JOB_SCHEDULER_API_LEVEL = 23;
public static final String REMOTE_WORK_MANAGER_CLIENT = "androidx.work.multiprocess.RemoteWorkManagerClient";
private Configuration mConfiguration;
private Context mContext;
private boolean mForceStopRunnableCompleted = false;
private PreferenceUtils mPreferenceUtils;
private Processor mProcessor;
private volatile RemoteWorkManager mRemoteWorkManager;
private BroadcastReceiver.PendingResult mRescheduleReceiverResult;
private List<Scheduler> mSchedulers;
private final Trackers mTrackers;
private WorkDatabase mWorkDatabase;
private final CoroutineScope mWorkManagerScope;
private TaskExecutor mWorkTaskExecutor;
private static final String TAG = Logger.tagWithPrefix("WorkManagerImpl");
private static WorkManagerImpl sDelegatedInstance = null;
private static WorkManagerImpl sDefaultInstance = null;
private static final Object sLock = new Object();
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public Context getApplicationContext() {
return this.mContext;
}
@Override // androidx.work.WorkManager
@NonNull
public Configuration getConfiguration() {
return this.mConfiguration;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public PreferenceUtils getPreferenceUtils() {
return this.mPreferenceUtils;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public Processor getProcessor() {
return this.mProcessor;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public List<Scheduler> getSchedulers() {
return this.mSchedulers;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public Trackers getTrackers() {
return this.mTrackers;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public WorkDatabase getWorkDatabase() {
return this.mWorkDatabase;
}
@NonNull
public CoroutineScope getWorkManagerScope() {
return this.mWorkManagerScope;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public TaskExecutor getWorkTaskExecutor() {
return this.mWorkTaskExecutor;
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static void setDelegate(@Nullable WorkManagerImpl workManagerImpl) {
synchronized (sLock) {
sDelegatedInstance = workManagerImpl;
}
}
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
@Deprecated
public static WorkManagerImpl getInstance() {
synchronized (sLock) {
try {
WorkManagerImpl workManagerImpl = sDelegatedInstance;
if (workManagerImpl != null) {
return workManagerImpl;
}
return sDefaultInstance;
} catch (Throwable th) {
throw th;
}
}
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static boolean isInitialized() {
return getInstance() != null;
}
/* JADX WARN: Multi-variable type inference failed */
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static WorkManagerImpl getInstance(@NonNull Context context) {
WorkManagerImpl workManagerImpl;
synchronized (sLock) {
try {
workManagerImpl = getInstance();
if (workManagerImpl == null) {
Context applicationContext = context.getApplicationContext();
if (applicationContext instanceof Configuration.Provider) {
initialize(applicationContext, ((Configuration.Provider) applicationContext).getWorkManagerConfiguration());
workManagerImpl = getInstance(applicationContext);
} else {
throw new IllegalStateException("WorkManager is not initialized properly. You have explicitly disabled WorkManagerInitializer in your manifest, have not manually called WorkManager#initialize at this point, and your Application does not implement Configuration.Provider.");
}
}
} catch (Throwable th) {
throw th;
}
}
return workManagerImpl;
}
/* JADX WARN: Code restructure failed: missing block: B:13:0x0018, code lost:
r3 = r3.getApplicationContext();
*/
/* JADX WARN: Code restructure failed: missing block: B:14:0x001e, code lost:
if (androidx.work.impl.WorkManagerImpl.sDefaultInstance != null) goto L17;
*/
/* JADX WARN: Code restructure failed: missing block: B:15:0x0020, code lost:
androidx.work.impl.WorkManagerImpl.sDefaultInstance = androidx.work.impl.WorkManagerImplExtKt.createWorkManager(r3, r4);
*/
/* JADX WARN: Code restructure failed: missing block: B:16:0x0026, code lost:
androidx.work.impl.WorkManagerImpl.sDelegatedInstance = androidx.work.impl.WorkManagerImpl.sDefaultInstance;
*/
@androidx.annotation.RestrictTo({androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP})
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static void initialize(@androidx.annotation.NonNull android.content.Context r3, @androidx.annotation.NonNull androidx.work.Configuration r4) {
/*
java.lang.Object r0 = androidx.work.impl.WorkManagerImpl.sLock
monitor-enter(r0)
androidx.work.impl.WorkManagerImpl r1 = androidx.work.impl.WorkManagerImpl.sDelegatedInstance // Catch: java.lang.Throwable -> L14
if (r1 == 0) goto L16
androidx.work.impl.WorkManagerImpl r2 = androidx.work.impl.WorkManagerImpl.sDefaultInstance // Catch: java.lang.Throwable -> L14
if (r2 != 0) goto Lc
goto L16
Lc:
java.lang.IllegalStateException r3 = new java.lang.IllegalStateException // Catch: java.lang.Throwable -> L14
java.lang.String r4 = "WorkManager is already initialized. Did you try to initialize it manually without disabling WorkManagerInitializer? See WorkManager#initialize(Context, Configuration) or the class level Javadoc for more information."
r3.<init>(r4) // Catch: java.lang.Throwable -> L14
throw r3 // Catch: java.lang.Throwable -> L14
L14:
r3 = move-exception
goto L2c
L16:
if (r1 != 0) goto L2a
android.content.Context r3 = r3.getApplicationContext() // Catch: java.lang.Throwable -> L14
androidx.work.impl.WorkManagerImpl r1 = androidx.work.impl.WorkManagerImpl.sDefaultInstance // Catch: java.lang.Throwable -> L14
if (r1 != 0) goto L26
androidx.work.impl.WorkManagerImpl r3 = androidx.work.impl.WorkManagerImplExtKt.createWorkManager(r3, r4) // Catch: java.lang.Throwable -> L14
androidx.work.impl.WorkManagerImpl.sDefaultInstance = r3 // Catch: java.lang.Throwable -> L14
L26:
androidx.work.impl.WorkManagerImpl r3 = androidx.work.impl.WorkManagerImpl.sDefaultInstance // Catch: java.lang.Throwable -> L14
androidx.work.impl.WorkManagerImpl.sDelegatedInstance = r3 // Catch: java.lang.Throwable -> L14
L2a:
monitor-exit(r0) // Catch: java.lang.Throwable -> L14
return
L2c:
monitor-exit(r0) // Catch: java.lang.Throwable -> L14
throw r3
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.work.impl.WorkManagerImpl.initialize(android.content.Context, androidx.work.Configuration):void");
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public WorkManagerImpl(@NonNull Context context, @NonNull Configuration configuration, @NonNull TaskExecutor taskExecutor, @NonNull WorkDatabase workDatabase, @NonNull List<Scheduler> list, @NonNull Processor processor, @NonNull Trackers trackers) {
Context applicationContext = context.getApplicationContext();
if (Api24Impl.isDeviceProtectedStorage(applicationContext)) {
throw new IllegalStateException("Cannot initialize WorkManager in direct boot mode");
}
Logger.setLogger(new Logger.LogcatLogger(configuration.getMinimumLoggingLevel()));
this.mContext = applicationContext;
this.mWorkTaskExecutor = taskExecutor;
this.mWorkDatabase = workDatabase;
this.mProcessor = processor;
this.mTrackers = trackers;
this.mConfiguration = configuration;
this.mSchedulers = list;
CoroutineScope createWorkManagerScope = WorkManagerImplExtKt.createWorkManagerScope(taskExecutor);
this.mWorkManagerScope = createWorkManagerScope;
this.mPreferenceUtils = new PreferenceUtils(this.mWorkDatabase);
Schedulers.registerRescheduling(list, this.mProcessor, taskExecutor.getSerialTaskExecutor(), this.mWorkDatabase, configuration);
this.mWorkTaskExecutor.executeOnTaskThread(new ForceStopRunnable(applicationContext, this));
UnfinishedWorkListenerKt.maybeLaunchUnfinishedWorkListener(createWorkManagerScope, this.mContext, configuration, workDatabase);
}
@Override // androidx.work.WorkManager
@NonNull
public Operation enqueue(@NonNull List<? extends WorkRequest> list) {
if (list.isEmpty()) {
throw new IllegalArgumentException("enqueue needs at least one WorkRequest.");
}
return new WorkContinuationImpl(this, list).enqueue();
}
@Override // androidx.work.WorkManager
@NonNull
public WorkContinuation beginWith(@NonNull List<OneTimeWorkRequest> list) {
if (list.isEmpty()) {
throw new IllegalArgumentException("beginWith needs at least one OneTimeWorkRequest.");
}
return new WorkContinuationImpl(this, list);
}
@Override // androidx.work.WorkManager
@NonNull
public WorkContinuation beginUniqueWork(@NonNull String str, @NonNull ExistingWorkPolicy existingWorkPolicy, @NonNull List<OneTimeWorkRequest> list) {
if (list.isEmpty()) {
throw new IllegalArgumentException("beginUniqueWork needs at least one OneTimeWorkRequest.");
}
return new WorkContinuationImpl(this, str, existingWorkPolicy, list);
}
@Override // androidx.work.WorkManager
@NonNull
public Operation enqueueUniqueWork(@NonNull String str, @NonNull ExistingWorkPolicy existingWorkPolicy, @NonNull List<OneTimeWorkRequest> list) {
return new WorkContinuationImpl(this, str, existingWorkPolicy, list).enqueue();
}
@Override // androidx.work.WorkManager
@NonNull
public Operation enqueueUniquePeriodicWork(@NonNull String str, @NonNull ExistingPeriodicWorkPolicy existingPeriodicWorkPolicy, @NonNull PeriodicWorkRequest periodicWorkRequest) {
if (existingPeriodicWorkPolicy == ExistingPeriodicWorkPolicy.UPDATE) {
return WorkerUpdater.enqueueUniquelyNamedPeriodic(this, str, periodicWorkRequest);
}
return createWorkContinuationForUniquePeriodicWork(str, existingPeriodicWorkPolicy, periodicWorkRequest).enqueue();
}
@NonNull
public WorkContinuationImpl createWorkContinuationForUniquePeriodicWork(@NonNull String str, @NonNull ExistingPeriodicWorkPolicy existingPeriodicWorkPolicy, @NonNull PeriodicWorkRequest periodicWorkRequest) {
ExistingWorkPolicy existingWorkPolicy;
if (existingPeriodicWorkPolicy == ExistingPeriodicWorkPolicy.KEEP) {
existingWorkPolicy = ExistingWorkPolicy.KEEP;
} else {
existingWorkPolicy = ExistingWorkPolicy.REPLACE;
}
return new WorkContinuationImpl(this, str, existingWorkPolicy, Collections.singletonList(periodicWorkRequest));
}
@Override // androidx.work.WorkManager
@NonNull
public Operation cancelWorkById(@NonNull UUID uuid) {
return CancelWorkRunnable.forId(uuid, this);
}
@Override // androidx.work.WorkManager
@NonNull
public Operation cancelAllWorkByTag(@NonNull String str) {
return CancelWorkRunnable.forTag(str, this);
}
@Override // androidx.work.WorkManager
@NonNull
public Operation cancelUniqueWork(@NonNull String str) {
return CancelWorkRunnable.forName(str, this);
}
@Override // androidx.work.WorkManager
@NonNull
public Operation cancelAllWork() {
return CancelWorkRunnable.forAll(this);
}
@Override // androidx.work.WorkManager
@NonNull
public PendingIntent createCancelPendingIntent(@NonNull UUID uuid) {
return PendingIntent.getService(this.mContext, 0, SystemForegroundDispatcher.createCancelWorkIntent(this.mContext, uuid.toString()), Build.VERSION.SDK_INT >= 31 ? 167772160 : 134217728);
}
@Override // androidx.work.WorkManager
@NonNull
public LiveData<Long> getLastCancelAllTimeMillisLiveData() {
return this.mPreferenceUtils.getLastCancelAllTimeMillisLiveData();
}
@Override // androidx.work.WorkManager
@NonNull
public ListenableFuture getLastCancelAllTimeMillis() {
final PreferenceUtils preferenceUtils = this.mPreferenceUtils;
SerialExecutor serialTaskExecutor = this.mWorkTaskExecutor.getSerialTaskExecutor();
Objects.requireNonNull(preferenceUtils);
return ListenableFutureKt.executeAsync(serialTaskExecutor, "getLastCancelAllTimeMillis", new Function0() { // from class: androidx.work.impl.WorkManagerImpl$$ExternalSyntheticLambda1
@Override // kotlin.jvm.functions.Function0
public final Object invoke() {
return Long.valueOf(PreferenceUtils.this.getLastCancelAllTimeMillis());
}
});
}
@Override // androidx.work.WorkManager
@NonNull
public Operation pruneWork() {
return PruneWorkRunnableKt.pruneWork(this.mWorkDatabase, this.mConfiguration, this.mWorkTaskExecutor);
}
@Override // androidx.work.WorkManager
@NonNull
public LiveData<WorkInfo> getWorkInfoByIdLiveData(@NonNull UUID uuid) {
return LiveDataUtils.dedupedMappedLiveDataFor(this.mWorkDatabase.workSpecDao().getWorkStatusPojoLiveDataForIds(Collections.singletonList(uuid.toString())), new Function<List<WorkSpec.WorkInfoPojo>, WorkInfo>() { // from class: androidx.work.impl.WorkManagerImpl.1
@Override // androidx.arch.core.util.Function
public WorkInfo apply(List<WorkSpec.WorkInfoPojo> list) {
if (list == null || list.size() <= 0) {
return null;
}
return list.get(0).toWorkInfo();
}
}, this.mWorkTaskExecutor);
}
@Override // androidx.work.WorkManager
@NonNull
public Flow getWorkInfoByIdFlow(@NonNull UUID uuid) {
return WorkSpecDaoKt.getWorkStatusPojoFlowDataForIds(getWorkDatabase().workSpecDao(), uuid);
}
@Override // androidx.work.WorkManager
@NonNull
public ListenableFuture getWorkInfoById(@NonNull UUID uuid) {
return StatusRunnable.forUUID(this.mWorkDatabase, this.mWorkTaskExecutor, uuid);
}
@Override // androidx.work.WorkManager
@NonNull
public Flow getWorkInfosByTagFlow(@NonNull String str) {
return WorkSpecDaoKt.getWorkStatusPojoFlowForTag(this.mWorkDatabase.workSpecDao(), this.mWorkTaskExecutor.getTaskCoroutineDispatcher(), str);
}
@Override // androidx.work.WorkManager
@NonNull
public LiveData<List<WorkInfo>> getWorkInfosByTagLiveData(@NonNull String str) {
return LiveDataUtils.dedupedMappedLiveDataFor(this.mWorkDatabase.workSpecDao().getWorkStatusPojoLiveDataForTag(str), WorkSpec.WORK_INFO_MAPPER, this.mWorkTaskExecutor);
}
@Override // androidx.work.WorkManager
@NonNull
public ListenableFuture getWorkInfosByTag(@NonNull String str) {
return StatusRunnable.forTag(this.mWorkDatabase, this.mWorkTaskExecutor, str);
}
@Override // androidx.work.WorkManager
@NonNull
public LiveData<List<WorkInfo>> getWorkInfosForUniqueWorkLiveData(@NonNull String str) {
return LiveDataUtils.dedupedMappedLiveDataFor(this.mWorkDatabase.workSpecDao().getWorkStatusPojoLiveDataForName(str), WorkSpec.WORK_INFO_MAPPER, this.mWorkTaskExecutor);
}
@Override // androidx.work.WorkManager
@NonNull
public Flow getWorkInfosForUniqueWorkFlow(@NonNull String str) {
return WorkSpecDaoKt.getWorkStatusPojoFlowForName(this.mWorkDatabase.workSpecDao(), this.mWorkTaskExecutor.getTaskCoroutineDispatcher(), str);
}
@Override // androidx.work.WorkManager
@NonNull
public ListenableFuture getWorkInfosForUniqueWork(@NonNull String str) {
return StatusRunnable.forUniqueWork(this.mWorkDatabase, this.mWorkTaskExecutor, str);
}
@Override // androidx.work.WorkManager
@NonNull
public LiveData<List<WorkInfo>> getWorkInfosLiveData(@NonNull WorkQuery workQuery) {
return LiveDataUtils.dedupedMappedLiveDataFor(this.mWorkDatabase.rawWorkInfoDao().getWorkInfoPojosLiveData(RawQueries.toRawQuery(workQuery)), WorkSpec.WORK_INFO_MAPPER, this.mWorkTaskExecutor);
}
@Override // androidx.work.WorkManager
@NonNull
public Flow getWorkInfosFlow(@NonNull WorkQuery workQuery) {
return RawWorkInfoDaoKt.getWorkInfoPojosFlow(this.mWorkDatabase.rawWorkInfoDao(), this.mWorkTaskExecutor.getTaskCoroutineDispatcher(), RawQueries.toRawQuery(workQuery));
}
@Override // androidx.work.WorkManager
@NonNull
public ListenableFuture getWorkInfos(@NonNull WorkQuery workQuery) {
return StatusRunnable.forWorkQuerySpec(this.mWorkDatabase, this.mWorkTaskExecutor, workQuery);
}
@Override // androidx.work.WorkManager
@NonNull
public ListenableFuture updateWork(@NonNull WorkRequest workRequest) {
return WorkerUpdater.updateWorkImpl(this, workRequest);
}
public LiveData<List<WorkInfo>> getWorkInfosById(@NonNull List<String> list) {
return LiveDataUtils.dedupedMappedLiveDataFor(this.mWorkDatabase.workSpecDao().getWorkStatusPojoLiveDataForIds(list), WorkSpec.WORK_INFO_MAPPER, this.mWorkTaskExecutor);
}
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public RemoteWorkManager getRemoteWorkManager() {
if (this.mRemoteWorkManager == null) {
synchronized (sLock) {
try {
if (this.mRemoteWorkManager == null) {
tryInitializeMultiProcessSupport();
if (this.mRemoteWorkManager == null && !TextUtils.isEmpty(this.mConfiguration.getDefaultProcessName())) {
throw new IllegalStateException("Invalid multiprocess configuration. Define an `implementation` dependency on :work:work-multiprocess library");
}
}
} finally {
}
}
}
return this.mRemoteWorkManager;
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public void stopForegroundWork(@NonNull WorkGenerationalId workGenerationalId, int i) {
this.mWorkTaskExecutor.executeOnTaskThread(new StopWorkRunnable(this.mProcessor, new StartStopToken(workGenerationalId), true, i));
}
public void rescheduleEligibleWork() {
TracerKt.traced(getConfiguration().getTracer(), "ReschedulingWork", new Function0() { // from class: androidx.work.impl.WorkManagerImpl$$ExternalSyntheticLambda0
@Override // kotlin.jvm.functions.Function0
public final Object invoke() {
Unit lambda$rescheduleEligibleWork$0;
lambda$rescheduleEligibleWork$0 = WorkManagerImpl.this.lambda$rescheduleEligibleWork$0();
return lambda$rescheduleEligibleWork$0;
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ Unit lambda$rescheduleEligibleWork$0() {
SystemJobScheduler.cancelAllInAllNamespaces(getApplicationContext());
getWorkDatabase().workSpecDao().resetScheduledState();
Schedulers.schedule(getConfiguration(), getWorkDatabase(), getSchedulers());
return Unit.INSTANCE;
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public void onForceStopRunnableCompleted() {
synchronized (sLock) {
try {
this.mForceStopRunnableCompleted = true;
BroadcastReceiver.PendingResult pendingResult = this.mRescheduleReceiverResult;
if (pendingResult != null) {
pendingResult.finish();
this.mRescheduleReceiverResult = null;
}
} catch (Throwable th) {
throw th;
}
}
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public void setReschedulePendingResult(@NonNull BroadcastReceiver.PendingResult pendingResult) {
synchronized (sLock) {
try {
BroadcastReceiver.PendingResult pendingResult2 = this.mRescheduleReceiverResult;
if (pendingResult2 != null) {
pendingResult2.finish();
}
this.mRescheduleReceiverResult = pendingResult;
if (this.mForceStopRunnableCompleted) {
pendingResult.finish();
this.mRescheduleReceiverResult = null;
}
} catch (Throwable th) {
throw th;
}
}
}
public void closeDatabase() {
WorkManagerImplExtKt.close(this);
}
private void tryInitializeMultiProcessSupport() {
try {
this.mRemoteWorkManager = (RemoteWorkManager) Class.forName(REMOTE_WORK_MANAGER_CLIENT).getConstructor(Context.class, WorkManagerImpl.class).newInstance(this.mContext, this);
} catch (Throwable th) {
Logger.get().debug(TAG, "Unable to initialize multi-process support", th);
}
}
@RequiresApi(24)
public static class Api24Impl {
private Api24Impl() {
}
public static boolean isDeviceProtectedStorage(Context context) {
return context.isDeviceProtectedStorage();
}
}
}

View File

@@ -0,0 +1,32 @@
package androidx.work.impl;
import android.content.Context;
import androidx.work.Configuration;
import androidx.work.impl.constraints.trackers.Trackers;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import java.util.List;
import kotlin.jvm.functions.Function6;
import kotlin.jvm.internal.FunctionReferenceImpl;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public /* synthetic */ class WorkManagerImplExtKt$WorkManagerImpl$1 extends FunctionReferenceImpl implements Function6 {
public static final WorkManagerImplExtKt$WorkManagerImpl$1 INSTANCE = new WorkManagerImplExtKt$WorkManagerImpl$1();
public WorkManagerImplExtKt$WorkManagerImpl$1() {
super(6, WorkManagerImplExtKt.class, "createSchedulers", "createSchedulers(Landroid/content/Context;Landroidx/work/Configuration;Landroidx/work/impl/utils/taskexecutor/TaskExecutor;Landroidx/work/impl/WorkDatabase;Landroidx/work/impl/constraints/trackers/Trackers;Landroidx/work/impl/Processor;)Ljava/util/List;", 1);
}
@Override // kotlin.jvm.functions.Function6
public final List<Scheduler> invoke(Context p0, Configuration p1, TaskExecutor p2, WorkDatabase p3, Trackers p4, Processor p5) {
List<Scheduler> createSchedulers;
Intrinsics.checkNotNullParameter(p0, "p0");
Intrinsics.checkNotNullParameter(p1, "p1");
Intrinsics.checkNotNullParameter(p2, "p2");
Intrinsics.checkNotNullParameter(p3, "p3");
Intrinsics.checkNotNullParameter(p4, "p4");
Intrinsics.checkNotNullParameter(p5, "p5");
createSchedulers = WorkManagerImplExtKt.createSchedulers(p0, p1, p2, p3, p4, p5);
return createSchedulers;
}
}

View File

@@ -0,0 +1,59 @@
package androidx.work.impl;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.CoroutineContext;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.Job;
import kotlinx.coroutines.JobKt;
@DebugMetadata(c = "androidx.work.impl.WorkManagerImplExtKt$close$1", f = "WorkManagerImplExt.kt", l = {121}, m = "invokeSuspend")
/* loaded from: classes.dex */
public final class WorkManagerImplExtKt$close$1 extends SuspendLambda implements Function2 {
final /* synthetic */ WorkManagerImpl $this_close;
int label;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public WorkManagerImplExtKt$close$1(WorkManagerImpl workManagerImpl, Continuation continuation) {
super(2, continuation);
this.$this_close = workManagerImpl;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
return new WorkManagerImplExtKt$close$1(this.$this_close, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) {
return ((WorkManagerImplExtKt$close$1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
CoroutineContext.Element element = this.$this_close.getWorkManagerScope().getCoroutineContext().get(Job.Key);
Intrinsics.checkNotNull(element);
this.label = 1;
if (JobKt.cancelAndJoin((Job) element, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
return Unit.INSTANCE;
}
}

View File

@@ -0,0 +1,153 @@
package androidx.work.impl;
import android.content.Context;
import androidx.work.Configuration;
import androidx.work.R;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.background.greedy.GreedyScheduler;
import androidx.work.impl.constraints.trackers.Trackers;
import androidx.work.impl.utils.taskexecutor.SerialExecutor;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import androidx.work.impl.utils.taskexecutor.WorkManagerTaskExecutor;
import java.util.List;
import kotlin.collections.ArraysKt___ArraysKt;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.jvm.functions.Function6;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.BuildersKt__BuildersKt;
import kotlinx.coroutines.CoroutineDispatcher;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.CoroutineScopeKt;
/* loaded from: classes.dex */
public final class WorkManagerImplExtKt {
public static final WorkManagerImpl createWorkManager(Context context, Configuration configuration) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(configuration, "configuration");
return createWorkManager$default(context, configuration, null, null, null, null, null, 124, null);
}
public static final WorkManagerImpl createWorkManager(Context context, Configuration configuration, TaskExecutor workTaskExecutor) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(configuration, "configuration");
Intrinsics.checkNotNullParameter(workTaskExecutor, "workTaskExecutor");
return createWorkManager$default(context, configuration, workTaskExecutor, null, null, null, null, 120, null);
}
public static final WorkManagerImpl createWorkManager(Context context, Configuration configuration, TaskExecutor workTaskExecutor, WorkDatabase workDatabase) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(configuration, "configuration");
Intrinsics.checkNotNullParameter(workTaskExecutor, "workTaskExecutor");
Intrinsics.checkNotNullParameter(workDatabase, "workDatabase");
return createWorkManager$default(context, configuration, workTaskExecutor, workDatabase, null, null, null, 112, null);
}
public static final WorkManagerImpl createWorkManager(Context context, Configuration configuration, TaskExecutor workTaskExecutor, WorkDatabase workDatabase, Trackers trackers) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(configuration, "configuration");
Intrinsics.checkNotNullParameter(workTaskExecutor, "workTaskExecutor");
Intrinsics.checkNotNullParameter(workDatabase, "workDatabase");
Intrinsics.checkNotNullParameter(trackers, "trackers");
return createWorkManager$default(context, configuration, workTaskExecutor, workDatabase, trackers, null, null, 96, null);
}
public static final WorkManagerImpl createWorkManager(Context context, Configuration configuration, TaskExecutor workTaskExecutor, WorkDatabase workDatabase, Trackers trackers, Processor processor) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(configuration, "configuration");
Intrinsics.checkNotNullParameter(workTaskExecutor, "workTaskExecutor");
Intrinsics.checkNotNullParameter(workDatabase, "workDatabase");
Intrinsics.checkNotNullParameter(trackers, "trackers");
Intrinsics.checkNotNullParameter(processor, "processor");
return createWorkManager$default(context, configuration, workTaskExecutor, workDatabase, trackers, processor, null, 64, null);
}
public static /* synthetic */ WorkManagerImpl createWorkManager$default(Context context, Configuration configuration, TaskExecutor taskExecutor, WorkDatabase workDatabase, Trackers trackers, Processor processor, Function6 function6, int i, Object obj) {
WorkDatabase workDatabase2;
Trackers trackers2;
TaskExecutor workManagerTaskExecutor = (i & 4) != 0 ? new WorkManagerTaskExecutor(configuration.getTaskExecutor()) : taskExecutor;
if ((i & 8) != 0) {
WorkDatabase.Companion companion = WorkDatabase.Companion;
Context applicationContext = context.getApplicationContext();
Intrinsics.checkNotNullExpressionValue(applicationContext, "context.applicationContext");
SerialExecutor serialTaskExecutor = workManagerTaskExecutor.getSerialTaskExecutor();
Intrinsics.checkNotNullExpressionValue(serialTaskExecutor, "workTaskExecutor.serialTaskExecutor");
workDatabase2 = companion.create(applicationContext, serialTaskExecutor, configuration.getClock(), context.getResources().getBoolean(R.bool.workmanager_test_configuration));
} else {
workDatabase2 = workDatabase;
}
if ((i & 16) != 0) {
Context applicationContext2 = context.getApplicationContext();
Intrinsics.checkNotNullExpressionValue(applicationContext2, "context.applicationContext");
trackers2 = new Trackers(applicationContext2, workManagerTaskExecutor, null, null, null, null, 60, null);
} else {
trackers2 = trackers;
}
return createWorkManager(context, configuration, workManagerTaskExecutor, workDatabase2, trackers2, (i & 32) != 0 ? new Processor(context.getApplicationContext(), configuration, workManagerTaskExecutor, workDatabase2) : processor, (i & 64) != 0 ? WorkManagerImplExtKt$WorkManagerImpl$1.INSTANCE : function6);
}
public static final WorkManagerImpl createWorkManager(Context context, Configuration configuration, TaskExecutor workTaskExecutor, WorkDatabase workDatabase, Trackers trackers, Processor processor, Function6 schedulersCreator) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(configuration, "configuration");
Intrinsics.checkNotNullParameter(workTaskExecutor, "workTaskExecutor");
Intrinsics.checkNotNullParameter(workDatabase, "workDatabase");
Intrinsics.checkNotNullParameter(trackers, "trackers");
Intrinsics.checkNotNullParameter(processor, "processor");
Intrinsics.checkNotNullParameter(schedulersCreator, "schedulersCreator");
return new WorkManagerImpl(context.getApplicationContext(), configuration, workTaskExecutor, workDatabase, (List) schedulersCreator.invoke(context, configuration, workTaskExecutor, workDatabase, trackers, processor), processor, trackers);
}
public static final WorkManagerImpl createTestWorkManager(Context context, Configuration configuration, TaskExecutor workTaskExecutor) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(configuration, "configuration");
Intrinsics.checkNotNullParameter(workTaskExecutor, "workTaskExecutor");
WorkDatabase.Companion companion = WorkDatabase.Companion;
SerialExecutor serialTaskExecutor = workTaskExecutor.getSerialTaskExecutor();
Intrinsics.checkNotNullExpressionValue(serialTaskExecutor, "workTaskExecutor.serialTaskExecutor");
return createWorkManager$default(context, configuration, workTaskExecutor, companion.create(context, serialTaskExecutor, configuration.getClock(), true), null, null, null, 112, null);
}
public static final Function6 schedulers(final Scheduler... schedulers) {
Intrinsics.checkNotNullParameter(schedulers, "schedulers");
return new Function6() { // from class: androidx.work.impl.WorkManagerImplExtKt$schedulers$1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(6);
}
@Override // kotlin.jvm.functions.Function6
public final List<Scheduler> invoke(Context context, Configuration configuration, TaskExecutor taskExecutor, WorkDatabase workDatabase, Trackers trackers, Processor processor) {
List<Scheduler> list;
Intrinsics.checkNotNullParameter(context, "<anonymous parameter 0>");
Intrinsics.checkNotNullParameter(configuration, "<anonymous parameter 1>");
Intrinsics.checkNotNullParameter(taskExecutor, "<anonymous parameter 2>");
Intrinsics.checkNotNullParameter(workDatabase, "<anonymous parameter 3>");
Intrinsics.checkNotNullParameter(trackers, "<anonymous parameter 4>");
Intrinsics.checkNotNullParameter(processor, "<anonymous parameter 5>");
list = ArraysKt___ArraysKt.toList(schedulers);
return list;
}
};
}
/* JADX INFO: Access modifiers changed from: private */
public static final List<Scheduler> createSchedulers(Context context, Configuration configuration, TaskExecutor taskExecutor, WorkDatabase workDatabase, Trackers trackers, Processor processor) {
List<Scheduler> listOf;
Scheduler createBestAvailableBackgroundScheduler = Schedulers.createBestAvailableBackgroundScheduler(context, workDatabase, configuration);
Intrinsics.checkNotNullExpressionValue(createBestAvailableBackgroundScheduler, "createBestAvailableBackg…kDatabase, configuration)");
listOf = CollectionsKt__CollectionsKt.listOf((Object[]) new Scheduler[]{createBestAvailableBackgroundScheduler, new GreedyScheduler(context, configuration, trackers, processor, new WorkLauncherImpl(processor, taskExecutor), taskExecutor)});
return listOf;
}
public static final CoroutineScope createWorkManagerScope(TaskExecutor taskExecutor) {
Intrinsics.checkNotNullParameter(taskExecutor, "taskExecutor");
CoroutineDispatcher taskCoroutineDispatcher = taskExecutor.getTaskCoroutineDispatcher();
Intrinsics.checkNotNullExpressionValue(taskCoroutineDispatcher, "taskExecutor.taskCoroutineDispatcher");
return CoroutineScopeKt.CoroutineScope(taskCoroutineDispatcher);
}
public static final void close(WorkManagerImpl workManagerImpl) {
Intrinsics.checkNotNullParameter(workManagerImpl, "<this>");
BuildersKt__BuildersKt.runBlocking$default(null, new WorkManagerImplExtKt$close$1(workManagerImpl, null), 1, null);
workManagerImpl.getWorkDatabase().close();
}
}

View File

@@ -0,0 +1,28 @@
package androidx.work.impl;
import android.content.Context;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.work.impl.utils.IdGeneratorKt;
import androidx.work.impl.utils.PreferenceUtils;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class WorkMigration9To10 extends Migration {
private final Context context;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public WorkMigration9To10(Context context) {
super(9, 10);
Intrinsics.checkNotNullParameter(context, "context");
this.context = context;
}
@Override // androidx.room.migration.Migration
public void migrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
db.execSQL(PreferenceUtils.CREATE_PREFERENCE);
PreferenceUtils.migrateLegacyPreferences(this.context, db);
IdGeneratorKt.migrateLegacyIdGenerator(this.context, db);
}
}

View File

@@ -0,0 +1,16 @@
package androidx.work.impl;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.work.WorkRequest;
import androidx.work.impl.model.WorkSpec;
import java.util.Set;
import java.util.UUID;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class WorkRequestHolder extends WorkRequest {
public WorkRequestHolder(@NonNull UUID uuid, @NonNull WorkSpec workSpec, @NonNull Set<String> set) {
super(uuid, workSpec, set);
}
}

View File

@@ -0,0 +1,18 @@
package androidx.work.impl;
import androidx.annotation.RestrictTo;
import java.util.concurrent.CancellationException;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public final class WorkerStoppedException extends CancellationException {
private final int reason;
public final int getReason() {
return this.reason;
}
public WorkerStoppedException(int i) {
this.reason = i;
}
}

View File

@@ -0,0 +1,200 @@
package androidx.work.impl;
import androidx.annotation.RestrictTo;
import androidx.work.Configuration;
import androidx.work.ExistingWorkPolicy;
import androidx.work.ListenableFutureKt;
import androidx.work.Operation;
import androidx.work.OperationKt;
import androidx.work.Tracer;
import androidx.work.WorkInfo;
import androidx.work.WorkManager;
import androidx.work.WorkRequest;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.model.WorkSpecDao;
import androidx.work.impl.model.WorkTagDao;
import androidx.work.impl.utils.EnqueueRunnable;
import androidx.work.impl.utils.EnqueueUtilsKt;
import androidx.work.impl.utils.taskexecutor.SerialExecutor;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import kotlin.Unit;
import kotlin.collections.CollectionsKt__CollectionsJVMKt;
import kotlin.collections.CollectionsKt___CollectionsKt;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
@SourceDebugExtension({"SMAP\nWorkerUpdater.kt\nKotlin\n*S Kotlin\n*F\n+ 1 WorkerUpdater.kt\nandroidx/work/impl/WorkerUpdater\n+ 2 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n*L\n1#1,165:1\n1855#2,2:166\n*S KotlinDebug\n*F\n+ 1 WorkerUpdater.kt\nandroidx/work/impl/WorkerUpdater\n*L\n56#1:166,2\n*E\n"})
/* loaded from: classes.dex */
public final class WorkerUpdater {
/* JADX INFO: Access modifiers changed from: private */
public static final WorkManager.UpdateResult updateWorkImpl(Processor processor, final WorkDatabase workDatabase, Configuration configuration, final List<? extends Scheduler> list, final WorkSpec workSpec, final Set<String> set) {
final String str = workSpec.id;
final WorkSpec workSpec2 = workDatabase.workSpecDao().getWorkSpec(str);
if (workSpec2 == null) {
throw new IllegalArgumentException("Worker with " + str + " doesn't exist");
}
if (workSpec2.state.isFinished()) {
return WorkManager.UpdateResult.NOT_APPLIED;
}
if (workSpec2.isPeriodic() ^ workSpec.isPeriodic()) {
WorkerUpdater$updateWorkImpl$type$1 workerUpdater$updateWorkImpl$type$1 = new Function1() { // from class: androidx.work.impl.WorkerUpdater$updateWorkImpl$type$1
@Override // kotlin.jvm.functions.Function1
public final String invoke(WorkSpec spec) {
Intrinsics.checkNotNullParameter(spec, "spec");
return spec.isPeriodic() ? "Periodic" : "OneTime";
}
};
throw new UnsupportedOperationException("Can't update " + ((String) workerUpdater$updateWorkImpl$type$1.invoke((Object) workSpec2)) + " Worker to " + ((String) workerUpdater$updateWorkImpl$type$1.invoke((Object) workSpec)) + " Worker. Update operation must preserve worker's type.");
}
final boolean isEnqueued = processor.isEnqueued(str);
if (!isEnqueued) {
Iterator<T> it = list.iterator();
while (it.hasNext()) {
((Scheduler) it.next()).cancel(str);
}
}
workDatabase.runInTransaction(new Runnable() { // from class: androidx.work.impl.WorkerUpdater$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
WorkerUpdater.updateWorkImpl$lambda$2(WorkDatabase.this, workSpec2, workSpec, list, str, set, isEnqueued);
}
});
if (!isEnqueued) {
Schedulers.schedule(configuration, workDatabase, list);
}
return isEnqueued ? WorkManager.UpdateResult.APPLIED_FOR_NEXT_RUN : WorkManager.UpdateResult.APPLIED_IMMEDIATELY;
}
/* JADX INFO: Access modifiers changed from: private */
public static final void updateWorkImpl$lambda$2(WorkDatabase workDatabase, WorkSpec workSpec, WorkSpec workSpec2, List list, String str, Set set, boolean z) {
WorkSpecDao workSpecDao = workDatabase.workSpecDao();
WorkTagDao workTagDao = workDatabase.workTagDao();
WorkSpec copy$default = WorkSpec.copy$default(workSpec2, null, workSpec.state, null, null, null, null, 0L, 0L, 0L, null, workSpec.runAttemptCount, null, 0L, workSpec.lastEnqueueTime, 0L, 0L, false, null, workSpec.getPeriodCount(), workSpec.getGeneration() + 1, workSpec.getNextScheduleTimeOverride(), workSpec.getNextScheduleTimeOverrideGeneration(), 0, null, 12835837, null);
if (workSpec2.getNextScheduleTimeOverrideGeneration() == 1) {
copy$default.setNextScheduleTimeOverride(workSpec2.getNextScheduleTimeOverride());
copy$default.setNextScheduleTimeOverrideGeneration(copy$default.getNextScheduleTimeOverrideGeneration() + 1);
}
workSpecDao.updateWorkSpec(EnqueueUtilsKt.wrapWorkSpecIfNeeded(list, copy$default));
workTagDao.deleteByWorkSpecId(str);
workTagDao.insertTags(str, set);
if (z) {
return;
}
workSpecDao.markWorkSpecScheduled(str, -1L);
workDatabase.workProgressDao().delete(str);
}
public static final ListenableFuture updateWorkImpl(final WorkManagerImpl workManagerImpl, final WorkRequest workRequest) {
Intrinsics.checkNotNullParameter(workManagerImpl, "<this>");
Intrinsics.checkNotNullParameter(workRequest, "workRequest");
SerialExecutor serialTaskExecutor = workManagerImpl.getWorkTaskExecutor().getSerialTaskExecutor();
Intrinsics.checkNotNullExpressionValue(serialTaskExecutor, "workTaskExecutor.serialTaskExecutor");
return ListenableFutureKt.executeAsync(serialTaskExecutor, "updateWorkImpl", new Function0() { // from class: androidx.work.impl.WorkerUpdater$updateWorkImpl$3
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
@Override // kotlin.jvm.functions.Function0
public final WorkManager.UpdateResult invoke() {
WorkManager.UpdateResult updateWorkImpl;
Processor processor = WorkManagerImpl.this.getProcessor();
Intrinsics.checkNotNullExpressionValue(processor, "processor");
WorkDatabase workDatabase = WorkManagerImpl.this.getWorkDatabase();
Intrinsics.checkNotNullExpressionValue(workDatabase, "workDatabase");
Configuration configuration = WorkManagerImpl.this.getConfiguration();
Intrinsics.checkNotNullExpressionValue(configuration, "configuration");
List<Scheduler> schedulers = WorkManagerImpl.this.getSchedulers();
Intrinsics.checkNotNullExpressionValue(schedulers, "schedulers");
updateWorkImpl = WorkerUpdater.updateWorkImpl(processor, workDatabase, configuration, schedulers, workRequest.getWorkSpec(), workRequest.getTags());
return updateWorkImpl;
}
});
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static final Operation enqueueUniquelyNamedPeriodic(final WorkManagerImpl workManagerImpl, final String name, final WorkRequest workRequest) {
Intrinsics.checkNotNullParameter(workManagerImpl, "<this>");
Intrinsics.checkNotNullParameter(name, "name");
Intrinsics.checkNotNullParameter(workRequest, "workRequest");
Tracer tracer = workManagerImpl.getConfiguration().getTracer();
String str = "enqueueUniquePeriodic_" + name;
SerialExecutor serialTaskExecutor = workManagerImpl.getWorkTaskExecutor().getSerialTaskExecutor();
Intrinsics.checkNotNullExpressionValue(serialTaskExecutor, "workTaskExecutor.serialTaskExecutor");
return OperationKt.launchOperation(tracer, str, serialTaskExecutor, new Function0() { // from class: androidx.work.impl.WorkerUpdater$enqueueUniquelyNamedPeriodic$1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
@Override // kotlin.jvm.functions.Function0
public /* bridge */ /* synthetic */ Object invoke() {
m187invoke();
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: collision with other method in class */
public final void m187invoke() {
Object firstOrNull;
final WorkRequest workRequest2 = workRequest;
final WorkManagerImpl workManagerImpl2 = WorkManagerImpl.this;
final String str2 = name;
Function0 function0 = new Function0() { // from class: androidx.work.impl.WorkerUpdater$enqueueUniquelyNamedPeriodic$1$enqueueNew$1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
@Override // kotlin.jvm.functions.Function0
public /* bridge */ /* synthetic */ Object invoke() {
m188invoke();
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: collision with other method in class */
public final void m188invoke() {
EnqueueRunnable.enqueue(new WorkContinuationImpl(workManagerImpl2, str2, ExistingWorkPolicy.KEEP, CollectionsKt__CollectionsJVMKt.listOf(WorkRequest.this)));
}
};
WorkSpecDao workSpecDao = WorkManagerImpl.this.getWorkDatabase().workSpecDao();
List<WorkSpec.IdAndState> workSpecIdAndStatesForName = workSpecDao.getWorkSpecIdAndStatesForName(name);
if (workSpecIdAndStatesForName.size() > 1) {
throw new UnsupportedOperationException("Can't apply UPDATE policy to the chains of work.");
}
firstOrNull = CollectionsKt___CollectionsKt.firstOrNull((List) workSpecIdAndStatesForName);
WorkSpec.IdAndState idAndState = (WorkSpec.IdAndState) firstOrNull;
if (idAndState == null) {
function0.invoke();
return;
}
WorkSpec workSpec = workSpecDao.getWorkSpec(idAndState.id);
if (workSpec == null) {
throw new IllegalStateException("WorkSpec with " + idAndState.id + ", that matches a name \"" + name + "\", wasn't found");
}
if (!workSpec.isPeriodic()) {
throw new UnsupportedOperationException("Can't update OneTimeWorker to Periodic Worker. Update operation must preserve worker's type.");
}
if (idAndState.state == WorkInfo.State.CANCELLED) {
workSpecDao.delete(idAndState.id);
function0.invoke();
return;
}
WorkSpec copy$default = WorkSpec.copy$default(workRequest.getWorkSpec(), idAndState.id, null, null, null, null, null, 0L, 0L, 0L, null, 0, null, 0L, 0L, 0L, 0L, false, null, 0, 0, 0L, 0, 0, null, 16777214, null);
Processor processor = WorkManagerImpl.this.getProcessor();
Intrinsics.checkNotNullExpressionValue(processor, "processor");
WorkDatabase workDatabase = WorkManagerImpl.this.getWorkDatabase();
Intrinsics.checkNotNullExpressionValue(workDatabase, "workDatabase");
Configuration configuration = WorkManagerImpl.this.getConfiguration();
Intrinsics.checkNotNullExpressionValue(configuration, "configuration");
List<Scheduler> schedulers = WorkManagerImpl.this.getSchedulers();
Intrinsics.checkNotNullExpressionValue(schedulers, "schedulers");
WorkerUpdater.updateWorkImpl(processor, workDatabase, configuration, schedulers, copy$default, workRequest.getTags());
}
});
}
}

View File

@@ -0,0 +1,55 @@
package androidx.work.impl;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlinx.coroutines.CoroutineScope;
@DebugMetadata(c = "androidx.work.impl.WorkerWrapper$launch$1$resolution$1", f = "WorkerWrapper.kt", l = {98}, m = "invokeSuspend")
/* loaded from: classes.dex */
public final class WorkerWrapper$launch$1$resolution$1 extends SuspendLambda implements Function2 {
int label;
final /* synthetic */ WorkerWrapper this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public WorkerWrapper$launch$1$resolution$1(WorkerWrapper workerWrapper, Continuation continuation) {
super(2, continuation);
this.this$0 = workerWrapper;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
return new WorkerWrapper$launch$1$resolution$1(this.this$0, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) {
return ((WorkerWrapper$launch$1$resolution$1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
WorkerWrapper workerWrapper = this.this$0;
this.label = 1;
obj = workerWrapper.runWorker(this);
if (obj == coroutine_suspended) {
return coroutine_suspended;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
return obj;
}
}

View File

@@ -0,0 +1,109 @@
package androidx.work.impl;
import androidx.work.Logger;
import androidx.work.impl.WorkerWrapper;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import kotlin.NoWhenBranchMatchedException;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CompletableJob;
import kotlinx.coroutines.CoroutineScope;
@DebugMetadata(c = "androidx.work.impl.WorkerWrapper$launch$1", f = "WorkerWrapper.kt", l = {98}, m = "invokeSuspend")
@SourceDebugExtension({"SMAP\nWorkerWrapper.kt\nKotlin\n*S Kotlin\n*F\n+ 1 WorkerWrapper.kt\nandroidx/work/impl/WorkerWrapper$launch$1\n+ 2 LoggerExt.kt\nandroidx/work/LoggerExtKt\n*L\n1#1,607:1\n32#2:608\n*S KotlinDebug\n*F\n+ 1 WorkerWrapper.kt\nandroidx/work/impl/WorkerWrapper$launch$1\n*L\n105#1:608\n*E\n"})
/* loaded from: classes.dex */
public final class WorkerWrapper$launch$1 extends SuspendLambda implements Function2 {
int label;
final /* synthetic */ WorkerWrapper this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public WorkerWrapper$launch$1(WorkerWrapper workerWrapper, Continuation continuation) {
super(2, continuation);
this.this$0 = workerWrapper;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
return new WorkerWrapper$launch$1(this.this$0, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) {
return ((WorkerWrapper$launch$1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
String str;
final WorkerWrapper.Resolution failed;
WorkDatabase workDatabase;
CompletableJob completableJob;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
try {
if (i == 0) {
ResultKt.throwOnFailure(obj);
completableJob = this.this$0.workerJob;
WorkerWrapper$launch$1$resolution$1 workerWrapper$launch$1$resolution$1 = new WorkerWrapper$launch$1$resolution$1(this.this$0, null);
this.label = 1;
obj = BuildersKt.withContext(completableJob, workerWrapper$launch$1$resolution$1, this);
if (obj == coroutine_suspended) {
return coroutine_suspended;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
failed = (WorkerWrapper.Resolution) obj;
} catch (WorkerStoppedException e) {
failed = new WorkerWrapper.Resolution.ResetWorkerStatus(e.getReason());
} catch (CancellationException unused) {
failed = new WorkerWrapper.Resolution.Failed(null, 1, null);
} catch (Throwable th) {
str = WorkerWrapperKt.TAG;
Logger.get().error(str, "Unexpected error in WorkerWrapper", th);
failed = new WorkerWrapper.Resolution.Failed(null, 1, null);
}
workDatabase = this.this$0.workDatabase;
final WorkerWrapper workerWrapper = this.this$0;
Object runInTransaction = workDatabase.runInTransaction((Callable<Object>) new Callable() { // from class: androidx.work.impl.WorkerWrapper$launch$1$$ExternalSyntheticLambda0
@Override // java.util.concurrent.Callable
public final Object call() {
Boolean invokeSuspend$lambda$1;
invokeSuspend$lambda$1 = WorkerWrapper$launch$1.invokeSuspend$lambda$1(WorkerWrapper.Resolution.this, workerWrapper);
return invokeSuspend$lambda$1;
}
});
Intrinsics.checkNotNullExpressionValue(runInTransaction, "workDatabase.runInTransa… }\n )");
return runInTransaction;
}
/* JADX INFO: Access modifiers changed from: private */
public static final Boolean invokeSuspend$lambda$1(WorkerWrapper.Resolution resolution, WorkerWrapper workerWrapper) {
boolean resetWorkerStatus;
if (resolution instanceof WorkerWrapper.Resolution.Finished) {
resetWorkerStatus = workerWrapper.onWorkFinished(((WorkerWrapper.Resolution.Finished) resolution).getResult());
} else if (resolution instanceof WorkerWrapper.Resolution.Failed) {
workerWrapper.setFailed(((WorkerWrapper.Resolution.Failed) resolution).getResult());
resetWorkerStatus = false;
} else {
if (!(resolution instanceof WorkerWrapper.Resolution.ResetWorkerStatus)) {
throw new NoWhenBranchMatchedException();
}
resetWorkerStatus = workerWrapper.resetWorkerStatus(((WorkerWrapper.Resolution.ResetWorkerStatus) resolution).getReason());
}
return Boolean.valueOf(resetWorkerStatus);
}
}

View File

@@ -0,0 +1,30 @@
package androidx.work.impl;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.coroutines.jvm.internal.DebugMetadata;
@DebugMetadata(c = "androidx.work.impl.WorkerWrapper", f = "WorkerWrapper.kt", l = {299}, m = "runWorker")
/* loaded from: classes.dex */
public final class WorkerWrapper$runWorker$1 extends ContinuationImpl {
Object L$0;
Object L$1;
int label;
/* synthetic */ Object result;
final /* synthetic */ WorkerWrapper this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public WorkerWrapper$runWorker$1(WorkerWrapper workerWrapper, Continuation continuation) {
super(continuation);
this.this$0 = workerWrapper;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object runWorker;
this.result = obj;
this.label |= Integer.MIN_VALUE;
runWorker = this.this$0.runWorker(this);
return runWorker;
}
}

View File

@@ -0,0 +1,87 @@
package androidx.work.impl;
import android.content.Context;
import androidx.work.ForegroundUpdater;
import androidx.work.ListenableWorker;
import androidx.work.Logger;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.utils.WorkForegroundKt;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import com.google.common.util.concurrent.ListenableFuture;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlinx.coroutines.CoroutineScope;
@DebugMetadata(c = "androidx.work.impl.WorkerWrapper$runWorker$result$1", f = "WorkerWrapper.kt", l = {300, 311}, m = "invokeSuspend")
@SourceDebugExtension({"SMAP\nWorkerWrapper.kt\nKotlin\n*S Kotlin\n*F\n+ 1 WorkerWrapper.kt\nandroidx/work/impl/WorkerWrapper$runWorker$result$1\n+ 2 LoggerExt.kt\nandroidx/work/LoggerExtKt\n*L\n1#1,607:1\n19#2:608\n*S KotlinDebug\n*F\n+ 1 WorkerWrapper.kt\nandroidx/work/impl/WorkerWrapper$runWorker$result$1\n*L\n307#1:608\n*E\n"})
/* loaded from: classes.dex */
public final class WorkerWrapper$runWorker$result$1 extends SuspendLambda implements Function2 {
final /* synthetic */ ForegroundUpdater $foregroundUpdater;
final /* synthetic */ ListenableWorker $worker;
int label;
final /* synthetic */ WorkerWrapper this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public WorkerWrapper$runWorker$result$1(WorkerWrapper workerWrapper, ListenableWorker listenableWorker, ForegroundUpdater foregroundUpdater, Continuation continuation) {
super(2, continuation);
this.this$0 = workerWrapper;
this.$worker = listenableWorker;
this.$foregroundUpdater = foregroundUpdater;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
return new WorkerWrapper$runWorker$result$1(this.this$0, this.$worker, this.$foregroundUpdater, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) {
return ((WorkerWrapper$runWorker$result$1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
Context context;
TaskExecutor taskExecutor;
String str;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
context = this.this$0.appContext;
WorkSpec workSpec = this.this$0.getWorkSpec();
ListenableWorker listenableWorker = this.$worker;
ForegroundUpdater foregroundUpdater = this.$foregroundUpdater;
taskExecutor = this.this$0.workTaskExecutor;
this.label = 1;
if (WorkForegroundKt.workForeground(context, workSpec, listenableWorker, foregroundUpdater, taskExecutor, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else {
if (i != 1) {
if (i == 2) {
ResultKt.throwOnFailure(obj);
}
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
str = WorkerWrapperKt.TAG;
WorkerWrapper workerWrapper = this.this$0;
Logger.get().debug(str, "Starting work for " + workerWrapper.getWorkSpec().workerClassName);
ListenableFuture startWork = this.$worker.startWork();
Intrinsics.checkNotNullExpressionValue(startWork, "worker.startWork()");
ListenableWorker listenableWorker2 = this.$worker;
this.label = 2;
obj = WorkerWrapperKt.awaitWithin(startWork, listenableWorker2, this);
return obj == coroutine_suspended ? coroutine_suspended : obj;
}
}

View File

@@ -0,0 +1,462 @@
package androidx.work.impl;
import android.annotation.SuppressLint;
import android.content.Context;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.work.Clock;
import androidx.work.Configuration;
import androidx.work.Data;
import androidx.work.ListenableFutureKt;
import androidx.work.ListenableWorker;
import androidx.work.Logger;
import androidx.work.WorkInfo;
import androidx.work.WorkerParameters;
import androidx.work.impl.foreground.ForegroundProcessor;
import androidx.work.impl.model.DependencyDao;
import androidx.work.impl.model.WorkGenerationalId;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.model.WorkSpecDao;
import androidx.work.impl.model.WorkSpecKt;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
import java.util.concurrent.Callable;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.collections.CollectionsKt__MutableCollectionsKt;
import kotlin.collections.CollectionsKt___CollectionsKt;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlinx.coroutines.CompletableJob;
import kotlinx.coroutines.CoroutineDispatcher;
import kotlinx.coroutines.JobKt__JobKt;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
@SourceDebugExtension({"SMAP\nWorkerWrapper.kt\nKotlin\n*S Kotlin\n*F\n+ 1 WorkerWrapper.kt\nandroidx/work/impl/WorkerWrapper\n+ 2 LoggerExt.kt\nandroidx/work/LoggerExtKt\n*L\n1#1,607:1\n29#2:608\n29#2:609\n27#2:610\n32#2:611\n19#2:612\n19#2:613\n24#2:614\n24#2:615\n24#2:616\n24#2:617\n19#2:618\n*S KotlinDebug\n*F\n+ 1 WorkerWrapper.kt\nandroidx/work/impl/WorkerWrapper\n*L\n206#1:608\n240#1:609\n315#1:610\n318#1:611\n354#1:612\n367#1:613\n374#1:614\n381#1:615\n384#1:616\n477#1:617\n151#1:618\n*E\n"})
/* loaded from: classes.dex */
public final class WorkerWrapper {
private final Context appContext;
private final ListenableWorker builderWorker;
private final Clock clock;
private final Configuration configuration;
private final DependencyDao dependencyDao;
private final ForegroundProcessor foregroundProcessor;
private final WorkerParameters.RuntimeExtras runtimeExtras;
private final List<String> tags;
private final WorkDatabase workDatabase;
private final String workDescription;
private final WorkSpec workSpec;
private final WorkSpecDao workSpecDao;
private final String workSpecId;
private final TaskExecutor workTaskExecutor;
private final CompletableJob workerJob;
public final WorkSpec getWorkSpec() {
return this.workSpec;
}
public WorkerWrapper(Builder builder) {
CompletableJob Job$default;
Intrinsics.checkNotNullParameter(builder, "builder");
WorkSpec workSpec = builder.getWorkSpec();
this.workSpec = workSpec;
this.appContext = builder.getAppContext();
this.workSpecId = workSpec.id;
this.runtimeExtras = builder.getRuntimeExtras();
this.builderWorker = builder.getWorker();
this.workTaskExecutor = builder.getWorkTaskExecutor();
Configuration configuration = builder.getConfiguration();
this.configuration = configuration;
this.clock = configuration.getClock();
this.foregroundProcessor = builder.getForegroundProcessor();
WorkDatabase workDatabase = builder.getWorkDatabase();
this.workDatabase = workDatabase;
this.workSpecDao = workDatabase.workSpecDao();
this.dependencyDao = workDatabase.dependencyDao();
List<String> tags = builder.getTags();
this.tags = tags;
this.workDescription = createWorkDescription(tags);
Job$default = JobKt__JobKt.Job$default(null, 1, null);
this.workerJob = Job$default;
}
public final WorkGenerationalId getWorkGenerationalId() {
return WorkSpecKt.generationalId(this.workSpec);
}
public final ListenableFuture launch() {
CompletableJob Job$default;
CoroutineDispatcher taskCoroutineDispatcher = this.workTaskExecutor.getTaskCoroutineDispatcher();
Job$default = JobKt__JobKt.Job$default(null, 1, null);
return ListenableFutureKt.launchFuture$default(taskCoroutineDispatcher.plus(Job$default), null, new WorkerWrapper$launch$1(this, null), 2, null);
}
public static abstract class Resolution {
public /* synthetic */ Resolution(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static final class ResetWorkerStatus extends Resolution {
private final int reason;
public ResetWorkerStatus() {
this(0, 1, null);
}
public final int getReason() {
return this.reason;
}
public ResetWorkerStatus(int i) {
super(null);
this.reason = i;
}
public /* synthetic */ ResetWorkerStatus(int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
this((i2 & 1) != 0 ? -256 : i);
}
}
private Resolution() {
}
public static final class Failed extends Resolution {
private final ListenableWorker.Result result;
/* JADX WARN: Multi-variable type inference failed */
public Failed() {
this(null, 1, 0 == true ? 1 : 0);
}
public final ListenableWorker.Result getResult() {
return this.result;
}
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public Failed(ListenableWorker.Result result) {
super(null);
Intrinsics.checkNotNullParameter(result, "result");
this.result = result;
}
public /* synthetic */ Failed(ListenableWorker.Result result, int i, DefaultConstructorMarker defaultConstructorMarker) {
this((i & 1) != 0 ? new ListenableWorker.Result.Failure() : result);
}
}
public static final class Finished extends Resolution {
private final ListenableWorker.Result result;
public final ListenableWorker.Result getResult() {
return this.result;
}
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public Finished(ListenableWorker.Result result) {
super(null);
Intrinsics.checkNotNullParameter(result, "result");
this.result = result;
}
}
}
/* JADX INFO: Access modifiers changed from: private */
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Removed duplicated region for block: B:22:0x0230 */
/* JADX WARN: Removed duplicated region for block: B:27:0x0045 */
/* JADX WARN: Removed duplicated region for block: B:8:0x0028 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final java.lang.Object runWorker(kotlin.coroutines.Continuation r24) {
/*
Method dump skipped, instructions count: 615
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.work.impl.WorkerWrapper.runWorker(kotlin.coroutines.Continuation):java.lang.Object");
}
/* JADX INFO: Access modifiers changed from: private */
public static final Boolean runWorker$lambda$1(WorkerWrapper workerWrapper) {
String str;
String str2;
WorkSpec workSpec = workerWrapper.workSpec;
if (workSpec.state != WorkInfo.State.ENQUEUED) {
str2 = WorkerWrapperKt.TAG;
Logger.get().debug(str2, workerWrapper.workSpec.workerClassName + " is not in ENQUEUED state. Nothing more to do");
return Boolean.TRUE;
}
if ((!workSpec.isPeriodic() && !workerWrapper.workSpec.isBackedOff()) || workerWrapper.clock.currentTimeMillis() >= workerWrapper.workSpec.calculateNextRunTime()) {
return Boolean.FALSE;
}
Logger logger = Logger.get();
str = WorkerWrapperKt.TAG;
logger.debug(str, "Delaying execution for " + workerWrapper.workSpec.workerClassName + " because it is being executed before schedule.");
return Boolean.TRUE;
}
/* JADX INFO: Access modifiers changed from: private */
public final boolean onWorkFinished(ListenableWorker.Result result) {
WorkInfo.State state = this.workSpecDao.getState(this.workSpecId);
this.workDatabase.workProgressDao().delete(this.workSpecId);
if (state == null) {
return false;
}
if (state == WorkInfo.State.RUNNING) {
return handleResult(result);
}
if (state.isFinished()) {
return false;
}
return reschedule(WorkInfo.STOP_REASON_UNKNOWN);
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public final void interrupt(int i) {
this.workerJob.cancel(new WorkerStoppedException(i));
}
/* JADX INFO: Access modifiers changed from: private */
public final boolean resetWorkerStatus(int i) {
String str;
String str2;
WorkInfo.State state = this.workSpecDao.getState(this.workSpecId);
if (state == null || state.isFinished()) {
str = WorkerWrapperKt.TAG;
Logger.get().debug(str, "Status for " + this.workSpecId + " is " + state + " ; not doing any work");
return false;
}
str2 = WorkerWrapperKt.TAG;
Logger.get().debug(str2, "Status for " + this.workSpecId + " is " + state + "; not doing any work and rescheduling for later execution");
this.workSpecDao.setState(WorkInfo.State.ENQUEUED, this.workSpecId);
this.workSpecDao.setStopReason(this.workSpecId, i);
this.workSpecDao.markWorkSpecScheduled(this.workSpecId, -1L);
return true;
}
private final boolean handleResult(ListenableWorker.Result result) {
String str;
String str2;
String str3;
if (result instanceof ListenableWorker.Result.Success) {
str3 = WorkerWrapperKt.TAG;
Logger.get().info(str3, "Worker result SUCCESS for " + this.workDescription);
return this.workSpec.isPeriodic() ? resetPeriodic() : setSucceeded(result);
}
if (result instanceof ListenableWorker.Result.Retry) {
str2 = WorkerWrapperKt.TAG;
Logger.get().info(str2, "Worker result RETRY for " + this.workDescription);
return reschedule(-256);
}
str = WorkerWrapperKt.TAG;
Logger.get().info(str, "Worker result FAILURE for " + this.workDescription);
if (this.workSpec.isPeriodic()) {
return resetPeriodic();
}
if (result == null) {
result = new ListenableWorker.Result.Failure();
}
return setFailed(result);
}
private final boolean trySetRunning() {
Object runInTransaction = this.workDatabase.runInTransaction((Callable<Object>) new Callable() { // from class: androidx.work.impl.WorkerWrapper$$ExternalSyntheticLambda1
@Override // java.util.concurrent.Callable
public final Object call() {
Boolean trySetRunning$lambda$11;
trySetRunning$lambda$11 = WorkerWrapper.trySetRunning$lambda$11(WorkerWrapper.this);
return trySetRunning$lambda$11;
}
});
Intrinsics.checkNotNullExpressionValue(runInTransaction, "workDatabase.runInTransa…e\n }\n )");
return ((Boolean) runInTransaction).booleanValue();
}
/* JADX INFO: Access modifiers changed from: private */
public static final Boolean trySetRunning$lambda$11(WorkerWrapper workerWrapper) {
boolean z;
if (workerWrapper.workSpecDao.getState(workerWrapper.workSpecId) == WorkInfo.State.ENQUEUED) {
workerWrapper.workSpecDao.setState(WorkInfo.State.RUNNING, workerWrapper.workSpecId);
workerWrapper.workSpecDao.incrementWorkSpecRunAttemptCount(workerWrapper.workSpecId);
workerWrapper.workSpecDao.setStopReason(workerWrapper.workSpecId, -256);
z = true;
} else {
z = false;
}
return Boolean.valueOf(z);
}
@VisibleForTesting
public final boolean setFailed(ListenableWorker.Result result) {
Intrinsics.checkNotNullParameter(result, "result");
iterativelyFailWorkAndDependents(this.workSpecId);
Data outputData = ((ListenableWorker.Result.Failure) result).getOutputData();
Intrinsics.checkNotNullExpressionValue(outputData, "failure.outputData");
this.workSpecDao.resetWorkSpecNextScheduleTimeOverride(this.workSpecId, this.workSpec.getNextScheduleTimeOverrideGeneration());
this.workSpecDao.setOutput(this.workSpecId, outputData);
return false;
}
private final void iterativelyFailWorkAndDependents(String str) {
List mutableListOf;
Object removeLast;
mutableListOf = CollectionsKt__CollectionsKt.mutableListOf(str);
while (!mutableListOf.isEmpty()) {
removeLast = CollectionsKt__MutableCollectionsKt.removeLast(mutableListOf);
String str2 = (String) removeLast;
if (this.workSpecDao.getState(str2) != WorkInfo.State.CANCELLED) {
this.workSpecDao.setState(WorkInfo.State.FAILED, str2);
}
mutableListOf.addAll(this.dependencyDao.getDependentWorkIds(str2));
}
}
private final boolean reschedule(int i) {
this.workSpecDao.setState(WorkInfo.State.ENQUEUED, this.workSpecId);
this.workSpecDao.setLastEnqueueTime(this.workSpecId, this.clock.currentTimeMillis());
this.workSpecDao.resetWorkSpecNextScheduleTimeOverride(this.workSpecId, this.workSpec.getNextScheduleTimeOverrideGeneration());
this.workSpecDao.markWorkSpecScheduled(this.workSpecId, -1L);
this.workSpecDao.setStopReason(this.workSpecId, i);
return true;
}
private final boolean resetPeriodic() {
this.workSpecDao.setLastEnqueueTime(this.workSpecId, this.clock.currentTimeMillis());
this.workSpecDao.setState(WorkInfo.State.ENQUEUED, this.workSpecId);
this.workSpecDao.resetWorkSpecRunAttemptCount(this.workSpecId);
this.workSpecDao.resetWorkSpecNextScheduleTimeOverride(this.workSpecId, this.workSpec.getNextScheduleTimeOverrideGeneration());
this.workSpecDao.incrementPeriodCount(this.workSpecId);
this.workSpecDao.markWorkSpecScheduled(this.workSpecId, -1L);
return false;
}
private final boolean setSucceeded(ListenableWorker.Result result) {
String str;
this.workSpecDao.setState(WorkInfo.State.SUCCEEDED, this.workSpecId);
Intrinsics.checkNotNull(result, "null cannot be cast to non-null type androidx.work.ListenableWorker.Result.Success");
Data outputData = ((ListenableWorker.Result.Success) result).getOutputData();
Intrinsics.checkNotNullExpressionValue(outputData, "success.outputData");
this.workSpecDao.setOutput(this.workSpecId, outputData);
long currentTimeMillis = this.clock.currentTimeMillis();
for (String str2 : this.dependencyDao.getDependentWorkIds(this.workSpecId)) {
if (this.workSpecDao.getState(str2) == WorkInfo.State.BLOCKED && this.dependencyDao.hasCompletedAllPrerequisites(str2)) {
str = WorkerWrapperKt.TAG;
Logger.get().info(str, "Setting status to enqueued for " + str2);
this.workSpecDao.setState(WorkInfo.State.ENQUEUED, str2);
this.workSpecDao.setLastEnqueueTime(str2, currentTimeMillis);
}
}
return false;
}
private final String createWorkDescription(List<String> list) {
String joinToString$default;
StringBuilder sb = new StringBuilder();
sb.append("Work [ id=");
sb.append(this.workSpecId);
sb.append(", tags={ ");
joinToString$default = CollectionsKt___CollectionsKt.joinToString$default(list, ",", null, null, 0, null, null, 62, null);
sb.append(joinToString$default);
sb.append(" } ]");
return sb.toString();
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static final class Builder {
private final Context appContext;
private final Configuration configuration;
private final ForegroundProcessor foregroundProcessor;
private WorkerParameters.RuntimeExtras runtimeExtras;
private final List<String> tags;
private final WorkDatabase workDatabase;
private final WorkSpec workSpec;
private final TaskExecutor workTaskExecutor;
private ListenableWorker worker;
public final Context getAppContext() {
return this.appContext;
}
public final Configuration getConfiguration() {
return this.configuration;
}
public final ForegroundProcessor getForegroundProcessor() {
return this.foregroundProcessor;
}
public final WorkerParameters.RuntimeExtras getRuntimeExtras() {
return this.runtimeExtras;
}
public final List<String> getTags() {
return this.tags;
}
public final WorkDatabase getWorkDatabase() {
return this.workDatabase;
}
public final WorkSpec getWorkSpec() {
return this.workSpec;
}
public final TaskExecutor getWorkTaskExecutor() {
return this.workTaskExecutor;
}
public final ListenableWorker getWorker() {
return this.worker;
}
public final void setRuntimeExtras(WorkerParameters.RuntimeExtras runtimeExtras) {
Intrinsics.checkNotNullParameter(runtimeExtras, "<set-?>");
this.runtimeExtras = runtimeExtras;
}
public final void setWorker(ListenableWorker listenableWorker) {
this.worker = listenableWorker;
}
public final Builder withRuntimeExtras(WorkerParameters.RuntimeExtras runtimeExtras) {
if (runtimeExtras != null) {
this.runtimeExtras = runtimeExtras;
}
return this;
}
@VisibleForTesting
public final Builder withWorker(ListenableWorker worker) {
Intrinsics.checkNotNullParameter(worker, "worker");
this.worker = worker;
return this;
}
@SuppressLint({"LambdaLast"})
public Builder(Context context, Configuration configuration, TaskExecutor workTaskExecutor, ForegroundProcessor foregroundProcessor, WorkDatabase workDatabase, WorkSpec workSpec, List<String> tags) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(configuration, "configuration");
Intrinsics.checkNotNullParameter(workTaskExecutor, "workTaskExecutor");
Intrinsics.checkNotNullParameter(foregroundProcessor, "foregroundProcessor");
Intrinsics.checkNotNullParameter(workDatabase, "workDatabase");
Intrinsics.checkNotNullParameter(workSpec, "workSpec");
Intrinsics.checkNotNullParameter(tags, "tags");
this.configuration = configuration;
this.workTaskExecutor = workTaskExecutor;
this.foregroundProcessor = foregroundProcessor;
this.workDatabase = workDatabase;
this.workSpec = workSpec;
this.tags = tags;
Context applicationContext = context.getApplicationContext();
Intrinsics.checkNotNullExpressionValue(applicationContext, "context.applicationContext");
this.appContext = applicationContext;
this.runtimeExtras = new WorkerParameters.RuntimeExtras();
}
public final WorkerWrapper build() {
return new WorkerWrapper(this);
}
}
}

View File

@@ -0,0 +1,102 @@
package androidx.work.impl;
import androidx.annotation.RestrictTo;
import androidx.work.DirectExecutor;
import androidx.work.ListenableWorker;
import androidx.work.Logger;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugProbesKt;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlinx.coroutines.CancellableContinuationImpl;
@SourceDebugExtension({"SMAP\nWorkerWrapper.kt\nKotlin\n*S Kotlin\n*F\n+ 1 WorkerWrapper.kt\nandroidx/work/impl/WorkerWrapperKt\n+ 2 CancellableContinuation.kt\nkotlinx/coroutines/CancellableContinuationKt\n*L\n1#1,607:1\n314#2,11:608\n*S KotlinDebug\n*F\n+ 1 WorkerWrapper.kt\nandroidx/work/impl/WorkerWrapperKt\n*L\n553#1:608,11\n*E\n"})
/* loaded from: classes.dex */
public final class WorkerWrapperKt {
private static final String TAG;
static {
String tagWithPrefix = Logger.tagWithPrefix("WorkerWrapper");
Intrinsics.checkNotNullExpressionValue(tagWithPrefix, "tagWithPrefix(\"WorkerWrapper\")");
TAG = tagWithPrefix;
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static final <T> Object awaitWithin(final ListenableFuture listenableFuture, final ListenableWorker listenableWorker, Continuation continuation) {
Continuation intercepted;
Object coroutine_suspended;
try {
if (listenableFuture.isDone()) {
return getUninterruptibly(listenableFuture);
}
intercepted = IntrinsicsKt__IntrinsicsJvmKt.intercepted(continuation);
CancellableContinuationImpl cancellableContinuationImpl = new CancellableContinuationImpl(intercepted, 1);
cancellableContinuationImpl.initCancellability();
listenableFuture.addListener(new ToContinuation(listenableFuture, cancellableContinuationImpl), DirectExecutor.INSTANCE);
cancellableContinuationImpl.invokeOnCancellation(new Function1() { // from class: androidx.work.impl.WorkerWrapperKt$awaitWithin$2$1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(1);
}
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Object invoke(Object obj) {
invoke((Throwable) obj);
return Unit.INSTANCE;
}
public final void invoke(Throwable th) {
if (th instanceof WorkerStoppedException) {
ListenableWorker.this.stop(((WorkerStoppedException) th).getReason());
}
listenableFuture.cancel(false);
}
});
Object result = cancellableContinuationImpl.getResult();
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
if (result == coroutine_suspended) {
DebugProbesKt.probeCoroutineSuspended(continuation);
}
return result;
} catch (ExecutionException e) {
throw nonNullCause(e);
}
}
/* JADX INFO: Access modifiers changed from: private */
public static final <V> V getUninterruptibly(Future<V> future) {
V v;
boolean z = false;
while (true) {
try {
v = future.get();
break;
} catch (InterruptedException unused) {
z = true;
} catch (Throwable th) {
if (z) {
Thread.currentThread().interrupt();
}
throw th;
}
}
if (z) {
Thread.currentThread().interrupt();
}
return v;
}
/* JADX INFO: Access modifiers changed from: private */
public static final Throwable nonNullCause(ExecutionException executionException) {
Throwable cause = executionException.getCause();
Intrinsics.checkNotNull(cause);
return cause;
}
}

View File

@@ -0,0 +1,50 @@
package androidx.work.impl.background.greedy;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.work.Clock;
import androidx.work.Logger;
import androidx.work.RunnableScheduler;
import androidx.work.impl.Scheduler;
import androidx.work.impl.model.WorkSpec;
import java.util.HashMap;
import java.util.Map;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class DelayedWorkTracker {
static final String TAG = Logger.tagWithPrefix("DelayedWorkTracker");
private final Clock mClock;
final Scheduler mImmediateScheduler;
private final RunnableScheduler mRunnableScheduler;
private final Map<String, Runnable> mRunnables = new HashMap();
public DelayedWorkTracker(@NonNull Scheduler scheduler, @NonNull RunnableScheduler runnableScheduler, @NonNull Clock clock) {
this.mImmediateScheduler = scheduler;
this.mRunnableScheduler = runnableScheduler;
this.mClock = clock;
}
public void schedule(@NonNull final WorkSpec workSpec, long j) {
Runnable remove = this.mRunnables.remove(workSpec.id);
if (remove != null) {
this.mRunnableScheduler.cancel(remove);
}
Runnable runnable = new Runnable() { // from class: androidx.work.impl.background.greedy.DelayedWorkTracker.1
@Override // java.lang.Runnable
public void run() {
Logger.get().debug(DelayedWorkTracker.TAG, "Scheduling work " + workSpec.id);
DelayedWorkTracker.this.mImmediateScheduler.schedule(workSpec);
}
};
this.mRunnables.put(workSpec.id, runnable);
this.mRunnableScheduler.scheduleWithDelay(j - this.mClock.currentTimeMillis(), runnable);
}
public void unschedule(@NonNull String str) {
Runnable remove = this.mRunnables.remove(str);
if (remove != null) {
this.mRunnableScheduler.cancel(remove);
}
}
}

View File

@@ -0,0 +1,242 @@
package androidx.work.impl.background.greedy;
import android.content.Context;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.work.Configuration;
import androidx.work.Constraints;
import androidx.work.Logger;
import androidx.work.RunnableScheduler;
import androidx.work.WorkInfo;
import androidx.work.WorkRequest;
import androidx.work.impl.ExecutionListener;
import androidx.work.impl.Processor;
import androidx.work.impl.Scheduler;
import androidx.work.impl.StartStopToken;
import androidx.work.impl.StartStopTokens;
import androidx.work.impl.WorkLauncher;
import androidx.work.impl.constraints.ConstraintsState;
import androidx.work.impl.constraints.OnConstraintsStateChangedListener;
import androidx.work.impl.constraints.WorkConstraintsTracker;
import androidx.work.impl.constraints.WorkConstraintsTrackerKt;
import androidx.work.impl.constraints.trackers.Trackers;
import androidx.work.impl.model.WorkGenerationalId;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.model.WorkSpecKt;
import androidx.work.impl.utils.ProcessUtils;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import kotlinx.coroutines.Job;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class GreedyScheduler implements Scheduler, OnConstraintsStateChangedListener, ExecutionListener {
private static final int NON_THROTTLE_RUN_ATTEMPT_COUNT = 5;
private static final String TAG = Logger.tagWithPrefix("GreedyScheduler");
private final Configuration mConfiguration;
private final WorkConstraintsTracker mConstraintsTracker;
private final Context mContext;
private DelayedWorkTracker mDelayedWorkTracker;
Boolean mInDefaultProcess;
private final Processor mProcessor;
private boolean mRegisteredExecutionListener;
private final TaskExecutor mTaskExecutor;
private final TimeLimiter mTimeLimiter;
private final WorkLauncher mWorkLauncher;
private final Map<WorkGenerationalId, Job> mConstrainedWorkSpecs = new HashMap();
private final Object mLock = new Object();
private final StartStopTokens mStartStopTokens = StartStopTokens.create();
private final Map<WorkGenerationalId, AttemptData> mFirstRunAttempts = new HashMap();
@Override // androidx.work.impl.Scheduler
public boolean hasLimitedSchedulingSlots() {
return false;
}
@VisibleForTesting
public void setDelayedWorkTracker(@NonNull DelayedWorkTracker delayedWorkTracker) {
this.mDelayedWorkTracker = delayedWorkTracker;
}
public GreedyScheduler(@NonNull Context context, @NonNull Configuration configuration, @NonNull Trackers trackers, @NonNull Processor processor, @NonNull WorkLauncher workLauncher, @NonNull TaskExecutor taskExecutor) {
this.mContext = context;
RunnableScheduler runnableScheduler = configuration.getRunnableScheduler();
this.mDelayedWorkTracker = new DelayedWorkTracker(this, runnableScheduler, configuration.getClock());
this.mTimeLimiter = new TimeLimiter(runnableScheduler, workLauncher);
this.mTaskExecutor = taskExecutor;
this.mConstraintsTracker = new WorkConstraintsTracker(trackers);
this.mConfiguration = configuration;
this.mProcessor = processor;
this.mWorkLauncher = workLauncher;
}
@Override // androidx.work.impl.Scheduler
public void schedule(@NonNull WorkSpec... workSpecArr) {
if (this.mInDefaultProcess == null) {
checkDefaultProcess();
}
if (!this.mInDefaultProcess.booleanValue()) {
Logger.get().info(TAG, "Ignoring schedule request in a secondary process");
return;
}
registerExecutionListenerIfNeeded();
HashSet<WorkSpec> hashSet = new HashSet();
HashSet hashSet2 = new HashSet();
for (WorkSpec workSpec : workSpecArr) {
if (!this.mStartStopTokens.contains(WorkSpecKt.generationalId(workSpec))) {
long max = Math.max(workSpec.calculateNextRunTime(), throttleIfNeeded(workSpec));
long currentTimeMillis = this.mConfiguration.getClock().currentTimeMillis();
if (workSpec.state == WorkInfo.State.ENQUEUED) {
if (currentTimeMillis < max) {
DelayedWorkTracker delayedWorkTracker = this.mDelayedWorkTracker;
if (delayedWorkTracker != null) {
delayedWorkTracker.schedule(workSpec, max);
}
} else if (workSpec.hasConstraints()) {
Constraints constraints = workSpec.constraints;
if (constraints.requiresDeviceIdle()) {
Logger.get().debug(TAG, "Ignoring " + workSpec + ". Requires device idle.");
} else if (constraints.hasContentUriTriggers()) {
Logger.get().debug(TAG, "Ignoring " + workSpec + ". Requires ContentUri triggers.");
} else {
hashSet.add(workSpec);
hashSet2.add(workSpec.id);
}
} else if (!this.mStartStopTokens.contains(WorkSpecKt.generationalId(workSpec))) {
Logger.get().debug(TAG, "Starting work for " + workSpec.id);
StartStopToken startStopToken = this.mStartStopTokens.tokenFor(workSpec);
this.mTimeLimiter.track(startStopToken);
this.mWorkLauncher.startWork(startStopToken);
}
}
}
}
synchronized (this.mLock) {
try {
if (!hashSet.isEmpty()) {
Logger.get().debug(TAG, "Starting tracking for " + TextUtils.join(",", hashSet2));
for (WorkSpec workSpec2 : hashSet) {
WorkGenerationalId generationalId = WorkSpecKt.generationalId(workSpec2);
if (!this.mConstrainedWorkSpecs.containsKey(generationalId)) {
this.mConstrainedWorkSpecs.put(generationalId, WorkConstraintsTrackerKt.listen(this.mConstraintsTracker, workSpec2, this.mTaskExecutor.getTaskCoroutineDispatcher(), this));
}
}
}
} catch (Throwable th) {
throw th;
}
}
}
private void checkDefaultProcess() {
this.mInDefaultProcess = Boolean.valueOf(ProcessUtils.isDefaultProcess(this.mContext, this.mConfiguration));
}
@Override // androidx.work.impl.Scheduler
public void cancel(@NonNull String str) {
if (this.mInDefaultProcess == null) {
checkDefaultProcess();
}
if (!this.mInDefaultProcess.booleanValue()) {
Logger.get().info(TAG, "Ignoring schedule request in non-main process");
return;
}
registerExecutionListenerIfNeeded();
Logger.get().debug(TAG, "Cancelling work ID " + str);
DelayedWorkTracker delayedWorkTracker = this.mDelayedWorkTracker;
if (delayedWorkTracker != null) {
delayedWorkTracker.unschedule(str);
}
for (StartStopToken startStopToken : this.mStartStopTokens.remove(str)) {
this.mTimeLimiter.cancel(startStopToken);
this.mWorkLauncher.stopWork(startStopToken);
}
}
@Override // androidx.work.impl.constraints.OnConstraintsStateChangedListener
public void onConstraintsStateChanged(@NonNull WorkSpec workSpec, @NonNull ConstraintsState constraintsState) {
WorkGenerationalId generationalId = WorkSpecKt.generationalId(workSpec);
if (constraintsState instanceof ConstraintsState.ConstraintsMet) {
if (this.mStartStopTokens.contains(generationalId)) {
return;
}
Logger.get().debug(TAG, "Constraints met: Scheduling work ID " + generationalId);
StartStopToken startStopToken = this.mStartStopTokens.tokenFor(generationalId);
this.mTimeLimiter.track(startStopToken);
this.mWorkLauncher.startWork(startStopToken);
return;
}
Logger.get().debug(TAG, "Constraints not met: Cancelling work ID " + generationalId);
StartStopToken remove = this.mStartStopTokens.remove(generationalId);
if (remove != null) {
this.mTimeLimiter.cancel(remove);
this.mWorkLauncher.stopWorkWithReason(remove, ((ConstraintsState.ConstraintsNotMet) constraintsState).getReason());
}
}
@Override // androidx.work.impl.ExecutionListener
public void onExecuted(@NonNull WorkGenerationalId workGenerationalId, boolean z) {
StartStopToken remove = this.mStartStopTokens.remove(workGenerationalId);
if (remove != null) {
this.mTimeLimiter.cancel(remove);
}
removeConstraintTrackingFor(workGenerationalId);
if (z) {
return;
}
synchronized (this.mLock) {
this.mFirstRunAttempts.remove(workGenerationalId);
}
}
private void removeConstraintTrackingFor(@NonNull WorkGenerationalId workGenerationalId) {
Job remove;
synchronized (this.mLock) {
remove = this.mConstrainedWorkSpecs.remove(workGenerationalId);
}
if (remove != null) {
Logger.get().debug(TAG, "Stopping tracking for " + workGenerationalId);
remove.cancel(null);
}
}
private void registerExecutionListenerIfNeeded() {
if (this.mRegisteredExecutionListener) {
return;
}
this.mProcessor.addExecutionListener(this);
this.mRegisteredExecutionListener = true;
}
private long throttleIfNeeded(WorkSpec workSpec) {
long max;
synchronized (this.mLock) {
try {
WorkGenerationalId generationalId = WorkSpecKt.generationalId(workSpec);
AttemptData attemptData = this.mFirstRunAttempts.get(generationalId);
if (attemptData == null) {
attemptData = new AttemptData(workSpec.runAttemptCount, this.mConfiguration.getClock().currentTimeMillis());
this.mFirstRunAttempts.put(generationalId, attemptData);
}
max = attemptData.mTimeStamp + (Math.max((workSpec.runAttemptCount - attemptData.mRunAttemptCount) - 5, 0) * WorkRequest.DEFAULT_BACKOFF_DELAY_MILLIS);
} catch (Throwable th) {
throw th;
}
}
return max;
}
public static class AttemptData {
final int mRunAttemptCount;
final long mTimeStamp;
private AttemptData(int i, long j) {
this.mRunAttemptCount = i;
this.mTimeStamp = j;
}
}
}

View File

@@ -0,0 +1,72 @@
package androidx.work.impl.background.greedy;
import androidx.work.RunnableScheduler;
import androidx.work.impl.StartStopToken;
import androidx.work.impl.WorkLauncher;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
@SourceDebugExtension({"SMAP\nTimeLimiter.kt\nKotlin\n*S Kotlin\n*F\n+ 1 TimeLimiter.kt\nandroidx/work/impl/background/greedy/TimeLimiter\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,45:1\n1#2:46\n*E\n"})
/* loaded from: classes.dex */
public final class TimeLimiter {
private final WorkLauncher launcher;
private final Object lock;
private final RunnableScheduler runnableScheduler;
private final long timeoutMs;
private final Map<StartStopToken, Runnable> tracked;
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
public TimeLimiter(RunnableScheduler runnableScheduler, WorkLauncher launcher) {
this(runnableScheduler, launcher, 0L, 4, null);
Intrinsics.checkNotNullParameter(runnableScheduler, "runnableScheduler");
Intrinsics.checkNotNullParameter(launcher, "launcher");
}
public TimeLimiter(RunnableScheduler runnableScheduler, WorkLauncher launcher, long j) {
Intrinsics.checkNotNullParameter(runnableScheduler, "runnableScheduler");
Intrinsics.checkNotNullParameter(launcher, "launcher");
this.runnableScheduler = runnableScheduler;
this.launcher = launcher;
this.timeoutMs = j;
this.lock = new Object();
this.tracked = new LinkedHashMap();
}
public /* synthetic */ TimeLimiter(RunnableScheduler runnableScheduler, WorkLauncher workLauncher, long j, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(runnableScheduler, workLauncher, (i & 4) != 0 ? TimeUnit.MINUTES.toMillis(90L) : j);
}
/* JADX INFO: Access modifiers changed from: private */
public static final void track$lambda$0(TimeLimiter timeLimiter, StartStopToken startStopToken) {
timeLimiter.launcher.stopWork(startStopToken, 3);
}
public final void track(final StartStopToken token) {
Intrinsics.checkNotNullParameter(token, "token");
Runnable runnable = new Runnable() { // from class: androidx.work.impl.background.greedy.TimeLimiter$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
TimeLimiter.track$lambda$0(TimeLimiter.this, token);
}
};
synchronized (this.lock) {
this.tracked.put(token, runnable);
}
this.runnableScheduler.scheduleWithDelay(this.timeoutMs, runnable);
}
public final void cancel(StartStopToken token) {
Runnable remove;
Intrinsics.checkNotNullParameter(token, "token");
synchronized (this.lock) {
remove = this.tracked.remove(token);
}
if (remove != null) {
this.runnableScheduler.cancel(remove);
}
}
}

View File

@@ -0,0 +1,5 @@
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
package androidx.work.impl.background;
import androidx.annotation.RestrictTo;

View File

@@ -0,0 +1,65 @@
package androidx.work.impl.background.systemalarm;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.core.app.NotificationCompat;
import androidx.work.Logger;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.model.SystemIdInfo;
import androidx.work.impl.model.SystemIdInfoDao;
import androidx.work.impl.model.SystemIdInfoKt;
import androidx.work.impl.model.WorkGenerationalId;
import androidx.work.impl.utils.IdGenerator;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
class Alarms {
private static final String TAG = Logger.tagWithPrefix("Alarms");
public static void setAlarm(@NonNull Context context, @NonNull WorkDatabase workDatabase, @NonNull WorkGenerationalId workGenerationalId, long j) {
SystemIdInfoDao systemIdInfoDao = workDatabase.systemIdInfoDao();
SystemIdInfo systemIdInfo = systemIdInfoDao.getSystemIdInfo(workGenerationalId);
if (systemIdInfo != null) {
cancelExactAlarm(context, workGenerationalId, systemIdInfo.systemId);
setExactAlarm(context, workGenerationalId, systemIdInfo.systemId, j);
} else {
int nextAlarmManagerId = new IdGenerator(workDatabase).nextAlarmManagerId();
systemIdInfoDao.insertSystemIdInfo(SystemIdInfoKt.systemIdInfo(workGenerationalId, nextAlarmManagerId));
setExactAlarm(context, workGenerationalId, nextAlarmManagerId, j);
}
}
public static void cancelAlarm(@NonNull Context context, @NonNull WorkDatabase workDatabase, @NonNull WorkGenerationalId workGenerationalId) {
SystemIdInfoDao systemIdInfoDao = workDatabase.systemIdInfoDao();
SystemIdInfo systemIdInfo = systemIdInfoDao.getSystemIdInfo(workGenerationalId);
if (systemIdInfo != null) {
cancelExactAlarm(context, workGenerationalId, systemIdInfo.systemId);
Logger.get().debug(TAG, "Removing SystemIdInfo for workSpecId (" + workGenerationalId + ")");
systemIdInfoDao.removeSystemIdInfo(workGenerationalId);
}
}
private static void cancelExactAlarm(@NonNull Context context, @NonNull WorkGenerationalId workGenerationalId, int i) {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(NotificationCompat.CATEGORY_ALARM);
PendingIntent service = PendingIntent.getService(context, i, CommandHandler.createDelayMetIntent(context, workGenerationalId), 603979776);
if (service == null || alarmManager == null) {
return;
}
Logger.get().debug(TAG, "Cancelling existing alarm with (workSpecId, systemId) (" + workGenerationalId + ", " + i + ")");
alarmManager.cancel(service);
}
private static void setExactAlarm(@NonNull Context context, @NonNull WorkGenerationalId workGenerationalId, int i, long j) {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(NotificationCompat.CATEGORY_ALARM);
PendingIntent service = PendingIntent.getService(context, i, CommandHandler.createDelayMetIntent(context, workGenerationalId), 201326592);
if (alarmManager != null) {
alarmManager.setExact(0, j, service);
}
}
private Alarms() {
}
}

View File

@@ -0,0 +1,263 @@
package androidx.work.impl.background.systemalarm;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.WorkerThread;
import androidx.work.Clock;
import androidx.work.Logger;
import androidx.work.impl.ExecutionListener;
import androidx.work.impl.StartStopToken;
import androidx.work.impl.StartStopTokens;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.background.systemalarm.SystemAlarmDispatcher;
import androidx.work.impl.model.WorkGenerationalId;
import androidx.work.impl.model.WorkSpec;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class CommandHandler implements ExecutionListener {
static final String ACTION_CONSTRAINTS_CHANGED = "ACTION_CONSTRAINTS_CHANGED";
static final String ACTION_DELAY_MET = "ACTION_DELAY_MET";
static final String ACTION_EXECUTION_COMPLETED = "ACTION_EXECUTION_COMPLETED";
static final String ACTION_RESCHEDULE = "ACTION_RESCHEDULE";
static final String ACTION_SCHEDULE_WORK = "ACTION_SCHEDULE_WORK";
static final String ACTION_STOP_WORK = "ACTION_STOP_WORK";
private static final String KEY_NEEDS_RESCHEDULE = "KEY_NEEDS_RESCHEDULE";
private static final String KEY_WORKSPEC_GENERATION = "KEY_WORKSPEC_GENERATION";
private static final String KEY_WORKSPEC_ID = "KEY_WORKSPEC_ID";
private static final String TAG = Logger.tagWithPrefix("CommandHandler");
static final long WORK_PROCESSING_TIME_IN_MS = 600000;
private final Clock mClock;
private final Context mContext;
private final StartStopTokens mStartStopTokens;
private final Map<WorkGenerationalId, DelayMetCommandHandler> mPendingDelayMet = new HashMap();
private final Object mLock = new Object();
public static Intent createScheduleWorkIntent(@NonNull Context context, @NonNull WorkGenerationalId workGenerationalId) {
Intent intent = new Intent(context, (Class<?>) SystemAlarmService.class);
intent.setAction(ACTION_SCHEDULE_WORK);
return writeWorkGenerationalId(intent, workGenerationalId);
}
private static Intent writeWorkGenerationalId(@NonNull Intent intent, @NonNull WorkGenerationalId workGenerationalId) {
intent.putExtra(KEY_WORKSPEC_ID, workGenerationalId.getWorkSpecId());
intent.putExtra(KEY_WORKSPEC_GENERATION, workGenerationalId.getGeneration());
return intent;
}
public static WorkGenerationalId readWorkGenerationalId(@NonNull Intent intent) {
return new WorkGenerationalId(intent.getStringExtra(KEY_WORKSPEC_ID), intent.getIntExtra(KEY_WORKSPEC_GENERATION, 0));
}
public static Intent createDelayMetIntent(@NonNull Context context, @NonNull WorkGenerationalId workGenerationalId) {
Intent intent = new Intent(context, (Class<?>) SystemAlarmService.class);
intent.setAction(ACTION_DELAY_MET);
return writeWorkGenerationalId(intent, workGenerationalId);
}
public static Intent createStopWorkIntent(@NonNull Context context, @NonNull String str) {
Intent intent = new Intent(context, (Class<?>) SystemAlarmService.class);
intent.setAction(ACTION_STOP_WORK);
intent.putExtra(KEY_WORKSPEC_ID, str);
return intent;
}
public static Intent createStopWorkIntent(@NonNull Context context, @NonNull WorkGenerationalId workGenerationalId) {
Intent intent = new Intent(context, (Class<?>) SystemAlarmService.class);
intent.setAction(ACTION_STOP_WORK);
return writeWorkGenerationalId(intent, workGenerationalId);
}
public static Intent createConstraintsChangedIntent(@NonNull Context context) {
Intent intent = new Intent(context, (Class<?>) SystemAlarmService.class);
intent.setAction(ACTION_CONSTRAINTS_CHANGED);
return intent;
}
public static Intent createRescheduleIntent(@NonNull Context context) {
Intent intent = new Intent(context, (Class<?>) SystemAlarmService.class);
intent.setAction(ACTION_RESCHEDULE);
return intent;
}
public static Intent createExecutionCompletedIntent(@NonNull Context context, @NonNull WorkGenerationalId workGenerationalId, boolean z) {
Intent intent = new Intent(context, (Class<?>) SystemAlarmService.class);
intent.setAction(ACTION_EXECUTION_COMPLETED);
intent.putExtra(KEY_NEEDS_RESCHEDULE, z);
return writeWorkGenerationalId(intent, workGenerationalId);
}
public CommandHandler(@NonNull Context context, Clock clock, @NonNull StartStopTokens startStopTokens) {
this.mContext = context;
this.mClock = clock;
this.mStartStopTokens = startStopTokens;
}
@Override // androidx.work.impl.ExecutionListener
public void onExecuted(@NonNull WorkGenerationalId workGenerationalId, boolean z) {
synchronized (this.mLock) {
try {
DelayMetCommandHandler remove = this.mPendingDelayMet.remove(workGenerationalId);
this.mStartStopTokens.remove(workGenerationalId);
if (remove != null) {
remove.onExecuted(z);
}
} catch (Throwable th) {
throw th;
}
}
}
public boolean hasPendingCommands() {
boolean z;
synchronized (this.mLock) {
z = !this.mPendingDelayMet.isEmpty();
}
return z;
}
@WorkerThread
public void onHandleIntent(@NonNull Intent intent, int i, @NonNull SystemAlarmDispatcher systemAlarmDispatcher) {
String action = intent.getAction();
if (ACTION_CONSTRAINTS_CHANGED.equals(action)) {
handleConstraintsChanged(intent, i, systemAlarmDispatcher);
return;
}
if (ACTION_RESCHEDULE.equals(action)) {
handleReschedule(intent, i, systemAlarmDispatcher);
return;
}
if (!hasKeys(intent.getExtras(), KEY_WORKSPEC_ID)) {
Logger.get().error(TAG, "Invalid request for " + action + " , requires " + KEY_WORKSPEC_ID + " .");
return;
}
if (ACTION_SCHEDULE_WORK.equals(action)) {
handleScheduleWorkIntent(intent, i, systemAlarmDispatcher);
return;
}
if (ACTION_DELAY_MET.equals(action)) {
handleDelayMet(intent, i, systemAlarmDispatcher);
return;
}
if (ACTION_STOP_WORK.equals(action)) {
handleStopWork(intent, systemAlarmDispatcher);
return;
}
if (ACTION_EXECUTION_COMPLETED.equals(action)) {
handleExecutionCompleted(intent, i);
return;
}
Logger.get().warning(TAG, "Ignoring intent " + intent);
}
private void handleScheduleWorkIntent(@NonNull Intent intent, int i, @NonNull SystemAlarmDispatcher systemAlarmDispatcher) {
WorkGenerationalId readWorkGenerationalId = readWorkGenerationalId(intent);
Logger logger = Logger.get();
String str = TAG;
logger.debug(str, "Handling schedule work for " + readWorkGenerationalId);
WorkDatabase workDatabase = systemAlarmDispatcher.getWorkManager().getWorkDatabase();
workDatabase.beginTransaction();
try {
WorkSpec workSpec = workDatabase.workSpecDao().getWorkSpec(readWorkGenerationalId.getWorkSpecId());
if (workSpec == null) {
Logger.get().warning(str, "Skipping scheduling " + readWorkGenerationalId + " because it's no longer in the DB");
return;
}
if (workSpec.state.isFinished()) {
Logger.get().warning(str, "Skipping scheduling " + readWorkGenerationalId + "because it is finished.");
return;
}
long calculateNextRunTime = workSpec.calculateNextRunTime();
if (!workSpec.hasConstraints()) {
Logger.get().debug(str, "Setting up Alarms for " + readWorkGenerationalId + "at " + calculateNextRunTime);
Alarms.setAlarm(this.mContext, workDatabase, readWorkGenerationalId, calculateNextRunTime);
} else {
Logger.get().debug(str, "Opportunistically setting an alarm for " + readWorkGenerationalId + "at " + calculateNextRunTime);
Alarms.setAlarm(this.mContext, workDatabase, readWorkGenerationalId, calculateNextRunTime);
systemAlarmDispatcher.getTaskExecutor().getMainThreadExecutor().execute(new SystemAlarmDispatcher.AddRunnable(systemAlarmDispatcher, createConstraintsChangedIntent(this.mContext), i));
}
workDatabase.setTransactionSuccessful();
} finally {
workDatabase.endTransaction();
}
}
private void handleDelayMet(@NonNull Intent intent, int i, @NonNull SystemAlarmDispatcher systemAlarmDispatcher) {
synchronized (this.mLock) {
try {
WorkGenerationalId readWorkGenerationalId = readWorkGenerationalId(intent);
Logger logger = Logger.get();
String str = TAG;
logger.debug(str, "Handing delay met for " + readWorkGenerationalId);
if (!this.mPendingDelayMet.containsKey(readWorkGenerationalId)) {
DelayMetCommandHandler delayMetCommandHandler = new DelayMetCommandHandler(this.mContext, i, systemAlarmDispatcher, this.mStartStopTokens.tokenFor(readWorkGenerationalId));
this.mPendingDelayMet.put(readWorkGenerationalId, delayMetCommandHandler);
delayMetCommandHandler.handleProcessWork();
} else {
Logger.get().debug(str, "WorkSpec " + readWorkGenerationalId + " is is already being handled for ACTION_DELAY_MET");
}
} catch (Throwable th) {
throw th;
}
}
}
private void handleStopWork(@NonNull Intent intent, @NonNull SystemAlarmDispatcher systemAlarmDispatcher) {
List<StartStopToken> remove;
Bundle extras = intent.getExtras();
String string = extras.getString(KEY_WORKSPEC_ID);
if (extras.containsKey(KEY_WORKSPEC_GENERATION)) {
int i = extras.getInt(KEY_WORKSPEC_GENERATION);
remove = new ArrayList<>(1);
StartStopToken remove2 = this.mStartStopTokens.remove(new WorkGenerationalId(string, i));
if (remove2 != null) {
remove.add(remove2);
}
} else {
remove = this.mStartStopTokens.remove(string);
}
for (StartStopToken startStopToken : remove) {
Logger.get().debug(TAG, "Handing stopWork work for " + string);
systemAlarmDispatcher.getWorkerLauncher().stopWork(startStopToken);
Alarms.cancelAlarm(this.mContext, systemAlarmDispatcher.getWorkManager().getWorkDatabase(), startStopToken.getId());
systemAlarmDispatcher.onExecuted(startStopToken.getId(), false);
}
}
private void handleConstraintsChanged(@NonNull Intent intent, int i, @NonNull SystemAlarmDispatcher systemAlarmDispatcher) {
Logger.get().debug(TAG, "Handling constraints changed " + intent);
new ConstraintsCommandHandler(this.mContext, this.mClock, i, systemAlarmDispatcher).handleConstraintsChanged();
}
private void handleReschedule(@NonNull Intent intent, int i, @NonNull SystemAlarmDispatcher systemAlarmDispatcher) {
Logger.get().debug(TAG, "Handling reschedule " + intent + ", " + i);
systemAlarmDispatcher.getWorkManager().rescheduleEligibleWork();
}
private void handleExecutionCompleted(@NonNull Intent intent, int i) {
WorkGenerationalId readWorkGenerationalId = readWorkGenerationalId(intent);
boolean z = intent.getExtras().getBoolean(KEY_NEEDS_RESCHEDULE);
Logger.get().debug(TAG, "Handling onExecutionCompleted " + intent + ", " + i);
onExecuted(readWorkGenerationalId, z);
}
private static boolean hasKeys(@Nullable Bundle bundle, @NonNull String... strArr) {
if (bundle == null || bundle.isEmpty()) {
return false;
}
for (String str : strArr) {
if (bundle.get(str) == null) {
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,69 @@
package androidx.work.impl.background.systemalarm;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import androidx.work.Constraints;
import androidx.work.Logger;
import androidx.work.NetworkType;
import androidx.work.impl.model.WorkSpec;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
abstract class ConstraintProxy extends BroadcastReceiver {
private static final String TAG = Logger.tagWithPrefix("ConstraintProxy");
@Override // android.content.BroadcastReceiver
public void onReceive(Context context, Intent intent) {
Logger.get().debug(TAG, "onReceive : " + intent);
context.startService(CommandHandler.createConstraintsChangedIntent(context));
}
public static class BatteryNotLowProxy extends ConstraintProxy {
@Override // androidx.work.impl.background.systemalarm.ConstraintProxy, android.content.BroadcastReceiver
public /* bridge */ /* synthetic */ void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
}
}
public static class BatteryChargingProxy extends ConstraintProxy {
@Override // androidx.work.impl.background.systemalarm.ConstraintProxy, android.content.BroadcastReceiver
public /* bridge */ /* synthetic */ void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
}
}
public static class StorageNotLowProxy extends ConstraintProxy {
@Override // androidx.work.impl.background.systemalarm.ConstraintProxy, android.content.BroadcastReceiver
public /* bridge */ /* synthetic */ void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
}
}
public static class NetworkStateProxy extends ConstraintProxy {
@Override // androidx.work.impl.background.systemalarm.ConstraintProxy, android.content.BroadcastReceiver
public /* bridge */ /* synthetic */ void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
}
}
public static void updateAll(Context context, List<WorkSpec> list) {
Iterator<WorkSpec> it = list.iterator();
boolean z = false;
boolean z2 = false;
boolean z3 = false;
boolean z4 = false;
while (it.hasNext()) {
Constraints constraints = it.next().constraints;
z |= constraints.requiresBatteryNotLow();
z2 |= constraints.requiresCharging();
z3 |= constraints.requiresStorageNotLow();
z4 |= constraints.getRequiredNetworkType() != NetworkType.NOT_REQUIRED;
if (z && z2 && z3 && z4) {
break;
}
}
context.sendBroadcast(ConstraintProxyUpdateReceiver.newConstraintProxyUpdateIntent(context, z, z2, z3, z4));
}
}

View File

@@ -0,0 +1,58 @@
package androidx.work.impl.background.systemalarm;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.work.Logger;
import androidx.work.impl.WorkManagerImpl;
import androidx.work.impl.background.systemalarm.ConstraintProxy;
import androidx.work.impl.utils.PackageManagerHelper;
/* loaded from: classes.dex */
public class ConstraintProxyUpdateReceiver extends BroadcastReceiver {
static final String ACTION = "androidx.work.impl.background.systemalarm.UpdateProxies";
static final String KEY_BATTERY_CHARGING_PROXY_ENABLED = "KEY_BATTERY_CHARGING_PROXY_ENABLED";
static final String KEY_BATTERY_NOT_LOW_PROXY_ENABLED = "KEY_BATTERY_NOT_LOW_PROXY_ENABLED";
static final String KEY_NETWORK_STATE_PROXY_ENABLED = "KEY_NETWORK_STATE_PROXY_ENABLED";
static final String KEY_STORAGE_NOT_LOW_PROXY_ENABLED = "KEY_STORAGE_NOT_LOW_PROXY_ENABLED";
static final String TAG = Logger.tagWithPrefix("ConstrntProxyUpdtRecvr");
@NonNull
public static Intent newConstraintProxyUpdateIntent(@NonNull Context context, boolean z, boolean z2, boolean z3, boolean z4) {
Intent intent = new Intent(ACTION);
intent.setComponent(new ComponentName(context, (Class<?>) ConstraintProxyUpdateReceiver.class));
intent.putExtra(KEY_BATTERY_NOT_LOW_PROXY_ENABLED, z).putExtra(KEY_BATTERY_CHARGING_PROXY_ENABLED, z2).putExtra(KEY_STORAGE_NOT_LOW_PROXY_ENABLED, z3).putExtra(KEY_NETWORK_STATE_PROXY_ENABLED, z4);
return intent;
}
@Override // android.content.BroadcastReceiver
public void onReceive(@NonNull final Context context, @Nullable final Intent intent) {
String action = intent != null ? intent.getAction() : null;
if (!ACTION.equals(action)) {
Logger.get().debug(TAG, "Ignoring unknown action " + action);
return;
}
final BroadcastReceiver.PendingResult goAsync = goAsync();
WorkManagerImpl.getInstance(context).getWorkTaskExecutor().executeOnTaskThread(new Runnable() { // from class: androidx.work.impl.background.systemalarm.ConstraintProxyUpdateReceiver.1
@Override // java.lang.Runnable
public void run() {
try {
boolean booleanExtra = intent.getBooleanExtra(ConstraintProxyUpdateReceiver.KEY_BATTERY_NOT_LOW_PROXY_ENABLED, false);
boolean booleanExtra2 = intent.getBooleanExtra(ConstraintProxyUpdateReceiver.KEY_BATTERY_CHARGING_PROXY_ENABLED, false);
boolean booleanExtra3 = intent.getBooleanExtra(ConstraintProxyUpdateReceiver.KEY_STORAGE_NOT_LOW_PROXY_ENABLED, false);
boolean booleanExtra4 = intent.getBooleanExtra(ConstraintProxyUpdateReceiver.KEY_NETWORK_STATE_PROXY_ENABLED, false);
Logger.get().debug(ConstraintProxyUpdateReceiver.TAG, "Updating proxies: (BatteryNotLowProxy (" + booleanExtra + "), BatteryChargingProxy (" + booleanExtra2 + "), StorageNotLowProxy (" + booleanExtra3 + "), NetworkStateProxy (" + booleanExtra4 + "), ");
PackageManagerHelper.setComponentEnabled(context, ConstraintProxy.BatteryNotLowProxy.class, booleanExtra);
PackageManagerHelper.setComponentEnabled(context, ConstraintProxy.BatteryChargingProxy.class, booleanExtra2);
PackageManagerHelper.setComponentEnabled(context, ConstraintProxy.StorageNotLowProxy.class, booleanExtra3);
PackageManagerHelper.setComponentEnabled(context, ConstraintProxy.NetworkStateProxy.class, booleanExtra4);
} finally {
goAsync.finish();
}
}
});
}
}

View File

@@ -0,0 +1,53 @@
package androidx.work.impl.background.systemalarm;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.WorkerThread;
import androidx.work.Clock;
import androidx.work.Logger;
import androidx.work.impl.background.systemalarm.SystemAlarmDispatcher;
import androidx.work.impl.constraints.WorkConstraintsTracker;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.model.WorkSpecKt;
import java.util.ArrayList;
import java.util.List;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
class ConstraintsCommandHandler {
private static final String TAG = Logger.tagWithPrefix("ConstraintsCmdHandler");
private final Clock mClock;
private final Context mContext;
private final SystemAlarmDispatcher mDispatcher;
private final int mStartId;
private final WorkConstraintsTracker mWorkConstraintsTracker;
public ConstraintsCommandHandler(@NonNull Context context, Clock clock, int i, @NonNull SystemAlarmDispatcher systemAlarmDispatcher) {
this.mContext = context;
this.mClock = clock;
this.mStartId = i;
this.mDispatcher = systemAlarmDispatcher;
this.mWorkConstraintsTracker = new WorkConstraintsTracker(systemAlarmDispatcher.getWorkManager().getTrackers());
}
@WorkerThread
public void handleConstraintsChanged() {
List<WorkSpec> scheduledWork = this.mDispatcher.getWorkManager().getWorkDatabase().workSpecDao().getScheduledWork();
ConstraintProxy.updateAll(this.mContext, scheduledWork);
ArrayList<WorkSpec> arrayList = new ArrayList(scheduledWork.size());
long currentTimeMillis = this.mClock.currentTimeMillis();
for (WorkSpec workSpec : scheduledWork) {
if (currentTimeMillis >= workSpec.calculateNextRunTime() && (!workSpec.hasConstraints() || this.mWorkConstraintsTracker.areAllConstraintsMet(workSpec))) {
arrayList.add(workSpec);
}
}
for (WorkSpec workSpec2 : arrayList) {
String str = workSpec2.id;
Intent createDelayMetIntent = CommandHandler.createDelayMetIntent(this.mContext, WorkSpecKt.generationalId(workSpec2));
Logger.get().debug(TAG, "Creating a delay_met command for workSpec with id (" + str + ")");
this.mDispatcher.getTaskExecutor().getMainThreadExecutor().execute(new SystemAlarmDispatcher.AddRunnable(this.mDispatcher, createDelayMetIntent, this.mStartId));
}
}
}

View File

@@ -0,0 +1,15 @@
package androidx.work.impl.background.systemalarm;
/* loaded from: classes.dex */
public final /* synthetic */ class DelayMetCommandHandler$$ExternalSyntheticLambda0 implements Runnable {
public final /* synthetic */ DelayMetCommandHandler f$0;
public /* synthetic */ DelayMetCommandHandler$$ExternalSyntheticLambda0(DelayMetCommandHandler delayMetCommandHandler) {
this.f$0 = delayMetCommandHandler;
}
@Override // java.lang.Runnable
public final void run() {
this.f$0.stopWork();
}
}

View File

@@ -0,0 +1,15 @@
package androidx.work.impl.background.systemalarm;
/* loaded from: classes.dex */
public final /* synthetic */ class DelayMetCommandHandler$$ExternalSyntheticLambda1 implements Runnable {
public final /* synthetic */ DelayMetCommandHandler f$0;
public /* synthetic */ DelayMetCommandHandler$$ExternalSyntheticLambda1(DelayMetCommandHandler delayMetCommandHandler) {
this.f$0 = delayMetCommandHandler;
}
@Override // java.lang.Runnable
public final void run() {
this.f$0.startWork();
}
}

View File

@@ -0,0 +1,168 @@
package androidx.work.impl.background.systemalarm;
import android.content.Context;
import android.os.PowerManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.WorkerThread;
import androidx.work.Logger;
import androidx.work.impl.StartStopToken;
import androidx.work.impl.background.systemalarm.SystemAlarmDispatcher;
import androidx.work.impl.constraints.ConstraintsState;
import androidx.work.impl.constraints.OnConstraintsStateChangedListener;
import androidx.work.impl.constraints.WorkConstraintsTracker;
import androidx.work.impl.constraints.WorkConstraintsTrackerKt;
import androidx.work.impl.constraints.trackers.Trackers;
import androidx.work.impl.model.WorkGenerationalId;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.utils.WakeLocks;
import androidx.work.impl.utils.WorkTimer;
import com.facebook.AuthenticationTokenClaims;
import java.util.concurrent.Executor;
import kotlinx.coroutines.CoroutineDispatcher;
import kotlinx.coroutines.Job;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class DelayMetCommandHandler implements OnConstraintsStateChangedListener, WorkTimer.TimeLimitExceededListener {
private static final int STATE_INITIAL = 0;
private static final int STATE_START_REQUESTED = 1;
private static final int STATE_STOP_REQUESTED = 2;
private static final String TAG = Logger.tagWithPrefix("DelayMetCommandHandler");
private final Context mContext;
private final CoroutineDispatcher mCoroutineDispatcher;
private int mCurrentState;
private final SystemAlarmDispatcher mDispatcher;
private boolean mHasConstraints;
private volatile Job mJob;
private final Object mLock;
private final Executor mMainThreadExecutor;
private final Executor mSerialExecutor;
private final int mStartId;
private final StartStopToken mToken;
@Nullable
private PowerManager.WakeLock mWakeLock;
private final WorkConstraintsTracker mWorkConstraintsTracker;
private final WorkGenerationalId mWorkGenerationalId;
public DelayMetCommandHandler(@NonNull Context context, int i, @NonNull SystemAlarmDispatcher systemAlarmDispatcher, @NonNull StartStopToken startStopToken) {
this.mContext = context;
this.mStartId = i;
this.mDispatcher = systemAlarmDispatcher;
this.mWorkGenerationalId = startStopToken.getId();
this.mToken = startStopToken;
Trackers trackers = systemAlarmDispatcher.getWorkManager().getTrackers();
this.mSerialExecutor = systemAlarmDispatcher.getTaskExecutor().getSerialTaskExecutor();
this.mMainThreadExecutor = systemAlarmDispatcher.getTaskExecutor().getMainThreadExecutor();
this.mCoroutineDispatcher = systemAlarmDispatcher.getTaskExecutor().getTaskCoroutineDispatcher();
this.mWorkConstraintsTracker = new WorkConstraintsTracker(trackers);
this.mHasConstraints = false;
this.mCurrentState = 0;
this.mLock = new Object();
}
@Override // androidx.work.impl.constraints.OnConstraintsStateChangedListener
public void onConstraintsStateChanged(@NonNull WorkSpec workSpec, @NonNull ConstraintsState constraintsState) {
if (constraintsState instanceof ConstraintsState.ConstraintsMet) {
this.mSerialExecutor.execute(new DelayMetCommandHandler$$ExternalSyntheticLambda1(this));
} else {
this.mSerialExecutor.execute(new DelayMetCommandHandler$$ExternalSyntheticLambda0(this));
}
}
/* JADX INFO: Access modifiers changed from: private */
public void startWork() {
if (this.mCurrentState == 0) {
this.mCurrentState = 1;
Logger.get().debug(TAG, "onAllConstraintsMet for " + this.mWorkGenerationalId);
if (this.mDispatcher.getProcessor().startWork(this.mToken)) {
this.mDispatcher.getWorkTimer().startTimer(this.mWorkGenerationalId, AuthenticationTokenClaims.MAX_TIME_SINCE_TOKEN_ISSUED, this);
return;
} else {
cleanUp();
return;
}
}
Logger.get().debug(TAG, "Already started work for " + this.mWorkGenerationalId);
}
public void onExecuted(boolean z) {
Logger.get().debug(TAG, "onExecuted " + this.mWorkGenerationalId + ", " + z);
cleanUp();
if (z) {
this.mMainThreadExecutor.execute(new SystemAlarmDispatcher.AddRunnable(this.mDispatcher, CommandHandler.createScheduleWorkIntent(this.mContext, this.mWorkGenerationalId), this.mStartId));
}
if (this.mHasConstraints) {
this.mMainThreadExecutor.execute(new SystemAlarmDispatcher.AddRunnable(this.mDispatcher, CommandHandler.createConstraintsChangedIntent(this.mContext), this.mStartId));
}
}
@Override // androidx.work.impl.utils.WorkTimer.TimeLimitExceededListener
public void onTimeLimitExceeded(@NonNull WorkGenerationalId workGenerationalId) {
Logger.get().debug(TAG, "Exceeded time limits on execution for " + workGenerationalId);
this.mSerialExecutor.execute(new DelayMetCommandHandler$$ExternalSyntheticLambda0(this));
}
@WorkerThread
public void handleProcessWork() {
String workSpecId = this.mWorkGenerationalId.getWorkSpecId();
this.mWakeLock = WakeLocks.newWakeLock(this.mContext, workSpecId + " (" + this.mStartId + ")");
Logger logger = Logger.get();
String str = TAG;
logger.debug(str, "Acquiring wakelock " + this.mWakeLock + "for WorkSpec " + workSpecId);
this.mWakeLock.acquire();
WorkSpec workSpec = this.mDispatcher.getWorkManager().getWorkDatabase().workSpecDao().getWorkSpec(workSpecId);
if (workSpec == null) {
this.mSerialExecutor.execute(new DelayMetCommandHandler$$ExternalSyntheticLambda0(this));
return;
}
boolean hasConstraints = workSpec.hasConstraints();
this.mHasConstraints = hasConstraints;
if (!hasConstraints) {
Logger.get().debug(str, "No constraints for " + workSpecId);
this.mSerialExecutor.execute(new DelayMetCommandHandler$$ExternalSyntheticLambda1(this));
return;
}
this.mJob = WorkConstraintsTrackerKt.listen(this.mWorkConstraintsTracker, workSpec, this.mCoroutineDispatcher, this);
}
/* JADX INFO: Access modifiers changed from: private */
public void stopWork() {
String workSpecId = this.mWorkGenerationalId.getWorkSpecId();
if (this.mCurrentState < 2) {
this.mCurrentState = 2;
Logger logger = Logger.get();
String str = TAG;
logger.debug(str, "Stopping work for WorkSpec " + workSpecId);
this.mMainThreadExecutor.execute(new SystemAlarmDispatcher.AddRunnable(this.mDispatcher, CommandHandler.createStopWorkIntent(this.mContext, this.mWorkGenerationalId), this.mStartId));
if (this.mDispatcher.getProcessor().isEnqueued(this.mWorkGenerationalId.getWorkSpecId())) {
Logger.get().debug(str, "WorkSpec " + workSpecId + " needs to be rescheduled");
this.mMainThreadExecutor.execute(new SystemAlarmDispatcher.AddRunnable(this.mDispatcher, CommandHandler.createScheduleWorkIntent(this.mContext, this.mWorkGenerationalId), this.mStartId));
return;
}
Logger.get().debug(str, "Processor does not have WorkSpec " + workSpecId + ". No need to reschedule");
return;
}
Logger.get().debug(TAG, "Already stopped work for " + workSpecId);
}
private void cleanUp() {
synchronized (this.mLock) {
try {
if (this.mJob != null) {
this.mJob.cancel(null);
}
this.mDispatcher.getWorkTimer().stopTimer(this.mWorkGenerationalId);
PowerManager.WakeLock wakeLock = this.mWakeLock;
if (wakeLock != null && wakeLock.isHeld()) {
Logger.get().debug(TAG, "Releasing wakelock " + this.mWakeLock + "for WorkSpec " + this.mWorkGenerationalId);
this.mWakeLock.release();
}
} catch (Throwable th) {
throw th;
}
}
}
}

View File

@@ -0,0 +1,22 @@
package androidx.work.impl.background.systemalarm;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import androidx.work.Logger;
import androidx.work.impl.WorkManagerImpl;
/* loaded from: classes.dex */
public class RescheduleReceiver extends BroadcastReceiver {
private static final String TAG = Logger.tagWithPrefix("RescheduleReceiver");
@Override // android.content.BroadcastReceiver
public void onReceive(Context context, Intent intent) {
Logger.get().debug(TAG, "Received intent " + intent);
try {
WorkManagerImpl.getInstance(context).setReschedulePendingResult(goAsync());
} catch (IllegalStateException e) {
Logger.get().error(TAG, "Cannot reschedule jobs. WorkManager needs to be initialized via a ContentProvider#onCreate() or an Application#onCreate().", e);
}
}
}

View File

@@ -0,0 +1,287 @@
package androidx.work.impl.background.systemalarm;
import android.content.Context;
import android.content.Intent;
import android.os.Looper;
import android.os.PowerManager;
import android.text.TextUtils;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.work.Logger;
import androidx.work.impl.ExecutionListener;
import androidx.work.impl.Processor;
import androidx.work.impl.StartStopTokens;
import androidx.work.impl.WorkLauncher;
import androidx.work.impl.WorkLauncherImpl;
import androidx.work.impl.WorkManagerImpl;
import androidx.work.impl.model.WorkGenerationalId;
import androidx.work.impl.utils.WakeLocks;
import androidx.work.impl.utils.WorkTimer;
import androidx.work.impl.utils.taskexecutor.SerialExecutor;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Executor;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class SystemAlarmDispatcher implements ExecutionListener {
private static final int DEFAULT_START_ID = 0;
private static final String KEY_START_ID = "KEY_START_ID";
private static final String PROCESS_COMMAND_TAG = "ProcessCommand";
static final String TAG = Logger.tagWithPrefix("SystemAlarmDispatcher");
final CommandHandler mCommandHandler;
@Nullable
private CommandsCompletedListener mCompletedListener;
final Context mContext;
Intent mCurrentIntent;
final List<Intent> mIntents;
private final Processor mProcessor;
private StartStopTokens mStartStopTokens;
final TaskExecutor mTaskExecutor;
private final WorkLauncher mWorkLauncher;
private final WorkManagerImpl mWorkManager;
private final WorkTimer mWorkTimer;
public interface CommandsCompletedListener {
void onAllCommandsCompleted();
}
public Processor getProcessor() {
return this.mProcessor;
}
public TaskExecutor getTaskExecutor() {
return this.mTaskExecutor;
}
public WorkManagerImpl getWorkManager() {
return this.mWorkManager;
}
public WorkTimer getWorkTimer() {
return this.mWorkTimer;
}
public WorkLauncher getWorkerLauncher() {
return this.mWorkLauncher;
}
public SystemAlarmDispatcher(@NonNull Context context) {
this(context, null, null, null);
}
@VisibleForTesting
public SystemAlarmDispatcher(@NonNull Context context, @Nullable Processor processor, @Nullable WorkManagerImpl workManagerImpl, @Nullable WorkLauncher workLauncher) {
Context applicationContext = context.getApplicationContext();
this.mContext = applicationContext;
this.mStartStopTokens = StartStopTokens.create();
workManagerImpl = workManagerImpl == null ? WorkManagerImpl.getInstance(context) : workManagerImpl;
this.mWorkManager = workManagerImpl;
this.mCommandHandler = new CommandHandler(applicationContext, workManagerImpl.getConfiguration().getClock(), this.mStartStopTokens);
this.mWorkTimer = new WorkTimer(workManagerImpl.getConfiguration().getRunnableScheduler());
processor = processor == null ? workManagerImpl.getProcessor() : processor;
this.mProcessor = processor;
TaskExecutor workTaskExecutor = workManagerImpl.getWorkTaskExecutor();
this.mTaskExecutor = workTaskExecutor;
this.mWorkLauncher = workLauncher == null ? new WorkLauncherImpl(processor, workTaskExecutor) : workLauncher;
processor.addExecutionListener(this);
this.mIntents = new ArrayList();
this.mCurrentIntent = null;
}
public void onDestroy() {
Logger.get().debug(TAG, "Destroying SystemAlarmDispatcher");
this.mProcessor.removeExecutionListener(this);
this.mCompletedListener = null;
}
@Override // androidx.work.impl.ExecutionListener
public void onExecuted(@NonNull WorkGenerationalId workGenerationalId, boolean z) {
this.mTaskExecutor.getMainThreadExecutor().execute(new AddRunnable(this, CommandHandler.createExecutionCompletedIntent(this.mContext, workGenerationalId, z), 0));
}
@MainThread
public boolean add(@NonNull Intent intent, int i) {
Logger logger = Logger.get();
String str = TAG;
logger.debug(str, "Adding command " + intent + " (" + i + ")");
assertMainThread();
String action = intent.getAction();
if (TextUtils.isEmpty(action)) {
Logger.get().warning(str, "Unknown command. Ignoring");
return false;
}
if ("ACTION_CONSTRAINTS_CHANGED".equals(action) && hasIntentWithAction("ACTION_CONSTRAINTS_CHANGED")) {
return false;
}
intent.putExtra(KEY_START_ID, i);
synchronized (this.mIntents) {
try {
boolean z = !this.mIntents.isEmpty();
this.mIntents.add(intent);
if (!z) {
processCommand();
}
} catch (Throwable th) {
throw th;
}
}
return true;
}
public void setCompletedListener(@NonNull CommandsCompletedListener commandsCompletedListener) {
if (this.mCompletedListener != null) {
Logger.get().error(TAG, "A completion listener for SystemAlarmDispatcher already exists.");
} else {
this.mCompletedListener = commandsCompletedListener;
}
}
@MainThread
public void dequeueAndCheckForCompletion() {
Logger logger = Logger.get();
String str = TAG;
logger.debug(str, "Checking if commands are complete.");
assertMainThread();
synchronized (this.mIntents) {
try {
if (this.mCurrentIntent != null) {
Logger.get().debug(str, "Removing command " + this.mCurrentIntent);
if (!this.mIntents.remove(0).equals(this.mCurrentIntent)) {
throw new IllegalStateException("Dequeue-d command is not the first.");
}
this.mCurrentIntent = null;
}
SerialExecutor serialTaskExecutor = this.mTaskExecutor.getSerialTaskExecutor();
if (!this.mCommandHandler.hasPendingCommands() && this.mIntents.isEmpty() && !serialTaskExecutor.hasPendingTasks()) {
Logger.get().debug(str, "No more commands & intents.");
CommandsCompletedListener commandsCompletedListener = this.mCompletedListener;
if (commandsCompletedListener != null) {
commandsCompletedListener.onAllCommandsCompleted();
}
} else if (!this.mIntents.isEmpty()) {
processCommand();
}
} catch (Throwable th) {
throw th;
}
}
}
@MainThread
private void processCommand() {
assertMainThread();
PowerManager.WakeLock newWakeLock = WakeLocks.newWakeLock(this.mContext, PROCESS_COMMAND_TAG);
try {
newWakeLock.acquire();
this.mWorkManager.getWorkTaskExecutor().executeOnTaskThread(new Runnable() { // from class: androidx.work.impl.background.systemalarm.SystemAlarmDispatcher.1
@Override // java.lang.Runnable
public void run() {
Executor mainThreadExecutor;
DequeueAndCheckForCompletion dequeueAndCheckForCompletion;
synchronized (SystemAlarmDispatcher.this.mIntents) {
SystemAlarmDispatcher systemAlarmDispatcher = SystemAlarmDispatcher.this;
systemAlarmDispatcher.mCurrentIntent = systemAlarmDispatcher.mIntents.get(0);
}
Intent intent = SystemAlarmDispatcher.this.mCurrentIntent;
if (intent != null) {
String action = intent.getAction();
int intExtra = SystemAlarmDispatcher.this.mCurrentIntent.getIntExtra(SystemAlarmDispatcher.KEY_START_ID, 0);
Logger logger = Logger.get();
String str = SystemAlarmDispatcher.TAG;
logger.debug(str, "Processing command " + SystemAlarmDispatcher.this.mCurrentIntent + ", " + intExtra);
PowerManager.WakeLock newWakeLock2 = WakeLocks.newWakeLock(SystemAlarmDispatcher.this.mContext, action + " (" + intExtra + ")");
try {
Logger.get().debug(str, "Acquiring operation wake lock (" + action + ") " + newWakeLock2);
newWakeLock2.acquire();
SystemAlarmDispatcher systemAlarmDispatcher2 = SystemAlarmDispatcher.this;
systemAlarmDispatcher2.mCommandHandler.onHandleIntent(systemAlarmDispatcher2.mCurrentIntent, intExtra, systemAlarmDispatcher2);
Logger.get().debug(str, "Releasing operation wake lock (" + action + ") " + newWakeLock2);
newWakeLock2.release();
mainThreadExecutor = SystemAlarmDispatcher.this.mTaskExecutor.getMainThreadExecutor();
dequeueAndCheckForCompletion = new DequeueAndCheckForCompletion(SystemAlarmDispatcher.this);
} catch (Throwable th) {
try {
Logger logger2 = Logger.get();
String str2 = SystemAlarmDispatcher.TAG;
logger2.error(str2, "Unexpected error in onHandleIntent", th);
Logger.get().debug(str2, "Releasing operation wake lock (" + action + ") " + newWakeLock2);
newWakeLock2.release();
mainThreadExecutor = SystemAlarmDispatcher.this.mTaskExecutor.getMainThreadExecutor();
dequeueAndCheckForCompletion = new DequeueAndCheckForCompletion(SystemAlarmDispatcher.this);
} catch (Throwable th2) {
Logger.get().debug(SystemAlarmDispatcher.TAG, "Releasing operation wake lock (" + action + ") " + newWakeLock2);
newWakeLock2.release();
SystemAlarmDispatcher.this.mTaskExecutor.getMainThreadExecutor().execute(new DequeueAndCheckForCompletion(SystemAlarmDispatcher.this));
throw th2;
}
}
mainThreadExecutor.execute(dequeueAndCheckForCompletion);
}
}
});
} finally {
newWakeLock.release();
}
}
@MainThread
private boolean hasIntentWithAction(@NonNull String str) {
assertMainThread();
synchronized (this.mIntents) {
try {
Iterator<Intent> it = this.mIntents.iterator();
while (it.hasNext()) {
if (str.equals(it.next().getAction())) {
return true;
}
}
return false;
} catch (Throwable th) {
throw th;
}
}
}
private void assertMainThread() {
if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
throw new IllegalStateException("Needs to be invoked on the main thread.");
}
}
public static class DequeueAndCheckForCompletion implements Runnable {
private final SystemAlarmDispatcher mDispatcher;
public DequeueAndCheckForCompletion(@NonNull SystemAlarmDispatcher systemAlarmDispatcher) {
this.mDispatcher = systemAlarmDispatcher;
}
@Override // java.lang.Runnable
public void run() {
this.mDispatcher.dequeueAndCheckForCompletion();
}
}
public static class AddRunnable implements Runnable {
private final SystemAlarmDispatcher mDispatcher;
private final Intent mIntent;
private final int mStartId;
public AddRunnable(@NonNull SystemAlarmDispatcher systemAlarmDispatcher, @NonNull Intent intent, int i) {
this.mDispatcher = systemAlarmDispatcher;
this.mIntent = intent;
this.mStartId = i;
}
@Override // java.lang.Runnable
public void run() {
this.mDispatcher.add(this.mIntent, this.mStartId);
}
}
}

View File

@@ -0,0 +1,42 @@
package androidx.work.impl.background.systemalarm;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.work.Logger;
import androidx.work.impl.Scheduler;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.model.WorkSpecKt;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class SystemAlarmScheduler implements Scheduler {
private static final String TAG = Logger.tagWithPrefix("SystemAlarmScheduler");
private final Context mContext;
@Override // androidx.work.impl.Scheduler
public boolean hasLimitedSchedulingSlots() {
return true;
}
public SystemAlarmScheduler(@NonNull Context context) {
this.mContext = context.getApplicationContext();
}
@Override // androidx.work.impl.Scheduler
public void schedule(@NonNull WorkSpec... workSpecArr) {
for (WorkSpec workSpec : workSpecArr) {
scheduleWorkSpec(workSpec);
}
}
@Override // androidx.work.impl.Scheduler
public void cancel(@NonNull String str) {
this.mContext.startService(CommandHandler.createStopWorkIntent(this.mContext, str));
}
private void scheduleWorkSpec(@NonNull WorkSpec workSpec) {
Logger.get().debug(TAG, "Scheduling work with workSpecId " + workSpec.id);
this.mContext.startService(CommandHandler.createScheduleWorkIntent(this.mContext, WorkSpecKt.generationalId(workSpec)));
}
}

View File

@@ -0,0 +1,63 @@
package androidx.work.impl.background.systemalarm;
import android.content.Intent;
import androidx.annotation.MainThread;
import androidx.annotation.RestrictTo;
import androidx.lifecycle.LifecycleService;
import androidx.work.Logger;
import androidx.work.impl.background.systemalarm.SystemAlarmDispatcher;
import androidx.work.impl.utils.WakeLocks;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class SystemAlarmService extends LifecycleService implements SystemAlarmDispatcher.CommandsCompletedListener {
private static final String TAG = Logger.tagWithPrefix("SystemAlarmService");
private SystemAlarmDispatcher mDispatcher;
private boolean mIsShutdown;
@Override // androidx.lifecycle.LifecycleService, android.app.Service
public void onCreate() {
super.onCreate();
initializeDispatcher();
this.mIsShutdown = false;
}
@Override // androidx.lifecycle.LifecycleService, android.app.Service
public void onDestroy() {
super.onDestroy();
this.mIsShutdown = true;
this.mDispatcher.onDestroy();
}
@Override // androidx.lifecycle.LifecycleService, android.app.Service
public int onStartCommand(Intent intent, int i, int i2) {
super.onStartCommand(intent, i, i2);
if (this.mIsShutdown) {
Logger.get().info(TAG, "Re-initializing SystemAlarmDispatcher after a request to shut-down.");
this.mDispatcher.onDestroy();
initializeDispatcher();
this.mIsShutdown = false;
}
if (intent == null) {
return 3;
}
this.mDispatcher.add(intent, i2);
return 3;
}
@Override // androidx.work.impl.background.systemalarm.SystemAlarmDispatcher.CommandsCompletedListener
@MainThread
public void onAllCommandsCompleted() {
this.mIsShutdown = true;
Logger.get().debug(TAG, "All commands completed in dispatcher");
WakeLocks.checkWakeLocks();
stopSelf();
}
@MainThread
private void initializeDispatcher() {
SystemAlarmDispatcher systemAlarmDispatcher = new SystemAlarmDispatcher(this);
this.mDispatcher = systemAlarmDispatcher;
systemAlarmDispatcher.setCompletedListener(this);
}
}

View File

@@ -0,0 +1,5 @@
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
package androidx.work.impl.background.systemalarm;
import androidx.annotation.RestrictTo;

View File

@@ -0,0 +1,23 @@
package androidx.work.impl.background.systemjob;
import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import androidx.annotation.RequiresApi;
import java.util.List;
import kotlin.jvm.internal.Intrinsics;
@RequiresApi(21)
/* loaded from: classes.dex */
final class JobScheduler21 {
public static final JobScheduler21 INSTANCE = new JobScheduler21();
private JobScheduler21() {
}
public final List<JobInfo> getAllPendingJobs(JobScheduler jobScheduler) {
Intrinsics.checkNotNullParameter(jobScheduler, "jobScheduler");
List<JobInfo> allPendingJobs = jobScheduler.getAllPendingJobs();
Intrinsics.checkNotNullExpressionValue(allPendingJobs, "jobScheduler.allPendingJobs");
return allPendingJobs;
}
}

View File

@@ -0,0 +1,5 @@
package androidx.work.impl.background.systemjob;
/* loaded from: classes.dex */
public abstract /* synthetic */ class JobScheduler34$$ExternalSyntheticApiModelOutline0 {
}

View File

@@ -0,0 +1,22 @@
package androidx.work.impl.background.systemjob;
import android.app.job.JobScheduler;
import androidx.annotation.RequiresApi;
import kotlin.jvm.internal.Intrinsics;
@RequiresApi(34)
/* loaded from: classes.dex */
final class JobScheduler34 {
public static final JobScheduler34 INSTANCE = new JobScheduler34();
private JobScheduler34() {
}
public final JobScheduler forNamespace(JobScheduler jobScheduler) {
JobScheduler forNamespace;
Intrinsics.checkNotNullParameter(jobScheduler, "jobScheduler");
forNamespace = jobScheduler.forNamespace(JobSchedulerExtKt.WORKMANAGER_NAMESPACE);
Intrinsics.checkNotNullExpressionValue(forNamespace, "jobScheduler.forNamespace(WORKMANAGER_NAMESPACE)");
return forNamespace;
}
}

View File

@@ -0,0 +1,91 @@
package androidx.work.impl.background.systemjob;
import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.Context;
import android.os.Build;
import androidx.annotation.RequiresApi;
import androidx.work.Configuration;
import androidx.work.Logger;
import androidx.work.impl.WorkDatabase;
import com.ironsource.mediationsdk.utils.IronSourceConstants;
import java.util.List;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.collections.CollectionsKt___CollectionsKt;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
@SourceDebugExtension({"SMAP\nJobSchedulerExt.kt\nKotlin\n*S Kotlin\n*F\n+ 1 JobSchedulerExt.kt\nandroidx/work/impl/background/systemjob/JobSchedulerExtKt\n+ 2 LoggerExt.kt\nandroidx/work/LoggerExtKt\n*L\n1#1,127:1\n32#2:128\n*S KotlinDebug\n*F\n+ 1 JobSchedulerExt.kt\nandroidx/work/impl/background/systemjob/JobSchedulerExtKt\n*L\n70#1:128\n*E\n"})
/* loaded from: classes.dex */
public final class JobSchedulerExtKt {
private static final String TAG;
public static final String WORKMANAGER_NAMESPACE = "androidx.work.systemjobscheduler";
static {
String tagWithPrefix = Logger.tagWithPrefix("SystemJobScheduler");
Intrinsics.checkNotNullExpressionValue(tagWithPrefix, "tagWithPrefix(\"SystemJobScheduler\")");
TAG = tagWithPrefix;
}
@RequiresApi(21)
public static final JobScheduler getWmJobScheduler(Context context) {
Intrinsics.checkNotNullParameter(context, "<this>");
Object systemService = context.getSystemService("jobscheduler");
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.job.JobScheduler");
JobScheduler jobScheduler = (JobScheduler) systemService;
return Build.VERSION.SDK_INT >= 34 ? JobScheduler34.INSTANCE.forNamespace(jobScheduler) : jobScheduler;
}
@RequiresApi(21)
public static final List<JobInfo> getSafePendingJobs(JobScheduler jobScheduler) {
Intrinsics.checkNotNullParameter(jobScheduler, "<this>");
try {
return JobScheduler21.INSTANCE.getAllPendingJobs(jobScheduler);
} catch (Throwable th) {
Logger.get().error(TAG, "getAllPendingJobs() is not reliable on this device.", th);
return null;
}
}
@RequiresApi(23)
public static final String createErrorMessage(Context context, WorkDatabase workDatabase, Configuration configuration) {
String str;
List listOfNotNull;
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(workDatabase, "workDatabase");
Intrinsics.checkNotNullParameter(configuration, "configuration");
int i = Build.VERSION.SDK_INT;
int i2 = i >= 31 ? IronSourceConstants.REWARDED_VIDEO_DAILY_CAPPED : 100;
int size = workDatabase.workSpecDao().getScheduledWork().size();
String str2 = "<faulty JobScheduler failed to getPendingJobs>";
if (i >= 34) {
JobScheduler wmJobScheduler = getWmJobScheduler(context);
List<JobInfo> safePendingJobs = getSafePendingJobs(wmJobScheduler);
if (safePendingJobs != null) {
List<JobInfo> pendingJobs = SystemJobScheduler.getPendingJobs(context, wmJobScheduler);
int size2 = pendingJobs != null ? safePendingJobs.size() - pendingJobs.size() : 0;
String str3 = null;
if (size2 == 0) {
str = null;
} else {
str = size2 + " of which are not owned by WorkManager";
}
Object systemService = context.getSystemService("jobscheduler");
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.job.JobScheduler");
List<JobInfo> pendingJobs2 = SystemJobScheduler.getPendingJobs(context, (JobScheduler) systemService);
int size3 = pendingJobs2 != null ? pendingJobs2.size() : 0;
if (size3 != 0) {
str3 = size3 + " from WorkManager in the default namespace";
}
listOfNotNull = CollectionsKt__CollectionsKt.listOfNotNull(safePendingJobs.size() + " jobs in \"androidx.work.systemjobscheduler\" namespace", str, str3);
str2 = CollectionsKt___CollectionsKt.joinToString$default(listOfNotNull, ",\n", null, null, 0, null, null, 62, null);
}
} else {
List<JobInfo> pendingJobs3 = SystemJobScheduler.getPendingJobs(context, getWmJobScheduler(context));
if (pendingJobs3 != null) {
str2 = pendingJobs3.size() + " jobs from WorkManager";
}
}
return "JobScheduler " + i2 + " job limit exceeded.\nIn JobScheduler there are " + str2 + ".\nThere are " + size + " jobs tracked by WorkManager's database;\nthe Configuration limit is " + configuration.getMaxSchedulerLimit() + '.';
}
}

View File

@@ -0,0 +1,5 @@
package androidx.work.impl.background.systemjob;
/* loaded from: classes.dex */
public abstract /* synthetic */ class SystemJobInfoConverter$$ExternalSyntheticApiModelOutline0 {
}

View File

@@ -0,0 +1,5 @@
package androidx.work.impl.background.systemjob;
/* loaded from: classes.dex */
public abstract /* synthetic */ class SystemJobInfoConverter$$ExternalSyntheticApiModelOutline1 {
}

View File

@@ -0,0 +1,5 @@
package androidx.work.impl.background.systemjob;
/* loaded from: classes.dex */
public abstract /* synthetic */ class SystemJobInfoConverter$$ExternalSyntheticApiModelOutline2 {
}

View File

@@ -0,0 +1,152 @@
package androidx.work.impl.background.systemjob;
import android.annotation.SuppressLint;
import android.app.job.JobInfo;
import android.content.ComponentName;
import android.content.Context;
import android.net.NetworkRequest;
import android.os.Build;
import android.os.PersistableBundle;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.work.BackoffPolicy;
import androidx.work.Clock;
import androidx.work.Constraints;
import androidx.work.Logger;
import androidx.work.NetworkType;
import androidx.work.impl.model.WorkSpec;
import java.util.Iterator;
@RequiresApi(api = 23)
@SuppressLint({"ClassVerificationFailure"})
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
class SystemJobInfoConverter {
static final String EXTRA_IS_PERIODIC = "EXTRA_IS_PERIODIC";
static final String EXTRA_WORK_SPEC_GENERATION = "EXTRA_WORK_SPEC_GENERATION";
static final String EXTRA_WORK_SPEC_ID = "EXTRA_WORK_SPEC_ID";
private static final String TAG = Logger.tagWithPrefix("SystemJobInfoConverter");
private final Clock mClock;
private final boolean mMarkImportantWhileForeground;
private final ComponentName mWorkServiceComponent;
public SystemJobInfoConverter(@NonNull Context context, Clock clock, boolean z) {
this.mClock = clock;
this.mWorkServiceComponent = new ComponentName(context.getApplicationContext(), (Class<?>) SystemJobService.class);
this.mMarkImportantWhileForeground = z;
}
public JobInfo convert(WorkSpec workSpec, int i) {
String traceTag;
Constraints constraints = workSpec.constraints;
PersistableBundle persistableBundle = new PersistableBundle();
persistableBundle.putString(EXTRA_WORK_SPEC_ID, workSpec.id);
persistableBundle.putInt(EXTRA_WORK_SPEC_GENERATION, workSpec.getGeneration());
persistableBundle.putBoolean(EXTRA_IS_PERIODIC, workSpec.isPeriodic());
JobInfo.Builder extras = new JobInfo.Builder(i, this.mWorkServiceComponent).setRequiresCharging(constraints.requiresCharging()).setRequiresDeviceIdle(constraints.requiresDeviceIdle()).setExtras(persistableBundle);
NetworkRequest requiredNetworkRequest = constraints.getRequiredNetworkRequest();
int i2 = Build.VERSION.SDK_INT;
if (i2 >= 28 && requiredNetworkRequest != null) {
SystemJobInfoConverterExtKt.setRequiredNetworkRequest(extras, requiredNetworkRequest);
} else {
setRequiredNetwork(extras, constraints.getRequiredNetworkType());
}
if (!constraints.requiresDeviceIdle()) {
extras.setBackoffCriteria(workSpec.backoffDelayDuration, workSpec.backoffPolicy == BackoffPolicy.LINEAR ? 0 : 1);
}
long max = Math.max(workSpec.calculateNextRunTime() - this.mClock.currentTimeMillis(), 0L);
if (i2 <= 28) {
extras.setMinimumLatency(max);
} else if (max > 0) {
extras.setMinimumLatency(max);
} else if (!workSpec.expedited && this.mMarkImportantWhileForeground) {
extras.setImportantWhileForeground(true);
}
if (constraints.hasContentUriTriggers()) {
Iterator<Constraints.ContentUriTrigger> it = constraints.getContentUriTriggers().iterator();
while (it.hasNext()) {
extras.addTriggerContentUri(convertContentUriTrigger(it.next()));
}
extras.setTriggerContentUpdateDelay(constraints.getContentTriggerUpdateDelayMillis());
extras.setTriggerContentMaxDelay(constraints.getContentTriggerMaxDelayMillis());
}
extras.setPersisted(false);
int i3 = Build.VERSION.SDK_INT;
extras.setRequiresBatteryNotLow(constraints.requiresBatteryNotLow());
extras.setRequiresStorageNotLow(constraints.requiresStorageNotLow());
boolean z = workSpec.runAttemptCount > 0;
boolean z2 = max > 0;
if (i3 >= 31 && workSpec.expedited && !z && !z2) {
extras.setExpedited(true);
}
if (i3 >= 35 && (traceTag = workSpec.getTraceTag()) != null) {
extras.setTraceTag(traceTag);
}
return extras.build();
}
@RequiresApi(24)
private static JobInfo.TriggerContentUri convertContentUriTrigger(Constraints.ContentUriTrigger contentUriTrigger) {
return new JobInfo.TriggerContentUri(contentUriTrigger.getUri(), contentUriTrigger.isTriggeredForDescendants() ? 1 : 0);
}
public static void setRequiredNetwork(@NonNull JobInfo.Builder builder, @NonNull NetworkType networkType) {
if (Build.VERSION.SDK_INT >= 30 && networkType == NetworkType.TEMPORARILY_UNMETERED) {
builder.setRequiredNetwork(new NetworkRequest.Builder().addCapability(25).build());
} else {
builder.setRequiredNetworkType(convertNetworkType(networkType));
}
}
/* renamed from: androidx.work.impl.background.systemjob.SystemJobInfoConverter$1, reason: invalid class name */
public static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] $SwitchMap$androidx$work$NetworkType;
static {
int[] iArr = new int[NetworkType.values().length];
$SwitchMap$androidx$work$NetworkType = iArr;
try {
iArr[NetworkType.NOT_REQUIRED.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$androidx$work$NetworkType[NetworkType.CONNECTED.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$androidx$work$NetworkType[NetworkType.UNMETERED.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$androidx$work$NetworkType[NetworkType.NOT_ROAMING.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$androidx$work$NetworkType[NetworkType.METERED.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
}
}
public static int convertNetworkType(NetworkType networkType) {
int i = AnonymousClass1.$SwitchMap$androidx$work$NetworkType[networkType.ordinal()];
if (i == 1) {
return 0;
}
if (i == 2) {
return 1;
}
if (i == 3) {
return 2;
}
if (i == 4) {
return 3;
}
if (i == 5) {
return 4;
}
Logger.get().debug(TAG, "API version too low. Cannot convert network type value " + networkType);
return 1;
}
}

View File

@@ -0,0 +1,15 @@
package androidx.work.impl.background.systemjob;
import android.app.job.JobInfo;
import android.net.NetworkRequest;
import androidx.annotation.RequiresApi;
import kotlin.jvm.internal.Intrinsics;
@RequiresApi(28)
/* loaded from: classes.dex */
public final class SystemJobInfoConverterExtKt {
public static final void setRequiredNetworkRequest(JobInfo.Builder builder, NetworkRequest networkRequest) {
Intrinsics.checkNotNullParameter(builder, "builder");
builder.setRequiredNetwork(networkRequest);
}
}

View File

@@ -0,0 +1,250 @@
package androidx.work.impl.background.systemjob;
import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.ComponentName;
import android.content.Context;
import android.os.Build;
import android.os.PersistableBundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.core.util.Consumer;
import androidx.work.Configuration;
import androidx.work.Logger;
import androidx.work.OutOfQuotaPolicy;
import androidx.work.WorkInfo;
import androidx.work.impl.Scheduler;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.model.SystemIdInfo;
import androidx.work.impl.model.SystemIdInfoKt;
import androidx.work.impl.model.WorkGenerationalId;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.model.WorkSpecDao;
import androidx.work.impl.model.WorkSpecKt;
import androidx.work.impl.utils.IdGenerator;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@RequiresApi(23)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class SystemJobScheduler implements Scheduler {
private static final String TAG = Logger.tagWithPrefix("SystemJobScheduler");
private final Configuration mConfiguration;
private final Context mContext;
private final JobScheduler mJobScheduler;
private final SystemJobInfoConverter mSystemJobInfoConverter;
private final WorkDatabase mWorkDatabase;
@Override // androidx.work.impl.Scheduler
public boolean hasLimitedSchedulingSlots() {
return true;
}
public SystemJobScheduler(@NonNull Context context, @NonNull WorkDatabase workDatabase, @NonNull Configuration configuration) {
this(context, workDatabase, configuration, JobSchedulerExtKt.getWmJobScheduler(context), new SystemJobInfoConverter(context, configuration.getClock(), configuration.isMarkingJobsAsImportantWhileForeground()));
}
@VisibleForTesting
public SystemJobScheduler(@NonNull Context context, @NonNull WorkDatabase workDatabase, @NonNull Configuration configuration, @NonNull JobScheduler jobScheduler, @NonNull SystemJobInfoConverter systemJobInfoConverter) {
this.mContext = context;
this.mJobScheduler = jobScheduler;
this.mSystemJobInfoConverter = systemJobInfoConverter;
this.mWorkDatabase = workDatabase;
this.mConfiguration = configuration;
}
@Override // androidx.work.impl.Scheduler
public void schedule(@NonNull WorkSpec... workSpecArr) {
IdGenerator idGenerator = new IdGenerator(this.mWorkDatabase);
for (WorkSpec workSpec : workSpecArr) {
this.mWorkDatabase.beginTransaction();
try {
WorkSpec workSpec2 = this.mWorkDatabase.workSpecDao().getWorkSpec(workSpec.id);
if (workSpec2 == null) {
Logger.get().warning(TAG, "Skipping scheduling " + workSpec.id + " because it's no longer in the DB");
this.mWorkDatabase.setTransactionSuccessful();
} else if (workSpec2.state != WorkInfo.State.ENQUEUED) {
Logger.get().warning(TAG, "Skipping scheduling " + workSpec.id + " because it is no longer enqueued");
this.mWorkDatabase.setTransactionSuccessful();
} else {
WorkGenerationalId generationalId = WorkSpecKt.generationalId(workSpec);
SystemIdInfo systemIdInfo = this.mWorkDatabase.systemIdInfoDao().getSystemIdInfo(generationalId);
int nextJobSchedulerIdWithRange = systemIdInfo != null ? systemIdInfo.systemId : idGenerator.nextJobSchedulerIdWithRange(this.mConfiguration.getMinJobSchedulerId(), this.mConfiguration.getMaxJobSchedulerId());
if (systemIdInfo == null) {
this.mWorkDatabase.systemIdInfoDao().insertSystemIdInfo(SystemIdInfoKt.systemIdInfo(generationalId, nextJobSchedulerIdWithRange));
}
scheduleInternal(workSpec, nextJobSchedulerIdWithRange);
this.mWorkDatabase.setTransactionSuccessful();
}
} finally {
this.mWorkDatabase.endTransaction();
}
}
}
@VisibleForTesting
public void scheduleInternal(@NonNull WorkSpec workSpec, int i) {
JobInfo convert = this.mSystemJobInfoConverter.convert(workSpec, i);
Logger logger = Logger.get();
String str = TAG;
logger.debug(str, "Scheduling work ID " + workSpec.id + "Job ID " + i);
try {
if (this.mJobScheduler.schedule(convert) == 0) {
Logger.get().warning(str, "Unable to schedule work ID " + workSpec.id);
if (workSpec.expedited && workSpec.outOfQuotaPolicy == OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST) {
workSpec.expedited = false;
Logger.get().debug(str, String.format("Scheduling a non-expedited job (work ID %s)", workSpec.id));
scheduleInternal(workSpec, i);
}
}
} catch (IllegalStateException e) {
String createErrorMessage = JobSchedulerExtKt.createErrorMessage(this.mContext, this.mWorkDatabase, this.mConfiguration);
Logger.get().error(TAG, createErrorMessage);
IllegalStateException illegalStateException = new IllegalStateException(createErrorMessage, e);
Consumer<Throwable> schedulingExceptionHandler = this.mConfiguration.getSchedulingExceptionHandler();
if (schedulingExceptionHandler != null) {
schedulingExceptionHandler.accept(illegalStateException);
return;
}
throw illegalStateException;
} catch (Throwable th) {
Logger.get().error(TAG, "Unable to schedule " + workSpec, th);
}
}
@Override // androidx.work.impl.Scheduler
public void cancel(@NonNull String str) {
List<Integer> pendingJobIds = getPendingJobIds(this.mContext, this.mJobScheduler, str);
if (pendingJobIds == null || pendingJobIds.isEmpty()) {
return;
}
Iterator<Integer> it = pendingJobIds.iterator();
while (it.hasNext()) {
cancelJobById(this.mJobScheduler, it.next().intValue());
}
this.mWorkDatabase.systemIdInfoDao().removeSystemIdInfo(str);
}
private static void cancelJobById(@NonNull JobScheduler jobScheduler, int i) {
try {
jobScheduler.cancel(i);
} catch (Throwable th) {
Logger.get().error(TAG, String.format(Locale.getDefault(), "Exception while trying to cancel job (%d)", Integer.valueOf(i)), th);
}
}
public static void cancelAllInAllNamespaces(@NonNull Context context) {
if (Build.VERSION.SDK_INT >= 34) {
JobSchedulerExtKt.getWmJobScheduler(context).cancelAll();
}
JobScheduler jobScheduler = (JobScheduler) context.getSystemService("jobscheduler");
List<JobInfo> pendingJobs = getPendingJobs(context, jobScheduler);
if (pendingJobs == null || pendingJobs.isEmpty()) {
return;
}
Iterator<JobInfo> it = pendingJobs.iterator();
while (it.hasNext()) {
cancelJobById(jobScheduler, it.next().getId());
}
}
public static boolean reconcileJobs(@NonNull Context context, @NonNull WorkDatabase workDatabase) {
JobScheduler wmJobScheduler = JobSchedulerExtKt.getWmJobScheduler(context);
List<JobInfo> pendingJobs = getPendingJobs(context, wmJobScheduler);
List<String> workSpecIds = workDatabase.systemIdInfoDao().getWorkSpecIds();
boolean z = false;
HashSet hashSet = new HashSet(pendingJobs != null ? pendingJobs.size() : 0);
if (pendingJobs != null && !pendingJobs.isEmpty()) {
for (JobInfo jobInfo : pendingJobs) {
WorkGenerationalId workGenerationalIdFromJobInfo = getWorkGenerationalIdFromJobInfo(jobInfo);
if (workGenerationalIdFromJobInfo != null) {
hashSet.add(workGenerationalIdFromJobInfo.getWorkSpecId());
} else {
cancelJobById(wmJobScheduler, jobInfo.getId());
}
}
}
Iterator<String> it = workSpecIds.iterator();
while (true) {
if (!it.hasNext()) {
break;
}
if (!hashSet.contains(it.next())) {
Logger.get().debug(TAG, "Reconciling jobs");
z = true;
break;
}
}
if (z) {
workDatabase.beginTransaction();
try {
WorkSpecDao workSpecDao = workDatabase.workSpecDao();
Iterator<String> it2 = workSpecIds.iterator();
while (it2.hasNext()) {
workSpecDao.markWorkSpecScheduled(it2.next(), -1L);
}
workDatabase.setTransactionSuccessful();
workDatabase.endTransaction();
} catch (Throwable th) {
workDatabase.endTransaction();
throw th;
}
}
return z;
}
@Nullable
public static List<JobInfo> getPendingJobs(@NonNull Context context, @NonNull JobScheduler jobScheduler) {
List<JobInfo> safePendingJobs = JobSchedulerExtKt.getSafePendingJobs(jobScheduler);
if (safePendingJobs == null) {
return null;
}
ArrayList arrayList = new ArrayList(safePendingJobs.size());
ComponentName componentName = new ComponentName(context, (Class<?>) SystemJobService.class);
for (JobInfo jobInfo : safePendingJobs) {
if (componentName.equals(jobInfo.getService())) {
arrayList.add(jobInfo);
}
}
return arrayList;
}
@Nullable
private static List<Integer> getPendingJobIds(@NonNull Context context, @NonNull JobScheduler jobScheduler, @NonNull String str) {
List<JobInfo> pendingJobs = getPendingJobs(context, jobScheduler);
if (pendingJobs == null) {
return null;
}
ArrayList arrayList = new ArrayList(2);
for (JobInfo jobInfo : pendingJobs) {
WorkGenerationalId workGenerationalIdFromJobInfo = getWorkGenerationalIdFromJobInfo(jobInfo);
if (workGenerationalIdFromJobInfo != null && str.equals(workGenerationalIdFromJobInfo.getWorkSpecId())) {
arrayList.add(Integer.valueOf(jobInfo.getId()));
}
}
return arrayList;
}
@Nullable
private static WorkGenerationalId getWorkGenerationalIdFromJobInfo(@NonNull JobInfo jobInfo) {
PersistableBundle extras = jobInfo.getExtras();
if (extras == null) {
return null;
}
try {
if (!extras.containsKey("EXTRA_WORK_SPEC_ID")) {
return null;
}
return new WorkGenerationalId(extras.getString("EXTRA_WORK_SPEC_ID"), extras.getInt("EXTRA_WORK_SPEC_GENERATION", 0));
} catch (NullPointerException unused) {
return null;
}
}
}

View File

@@ -0,0 +1,211 @@
package androidx.work.impl.background.systemjob;
import android.app.Application;
import android.app.job.JobParameters;
import android.app.job.JobService;
import android.net.Network;
import android.net.Uri;
import android.os.Build;
import android.os.Looper;
import android.os.PersistableBundle;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.work.Logger;
import androidx.work.WorkInfo;
import androidx.work.WorkerParameters;
import androidx.work.impl.ExecutionListener;
import androidx.work.impl.Processor;
import androidx.work.impl.StartStopToken;
import androidx.work.impl.StartStopTokens;
import androidx.work.impl.WorkLauncher;
import androidx.work.impl.WorkLauncherImpl;
import androidx.work.impl.WorkManagerImpl;
import androidx.work.impl.model.WorkGenerationalId;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@RequiresApi(23)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class SystemJobService extends JobService implements ExecutionListener {
private static final String TAG = Logger.tagWithPrefix("SystemJobService");
private final Map<WorkGenerationalId, JobParameters> mJobParameters = new HashMap();
private final StartStopTokens mStartStopTokens = StartStopTokens.create(false);
private WorkLauncher mWorkLauncher;
private WorkManagerImpl mWorkManagerImpl;
public static int stopReason(int i) {
switch (i) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
return i;
default:
return WorkInfo.STOP_REASON_UNKNOWN;
}
}
@Override // android.app.Service
public void onCreate() {
super.onCreate();
try {
WorkManagerImpl workManagerImpl = WorkManagerImpl.getInstance(getApplicationContext());
this.mWorkManagerImpl = workManagerImpl;
Processor processor = workManagerImpl.getProcessor();
this.mWorkLauncher = new WorkLauncherImpl(processor, this.mWorkManagerImpl.getWorkTaskExecutor());
processor.addExecutionListener(this);
} catch (IllegalStateException e) {
if (!Application.class.equals(getApplication().getClass())) {
throw new IllegalStateException("WorkManager needs to be initialized via a ContentProvider#onCreate() or an Application#onCreate().", e);
}
Logger.get().warning(TAG, "Could not find WorkManager instance; this may be because an auto-backup is in progress. Ignoring JobScheduler commands for now. Please make sure that you are initializing WorkManager if you have manually disabled WorkManagerInitializer.");
}
}
@Override // android.app.Service
public void onDestroy() {
super.onDestroy();
WorkManagerImpl workManagerImpl = this.mWorkManagerImpl;
if (workManagerImpl != null) {
workManagerImpl.getProcessor().removeExecutionListener(this);
}
}
@Override // android.app.job.JobService
public boolean onStartJob(@NonNull JobParameters jobParameters) {
assertMainThread("onStartJob");
if (this.mWorkManagerImpl == null) {
Logger.get().debug(TAG, "WorkManager is not initialized; requesting retry.");
jobFinished(jobParameters, true);
return false;
}
WorkGenerationalId workGenerationalIdFromJobParameters = workGenerationalIdFromJobParameters(jobParameters);
if (workGenerationalIdFromJobParameters == null) {
Logger.get().error(TAG, "WorkSpec id not found!");
return false;
}
if (this.mJobParameters.containsKey(workGenerationalIdFromJobParameters)) {
Logger.get().debug(TAG, "Job is already being executed by SystemJobService: " + workGenerationalIdFromJobParameters);
return false;
}
Logger.get().debug(TAG, "onStartJob for " + workGenerationalIdFromJobParameters);
this.mJobParameters.put(workGenerationalIdFromJobParameters, jobParameters);
int i = Build.VERSION.SDK_INT;
WorkerParameters.RuntimeExtras runtimeExtras = new WorkerParameters.RuntimeExtras();
if (Api24Impl.getTriggeredContentUris(jobParameters) != null) {
runtimeExtras.triggeredContentUris = Arrays.asList(Api24Impl.getTriggeredContentUris(jobParameters));
}
if (Api24Impl.getTriggeredContentAuthorities(jobParameters) != null) {
runtimeExtras.triggeredContentAuthorities = Arrays.asList(Api24Impl.getTriggeredContentAuthorities(jobParameters));
}
if (i >= 28) {
runtimeExtras.network = Api28Impl.getNetwork(jobParameters);
}
this.mWorkLauncher.startWork(this.mStartStopTokens.tokenFor(workGenerationalIdFromJobParameters), runtimeExtras);
return true;
}
@Override // android.app.job.JobService
public boolean onStopJob(@NonNull JobParameters jobParameters) {
assertMainThread("onStopJob");
if (this.mWorkManagerImpl == null) {
Logger.get().debug(TAG, "WorkManager is not initialized; requesting retry.");
return true;
}
WorkGenerationalId workGenerationalIdFromJobParameters = workGenerationalIdFromJobParameters(jobParameters);
if (workGenerationalIdFromJobParameters == null) {
Logger.get().error(TAG, "WorkSpec id not found!");
return false;
}
Logger.get().debug(TAG, "onStopJob for " + workGenerationalIdFromJobParameters);
this.mJobParameters.remove(workGenerationalIdFromJobParameters);
StartStopToken remove = this.mStartStopTokens.remove(workGenerationalIdFromJobParameters);
if (remove != null) {
this.mWorkLauncher.stopWorkWithReason(remove, Build.VERSION.SDK_INT >= 31 ? Api31Impl.getStopReason(jobParameters) : WorkInfo.STOP_REASON_UNKNOWN);
}
return !this.mWorkManagerImpl.getProcessor().isCancelled(workGenerationalIdFromJobParameters.getWorkSpecId());
}
@Override // androidx.work.impl.ExecutionListener
@MainThread
public void onExecuted(@NonNull WorkGenerationalId workGenerationalId, boolean z) {
assertMainThread("onExecuted");
Logger.get().debug(TAG, workGenerationalId.getWorkSpecId() + " executed on JobScheduler");
JobParameters remove = this.mJobParameters.remove(workGenerationalId);
this.mStartStopTokens.remove(workGenerationalId);
if (remove != null) {
jobFinished(remove, z);
}
}
@Nullable
private static WorkGenerationalId workGenerationalIdFromJobParameters(@NonNull JobParameters jobParameters) {
try {
PersistableBundle extras = jobParameters.getExtras();
if (extras == null || !extras.containsKey("EXTRA_WORK_SPEC_ID")) {
return null;
}
return new WorkGenerationalId(extras.getString("EXTRA_WORK_SPEC_ID"), extras.getInt("EXTRA_WORK_SPEC_GENERATION"));
} catch (NullPointerException unused) {
return null;
}
}
@RequiresApi(24)
public static class Api24Impl {
private Api24Impl() {
}
public static Uri[] getTriggeredContentUris(JobParameters jobParameters) {
return jobParameters.getTriggeredContentUris();
}
public static String[] getTriggeredContentAuthorities(JobParameters jobParameters) {
return jobParameters.getTriggeredContentAuthorities();
}
}
@RequiresApi(28)
public static class Api28Impl {
private Api28Impl() {
}
public static Network getNetwork(JobParameters jobParameters) {
return jobParameters.getNetwork();
}
}
@RequiresApi(31)
public static class Api31Impl {
private Api31Impl() {
}
public static int getStopReason(JobParameters jobParameters) {
return SystemJobService.stopReason(jobParameters.getStopReason());
}
}
private static void assertMainThread(String str) {
if (Looper.getMainLooper().getThread() == Thread.currentThread()) {
return;
}
throw new IllegalStateException("Cannot invoke " + str + " on a background thread");
}
}

View File

@@ -0,0 +1,5 @@
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
package androidx.work.impl.background.systemjob;
import androidx.annotation.RestrictTo;

View File

@@ -0,0 +1,9 @@
package androidx.work.impl.constraints;
import androidx.annotation.MainThread;
/* loaded from: classes.dex */
public interface ConstraintListener<T> {
@MainThread
void onConstraintChanged(T t);
}

View File

@@ -0,0 +1,64 @@
package androidx.work.impl.constraints;
import kotlin.jvm.internal.DefaultConstructorMarker;
/* loaded from: classes.dex */
public abstract class ConstraintsState {
public /* synthetic */ ConstraintsState(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static final class ConstraintsMet extends ConstraintsState {
public static final ConstraintsMet INSTANCE = new ConstraintsMet();
private ConstraintsMet() {
super(null);
}
}
private ConstraintsState() {
}
public static final class ConstraintsNotMet extends ConstraintsState {
private final int reason;
public static /* synthetic */ ConstraintsNotMet copy$default(ConstraintsNotMet constraintsNotMet, int i, int i2, Object obj) {
if ((i2 & 1) != 0) {
i = constraintsNotMet.reason;
}
return constraintsNotMet.copy(i);
}
public final int component1() {
return this.reason;
}
public final ConstraintsNotMet copy(int i) {
return new ConstraintsNotMet(i);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
return (obj instanceof ConstraintsNotMet) && this.reason == ((ConstraintsNotMet) obj).reason;
}
public final int getReason() {
return this.reason;
}
public int hashCode() {
return Integer.hashCode(this.reason);
}
public String toString() {
return "ConstraintsNotMet(reason=" + this.reason + ')';
}
public ConstraintsNotMet(int i) {
super(null);
this.reason = i;
}
}
}

View File

@@ -0,0 +1,72 @@
package androidx.work.impl.constraints;
import androidx.work.Logger;
import androidx.work.impl.constraints.ConstraintsState;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.DelayKt;
import kotlinx.coroutines.channels.ProducerScope;
@DebugMetadata(c = "androidx.work.impl.constraints.NetworkRequestConstraintController$track$1$job$1", f = "WorkConstraintsTracker.kt", l = {148}, m = "invokeSuspend")
/* loaded from: classes.dex */
public final class NetworkRequestConstraintController$track$1$job$1 extends SuspendLambda implements Function2 {
final /* synthetic */ ProducerScope $$this$callbackFlow;
int label;
final /* synthetic */ NetworkRequestConstraintController this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public NetworkRequestConstraintController$track$1$job$1(NetworkRequestConstraintController networkRequestConstraintController, ProducerScope producerScope, Continuation continuation) {
super(2, continuation);
this.this$0 = networkRequestConstraintController;
this.$$this$callbackFlow = producerScope;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
return new NetworkRequestConstraintController$track$1$job$1(this.this$0, this.$$this$callbackFlow, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) {
return ((NetworkRequestConstraintController$track$1$job$1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
long j;
String str;
long j2;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
j = this.this$0.timeoutMs;
this.label = 1;
if (DelayKt.delay(j, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
Logger logger = Logger.get();
str = WorkConstraintsTrackerKt.TAG;
StringBuilder sb = new StringBuilder();
sb.append("NetworkRequestConstraintController didn't receive neither onCapabilitiesChanged/onLost callback, sending `ConstraintsNotMet` after ");
j2 = this.this$0.timeoutMs;
sb.append(j2);
sb.append(" ms");
logger.debug(str, sb.toString());
this.$$this$callbackFlow.mo4126trySendJP2dKIU(new ConstraintsState.ConstraintsNotMet(7));
return Unit.INSTANCE;
}
}

View File

@@ -0,0 +1,137 @@
package androidx.work.impl.constraints;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import androidx.work.Constraints;
import androidx.work.Logger;
import androidx.work.impl.constraints.ConstraintsState;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.BuildersKt__Builders_commonKt;
import kotlinx.coroutines.Job;
import kotlinx.coroutines.channels.ProduceKt;
import kotlinx.coroutines.channels.ProducerScope;
import kotlinx.coroutines.channels.SendChannel;
@DebugMetadata(c = "androidx.work.impl.constraints.NetworkRequestConstraintController$track$1", f = "WorkConstraintsTracker.kt", l = {182}, m = "invokeSuspend")
/* loaded from: classes.dex */
public final class NetworkRequestConstraintController$track$1 extends SuspendLambda implements Function2 {
final /* synthetic */ Constraints $constraints;
private /* synthetic */ Object L$0;
int label;
final /* synthetic */ NetworkRequestConstraintController this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public NetworkRequestConstraintController$track$1(Constraints constraints, NetworkRequestConstraintController networkRequestConstraintController, Continuation continuation) {
super(2, continuation);
this.$constraints = constraints;
this.this$0 = networkRequestConstraintController;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
NetworkRequestConstraintController$track$1 networkRequestConstraintController$track$1 = new NetworkRequestConstraintController$track$1(this.$constraints, this.this$0, continuation);
networkRequestConstraintController$track$1.L$0 = obj;
return networkRequestConstraintController$track$1;
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(ProducerScope producerScope, Continuation continuation) {
return ((NetworkRequestConstraintController$track$1) create(producerScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r4v1, types: [android.net.ConnectivityManager$NetworkCallback, androidx.work.impl.constraints.NetworkRequestConstraintController$track$1$networkCallback$1] */
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
final Job launch$default;
String str;
ConnectivityManager connectivityManager;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
final ProducerScope producerScope = (ProducerScope) this.L$0;
NetworkRequest requiredNetworkRequest = this.$constraints.getRequiredNetworkRequest();
if (requiredNetworkRequest != null) {
launch$default = BuildersKt__Builders_commonKt.launch$default(producerScope, null, null, new NetworkRequestConstraintController$track$1$job$1(this.this$0, producerScope, null), 3, null);
final ?? r4 = new ConnectivityManager.NetworkCallback() { // from class: androidx.work.impl.constraints.NetworkRequestConstraintController$track$1$networkCallback$1
@Override // android.net.ConnectivityManager.NetworkCallback
public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) {
String str2;
Intrinsics.checkNotNullParameter(network, "network");
Intrinsics.checkNotNullParameter(networkCapabilities, "networkCapabilities");
Job.DefaultImpls.cancel$default(Job.this, null, 1, null);
Logger logger = Logger.get();
str2 = WorkConstraintsTrackerKt.TAG;
logger.debug(str2, "NetworkRequestConstraintController onCapabilitiesChanged callback");
producerScope.mo4126trySendJP2dKIU(ConstraintsState.ConstraintsMet.INSTANCE);
}
@Override // android.net.ConnectivityManager.NetworkCallback
public void onLost(Network network) {
String str2;
Intrinsics.checkNotNullParameter(network, "network");
Job.DefaultImpls.cancel$default(Job.this, null, 1, null);
Logger logger = Logger.get();
str2 = WorkConstraintsTrackerKt.TAG;
logger.debug(str2, "NetworkRequestConstraintController onLost callback");
producerScope.mo4126trySendJP2dKIU(new ConstraintsState.ConstraintsNotMet(7));
}
};
Logger logger = Logger.get();
str = WorkConstraintsTrackerKt.TAG;
logger.debug(str, "NetworkRequestConstraintController register callback");
connectivityManager = this.this$0.connManager;
connectivityManager.registerNetworkCallback(requiredNetworkRequest, (ConnectivityManager.NetworkCallback) r4);
final NetworkRequestConstraintController networkRequestConstraintController = this.this$0;
Function0 function0 = new Function0() { // from class: androidx.work.impl.constraints.NetworkRequestConstraintController$track$1.1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
@Override // kotlin.jvm.functions.Function0
public /* bridge */ /* synthetic */ Object invoke() {
m191invoke();
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: collision with other method in class */
public final void m191invoke() {
String str2;
ConnectivityManager connectivityManager2;
Logger logger2 = Logger.get();
str2 = WorkConstraintsTrackerKt.TAG;
logger2.debug(str2, "NetworkRequestConstraintController unregister callback");
connectivityManager2 = NetworkRequestConstraintController.this.connManager;
connectivityManager2.unregisterNetworkCallback(r4);
}
};
this.label = 1;
if (ProduceKt.awaitClose(producerScope, function0, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else {
SendChannel.DefaultImpls.close$default(producerScope.getChannel(), null, 1, null);
return Unit.INSTANCE;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
return Unit.INSTANCE;
}
}

View File

@@ -0,0 +1,49 @@
package androidx.work.impl.constraints;
import android.net.ConnectivityManager;
import androidx.annotation.RequiresApi;
import androidx.work.Constraints;
import androidx.work.impl.constraints.controllers.ConstraintController;
import androidx.work.impl.model.WorkSpec;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.flow.Flow;
import kotlinx.coroutines.flow.FlowKt;
@RequiresApi(28)
/* loaded from: classes.dex */
public final class NetworkRequestConstraintController implements ConstraintController {
private final ConnectivityManager connManager;
private final long timeoutMs;
public NetworkRequestConstraintController(ConnectivityManager connManager, long j) {
Intrinsics.checkNotNullParameter(connManager, "connManager");
this.connManager = connManager;
this.timeoutMs = j;
}
public /* synthetic */ NetworkRequestConstraintController(ConnectivityManager connectivityManager, long j, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(connectivityManager, (i & 2) != 0 ? WorkConstraintsTrackerKt.DefaultNetworkRequestTimeoutMs : j);
}
@Override // androidx.work.impl.constraints.controllers.ConstraintController
public Flow track(Constraints constraints) {
Intrinsics.checkNotNullParameter(constraints, "constraints");
return FlowKt.callbackFlow(new NetworkRequestConstraintController$track$1(constraints, this, null));
}
@Override // androidx.work.impl.constraints.controllers.ConstraintController
public boolean hasConstraint(WorkSpec workSpec) {
Intrinsics.checkNotNullParameter(workSpec, "workSpec");
return workSpec.constraints.getRequiredNetworkRequest() != null;
}
@Override // androidx.work.impl.constraints.controllers.ConstraintController
public boolean isCurrentlyConstrained(WorkSpec workSpec) {
Intrinsics.checkNotNullParameter(workSpec, "workSpec");
if (hasConstraint(workSpec)) {
throw new IllegalStateException("isCurrentlyConstrained() must never be called onNetworkRequestConstraintController. isCurrentlyConstrained() is called only on older platforms where NetworkRequest isn't supported");
}
return false;
}
}

View File

@@ -0,0 +1,87 @@
package androidx.work.impl.constraints;
/* loaded from: classes.dex */
public final class NetworkState {
private final boolean isConnected;
private final boolean isMetered;
private final boolean isNotRoaming;
private final boolean isValidated;
public static /* synthetic */ NetworkState copy$default(NetworkState networkState, boolean z, boolean z2, boolean z3, boolean z4, int i, Object obj) {
if ((i & 1) != 0) {
z = networkState.isConnected;
}
if ((i & 2) != 0) {
z2 = networkState.isValidated;
}
if ((i & 4) != 0) {
z3 = networkState.isMetered;
}
if ((i & 8) != 0) {
z4 = networkState.isNotRoaming;
}
return networkState.copy(z, z2, z3, z4);
}
public final boolean component1() {
return this.isConnected;
}
public final boolean component2() {
return this.isValidated;
}
public final boolean component3() {
return this.isMetered;
}
public final boolean component4() {
return this.isNotRoaming;
}
public final NetworkState copy(boolean z, boolean z2, boolean z3, boolean z4) {
return new NetworkState(z, z2, z3, z4);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof NetworkState)) {
return false;
}
NetworkState networkState = (NetworkState) obj;
return this.isConnected == networkState.isConnected && this.isValidated == networkState.isValidated && this.isMetered == networkState.isMetered && this.isNotRoaming == networkState.isNotRoaming;
}
public int hashCode() {
return (((((Boolean.hashCode(this.isConnected) * 31) + Boolean.hashCode(this.isValidated)) * 31) + Boolean.hashCode(this.isMetered)) * 31) + Boolean.hashCode(this.isNotRoaming);
}
public final boolean isConnected() {
return this.isConnected;
}
public final boolean isMetered() {
return this.isMetered;
}
public final boolean isNotRoaming() {
return this.isNotRoaming;
}
public final boolean isValidated() {
return this.isValidated;
}
public String toString() {
return "NetworkState(isConnected=" + this.isConnected + ", isValidated=" + this.isValidated + ", isMetered=" + this.isMetered + ", isNotRoaming=" + this.isNotRoaming + ')';
}
public NetworkState(boolean z, boolean z2, boolean z3, boolean z4) {
this.isConnected = z;
this.isValidated = z2;
this.isMetered = z3;
this.isNotRoaming = z4;
}
}

View File

@@ -0,0 +1,8 @@
package androidx.work.impl.constraints;
import androidx.work.impl.model.WorkSpec;
/* loaded from: classes.dex */
public interface OnConstraintsStateChangedListener {
void onConstraintsStateChanged(WorkSpec workSpec, ConstraintsState constraintsState);
}

View File

@@ -0,0 +1,233 @@
package androidx.work.impl.constraints;
import androidx.work.Logger;
import androidx.work.impl.constraints.ConstraintsState;
import androidx.work.impl.constraints.controllers.ConstraintController;
import androidx.work.impl.model.WorkSpec;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.collections.CollectionsKt__IterablesKt;
import kotlin.collections.CollectionsKt___CollectionsKt;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function3;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlinx.coroutines.flow.Flow;
import kotlinx.coroutines.flow.FlowCollector;
import kotlinx.coroutines.flow.FlowKt;
import kotlinx.coroutines.flow.internal.CombineKt;
@SourceDebugExtension({"SMAP\nWorkConstraintsTracker.kt\nKotlin\n*S Kotlin\n*F\n+ 1 WorkConstraintsTracker.kt\nandroidx/work/impl/constraints/WorkConstraintsTracker\n+ 2 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n+ 3 Zip.kt\nkotlinx/coroutines/flow/FlowKt__ZipKt\n+ 4 ArraysJVM.kt\nkotlin/collections/ArraysKt__ArraysJVMKt\n+ 5 SafeCollector.common.kt\nkotlinx/coroutines/flow/internal/SafeCollector_commonKt\n*L\n1#1,205:1\n766#2:206\n857#2,2:207\n1549#2:209\n1620#2,3:210\n766#2:218\n857#2,2:219\n287#3:213\n288#3:216\n37#4,2:214\n107#5:217\n*S KotlinDebug\n*F\n+ 1 WorkConstraintsTracker.kt\nandroidx/work/impl/constraints/WorkConstraintsTracker\n*L\n92#1:206\n92#1:207,2\n92#1:209\n92#1:210,3\n100#1:218\n100#1:219,2\n93#1:213\n93#1:216\n93#1:214,2\n93#1:217\n*E\n"})
/* loaded from: classes.dex */
public final class WorkConstraintsTracker {
private final List<ConstraintController> controllers;
/* JADX WARN: Multi-variable type inference failed */
public WorkConstraintsTracker(List<? extends ConstraintController> controllers) {
Intrinsics.checkNotNullParameter(controllers, "controllers");
this.controllers = controllers;
}
/* JADX WARN: Illegal instructions before constructor call */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public WorkConstraintsTracker(androidx.work.impl.constraints.trackers.Trackers r4) {
/*
r3 = this;
java.lang.String r0 = "trackers"
kotlin.jvm.internal.Intrinsics.checkNotNullParameter(r4, r0)
r0 = 8
androidx.work.impl.constraints.controllers.ConstraintController[] r0 = new androidx.work.impl.constraints.controllers.ConstraintController[r0]
androidx.work.impl.constraints.controllers.BatteryChargingController r1 = new androidx.work.impl.constraints.controllers.BatteryChargingController
androidx.work.impl.constraints.trackers.ConstraintTracker r2 = r4.getBatteryChargingTracker()
r1.<init>(r2)
r2 = 0
r0[r2] = r1
androidx.work.impl.constraints.controllers.BatteryNotLowController r1 = new androidx.work.impl.constraints.controllers.BatteryNotLowController
androidx.work.impl.constraints.trackers.BatteryNotLowTracker r2 = r4.getBatteryNotLowTracker()
r1.<init>(r2)
r2 = 1
r0[r2] = r1
androidx.work.impl.constraints.controllers.StorageNotLowController r1 = new androidx.work.impl.constraints.controllers.StorageNotLowController
androidx.work.impl.constraints.trackers.ConstraintTracker r2 = r4.getStorageNotLowTracker()
r1.<init>(r2)
r2 = 2
r0[r2] = r1
androidx.work.impl.constraints.controllers.NetworkConnectedController r1 = new androidx.work.impl.constraints.controllers.NetworkConnectedController
androidx.work.impl.constraints.trackers.ConstraintTracker r2 = r4.getNetworkStateTracker()
r1.<init>(r2)
r2 = 3
r0[r2] = r1
androidx.work.impl.constraints.controllers.NetworkUnmeteredController r1 = new androidx.work.impl.constraints.controllers.NetworkUnmeteredController
androidx.work.impl.constraints.trackers.ConstraintTracker r2 = r4.getNetworkStateTracker()
r1.<init>(r2)
r2 = 4
r0[r2] = r1
androidx.work.impl.constraints.controllers.NetworkNotRoamingController r1 = new androidx.work.impl.constraints.controllers.NetworkNotRoamingController
androidx.work.impl.constraints.trackers.ConstraintTracker r2 = r4.getNetworkStateTracker()
r1.<init>(r2)
r2 = 5
r0[r2] = r1
androidx.work.impl.constraints.controllers.NetworkMeteredController r1 = new androidx.work.impl.constraints.controllers.NetworkMeteredController
androidx.work.impl.constraints.trackers.ConstraintTracker r2 = r4.getNetworkStateTracker()
r1.<init>(r2)
r2 = 6
r0[r2] = r1
int r1 = android.os.Build.VERSION.SDK_INT
r2 = 28
if (r1 < r2) goto L6c
android.content.Context r4 = r4.getContext()
androidx.work.impl.constraints.NetworkRequestConstraintController r4 = androidx.work.impl.constraints.WorkConstraintsTrackerKt.NetworkRequestConstraintController(r4)
goto L6d
L6c:
r4 = 0
L6d:
r1 = 7
r0[r1] = r4
java.util.List r4 = kotlin.collections.CollectionsKt.listOfNotNull(r0)
r3.<init>(r4)
return
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.work.impl.constraints.WorkConstraintsTracker.<init>(androidx.work.impl.constraints.trackers.Trackers):void");
}
public final Flow track(WorkSpec spec) {
Intrinsics.checkNotNullParameter(spec, "spec");
List<ConstraintController> list = this.controllers;
ArrayList arrayList = new ArrayList();
for (Object obj : list) {
if (((ConstraintController) obj).hasConstraint(spec)) {
arrayList.add(obj);
}
}
ArrayList arrayList2 = new ArrayList(CollectionsKt__IterablesKt.collectionSizeOrDefault(arrayList, 10));
Iterator it = arrayList.iterator();
while (it.hasNext()) {
arrayList2.add(((ConstraintController) it.next()).track(spec.constraints));
}
final Flow[] flowArr = (Flow[]) CollectionsKt___CollectionsKt.toList(arrayList2).toArray(new Flow[0]);
return FlowKt.distinctUntilChanged(new Flow() { // from class: androidx.work.impl.constraints.WorkConstraintsTracker$track$$inlined$combine$1
@Override // kotlinx.coroutines.flow.Flow
public Object collect(FlowCollector flowCollector, Continuation continuation) {
Object coroutine_suspended;
final Flow[] flowArr2 = flowArr;
Object combineInternal = CombineKt.combineInternal(flowCollector, flowArr2, new Function0() { // from class: androidx.work.impl.constraints.WorkConstraintsTracker$track$$inlined$combine$1.2
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
@Override // kotlin.jvm.functions.Function0
public final ConstraintsState[] invoke() {
return new ConstraintsState[flowArr2.length];
}
}, new AnonymousClass3(null), continuation);
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
return combineInternal == coroutine_suspended ? combineInternal : Unit.INSTANCE;
}
@DebugMetadata(c = "androidx.work.impl.constraints.WorkConstraintsTracker$track$$inlined$combine$1$3", f = "WorkConstraintsTracker.kt", l = {292}, m = "invokeSuspend")
@SourceDebugExtension({"SMAP\nZip.kt\nKotlin\n*S Kotlin\n*F\n+ 1 Zip.kt\nkotlinx/coroutines/flow/FlowKt__ZipKt$combine$6$2\n+ 2 WorkConstraintsTracker.kt\nandroidx/work/impl/constraints/WorkConstraintsTracker\n+ 3 _Arrays.kt\nkotlin/collections/ArraysKt___ArraysKt\n*L\n1#1,332:1\n94#2:333\n1282#3,2:334\n*S KotlinDebug\n*F\n+ 1 WorkConstraintsTracker.kt\nandroidx/work/impl/constraints/WorkConstraintsTracker\n*L\n94#1:334,2\n*E\n"})
/* renamed from: androidx.work.impl.constraints.WorkConstraintsTracker$track$$inlined$combine$1$3, reason: invalid class name */
public static final class AnonymousClass3 extends SuspendLambda implements Function3 {
private /* synthetic */ Object L$0;
/* synthetic */ Object L$1;
int label;
public AnonymousClass3(Continuation continuation) {
super(3, continuation);
}
@Override // kotlin.jvm.functions.Function3
public final Object invoke(FlowCollector flowCollector, ConstraintsState[] constraintsStateArr, Continuation continuation) {
AnonymousClass3 anonymousClass3 = new AnonymousClass3(continuation);
anonymousClass3.L$0 = flowCollector;
anonymousClass3.L$1 = constraintsStateArr;
return anonymousClass3.invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
ConstraintsState constraintsState;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
FlowCollector flowCollector = (FlowCollector) this.L$0;
ConstraintsState[] constraintsStateArr = (ConstraintsState[]) ((Object[]) this.L$1);
int length = constraintsStateArr.length;
int i2 = 0;
while (true) {
if (i2 >= length) {
constraintsState = null;
break;
}
constraintsState = constraintsStateArr[i2];
if (!Intrinsics.areEqual(constraintsState, ConstraintsState.ConstraintsMet.INSTANCE)) {
break;
}
i2++;
}
if (constraintsState == null) {
constraintsState = ConstraintsState.ConstraintsMet.INSTANCE;
}
this.label = 1;
if (flowCollector.emit(constraintsState, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
return Unit.INSTANCE;
}
}
});
}
public final boolean areAllConstraintsMet(WorkSpec workSpec) {
String str;
String joinToString$default;
Intrinsics.checkNotNullParameter(workSpec, "workSpec");
List<ConstraintController> list = this.controllers;
ArrayList arrayList = new ArrayList();
for (Object obj : list) {
if (((ConstraintController) obj).isCurrentlyConstrained(workSpec)) {
arrayList.add(obj);
}
}
if (!arrayList.isEmpty()) {
Logger logger = Logger.get();
str = WorkConstraintsTrackerKt.TAG;
StringBuilder sb = new StringBuilder();
sb.append("Work ");
sb.append(workSpec.id);
sb.append(" constrained by ");
joinToString$default = CollectionsKt___CollectionsKt.joinToString$default(arrayList, null, null, null, 0, null, new Function1() { // from class: androidx.work.impl.constraints.WorkConstraintsTracker$areAllConstraintsMet$1
@Override // kotlin.jvm.functions.Function1
public final CharSequence invoke(ConstraintController it) {
Intrinsics.checkNotNullParameter(it, "it");
String simpleName = it.getClass().getSimpleName();
Intrinsics.checkNotNullExpressionValue(simpleName, "it.javaClass.simpleName");
return simpleName;
}
}, 31, null);
sb.append(joinToString$default);
logger.debug(str, sb.toString());
}
return arrayList.isEmpty();
}
}

View File

@@ -0,0 +1,70 @@
package androidx.work.impl.constraints;
import androidx.work.impl.model.WorkSpec;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.flow.Flow;
import kotlinx.coroutines.flow.FlowCollector;
@DebugMetadata(c = "androidx.work.impl.constraints.WorkConstraintsTrackerKt$listen$1", f = "WorkConstraintsTracker.kt", l = {64}, m = "invokeSuspend")
/* loaded from: classes.dex */
public final class WorkConstraintsTrackerKt$listen$1 extends SuspendLambda implements Function2 {
final /* synthetic */ OnConstraintsStateChangedListener $listener;
final /* synthetic */ WorkSpec $spec;
final /* synthetic */ WorkConstraintsTracker $this_listen;
int label;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public WorkConstraintsTrackerKt$listen$1(WorkConstraintsTracker workConstraintsTracker, WorkSpec workSpec, OnConstraintsStateChangedListener onConstraintsStateChangedListener, Continuation continuation) {
super(2, continuation);
this.$this_listen = workConstraintsTracker;
this.$spec = workSpec;
this.$listener = onConstraintsStateChangedListener;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
return new WorkConstraintsTrackerKt$listen$1(this.$this_listen, this.$spec, this.$listener, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) {
return ((WorkConstraintsTrackerKt$listen$1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
Flow track = this.$this_listen.track(this.$spec);
final OnConstraintsStateChangedListener onConstraintsStateChangedListener = this.$listener;
final WorkSpec workSpec = this.$spec;
FlowCollector flowCollector = new FlowCollector() { // from class: androidx.work.impl.constraints.WorkConstraintsTrackerKt$listen$1.1
@Override // kotlinx.coroutines.flow.FlowCollector
public final Object emit(ConstraintsState constraintsState, Continuation continuation) {
OnConstraintsStateChangedListener.this.onConstraintsStateChanged(workSpec, constraintsState);
return Unit.INSTANCE;
}
};
this.label = 1;
if (track.collect(flowCollector, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
return Unit.INSTANCE;
}
}

View File

@@ -0,0 +1,46 @@
package androidx.work.impl.constraints;
import android.content.Context;
import android.net.ConnectivityManager;
import androidx.annotation.RequiresApi;
import androidx.work.Logger;
import androidx.work.impl.model.WorkSpec;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.BuildersKt__Builders_commonKt;
import kotlinx.coroutines.CompletableJob;
import kotlinx.coroutines.CoroutineDispatcher;
import kotlinx.coroutines.CoroutineScopeKt;
import kotlinx.coroutines.Job;
import kotlinx.coroutines.JobKt__JobKt;
/* loaded from: classes.dex */
public final class WorkConstraintsTrackerKt {
private static final long DefaultNetworkRequestTimeoutMs;
private static final String TAG;
public static final Job listen(WorkConstraintsTracker workConstraintsTracker, WorkSpec spec, CoroutineDispatcher dispatcher, OnConstraintsStateChangedListener listener) {
CompletableJob Job$default;
Intrinsics.checkNotNullParameter(workConstraintsTracker, "<this>");
Intrinsics.checkNotNullParameter(spec, "spec");
Intrinsics.checkNotNullParameter(dispatcher, "dispatcher");
Intrinsics.checkNotNullParameter(listener, "listener");
Job$default = JobKt__JobKt.Job$default(null, 1, null);
BuildersKt__Builders_commonKt.launch$default(CoroutineScopeKt.CoroutineScope(dispatcher.plus(Job$default)), null, null, new WorkConstraintsTrackerKt$listen$1(workConstraintsTracker, spec, listener, null), 3, null);
return Job$default;
}
static {
String tagWithPrefix = Logger.tagWithPrefix("WorkConstraintsTracker");
Intrinsics.checkNotNullExpressionValue(tagWithPrefix, "tagWithPrefix(\"WorkConstraintsTracker\")");
TAG = tagWithPrefix;
DefaultNetworkRequestTimeoutMs = 1000L;
}
@RequiresApi(28)
public static final NetworkRequestConstraintController NetworkRequestConstraintController(Context context) {
Intrinsics.checkNotNullParameter(context, "context");
Object systemService = context.getSystemService("connectivity");
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.net.ConnectivityManager");
return new NetworkRequestConstraintController((ConnectivityManager) systemService, 0L, 2, null);
}
}

View File

@@ -0,0 +1,93 @@
package androidx.work.impl.constraints.controllers;
import androidx.work.impl.constraints.ConstraintListener;
import androidx.work.impl.constraints.ConstraintsState;
import androidx.work.impl.constraints.trackers.ConstraintTracker;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function2;
import kotlinx.coroutines.channels.ProduceKt;
import kotlinx.coroutines.channels.ProducerScope;
@DebugMetadata(c = "androidx.work.impl.constraints.controllers.BaseConstraintController$track$1", f = "ContraintControllers.kt", l = {63}, m = "invokeSuspend")
/* loaded from: classes.dex */
public final class BaseConstraintController$track$1 extends SuspendLambda implements Function2 {
private /* synthetic */ Object L$0;
int label;
final /* synthetic */ BaseConstraintController<T> this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public BaseConstraintController$track$1(BaseConstraintController<T> baseConstraintController, Continuation continuation) {
super(2, continuation);
this.this$0 = baseConstraintController;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
BaseConstraintController$track$1 baseConstraintController$track$1 = new BaseConstraintController$track$1(this.this$0, continuation);
baseConstraintController$track$1.L$0 = obj;
return baseConstraintController$track$1;
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(ProducerScope producerScope, Continuation continuation) {
return ((BaseConstraintController$track$1) create(producerScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
/* JADX WARN: Type inference failed for: r1v1, types: [androidx.work.impl.constraints.ConstraintListener, androidx.work.impl.constraints.controllers.BaseConstraintController$track$1$listener$1] */
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
ConstraintTracker constraintTracker;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
final ProducerScope producerScope = (ProducerScope) this.L$0;
final BaseConstraintController<T> baseConstraintController = this.this$0;
final ?? r1 = new ConstraintListener<T>() { // from class: androidx.work.impl.constraints.controllers.BaseConstraintController$track$1$listener$1
@Override // androidx.work.impl.constraints.ConstraintListener
public void onConstraintChanged(T t) {
producerScope.getChannel().mo4126trySendJP2dKIU(baseConstraintController.isConstrained(t) ? new ConstraintsState.ConstraintsNotMet(baseConstraintController.getReason()) : ConstraintsState.ConstraintsMet.INSTANCE);
}
};
constraintTracker = ((BaseConstraintController) this.this$0).tracker;
constraintTracker.addListener(r1);
final BaseConstraintController<T> baseConstraintController2 = this.this$0;
Function0 function0 = new Function0() { // from class: androidx.work.impl.constraints.controllers.BaseConstraintController$track$1.1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
@Override // kotlin.jvm.functions.Function0
public /* bridge */ /* synthetic */ Object invoke() {
m192invoke();
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: collision with other method in class */
public final void m192invoke() {
ConstraintTracker constraintTracker2;
constraintTracker2 = ((BaseConstraintController) baseConstraintController2).tracker;
constraintTracker2.removeListener(r1);
}
};
this.label = 1;
if (ProduceKt.awaitClose(producerScope, function0, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
return Unit.INSTANCE;
}
}

Some files were not shown because too many files have changed in this diff Show More