Rabbit-R1/android (non root)/java/sources/androidx/work/impl/utils/EnqueueRunnable.java
2024-05-21 17:08:36 -04:00

101 lines
4.6 KiB
Java

package androidx.work.impl.utils;
import android.text.TextUtils;
import androidx.work.Logger;
import androidx.work.Operation;
import androidx.work.impl.OperationImpl;
import androidx.work.impl.Schedulers;
import androidx.work.impl.WorkContinuationImpl;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.WorkManagerImpl;
import androidx.work.impl.background.systemalarm.RescheduleReceiver;
import java.util.List;
/* loaded from: classes2.dex */
public class EnqueueRunnable implements Runnable {
private static final String TAG = Logger.tagWithPrefix("EnqueueRunnable");
private final OperationImpl mOperation;
private final WorkContinuationImpl mWorkContinuation;
public Operation getOperation() {
return this.mOperation;
}
public EnqueueRunnable(WorkContinuationImpl workContinuation) {
this(workContinuation, new OperationImpl());
}
public EnqueueRunnable(WorkContinuationImpl workContinuation, OperationImpl result) {
this.mWorkContinuation = workContinuation;
this.mOperation = result;
}
@Override // java.lang.Runnable
public void run() {
try {
if (this.mWorkContinuation.hasCycles()) {
throw new IllegalStateException("WorkContinuation has cycles (" + this.mWorkContinuation + ")");
}
if (addToDatabase()) {
PackageManagerHelper.setComponentEnabled(this.mWorkContinuation.getWorkManagerImpl().getApplicationContext(), RescheduleReceiver.class, true);
scheduleWorkInBackground();
}
this.mOperation.markState(Operation.SUCCESS);
} catch (Throwable th) {
this.mOperation.markState(new Operation.State.FAILURE(th));
}
}
public boolean addToDatabase() {
WorkManagerImpl workManagerImpl = this.mWorkContinuation.getWorkManagerImpl();
WorkDatabase workDatabase = workManagerImpl.getWorkDatabase();
workDatabase.beginTransaction();
try {
EnqueueUtilsKt.checkContentUriTriggerWorkerLimits(workDatabase, workManagerImpl.getConfiguration(), this.mWorkContinuation);
boolean processContinuation = processContinuation(this.mWorkContinuation);
workDatabase.setTransactionSuccessful();
return processContinuation;
} finally {
workDatabase.endTransaction();
}
}
public void scheduleWorkInBackground() {
WorkManagerImpl workManagerImpl = this.mWorkContinuation.getWorkManagerImpl();
Schedulers.schedule(workManagerImpl.getConfiguration(), workManagerImpl.getWorkDatabase(), workManagerImpl.getSchedulers());
}
private static boolean processContinuation(WorkContinuationImpl workContinuation) {
List<WorkContinuationImpl> parents = workContinuation.getParents();
boolean z = false;
if (parents != null) {
for (WorkContinuationImpl workContinuationImpl : parents) {
if (!workContinuationImpl.isEnqueued()) {
z |= processContinuation(workContinuationImpl);
} else {
Logger.get().warning(TAG, "Already enqueued work ids (" + TextUtils.join(", ", workContinuationImpl.getIds()) + ")");
}
}
}
return enqueueContinuation(workContinuation) | z;
}
private static boolean enqueueContinuation(WorkContinuationImpl workContinuation) {
boolean enqueueWorkWithPrerequisites = enqueueWorkWithPrerequisites(workContinuation.getWorkManagerImpl(), workContinuation.getWork(), (String[]) WorkContinuationImpl.prerequisitesFor(workContinuation).toArray(new String[0]), workContinuation.getName(), workContinuation.getExistingWorkPolicy());
workContinuation.markEnqueued();
return enqueueWorkWithPrerequisites;
}
/* JADX WARN: Removed duplicated region for block: B:62:0x0162 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private static boolean enqueueWorkWithPrerequisites(androidx.work.impl.WorkManagerImpl r16, java.util.List<? extends androidx.work.WorkRequest> r17, java.lang.String[] r18, java.lang.String r19, androidx.work.ExistingWorkPolicy r20) {
/*
Method dump skipped, instructions count: 490
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.work.impl.utils.EnqueueRunnable.enqueueWorkWithPrerequisites(androidx.work.impl.WorkManagerImpl, java.util.List, java.lang.String[], java.lang.String, androidx.work.ExistingWorkPolicy):boolean");
}
}