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,20 @@
package androidx.work.impl.utils;
import android.app.Application;
import androidx.annotation.RequiresApi;
import kotlin.jvm.internal.Intrinsics;
@RequiresApi(28)
/* loaded from: classes.dex */
final class Api28Impl {
public static final Api28Impl INSTANCE = new Api28Impl();
private Api28Impl() {
}
public final String getProcessName() {
String processName = Application.getProcessName();
Intrinsics.checkNotNullExpressionValue(processName, "getProcessName()");
return processName;
}
}

View File

@@ -0,0 +1,48 @@
package androidx.work.impl.utils;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.WorkManagerImpl;
import java.util.Iterator;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Lambda;
/* loaded from: classes.dex */
public final class CancelWorkRunnable$forAll$1 extends Lambda implements Function0 {
final /* synthetic */ WorkManagerImpl $workManagerImpl;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public CancelWorkRunnable$forAll$1(WorkManagerImpl workManagerImpl) {
super(0);
this.$workManagerImpl = workManagerImpl;
}
@Override // kotlin.jvm.functions.Function0
public /* bridge */ /* synthetic */ Object invoke() {
m197invoke();
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: collision with other method in class */
public final void m197invoke() {
final WorkDatabase workDatabase = this.$workManagerImpl.getWorkDatabase();
Intrinsics.checkNotNullExpressionValue(workDatabase, "workManagerImpl.workDatabase");
final WorkManagerImpl workManagerImpl = this.$workManagerImpl;
workDatabase.runInTransaction(new Runnable() { // from class: androidx.work.impl.utils.CancelWorkRunnable$forAll$1$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
CancelWorkRunnable$forAll$1.invoke$lambda$0(WorkDatabase.this, workManagerImpl);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public static final void invoke$lambda$0(WorkDatabase workDatabase, WorkManagerImpl workManagerImpl) {
Iterator<String> it = workDatabase.workSpecDao().getAllUnfinishedWork().iterator();
while (it.hasNext()) {
CancelWorkRunnable.cancel(workManagerImpl, it.next());
}
new PreferenceUtils(workDatabase).setLastCancelAllTimeMillis(workManagerImpl.getConfiguration().getClock().currentTimeMillis());
}
}

View File

@@ -0,0 +1,50 @@
package androidx.work.impl.utils;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.WorkManagerImpl;
import java.util.UUID;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Lambda;
/* loaded from: classes.dex */
public final class CancelWorkRunnable$forId$1 extends Lambda implements Function0 {
final /* synthetic */ UUID $id;
final /* synthetic */ WorkManagerImpl $workManagerImpl;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public CancelWorkRunnable$forId$1(WorkManagerImpl workManagerImpl, UUID uuid) {
super(0);
this.$workManagerImpl = workManagerImpl;
this.$id = uuid;
}
@Override // kotlin.jvm.functions.Function0
public /* bridge */ /* synthetic */ Object invoke() {
m199invoke();
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: collision with other method in class */
public final void m199invoke() {
WorkDatabase workDatabase = this.$workManagerImpl.getWorkDatabase();
Intrinsics.checkNotNullExpressionValue(workDatabase, "workManagerImpl.workDatabase");
final WorkManagerImpl workManagerImpl = this.$workManagerImpl;
final UUID uuid = this.$id;
workDatabase.runInTransaction(new Runnable() { // from class: androidx.work.impl.utils.CancelWorkRunnable$forId$1$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
CancelWorkRunnable$forId$1.invoke$lambda$0(WorkManagerImpl.this, uuid);
}
});
CancelWorkRunnable.reschedulePendingWorkers(this.$workManagerImpl);
}
/* JADX INFO: Access modifiers changed from: private */
public static final void invoke$lambda$0(WorkManagerImpl workManagerImpl, UUID uuid) {
String uuid2 = uuid.toString();
Intrinsics.checkNotNullExpressionValue(uuid2, "id.toString()");
CancelWorkRunnable.cancel(workManagerImpl, uuid2);
}
}

View File

@@ -0,0 +1,51 @@
package androidx.work.impl.utils;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.WorkManagerImpl;
import java.util.Iterator;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Lambda;
/* loaded from: classes.dex */
public final class CancelWorkRunnable$forTag$1 extends Lambda implements Function0 {
final /* synthetic */ String $tag;
final /* synthetic */ WorkManagerImpl $workManagerImpl;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public CancelWorkRunnable$forTag$1(WorkManagerImpl workManagerImpl, String str) {
super(0);
this.$workManagerImpl = workManagerImpl;
this.$tag = str;
}
@Override // kotlin.jvm.functions.Function0
public /* bridge */ /* synthetic */ Object invoke() {
m201invoke();
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: collision with other method in class */
public final void m201invoke() {
final WorkDatabase workDatabase = this.$workManagerImpl.getWorkDatabase();
Intrinsics.checkNotNullExpressionValue(workDatabase, "workManagerImpl.workDatabase");
final String str = this.$tag;
final WorkManagerImpl workManagerImpl = this.$workManagerImpl;
workDatabase.runInTransaction(new Runnable() { // from class: androidx.work.impl.utils.CancelWorkRunnable$forTag$1$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
CancelWorkRunnable$forTag$1.invoke$lambda$0(WorkDatabase.this, str, workManagerImpl);
}
});
CancelWorkRunnable.reschedulePendingWorkers(this.$workManagerImpl);
}
/* JADX INFO: Access modifiers changed from: private */
public static final void invoke$lambda$0(WorkDatabase workDatabase, String str, WorkManagerImpl workManagerImpl) {
Iterator<String> it = workDatabase.workSpecDao().getUnfinishedWorkWithTag(str).iterator();
while (it.hasNext()) {
CancelWorkRunnable.cancel(workManagerImpl, it.next());
}
}
}

View File

@@ -0,0 +1,136 @@
package androidx.work.impl.utils;
import androidx.work.Operation;
import androidx.work.OperationKt;
import androidx.work.Tracer;
import androidx.work.WorkInfo;
import androidx.work.impl.Processor;
import androidx.work.impl.Scheduler;
import androidx.work.impl.Schedulers;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.WorkManagerImpl;
import androidx.work.impl.model.DependencyDao;
import androidx.work.impl.model.WorkSpecDao;
import androidx.work.impl.utils.taskexecutor.SerialExecutor;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import kotlin.Unit;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.collections.CollectionsKt__MutableCollectionsKt;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class CancelWorkRunnable {
/* JADX INFO: Access modifiers changed from: private */
public static final void cancel(WorkManagerImpl workManagerImpl, String str) {
WorkDatabase workDatabase = workManagerImpl.getWorkDatabase();
Intrinsics.checkNotNullExpressionValue(workDatabase, "workManagerImpl.workDatabase");
iterativelyCancelWorkAndDependents(workDatabase, str);
Processor processor = workManagerImpl.getProcessor();
Intrinsics.checkNotNullExpressionValue(processor, "workManagerImpl.processor");
processor.stopAndCancelWork(str, 1);
Iterator<Scheduler> it = workManagerImpl.getSchedulers().iterator();
while (it.hasNext()) {
it.next().cancel(str);
}
}
/* JADX INFO: Access modifiers changed from: private */
public static final void reschedulePendingWorkers(WorkManagerImpl workManagerImpl) {
Schedulers.schedule(workManagerImpl.getConfiguration(), workManagerImpl.getWorkDatabase(), workManagerImpl.getSchedulers());
}
private static final void iterativelyCancelWorkAndDependents(WorkDatabase workDatabase, String str) {
List mutableListOf;
Object removeLast;
WorkSpecDao workSpecDao = workDatabase.workSpecDao();
DependencyDao dependencyDao = workDatabase.dependencyDao();
mutableListOf = CollectionsKt__CollectionsKt.mutableListOf(str);
while (!mutableListOf.isEmpty()) {
removeLast = CollectionsKt__MutableCollectionsKt.removeLast(mutableListOf);
String str2 = (String) removeLast;
WorkInfo.State state = workSpecDao.getState(str2);
if (state != WorkInfo.State.SUCCEEDED && state != WorkInfo.State.FAILED) {
workSpecDao.setCancelledState(str2);
}
mutableListOf.addAll(dependencyDao.getDependentWorkIds(str2));
}
}
public static final Operation forId(UUID id, WorkManagerImpl workManagerImpl) {
Intrinsics.checkNotNullParameter(id, "id");
Intrinsics.checkNotNullParameter(workManagerImpl, "workManagerImpl");
Tracer tracer = workManagerImpl.getConfiguration().getTracer();
SerialExecutor serialTaskExecutor = workManagerImpl.getWorkTaskExecutor().getSerialTaskExecutor();
Intrinsics.checkNotNullExpressionValue(serialTaskExecutor, "workManagerImpl.workTask…ecutor.serialTaskExecutor");
return OperationKt.launchOperation(tracer, "CancelWorkById", serialTaskExecutor, new CancelWorkRunnable$forId$1(workManagerImpl, id));
}
public static final Operation forTag(String tag, WorkManagerImpl workManagerImpl) {
Intrinsics.checkNotNullParameter(tag, "tag");
Intrinsics.checkNotNullParameter(workManagerImpl, "workManagerImpl");
Tracer tracer = workManagerImpl.getConfiguration().getTracer();
String str = "CancelWorkByTag_" + tag;
SerialExecutor serialTaskExecutor = workManagerImpl.getWorkTaskExecutor().getSerialTaskExecutor();
Intrinsics.checkNotNullExpressionValue(serialTaskExecutor, "workManagerImpl.workTask…ecutor.serialTaskExecutor");
return OperationKt.launchOperation(tracer, str, serialTaskExecutor, new CancelWorkRunnable$forTag$1(workManagerImpl, tag));
}
public static final Operation forName(final String name, final WorkManagerImpl workManagerImpl) {
Intrinsics.checkNotNullParameter(name, "name");
Intrinsics.checkNotNullParameter(workManagerImpl, "workManagerImpl");
Tracer tracer = workManagerImpl.getConfiguration().getTracer();
String str = "CancelWorkByName_" + name;
SerialExecutor serialTaskExecutor = workManagerImpl.getWorkTaskExecutor().getSerialTaskExecutor();
Intrinsics.checkNotNullExpressionValue(serialTaskExecutor, "workManagerImpl.workTask…ecutor.serialTaskExecutor");
return OperationKt.launchOperation(tracer, str, serialTaskExecutor, new Function0() { // from class: androidx.work.impl.utils.CancelWorkRunnable$forName$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() {
m200invoke();
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: collision with other method in class */
public final void m200invoke() {
CancelWorkRunnable.forNameInline(name, workManagerImpl);
CancelWorkRunnable.reschedulePendingWorkers(workManagerImpl);
}
});
}
public static final void forNameInline(final String name, final WorkManagerImpl workManagerImpl) {
Intrinsics.checkNotNullParameter(name, "name");
Intrinsics.checkNotNullParameter(workManagerImpl, "workManagerImpl");
final WorkDatabase workDatabase = workManagerImpl.getWorkDatabase();
Intrinsics.checkNotNullExpressionValue(workDatabase, "workManagerImpl.workDatabase");
workDatabase.runInTransaction(new Runnable() { // from class: androidx.work.impl.utils.CancelWorkRunnable$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
CancelWorkRunnable.forNameInline$lambda$0(WorkDatabase.this, name, workManagerImpl);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public static final void forNameInline$lambda$0(WorkDatabase workDatabase, String str, WorkManagerImpl workManagerImpl) {
Iterator<String> it = workDatabase.workSpecDao().getUnfinishedWorkWithName(str).iterator();
while (it.hasNext()) {
cancel(workManagerImpl, it.next());
}
}
public static final Operation forAll(WorkManagerImpl workManagerImpl) {
Intrinsics.checkNotNullParameter(workManagerImpl, "workManagerImpl");
Tracer tracer = workManagerImpl.getConfiguration().getTracer();
SerialExecutor serialTaskExecutor = workManagerImpl.getWorkTaskExecutor().getSerialTaskExecutor();
Intrinsics.checkNotNullExpressionValue(serialTaskExecutor, "workManagerImpl.workTask…ecutor.serialTaskExecutor");
return OperationKt.launchOperation(tracer, "CancelAllWork", serialTaskExecutor, new CancelWorkRunnable$forAll$1(workManagerImpl));
}
}

View File

@@ -0,0 +1,14 @@
package androidx.work.impl.utils;
import androidx.annotation.RequiresApi;
import java.time.Duration;
import kotlin.jvm.internal.Intrinsics;
@RequiresApi(26)
/* loaded from: classes.dex */
public final class DurationApi26Impl {
public static final long toMillisCompat(Duration duration) {
Intrinsics.checkNotNullParameter(duration, "<this>");
return duration.toMillis();
}
}

View File

@@ -0,0 +1,85 @@
package androidx.work.impl.utils;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.work.Logger;
import androidx.work.impl.Schedulers;
import androidx.work.impl.WorkContinuationImpl;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.WorkManagerImpl;
import java.util.List;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class EnqueueRunnable {
private static final String TAG = Logger.tagWithPrefix("EnqueueRunnable");
private EnqueueRunnable() {
}
public static void enqueue(@NonNull WorkContinuationImpl workContinuationImpl) {
if (workContinuationImpl.hasCycles()) {
throw new IllegalStateException("WorkContinuation has cycles (" + workContinuationImpl + ")");
}
if (addToDatabase(workContinuationImpl)) {
scheduleWorkInBackground(workContinuationImpl);
}
}
@VisibleForTesting
public static boolean addToDatabase(@NonNull WorkContinuationImpl workContinuationImpl) {
WorkManagerImpl workManagerImpl = workContinuationImpl.getWorkManagerImpl();
WorkDatabase workDatabase = workManagerImpl.getWorkDatabase();
workDatabase.beginTransaction();
try {
EnqueueUtilsKt.checkContentUriTriggerWorkerLimits(workDatabase, workManagerImpl.getConfiguration(), workContinuationImpl);
boolean processContinuation = processContinuation(workContinuationImpl);
workDatabase.setTransactionSuccessful();
return processContinuation;
} finally {
workDatabase.endTransaction();
}
}
@VisibleForTesting
public static void scheduleWorkInBackground(@NonNull WorkContinuationImpl workContinuationImpl) {
WorkManagerImpl workManagerImpl = workContinuationImpl.getWorkManagerImpl();
Schedulers.schedule(workManagerImpl.getConfiguration(), workManagerImpl.getWorkDatabase(), workManagerImpl.getSchedulers());
}
private static boolean processContinuation(@NonNull WorkContinuationImpl workContinuationImpl) {
List<WorkContinuationImpl> parents = workContinuationImpl.getParents();
boolean z = false;
if (parents != null) {
for (WorkContinuationImpl workContinuationImpl2 : parents) {
if (!workContinuationImpl2.isEnqueued()) {
z |= processContinuation(workContinuationImpl2);
} else {
Logger.get().warning(TAG, "Already enqueued work ids (" + TextUtils.join(", ", workContinuationImpl2.getIds()) + ")");
}
}
}
return enqueueContinuation(workContinuationImpl) | z;
}
private static boolean enqueueContinuation(@NonNull WorkContinuationImpl workContinuationImpl) {
boolean enqueueWorkWithPrerequisites = enqueueWorkWithPrerequisites(workContinuationImpl.getWorkManagerImpl(), workContinuationImpl.getWork(), (String[]) WorkContinuationImpl.prerequisitesFor(workContinuationImpl).toArray(new String[0]), workContinuationImpl.getName(), workContinuationImpl.getExistingWorkPolicy());
workContinuationImpl.markEnqueued();
return enqueueWorkWithPrerequisites;
}
/* JADX WARN: Removed duplicated region for block: B:61:0x015f */
/*
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 r18, @androidx.annotation.NonNull java.util.List<? extends androidx.work.WorkRequest> r19, java.lang.String[] r20, java.lang.String r21, androidx.work.ExistingWorkPolicy r22) {
/*
Method dump skipped, instructions count: 487
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");
}
}

View File

@@ -0,0 +1,125 @@
package androidx.work.impl.utils;
import androidx.annotation.VisibleForTesting;
import androidx.work.Configuration;
import androidx.work.Constraints;
import androidx.work.Data;
import androidx.work.WorkRequest;
import androidx.work.impl.Scheduler;
import androidx.work.impl.WorkContinuationImpl;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.workers.ConstraintTrackingWorker;
import androidx.work.impl.workers.ConstraintTrackingWorkerKt;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.collections.CollectionsKt__MutableCollectionsKt;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
@SourceDebugExtension({"SMAP\nEnqueueUtils.kt\nKotlin\n*S Kotlin\n*F\n+ 1 EnqueueUtils.kt\nandroidx/work/impl/utils/EnqueueUtilsKt\n+ 2 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n+ 3 fake.kt\nkotlin/jvm/internal/FakeKt\n+ 4 Data_.kt\nandroidx/work/Data\n*L\n1#1,168:1\n1774#2,4:169\n1747#2,3:177\n1#3:173\n229#4:174\n229#4:175\n229#4:176\n*S KotlinDebug\n*F\n+ 1 EnqueueUtils.kt\nandroidx/work/impl/utils/EnqueueUtilsKt\n*L\n45#1:169,4\n140#1:177,3\n71#1:174\n72#1:175\n73#1:176\n*E\n"})
/* loaded from: classes.dex */
public final class EnqueueUtilsKt {
public static final String ARGUMENT_REMOTE_LISTENABLE_WORKER_NAME = "androidx.work.multiprocess.RemoteListenableDelegatingWorker.ARGUMENT_REMOTE_LISTENABLE_WORKER_NAME";
public static final String ARGUMENT_SERVICE_CLASS_NAME = "androidx.work.impl.workers.RemoteListenableWorker.ARGUMENT_CLASS_NAME";
public static final String ARGUMENT_SERVICE_PACKAGE_NAME = "androidx.work.impl.workers.RemoteListenableWorker.ARGUMENT_PACKAGE_NAME";
public static final String REMOTE_DELEGATING_LISTENABLE_WORKER_CLASS_NAME = "androidx.work.multiprocess.RemoteListenableDelegatingWorker";
public static final void checkContentUriTriggerWorkerLimits(WorkDatabase workDatabase, Configuration configuration, WorkContinuationImpl continuation) {
List mutableListOf;
Object removeLast;
int i;
Intrinsics.checkNotNullParameter(workDatabase, "workDatabase");
Intrinsics.checkNotNullParameter(configuration, "configuration");
Intrinsics.checkNotNullParameter(continuation, "continuation");
mutableListOf = CollectionsKt__CollectionsKt.mutableListOf(continuation);
int i2 = 0;
while (!mutableListOf.isEmpty()) {
removeLast = CollectionsKt__MutableCollectionsKt.removeLast(mutableListOf);
WorkContinuationImpl workContinuationImpl = (WorkContinuationImpl) removeLast;
List<? extends WorkRequest> work = workContinuationImpl.getWork();
Intrinsics.checkNotNullExpressionValue(work, "current.work");
List<? extends WorkRequest> list = work;
if ((list instanceof Collection) && list.isEmpty()) {
i = 0;
} else {
Iterator<T> it = list.iterator();
i = 0;
while (it.hasNext()) {
if (((WorkRequest) it.next()).getWorkSpec().constraints.hasContentUriTriggers() && (i = i + 1) < 0) {
CollectionsKt__CollectionsKt.throwCountOverflow();
}
}
}
i2 += i;
List<WorkContinuationImpl> parents = workContinuationImpl.getParents();
if (parents != null) {
mutableListOf.addAll(parents);
}
}
if (i2 == 0) {
return;
}
int countNonFinishedContentUriTriggerWorkers = workDatabase.workSpecDao().countNonFinishedContentUriTriggerWorkers();
int contentUriTriggerWorkersLimit = configuration.getContentUriTriggerWorkersLimit();
if (countNonFinishedContentUriTriggerWorkers + i2 <= contentUriTriggerWorkersLimit) {
return;
}
throw new IllegalArgumentException("Too many workers with contentUriTriggers are enqueued:\ncontentUriTrigger workers limit: " + contentUriTriggerWorkersLimit + ";\nalready enqueued count: " + countNonFinishedContentUriTriggerWorkers + ";\ncurrent enqueue operation count: " + i2 + ".\nTo address this issue you can: \n1. enqueue less workers or batch some of workers with content uri triggers together;\n2. increase limit via Configuration.Builder.setContentUriTriggerWorkersLimit;\nPlease beware that workers with content uri triggers immediately occupy slots in JobScheduler so no updates to content uris are missed.");
}
@VisibleForTesting
public static final WorkSpec tryDelegateRemoteListenableWorker(WorkSpec workSpec) {
Intrinsics.checkNotNullParameter(workSpec, "workSpec");
boolean hasKeyWithValueOfType = workSpec.input.hasKeyWithValueOfType(ARGUMENT_REMOTE_LISTENABLE_WORKER_NAME, String.class);
boolean hasKeyWithValueOfType2 = workSpec.input.hasKeyWithValueOfType(ARGUMENT_SERVICE_PACKAGE_NAME, String.class);
boolean hasKeyWithValueOfType3 = workSpec.input.hasKeyWithValueOfType(ARGUMENT_SERVICE_CLASS_NAME, String.class);
if (hasKeyWithValueOfType || !hasKeyWithValueOfType2 || !hasKeyWithValueOfType3) {
return workSpec;
}
return WorkSpec.copy$default(workSpec, null, null, REMOTE_DELEGATING_LISTENABLE_WORKER_CLASS_NAME, null, new Data.Builder().putAll(workSpec.input).putString(ARGUMENT_REMOTE_LISTENABLE_WORKER_NAME, workSpec.workerClassName).build(), null, 0L, 0L, 0L, null, 0, null, 0L, 0L, 0L, 0L, false, null, 0, 0, 0L, 0, 0, null, 16777195, null);
}
public static final WorkSpec tryDelegateConstrainedWorkSpec(WorkSpec workSpec) {
Intrinsics.checkNotNullParameter(workSpec, "workSpec");
Constraints constraints = workSpec.constraints;
String str = workSpec.workerClassName;
if (Intrinsics.areEqual(str, ConstraintTrackingWorker.class.getName())) {
return workSpec;
}
if (!constraints.requiresBatteryNotLow() && !constraints.requiresStorageNotLow()) {
return workSpec;
}
Data build = new Data.Builder().putAll(workSpec.input).putString(ConstraintTrackingWorkerKt.ARGUMENT_CLASS_NAME, str).build();
String name = ConstraintTrackingWorker.class.getName();
Intrinsics.checkNotNullExpressionValue(name, "name");
return WorkSpec.copy$default(workSpec, null, null, name, null, build, null, 0L, 0L, 0L, null, 0, null, 0L, 0L, 0L, 0L, false, null, 0, 0, 0L, 0, 0, null, 16777195, null);
}
public static final WorkSpec wrapWorkSpecIfNeeded(List<? extends Scheduler> schedulers, WorkSpec workSpec) {
Intrinsics.checkNotNullParameter(schedulers, "schedulers");
Intrinsics.checkNotNullParameter(workSpec, "workSpec");
return tryDelegateRemoteListenableWorker(workSpec);
}
private static final boolean usesScheduler(List<? extends Scheduler> list, String str) {
try {
Class<?> cls = Class.forName(str);
List<? extends Scheduler> list2 = list;
if ((list2 instanceof Collection) && list2.isEmpty()) {
return false;
}
Iterator<T> it = list2.iterator();
while (it.hasNext()) {
if (cls.isAssignableFrom(((Scheduler) it.next()).getClass())) {
return true;
}
}
return false;
} catch (ClassNotFoundException unused) {
return false;
}
}
}

View File

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

View File

@@ -0,0 +1,10 @@
package androidx.work.impl.utils;
import android.app.ApplicationExitInfo;
/* loaded from: classes.dex */
public abstract /* synthetic */ class ForceStopRunnable$$ExternalSyntheticApiModelOutline1 {
public static /* bridge */ /* synthetic */ ApplicationExitInfo m(Object obj) {
return (ApplicationExitInfo) obj;
}
}

View File

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

View File

@@ -0,0 +1,5 @@
package androidx.work.impl.utils;
/* loaded from: classes.dex */
public abstract /* synthetic */ class ForceStopRunnable$$ExternalSyntheticApiModelOutline3 {
}

View File

@@ -0,0 +1,269 @@
package androidx.work.impl.utils;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.ApplicationExitInfo;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.database.sqlite.SQLiteAccessPermException;
import android.database.sqlite.SQLiteCantOpenDatabaseException;
import android.database.sqlite.SQLiteConstraintException;
import android.database.sqlite.SQLiteDatabaseCorruptException;
import android.database.sqlite.SQLiteDatabaseLockedException;
import android.database.sqlite.SQLiteDiskIOException;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteFullException;
import android.database.sqlite.SQLiteTableLockedException;
import android.os.Build;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.core.app.NotificationCompat;
import androidx.core.os.UserManagerCompat;
import androidx.core.util.Consumer;
import androidx.work.Configuration;
import androidx.work.Logger;
import androidx.work.WorkInfo;
import androidx.work.impl.Schedulers;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.WorkDatabasePathHelper;
import androidx.work.impl.WorkManagerImpl;
import androidx.work.impl.background.systemjob.SystemJobScheduler;
import androidx.work.impl.model.WorkProgressDao;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.model.WorkSpecDao;
import com.google.android.gms.drive.DriveFile;
import java.util.List;
import java.util.concurrent.TimeUnit;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class ForceStopRunnable implements Runnable {
@VisibleForTesting
static final String ACTION_FORCE_STOP_RESCHEDULE = "ACTION_FORCE_STOP_RESCHEDULE";
private static final int ALARM_ID = -1;
private static final long BACKOFF_DURATION_MS = 300;
@VisibleForTesting
static final int MAX_ATTEMPTS = 3;
private static final String TAG = Logger.tagWithPrefix("ForceStopRunnable");
private static final long TEN_YEARS = TimeUnit.DAYS.toMillis(3650);
private final Context mContext;
private final PreferenceUtils mPreferenceUtils;
private int mRetryCount = 0;
private final WorkManagerImpl mWorkManager;
public ForceStopRunnable(@NonNull Context context, @NonNull WorkManagerImpl workManagerImpl) {
this.mContext = context.getApplicationContext();
this.mWorkManager = workManagerImpl;
this.mPreferenceUtils = workManagerImpl.getPreferenceUtils();
}
@Override // java.lang.Runnable
public void run() {
int i;
try {
if (multiProcessChecks()) {
while (true) {
try {
WorkDatabasePathHelper.migrateDatabase(this.mContext);
Logger.get().debug(TAG, "Performing cleanup operations.");
try {
forceStopRunnable();
break;
} catch (SQLiteAccessPermException | SQLiteCantOpenDatabaseException | SQLiteConstraintException | SQLiteDatabaseCorruptException | SQLiteDatabaseLockedException | SQLiteDiskIOException | SQLiteFullException | SQLiteTableLockedException e) {
i = this.mRetryCount + 1;
this.mRetryCount = i;
if (i >= 3) {
String str = UserManagerCompat.isUserUnlocked(this.mContext) ? "The file system on the device is in a bad state. WorkManager cannot access the app's internal data store." : "WorkManager can't be accessed from direct boot, because credential encrypted storage isn't accessible.\nDon't access or initialise WorkManager from directAware components. See https://developer.android.com/training/articles/direct-boot";
Logger logger = Logger.get();
String str2 = TAG;
logger.error(str2, str, e);
IllegalStateException illegalStateException = new IllegalStateException(str, e);
Consumer<Throwable> initializationExceptionHandler = this.mWorkManager.getConfiguration().getInitializationExceptionHandler();
if (initializationExceptionHandler != null) {
Logger.get().debug(str2, "Routing exception to the specified exception handler", illegalStateException);
initializationExceptionHandler.accept(illegalStateException);
} else {
throw illegalStateException;
}
} else {
long j = i * BACKOFF_DURATION_MS;
Logger.get().debug(TAG, "Retrying after " + j, e);
sleep(((long) this.mRetryCount) * BACKOFF_DURATION_MS);
}
}
long j2 = i * BACKOFF_DURATION_MS;
Logger.get().debug(TAG, "Retrying after " + j2, e);
sleep(((long) this.mRetryCount) * BACKOFF_DURATION_MS);
} catch (SQLiteException e2) {
Logger.get().error(TAG, "Unexpected SQLite exception during migrations");
IllegalStateException illegalStateException2 = new IllegalStateException("Unexpected SQLite exception during migrations", e2);
Consumer<Throwable> initializationExceptionHandler2 = this.mWorkManager.getConfiguration().getInitializationExceptionHandler();
if (initializationExceptionHandler2 != null) {
initializationExceptionHandler2.accept(illegalStateException2);
} else {
throw illegalStateException2;
}
}
}
}
} finally {
this.mWorkManager.onForceStopRunnableCompleted();
}
}
@SuppressLint({"ClassVerificationFailure"})
@VisibleForTesting
public boolean isForceStopped() {
List historicalProcessExitReasons;
int reason;
long timestamp;
try {
int i = Build.VERSION.SDK_INT;
PendingIntent pendingIntent = getPendingIntent(this.mContext, i >= 31 ? 570425344 : DriveFile.MODE_WRITE_ONLY);
if (i >= 30) {
if (pendingIntent != null) {
pendingIntent.cancel();
}
historicalProcessExitReasons = ((ActivityManager) this.mContext.getSystemService("activity")).getHistoricalProcessExitReasons(null, 0, 0);
if (historicalProcessExitReasons != null && !historicalProcessExitReasons.isEmpty()) {
long lastForceStopEventMillis = this.mPreferenceUtils.getLastForceStopEventMillis();
for (int i2 = 0; i2 < historicalProcessExitReasons.size(); i2++) {
ApplicationExitInfo m = ForceStopRunnable$$ExternalSyntheticApiModelOutline1.m(historicalProcessExitReasons.get(i2));
reason = m.getReason();
if (reason == 10) {
timestamp = m.getTimestamp();
if (timestamp >= lastForceStopEventMillis) {
return true;
}
}
}
}
} else if (pendingIntent == null) {
setAlarm(this.mContext);
return true;
}
return false;
} catch (IllegalArgumentException e) {
e = e;
Logger.get().warning(TAG, "Ignoring exception", e);
return true;
} catch (SecurityException e2) {
e = e2;
Logger.get().warning(TAG, "Ignoring exception", e);
return true;
}
}
@VisibleForTesting
public void forceStopRunnable() {
boolean cleanUp = cleanUp();
if (shouldRescheduleWorkers()) {
Logger.get().debug(TAG, "Rescheduling Workers.");
this.mWorkManager.rescheduleEligibleWork();
this.mWorkManager.getPreferenceUtils().setNeedsReschedule(false);
} else if (isForceStopped()) {
Logger.get().debug(TAG, "Application was force-stopped, rescheduling.");
this.mWorkManager.rescheduleEligibleWork();
this.mPreferenceUtils.setLastForceStopEventMillis(this.mWorkManager.getConfiguration().getClock().currentTimeMillis());
} else if (cleanUp) {
Logger.get().debug(TAG, "Found unfinished work, scheduling it.");
Schedulers.schedule(this.mWorkManager.getConfiguration(), this.mWorkManager.getWorkDatabase(), this.mWorkManager.getSchedulers());
}
}
@VisibleForTesting
public boolean cleanUp() {
boolean reconcileJobs = SystemJobScheduler.reconcileJobs(this.mContext, this.mWorkManager.getWorkDatabase());
WorkDatabase workDatabase = this.mWorkManager.getWorkDatabase();
WorkSpecDao workSpecDao = workDatabase.workSpecDao();
WorkProgressDao workProgressDao = workDatabase.workProgressDao();
workDatabase.beginTransaction();
try {
List<WorkSpec> runningWork = workSpecDao.getRunningWork();
boolean z = (runningWork == null || runningWork.isEmpty()) ? false : true;
if (z) {
for (WorkSpec workSpec : runningWork) {
workSpecDao.setState(WorkInfo.State.ENQUEUED, workSpec.id);
workSpecDao.setStopReason(workSpec.id, WorkInfo.STOP_REASON_UNKNOWN);
workSpecDao.markWorkSpecScheduled(workSpec.id, -1L);
}
}
workProgressDao.deleteAll();
workDatabase.setTransactionSuccessful();
workDatabase.endTransaction();
return z || reconcileJobs;
} catch (Throwable th) {
workDatabase.endTransaction();
throw th;
}
}
@VisibleForTesting
public boolean shouldRescheduleWorkers() {
return this.mWorkManager.getPreferenceUtils().getNeedsReschedule();
}
@VisibleForTesting
public boolean multiProcessChecks() {
Configuration configuration = this.mWorkManager.getConfiguration();
if (TextUtils.isEmpty(configuration.getDefaultProcessName())) {
Logger.get().debug(TAG, "The default process name was not specified.");
return true;
}
boolean isDefaultProcess = ProcessUtils.isDefaultProcess(this.mContext, configuration);
Logger.get().debug(TAG, "Is default app process = " + isDefaultProcess);
return isDefaultProcess;
}
@VisibleForTesting
public void sleep(long j) {
try {
Thread.sleep(j);
} catch (InterruptedException unused) {
}
}
private static PendingIntent getPendingIntent(Context context, int i) {
return PendingIntent.getBroadcast(context, -1, getIntent(context), i);
}
@VisibleForTesting
public static Intent getIntent(Context context) {
Intent intent = new Intent();
intent.setComponent(new ComponentName(context, (Class<?>) BroadcastReceiver.class));
intent.setAction(ACTION_FORCE_STOP_RESCHEDULE);
return intent;
}
@SuppressLint({"ClassVerificationFailure"})
public static void setAlarm(Context context) {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(NotificationCompat.CATEGORY_ALARM);
PendingIntent pendingIntent = getPendingIntent(context, Build.VERSION.SDK_INT >= 31 ? 167772160 : 134217728);
long currentTimeMillis = System.currentTimeMillis() + TEN_YEARS;
if (alarmManager != null) {
alarmManager.setExact(0, currentTimeMillis, pendingIntent);
}
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static class BroadcastReceiver extends android.content.BroadcastReceiver {
private static final String TAG = Logger.tagWithPrefix("ForceStopRunnable$Rcvr");
@Override // android.content.BroadcastReceiver
public void onReceive(@NonNull Context context, @Nullable Intent intent) {
if (intent == null || !ForceStopRunnable.ACTION_FORCE_STOP_RESCHEDULE.equals(intent.getAction())) {
return;
}
Logger.get().verbose(TAG, "Rescheduling alarm that keeps track of force-stops.");
ForceStopRunnable.setAlarm(context);
}
}
}

View File

@@ -0,0 +1,60 @@
package androidx.work.impl.utils;
import androidx.work.impl.WorkDatabase;
import java.util.concurrent.Callable;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class IdGenerator {
private final WorkDatabase workDatabase;
public IdGenerator(WorkDatabase workDatabase) {
Intrinsics.checkNotNullParameter(workDatabase, "workDatabase");
this.workDatabase = workDatabase;
}
public final int nextJobSchedulerIdWithRange(final int i, final int i2) {
Object runInTransaction = this.workDatabase.runInTransaction((Callable<Object>) new Callable() { // from class: androidx.work.impl.utils.IdGenerator$$ExternalSyntheticLambda1
@Override // java.util.concurrent.Callable
public final Object call() {
Integer nextJobSchedulerIdWithRange$lambda$0;
nextJobSchedulerIdWithRange$lambda$0 = IdGenerator.nextJobSchedulerIdWithRange$lambda$0(IdGenerator.this, i, i2);
return nextJobSchedulerIdWithRange$lambda$0;
}
});
Intrinsics.checkNotNullExpressionValue(runInTransaction, "workDatabase.runInTransa…d\n }\n )");
return ((Number) runInTransaction).intValue();
}
/* JADX INFO: Access modifiers changed from: private */
public static final Integer nextJobSchedulerIdWithRange$lambda$0(IdGenerator idGenerator, int i, int i2) {
int nextId;
nextId = IdGeneratorKt.nextId(idGenerator.workDatabase, IdGeneratorKt.NEXT_JOB_SCHEDULER_ID_KEY);
if (i > nextId || nextId > i2) {
IdGeneratorKt.updatePreference(idGenerator.workDatabase, IdGeneratorKt.NEXT_JOB_SCHEDULER_ID_KEY, i + 1);
} else {
i = nextId;
}
return Integer.valueOf(i);
}
public final int nextAlarmManagerId() {
Object runInTransaction = this.workDatabase.runInTransaction((Callable<Object>) new Callable() { // from class: androidx.work.impl.utils.IdGenerator$$ExternalSyntheticLambda0
@Override // java.util.concurrent.Callable
public final Object call() {
Integer nextAlarmManagerId$lambda$1;
nextAlarmManagerId$lambda$1 = IdGenerator.nextAlarmManagerId$lambda$1(IdGenerator.this);
return nextAlarmManagerId$lambda$1;
}
});
Intrinsics.checkNotNullExpressionValue(runInTransaction, "workDatabase.runInTransa…NAGER_ID_KEY) }\n )");
return ((Number) runInTransaction).intValue();
}
/* JADX INFO: Access modifiers changed from: private */
public static final Integer nextAlarmManagerId$lambda$1(IdGenerator idGenerator) {
int nextId;
nextId = IdGeneratorKt.nextId(idGenerator.workDatabase, IdGeneratorKt.NEXT_ALARM_MANAGER_ID_KEY);
return Integer.valueOf(nextId);
}
}

View File

@@ -0,0 +1,48 @@
package androidx.work.impl.utils;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.model.Preference;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class IdGeneratorKt {
public static final int INITIAL_ID = 0;
public static final String NEXT_ALARM_MANAGER_ID_KEY = "next_alarm_manager_id";
public static final String NEXT_JOB_SCHEDULER_ID_KEY = "next_job_scheduler_id";
public static final String PREFERENCE_FILE_KEY = "androidx.work.util.id";
/* JADX INFO: Access modifiers changed from: private */
public static final int nextId(WorkDatabase workDatabase, String str) {
Long longValue = workDatabase.preferenceDao().getLongValue(str);
int longValue2 = longValue != null ? (int) longValue.longValue() : 0;
updatePreference(workDatabase, str, longValue2 != Integer.MAX_VALUE ? longValue2 + 1 : 0);
return longValue2;
}
/* JADX INFO: Access modifiers changed from: private */
public static final void updatePreference(WorkDatabase workDatabase, String str, int i) {
workDatabase.preferenceDao().insertPreference(new Preference(str, Long.valueOf(i)));
}
public static final void migrateLegacyIdGenerator(Context context, SupportSQLiteDatabase sqLiteDatabase) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(sqLiteDatabase, "sqLiteDatabase");
SharedPreferences sharedPreferences = context.getSharedPreferences(PREFERENCE_FILE_KEY, 0);
if (sharedPreferences.contains(NEXT_JOB_SCHEDULER_ID_KEY) || sharedPreferences.contains(NEXT_JOB_SCHEDULER_ID_KEY)) {
int i = sharedPreferences.getInt(NEXT_JOB_SCHEDULER_ID_KEY, 0);
int i2 = sharedPreferences.getInt(NEXT_ALARM_MANAGER_ID_KEY, 0);
sqLiteDatabase.beginTransaction();
try {
sqLiteDatabase.execSQL(PreferenceUtils.INSERT_PREFERENCE, new Object[]{NEXT_JOB_SCHEDULER_ID_KEY, Integer.valueOf(i)});
sqLiteDatabase.execSQL(PreferenceUtils.INSERT_PREFERENCE, new Object[]{NEXT_ALARM_MANAGER_ID_KEY, Integer.valueOf(i2)});
sharedPreferences.edit().clear().apply();
sqLiteDatabase.setTransactionSuccessful();
} finally {
sqLiteDatabase.endTransaction();
}
}
}
}

View File

@@ -0,0 +1,72 @@
package androidx.work.impl.utils;
import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.arch.core.util.Function;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MediatorLiveData;
import androidx.lifecycle.Observer;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class LiveDataUtils {
@NonNull
@SuppressLint({"LambdaLast"})
public static <In, Out> LiveData<Out> dedupedMappedLiveDataFor(@NonNull LiveData<In> liveData, @NonNull Function<In, Out> function, @NonNull TaskExecutor taskExecutor) {
Object obj = new Object();
MediatorLiveData mediatorLiveData = new MediatorLiveData();
mediatorLiveData.addSource(liveData, new AnonymousClass1(taskExecutor, obj, function, mediatorLiveData));
return mediatorLiveData;
}
/* JADX INFO: Add missing generic type declarations: [In] */
/* renamed from: androidx.work.impl.utils.LiveDataUtils$1, reason: invalid class name */
public class AnonymousClass1<In> implements Observer<In> {
Out mCurrentOutput = null;
final /* synthetic */ Object val$lock;
final /* synthetic */ Function val$mappingMethod;
final /* synthetic */ MediatorLiveData val$outputLiveData;
final /* synthetic */ TaskExecutor val$workTaskExecutor;
public AnonymousClass1(TaskExecutor taskExecutor, Object obj, Function function, MediatorLiveData mediatorLiveData) {
this.val$workTaskExecutor = taskExecutor;
this.val$lock = obj;
this.val$mappingMethod = function;
this.val$outputLiveData = mediatorLiveData;
}
@Override // androidx.lifecycle.Observer
public void onChanged(@Nullable final In in) {
this.val$workTaskExecutor.executeOnTaskThread(new Runnable() { // from class: androidx.work.impl.utils.LiveDataUtils.1.1
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r1v3, types: [Out, java.lang.Object] */
@Override // java.lang.Runnable
public void run() {
synchronized (AnonymousClass1.this.val$lock) {
try {
?? apply = AnonymousClass1.this.val$mappingMethod.apply(in);
AnonymousClass1 anonymousClass1 = AnonymousClass1.this;
Out out = anonymousClass1.mCurrentOutput;
if (out == 0 && apply != 0) {
anonymousClass1.mCurrentOutput = apply;
anonymousClass1.val$outputLiveData.postValue(apply);
} else if (out != 0 && !out.equals(apply)) {
AnonymousClass1 anonymousClass12 = AnonymousClass1.this;
anonymousClass12.mCurrentOutput = apply;
anonymousClass12.val$outputLiveData.postValue(apply);
}
} catch (Throwable th) {
throw th;
}
}
}
});
}
}
private LiveDataUtils() {
}
}

View File

@@ -0,0 +1,27 @@
package androidx.work.impl.utils;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import androidx.annotation.RequiresApi;
import kotlin.jvm.internal.Intrinsics;
@RequiresApi(21)
/* loaded from: classes.dex */
public final class NetworkApi21 {
public static final void unregisterNetworkCallbackCompat(ConnectivityManager connectivityManager, ConnectivityManager.NetworkCallback networkCallback) {
Intrinsics.checkNotNullParameter(connectivityManager, "<this>");
Intrinsics.checkNotNullParameter(networkCallback, "networkCallback");
connectivityManager.unregisterNetworkCallback(networkCallback);
}
public static final NetworkCapabilities getNetworkCapabilitiesCompat(ConnectivityManager connectivityManager, Network network) {
Intrinsics.checkNotNullParameter(connectivityManager, "<this>");
return connectivityManager.getNetworkCapabilities(network);
}
public static final boolean hasCapabilityCompat(NetworkCapabilities networkCapabilities, int i) {
Intrinsics.checkNotNullParameter(networkCapabilities, "<this>");
return networkCapabilities.hasCapability(i);
}
}

View File

@@ -0,0 +1,15 @@
package androidx.work.impl.utils;
import android.net.ConnectivityManager;
import android.net.Network;
import androidx.annotation.RequiresApi;
import kotlin.jvm.internal.Intrinsics;
@RequiresApi(23)
/* loaded from: classes.dex */
public final class NetworkApi23 {
public static final Network getActiveNetworkCompat(ConnectivityManager connectivityManager) {
Intrinsics.checkNotNullParameter(connectivityManager, "<this>");
return connectivityManager.getActiveNetwork();
}
}

View File

@@ -0,0 +1,15 @@
package androidx.work.impl.utils;
import android.net.ConnectivityManager;
import androidx.annotation.RequiresApi;
import kotlin.jvm.internal.Intrinsics;
@RequiresApi(24)
/* loaded from: classes.dex */
public final class NetworkApi24 {
public static final void registerDefaultNetworkCallbackCompat(ConnectivityManager connectivityManager, ConnectivityManager.NetworkCallback networkCallback) {
Intrinsics.checkNotNullParameter(connectivityManager, "<this>");
Intrinsics.checkNotNullParameter(networkCallback, "networkCallback");
connectivityManager.registerDefaultNetworkCallback(networkCallback);
}
}

View File

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

View File

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

View File

@@ -0,0 +1,56 @@
package androidx.work.impl.utils;
import android.net.NetworkRequest;
import androidx.annotation.RequiresApi;
import androidx.work.Logger;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
@RequiresApi(28)
@SourceDebugExtension({"SMAP\nNetworkRequestCompat.kt\nKotlin\n*S Kotlin\n*F\n+ 1 NetworkRequestCompat.kt\nandroidx/work/impl/utils/NetworkRequest28\n+ 2 _Arrays.kt\nkotlin/collections/ArraysKt___ArraysKt\n*L\n1#1,145:1\n13600#2,2:146\n13600#2,2:148\n*S KotlinDebug\n*F\n+ 1 NetworkRequestCompat.kt\nandroidx/work/impl/utils/NetworkRequest28\n*L\n109#1:146,2\n122#1:148,2\n*E\n"})
/* loaded from: classes.dex */
public final class NetworkRequest28 {
public static final NetworkRequest28 INSTANCE = new NetworkRequest28();
private NetworkRequest28() {
}
public final boolean hasCapability$work_runtime_release(NetworkRequest request, int i) {
boolean hasCapability;
Intrinsics.checkNotNullParameter(request, "request");
hasCapability = request.hasCapability(i);
return hasCapability;
}
public final boolean hasTransport$work_runtime_release(NetworkRequest request, int i) {
boolean hasTransport;
Intrinsics.checkNotNullParameter(request, "request");
hasTransport = request.hasTransport(i);
return hasTransport;
}
public static final NetworkRequest createNetworkRequest(int[] capabilities, int[] transports) {
Intrinsics.checkNotNullParameter(capabilities, "capabilities");
Intrinsics.checkNotNullParameter(transports, "transports");
NetworkRequest.Builder builder = new NetworkRequest.Builder();
for (int i : capabilities) {
try {
builder.addCapability(i);
} catch (IllegalArgumentException e) {
Logger.get().warning(NetworkRequestCompat.Companion.getTAG(), "Ignoring adding capability '" + i + '\'', e);
}
}
for (int i2 : transports) {
builder.addTransportType(i2);
}
NetworkRequest build = builder.build();
Intrinsics.checkNotNullExpressionValue(build, "networkRequest.build()");
return build;
}
public final NetworkRequestCompat createNetworkRequestCompat$work_runtime_release(int[] capabilities, int[] transports) {
Intrinsics.checkNotNullParameter(capabilities, "capabilities");
Intrinsics.checkNotNullParameter(transports, "transports");
return new NetworkRequestCompat(createNetworkRequest(capabilities, transports));
}
}

View File

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

View File

@@ -0,0 +1,22 @@
package androidx.work.impl.utils;
import android.net.NetworkRequest;
import android.net.NetworkSpecifier;
import androidx.annotation.RequiresApi;
import kotlin.jvm.internal.Intrinsics;
@RequiresApi(30)
/* loaded from: classes.dex */
public final class NetworkRequest30 {
public static final NetworkRequest30 INSTANCE = new NetworkRequest30();
private NetworkRequest30() {
}
public final NetworkSpecifier getNetworkSpecifier(NetworkRequest request) {
NetworkSpecifier networkSpecifier;
Intrinsics.checkNotNullParameter(request, "request");
networkSpecifier = request.getNetworkSpecifier();
return networkSpecifier;
}
}

View File

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

View File

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

View File

@@ -0,0 +1,30 @@
package androidx.work.impl.utils;
import android.net.NetworkRequest;
import androidx.annotation.RequiresApi;
import kotlin.jvm.internal.Intrinsics;
@RequiresApi(31)
/* loaded from: classes.dex */
final class NetworkRequest31 {
public static final NetworkRequest31 INSTANCE = new NetworkRequest31();
private NetworkRequest31() {
}
public final int[] capabilities(NetworkRequest request) {
int[] capabilities;
Intrinsics.checkNotNullParameter(request, "request");
capabilities = request.getCapabilities();
Intrinsics.checkNotNullExpressionValue(capabilities, "request.capabilities");
return capabilities;
}
public final int[] transportTypes(NetworkRequest request) {
int[] transportTypes;
Intrinsics.checkNotNullParameter(request, "request");
transportTypes = request.getTransportTypes();
Intrinsics.checkNotNullExpressionValue(transportTypes, "request.transportTypes");
return transportTypes;
}
}

View File

@@ -0,0 +1,100 @@
package androidx.work.impl.utils;
import android.net.NetworkRequest;
import androidx.annotation.RequiresApi;
import androidx.work.Logger;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class NetworkRequestCompat {
public static final Companion Companion = new Companion(null);
private static final String TAG;
private final Object wrapped;
/* 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 NetworkRequestCompat() {
/*
r2 = this;
r0 = 0
r1 = 1
r2.<init>(r0, r1, r0)
return
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.work.impl.utils.NetworkRequestCompat.<init>():void");
}
public static /* synthetic */ NetworkRequestCompat copy$default(NetworkRequestCompat networkRequestCompat, Object obj, int i, Object obj2) {
if ((i & 1) != 0) {
obj = networkRequestCompat.wrapped;
}
return networkRequestCompat.copy(obj);
}
public final Object component1() {
return this.wrapped;
}
public final NetworkRequestCompat copy(Object obj) {
return new NetworkRequestCompat(obj);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
return (obj instanceof NetworkRequestCompat) && Intrinsics.areEqual(this.wrapped, ((NetworkRequestCompat) obj).wrapped);
}
public final Object getWrapped() {
return this.wrapped;
}
public int hashCode() {
Object obj = this.wrapped;
if (obj == null) {
return 0;
}
return obj.hashCode();
}
public String toString() {
return "NetworkRequestCompat(wrapped=" + this.wrapped + ')';
}
public NetworkRequestCompat(Object obj) {
this.wrapped = obj;
}
public /* synthetic */ NetworkRequestCompat(Object obj, int i, DefaultConstructorMarker defaultConstructorMarker) {
this((i & 1) != 0 ? null : obj);
}
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final String getTAG() {
return NetworkRequestCompat.TAG;
}
}
static {
String tagWithPrefix = Logger.tagWithPrefix("NetworkRequestCompat");
Intrinsics.checkNotNullExpressionValue(tagWithPrefix, "tagWithPrefix(\"NetworkRequestCompat\")");
TAG = tagWithPrefix;
}
@RequiresApi(21)
public final NetworkRequest getNetworkRequest() {
return (NetworkRequest) this.wrapped;
}
}

View File

@@ -0,0 +1,51 @@
package androidx.work.impl.utils;
import android.net.NetworkRequest;
import android.os.Build;
import androidx.annotation.RequiresApi;
import java.util.ArrayList;
import kotlin.collections.CollectionsKt___CollectionsKt;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
@SourceDebugExtension({"SMAP\nNetworkRequestCompat.kt\nKotlin\n*S Kotlin\n*F\n+ 1 NetworkRequestCompat.kt\nandroidx/work/impl/utils/NetworkRequestCompatKt\n+ 2 _Arrays.kt\nkotlin/collections/ArraysKt___ArraysKt\n*L\n1#1,145:1\n3819#2:146\n4337#2,2:147\n3819#2:149\n4337#2,2:150\n*S KotlinDebug\n*F\n+ 1 NetworkRequestCompat.kt\nandroidx/work/impl/utils/NetworkRequestCompatKt\n*L\n53#1:146\n53#1:147,2\n94#1:149\n94#1:150,2\n*E\n"})
/* loaded from: classes.dex */
public final class NetworkRequestCompatKt {
@RequiresApi(28)
public static final int[] getTransportTypesCompat(NetworkRequest networkRequest) {
int[] intArray;
Intrinsics.checkNotNullParameter(networkRequest, "<this>");
if (Build.VERSION.SDK_INT >= 31) {
return NetworkRequest31.INSTANCE.transportTypes(networkRequest);
}
int[] iArr = {2, 0, 3, 6, 9, 8, 4, 1, 5};
ArrayList arrayList = new ArrayList();
for (int i = 0; i < 9; i++) {
int i2 = iArr[i];
if (NetworkRequest28.INSTANCE.hasTransport$work_runtime_release(networkRequest, i2)) {
arrayList.add(Integer.valueOf(i2));
}
}
intArray = CollectionsKt___CollectionsKt.toIntArray(arrayList);
return intArray;
}
@RequiresApi(28)
public static final int[] getCapabilitiesCompat(NetworkRequest networkRequest) {
int[] intArray;
Intrinsics.checkNotNullParameter(networkRequest, "<this>");
if (Build.VERSION.SDK_INT >= 31) {
return NetworkRequest31.INSTANCE.capabilities(networkRequest);
}
int[] iArr = {17, 5, 2, 10, 29, 19, 3, 32, 7, 4, 12, 23, 0, 33, 20, 11, 13, 18, 21, 15, 35, 34, 8, 1, 25, 14, 16, 6, 9};
ArrayList arrayList = new ArrayList();
for (int i = 0; i < 29; i++) {
int i2 = iArr[i];
if (NetworkRequest28.INSTANCE.hasCapability$work_runtime_release(networkRequest, i2)) {
arrayList.add(Integer.valueOf(i2));
}
}
intArray = CollectionsKt___CollectionsKt.toIntArray(arrayList);
return intArray;
}
}

View File

@@ -0,0 +1,55 @@
package androidx.work.impl.utils;
import android.content.ComponentName;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.work.Logger;
/* loaded from: classes.dex */
public class PackageManagerHelper {
private static final String TAG = Logger.tagWithPrefix("PackageManagerHelper");
private static boolean isComponentEnabled(int i, boolean z) {
return i == 0 ? z : i == 1;
}
private PackageManagerHelper() {
}
public static void setComponentEnabled(@NonNull Context context, @NonNull Class<?> cls, boolean z) {
try {
if (z == isComponentEnabled(getComponentEnabledSetting(context, cls.getName()), false)) {
Logger.get().debug(TAG, "Skipping component enablement for " + cls.getName());
return;
}
context.getPackageManager().setComponentEnabledSetting(new ComponentName(context, cls.getName()), z ? 1 : 2, 1);
Logger logger = Logger.get();
String str = TAG;
StringBuilder sb = new StringBuilder();
sb.append(cls.getName());
sb.append(" ");
sb.append(z ? "enabled" : "disabled");
logger.debug(str, sb.toString());
} catch (Exception e) {
Logger logger2 = Logger.get();
String str2 = TAG;
StringBuilder sb2 = new StringBuilder();
sb2.append(cls.getName());
sb2.append("could not be ");
sb2.append(z ? "enabled" : "disabled");
logger2.debug(str2, sb2.toString(), e);
}
}
public static boolean isComponentExplicitlyEnabled(@NonNull Context context, @NonNull Class<?> cls) {
return isComponentEnabled(getComponentEnabledSetting(context, cls.getName()), false);
}
public static boolean isComponentExplicitlyEnabled(@NonNull Context context, @NonNull String str) {
return getComponentEnabledSetting(context, str) == 1;
}
private static int getComponentEnabledSetting(@NonNull Context context, @NonNull String str) {
return context.getPackageManager().getComponentEnabledSetting(new ComponentName(context, str));
}
}

View File

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

View File

@@ -0,0 +1,80 @@
package androidx.work.impl.utils;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import android.os.Process;
import androidx.work.Configuration;
import androidx.work.Logger;
import androidx.work.WorkManager;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
@SourceDebugExtension({"SMAP\nProcessUtils.kt\nKotlin\n*S Kotlin\n*F\n+ 1 ProcessUtils.kt\nandroidx/work/impl/utils/ProcessUtils\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,73:1\n1#2:74\n*E\n"})
/* loaded from: classes.dex */
public final class ProcessUtils {
private static final String TAG;
static {
String tagWithPrefix = Logger.tagWithPrefix("ProcessUtils");
Intrinsics.checkNotNullExpressionValue(tagWithPrefix, "tagWithPrefix(\"ProcessUtils\")");
TAG = tagWithPrefix;
}
public static final boolean isDefaultProcess(Context context, Configuration configuration) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(configuration, "configuration");
String processName = getProcessName(context);
String defaultProcessName = configuration.getDefaultProcessName();
if (defaultProcessName != null && defaultProcessName.length() != 0) {
return Intrinsics.areEqual(processName, configuration.getDefaultProcessName());
}
return Intrinsics.areEqual(processName, context.getApplicationInfo().processName);
}
@SuppressLint({"PrivateApi", "DiscouragedPrivateApi"})
private static final String getProcessName(Context context) {
Object obj;
if (Build.VERSION.SDK_INT >= 28) {
return Api28Impl.INSTANCE.getProcessName();
}
try {
Method declaredMethod = Class.forName("android.app.ActivityThread", false, WorkManager.class.getClassLoader()).getDeclaredMethod("currentProcessName", new Class[0]);
declaredMethod.setAccessible(true);
Object invoke = declaredMethod.invoke(null, new Object[0]);
Intrinsics.checkNotNull(invoke);
if (invoke instanceof String) {
return (String) invoke;
}
} catch (Throwable th) {
Logger.get().debug(TAG, "Unable to check ActivityThread for processName", th);
}
int myPid = Process.myPid();
Object systemService = context.getSystemService("activity");
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.ActivityManager");
List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = ((ActivityManager) systemService).getRunningAppProcesses();
if (runningAppProcesses == null) {
return null;
}
Iterator<T> it = runningAppProcesses.iterator();
while (true) {
if (!it.hasNext()) {
obj = null;
break;
}
obj = it.next();
if (((ActivityManager.RunningAppProcessInfo) obj).pid == myPid) {
break;
}
}
ActivityManager.RunningAppProcessInfo runningAppProcessInfo = (ActivityManager.RunningAppProcessInfo) obj;
if (runningAppProcessInfo != null) {
return runningAppProcessInfo.processName;
}
return null;
}
}

View File

@@ -0,0 +1,40 @@
package androidx.work.impl.utils;
import androidx.work.Configuration;
import androidx.work.Operation;
import androidx.work.OperationKt;
import androidx.work.Tracer;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.utils.taskexecutor.SerialExecutor;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class PruneWorkRunnableKt {
public static final Operation pruneWork(final WorkDatabase workDatabase, Configuration configuration, TaskExecutor executor) {
Intrinsics.checkNotNullParameter(workDatabase, "<this>");
Intrinsics.checkNotNullParameter(configuration, "configuration");
Intrinsics.checkNotNullParameter(executor, "executor");
Tracer tracer = configuration.getTracer();
SerialExecutor serialTaskExecutor = executor.getSerialTaskExecutor();
Intrinsics.checkNotNullExpressionValue(serialTaskExecutor, "executor.serialTaskExecutor");
return OperationKt.launchOperation(tracer, "PruneWork", serialTaskExecutor, new Function0() { // from class: androidx.work.impl.utils.PruneWorkRunnableKt$pruneWork$1
{
super(0);
}
@Override // kotlin.jvm.functions.Function0
public /* bridge */ /* synthetic */ Object invoke() {
m202invoke();
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: collision with other method in class */
public final void m202invoke() {
WorkDatabase.this.workSpecDao().pruneFinishedWorkWithZeroDependentsIgnoringKeepForAtLeast();
}
});
}
}

View File

@@ -0,0 +1,84 @@
package androidx.work.impl.utils;
import androidx.sqlite.db.SimpleSQLiteQuery;
import androidx.sqlite.db.SupportSQLiteQuery;
import androidx.work.WorkInfo;
import androidx.work.WorkQuery;
import androidx.work.impl.model.WorkTypeConverters;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import kotlin.collections.CollectionsKt__IterablesKt;
import kotlin.collections.CollectionsKt___CollectionsKt;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
@SourceDebugExtension({"SMAP\nRawQueries.kt\nKotlin\n*S Kotlin\n*F\n+ 1 RawQueries.kt\nandroidx/work/impl/utils/RawQueries\n+ 2 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n+ 3 ArraysJVM.kt\nkotlin/collections/ArraysKt__ArraysJVMKt\n+ 4 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,73:1\n1549#2:74\n1620#2,3:75\n1549#2:78\n1620#2,3:79\n37#3,2:82\n1#4:84\n*S KotlinDebug\n*F\n+ 1 RawQueries.kt\nandroidx/work/impl/utils/RawQueries\n*L\n35#1:74\n35#1:75,3\n43#1:78\n43#1:79,3\n64#1:82,2\n*E\n"})
/* loaded from: classes.dex */
public final class RawQueries {
public static final SupportSQLiteQuery toRawQuery(WorkQuery workQuery) {
Intrinsics.checkNotNullParameter(workQuery, "<this>");
ArrayList arrayList = new ArrayList();
StringBuilder sb = new StringBuilder("SELECT * FROM workspec");
String str = " AND";
String str2 = " WHERE";
if (!workQuery.getStates().isEmpty()) {
List<WorkInfo.State> states = workQuery.getStates();
ArrayList arrayList2 = new ArrayList(CollectionsKt__IterablesKt.collectionSizeOrDefault(states, 10));
Iterator<T> it = states.iterator();
while (it.hasNext()) {
arrayList2.add(Integer.valueOf(WorkTypeConverters.stateToInt((WorkInfo.State) it.next())));
}
sb.append(" WHERE state IN (");
bindings(sb, arrayList2.size());
sb.append(")");
arrayList.addAll(arrayList2);
str2 = " AND";
}
if (!workQuery.getIds().isEmpty()) {
List<UUID> ids = workQuery.getIds();
ArrayList arrayList3 = new ArrayList(CollectionsKt__IterablesKt.collectionSizeOrDefault(ids, 10));
Iterator<T> it2 = ids.iterator();
while (it2.hasNext()) {
arrayList3.add(((UUID) it2.next()).toString());
}
sb.append(str2 + " id IN (");
bindings(sb, workQuery.getIds().size());
sb.append(")");
arrayList.addAll(arrayList3);
str2 = " AND";
}
if (!workQuery.getTags().isEmpty()) {
sb.append(str2 + " id IN (SELECT work_spec_id FROM worktag WHERE tag IN (");
bindings(sb, workQuery.getTags().size());
sb.append("))");
arrayList.addAll(workQuery.getTags());
} else {
str = str2;
}
if (!workQuery.getUniqueWorkNames().isEmpty()) {
sb.append(str + " id IN (SELECT work_spec_id FROM workname WHERE name IN (");
bindings(sb, workQuery.getUniqueWorkNames().size());
sb.append("))");
arrayList.addAll(workQuery.getUniqueWorkNames());
}
sb.append(";");
String sb2 = sb.toString();
Intrinsics.checkNotNullExpressionValue(sb2, "builder.toString()");
return new SimpleSQLiteQuery(sb2, arrayList.toArray(new Object[0]));
}
private static final void bindings(StringBuilder sb, int i) {
String joinToString$default;
if (i <= 0) {
return;
}
ArrayList arrayList = new ArrayList(i);
for (int i2 = 0; i2 < i; i2++) {
arrayList.add("?");
}
joinToString$default = CollectionsKt___CollectionsKt.joinToString$default(arrayList, ",", null, null, 0, null, null, 62, null);
sb.append(joinToString$default);
}
}

View File

@@ -0,0 +1,85 @@
package androidx.work.impl.utils;
import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.work.impl.utils.taskexecutor.SerialExecutor;
import java.util.ArrayDeque;
import java.util.concurrent.Executor;
/* loaded from: classes.dex */
public class SerialExecutorImpl implements SerialExecutor {
@GuardedBy("mLock")
private Runnable mActive;
private final Executor mExecutor;
private final ArrayDeque<Task> mTasks = new ArrayDeque<>();
final Object mLock = new Object();
@NonNull
@VisibleForTesting
public Executor getDelegatedExecutor() {
return this.mExecutor;
}
public SerialExecutorImpl(@NonNull Executor executor) {
this.mExecutor = executor;
}
@Override // java.util.concurrent.Executor
public void execute(@NonNull Runnable runnable) {
synchronized (this.mLock) {
try {
this.mTasks.add(new Task(this, runnable));
if (this.mActive == null) {
scheduleNext();
}
} catch (Throwable th) {
throw th;
}
}
}
@GuardedBy("mLock")
public void scheduleNext() {
Task poll = this.mTasks.poll();
this.mActive = poll;
if (poll != null) {
this.mExecutor.execute(poll);
}
}
@Override // androidx.work.impl.utils.taskexecutor.SerialExecutor
public boolean hasPendingTasks() {
boolean z;
synchronized (this.mLock) {
z = !this.mTasks.isEmpty();
}
return z;
}
public static class Task implements Runnable {
final Runnable mRunnable;
final SerialExecutorImpl mSerialExecutor;
public Task(@NonNull SerialExecutorImpl serialExecutorImpl, @NonNull Runnable runnable) {
this.mSerialExecutor = serialExecutorImpl;
this.mRunnable = runnable;
}
@Override // java.lang.Runnable
public void run() {
try {
this.mRunnable.run();
synchronized (this.mSerialExecutor.mLock) {
this.mSerialExecutor.scheduleNext();
}
} catch (Throwable th) {
synchronized (this.mSerialExecutor.mLock) {
this.mSerialExecutor.scheduleNext();
throw th;
}
}
}
}
}

View File

@@ -0,0 +1,140 @@
package androidx.work.impl.utils;
import androidx.work.ListenableFutureKt;
import androidx.work.WorkInfo;
import androidx.work.WorkQuery;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.model.WorkSpecDao;
import androidx.work.impl.utils.taskexecutor.SerialExecutor;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
import java.util.UUID;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public final class StatusRunnable {
public static final ListenableFuture forStringIds(WorkDatabase workDatabase, TaskExecutor executor, final List<String> ids) {
Intrinsics.checkNotNullParameter(workDatabase, "<this>");
Intrinsics.checkNotNullParameter(executor, "executor");
Intrinsics.checkNotNullParameter(ids, "ids");
return loadStatusFuture(workDatabase, executor, new Function1() { // from class: androidx.work.impl.utils.StatusRunnable$forStringIds$1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(1);
}
@Override // kotlin.jvm.functions.Function1
public final List<WorkInfo> invoke(WorkDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
List<WorkInfo> apply = WorkSpec.WORK_INFO_MAPPER.apply(db.workSpecDao().getWorkStatusPojoForIds(ids));
Intrinsics.checkNotNullExpressionValue(apply, "WORK_INFO_MAPPER.apply(d…orkStatusPojoForIds(ids))");
return apply;
}
});
}
public static final ListenableFuture forUUID(WorkDatabase workDatabase, TaskExecutor executor, final UUID id) {
Intrinsics.checkNotNullParameter(workDatabase, "<this>");
Intrinsics.checkNotNullParameter(executor, "executor");
Intrinsics.checkNotNullParameter(id, "id");
return loadStatusFuture(workDatabase, executor, new Function1() { // from class: androidx.work.impl.utils.StatusRunnable$forUUID$1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(1);
}
@Override // kotlin.jvm.functions.Function1
public final WorkInfo invoke(WorkDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
WorkSpecDao workSpecDao = db.workSpecDao();
String uuid = id.toString();
Intrinsics.checkNotNullExpressionValue(uuid, "id.toString()");
WorkSpec.WorkInfoPojo workStatusPojoForId = workSpecDao.getWorkStatusPojoForId(uuid);
if (workStatusPojoForId != null) {
return workStatusPojoForId.toWorkInfo();
}
return null;
}
});
}
public static final ListenableFuture forTag(WorkDatabase workDatabase, TaskExecutor executor, final String tag) {
Intrinsics.checkNotNullParameter(workDatabase, "<this>");
Intrinsics.checkNotNullParameter(executor, "executor");
Intrinsics.checkNotNullParameter(tag, "tag");
return loadStatusFuture(workDatabase, executor, new Function1() { // from class: androidx.work.impl.utils.StatusRunnable$forTag$1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(1);
}
@Override // kotlin.jvm.functions.Function1
public final List<WorkInfo> invoke(WorkDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
List<WorkInfo> apply = WorkSpec.WORK_INFO_MAPPER.apply(db.workSpecDao().getWorkStatusPojoForTag(tag));
Intrinsics.checkNotNullExpressionValue(apply, "WORK_INFO_MAPPER.apply(d…orkStatusPojoForTag(tag))");
return apply;
}
});
}
public static final ListenableFuture forUniqueWork(WorkDatabase workDatabase, TaskExecutor executor, final String name) {
Intrinsics.checkNotNullParameter(workDatabase, "<this>");
Intrinsics.checkNotNullParameter(executor, "executor");
Intrinsics.checkNotNullParameter(name, "name");
return loadStatusFuture(workDatabase, executor, new Function1() { // from class: androidx.work.impl.utils.StatusRunnable$forUniqueWork$1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(1);
}
@Override // kotlin.jvm.functions.Function1
public final List<WorkInfo> invoke(WorkDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
List<WorkInfo> apply = WorkSpec.WORK_INFO_MAPPER.apply(db.workSpecDao().getWorkStatusPojoForName(name));
Intrinsics.checkNotNullExpressionValue(apply, "WORK_INFO_MAPPER.apply(d…kStatusPojoForName(name))");
return apply;
}
});
}
public static final ListenableFuture forWorkQuerySpec(WorkDatabase workDatabase, TaskExecutor executor, final WorkQuery querySpec) {
Intrinsics.checkNotNullParameter(workDatabase, "<this>");
Intrinsics.checkNotNullParameter(executor, "executor");
Intrinsics.checkNotNullParameter(querySpec, "querySpec");
return loadStatusFuture(workDatabase, executor, new Function1() { // from class: androidx.work.impl.utils.StatusRunnable$forWorkQuerySpec$1
{
super(1);
}
@Override // kotlin.jvm.functions.Function1
public final List<WorkInfo> invoke(WorkDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
List<WorkInfo> apply = WorkSpec.WORK_INFO_MAPPER.apply(db.rawWorkInfoDao().getWorkInfoPojos(RawQueries.toRawQuery(WorkQuery.this)));
Intrinsics.checkNotNullExpressionValue(apply, "WORK_INFO_MAPPER.apply(d…(querySpec.toRawQuery()))");
return apply;
}
});
}
private static final <T> ListenableFuture loadStatusFuture(final WorkDatabase workDatabase, TaskExecutor taskExecutor, final Function1 function1) {
SerialExecutor serialTaskExecutor = taskExecutor.getSerialTaskExecutor();
Intrinsics.checkNotNullExpressionValue(serialTaskExecutor, "executor.serialTaskExecutor");
return ListenableFutureKt.executeAsync(serialTaskExecutor, "loadStatusFuture", new Function0() { // from class: androidx.work.impl.utils.StatusRunnable$loadStatusFuture$1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
/* JADX WARN: Type inference failed for: r0v1, types: [T, java.lang.Object] */
@Override // kotlin.jvm.functions.Function0
public final T invoke() {
return Function1.this.invoke(workDatabase);
}
});
}
}

View File

@@ -0,0 +1,44 @@
package androidx.work.impl.utils;
import androidx.annotation.RestrictTo;
import androidx.work.Logger;
import androidx.work.WorkInfo;
import androidx.work.impl.Processor;
import androidx.work.impl.StartStopToken;
import kotlin.jvm.internal.Intrinsics;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public final class StopWorkRunnable implements Runnable {
private final Processor processor;
private final int reason;
private final boolean stopInForeground;
private final StartStopToken token;
public StopWorkRunnable(Processor processor, StartStopToken token, boolean z, int i) {
Intrinsics.checkNotNullParameter(processor, "processor");
Intrinsics.checkNotNullParameter(token, "token");
this.processor = processor;
this.token = token;
this.stopInForeground = z;
this.reason = i;
}
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
public StopWorkRunnable(Processor processor, StartStopToken token, boolean z) {
this(processor, token, z, WorkInfo.STOP_REASON_UNKNOWN);
Intrinsics.checkNotNullParameter(processor, "processor");
Intrinsics.checkNotNullParameter(token, "token");
}
@Override // java.lang.Runnable
public void run() {
boolean stopWork;
if (this.stopInForeground) {
stopWork = this.processor.stopForegroundWork(this.token, this.reason);
} else {
stopWork = this.processor.stopWork(this.token, this.reason);
}
Logger.get().debug(Logger.tagWithPrefix("StopWorkRunnable"), "StopWorkRunnable for " + this.token.getId().getWorkSpecId() + "; Processor.stopWork = " + stopWork);
}
}

View File

@@ -0,0 +1,14 @@
package androidx.work.impl.utils;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import java.util.concurrent.Executor;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class SynchronousExecutor implements Executor {
@Override // java.util.concurrent.Executor
public void execute(@NonNull Runnable runnable) {
runnable.run();
}
}

View File

@@ -0,0 +1,53 @@
package androidx.work.impl.utils;
import android.content.Context;
import android.os.PowerManager;
import androidx.work.Logger;
import java.util.LinkedHashMap;
import java.util.Map;
import kotlin.Unit;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
@SourceDebugExtension({"SMAP\nWakeLocks.kt\nKotlin\n*S Kotlin\n*F\n+ 1 WakeLocks.kt\nandroidx/work/impl/utils/WakeLocks\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n+ 3 _Maps.kt\nkotlin/collections/MapsKt___MapsKt\n*L\n1#1,71:1\n1#2:72\n215#3,2:73\n*S KotlinDebug\n*F\n+ 1 WakeLocks.kt\nandroidx/work/impl/utils/WakeLocks\n*L\n63#1:73,2\n*E\n"})
/* loaded from: classes.dex */
public final class WakeLocks {
private static final String TAG;
static {
String tagWithPrefix = Logger.tagWithPrefix("WakeLocks");
Intrinsics.checkNotNullExpressionValue(tagWithPrefix, "tagWithPrefix(\"WakeLocks\")");
TAG = tagWithPrefix;
}
public static final PowerManager.WakeLock newWakeLock(Context context, String tag) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(tag, "tag");
Object systemService = context.getApplicationContext().getSystemService("power");
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.os.PowerManager");
String str = "WorkManager: " + tag;
PowerManager.WakeLock wakeLock = ((PowerManager) systemService).newWakeLock(1, str);
WakeLocksHolder wakeLocksHolder = WakeLocksHolder.INSTANCE;
synchronized (wakeLocksHolder) {
wakeLocksHolder.getWakeLocks().put(wakeLock, str);
}
Intrinsics.checkNotNullExpressionValue(wakeLock, "wakeLock");
return wakeLock;
}
public static final void checkWakeLocks() {
LinkedHashMap linkedHashMap = new LinkedHashMap();
WakeLocksHolder wakeLocksHolder = WakeLocksHolder.INSTANCE;
synchronized (wakeLocksHolder) {
linkedHashMap.putAll(wakeLocksHolder.getWakeLocks());
Unit unit = Unit.INSTANCE;
}
for (Map.Entry entry : linkedHashMap.entrySet()) {
PowerManager.WakeLock wakeLock = (PowerManager.WakeLock) entry.getKey();
String str = (String) entry.getValue();
if (wakeLock != null && wakeLock.isHeld()) {
Logger.get().warning(TAG, "WakeLock held for " + str);
}
}
}
}

View File

@@ -0,0 +1,17 @@
package androidx.work.impl.utils;
import android.os.PowerManager;
import java.util.WeakHashMap;
/* loaded from: classes.dex */
final class WakeLocksHolder {
public static final WakeLocksHolder INSTANCE = new WakeLocksHolder();
private static final WeakHashMap<PowerManager.WakeLock, String> wakeLocks = new WeakHashMap<>();
public final WeakHashMap<PowerManager.WakeLock, String> getWakeLocks() {
return wakeLocks;
}
private WakeLocksHolder() {
}
}

View File

@@ -0,0 +1,90 @@
package androidx.work.impl.utils;
import android.content.Context;
import androidx.concurrent.futures.ListenableFutureKt;
import androidx.work.ForegroundInfo;
import androidx.work.ForegroundUpdater;
import androidx.work.ListenableWorker;
import androidx.work.Logger;
import androidx.work.impl.WorkerWrapperKt;
import androidx.work.impl.model.WorkSpec;
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.utils.WorkForegroundKt$workForeground$2", f = "WorkForeground.kt", l = {42, 50}, m = "invokeSuspend")
@SourceDebugExtension({"SMAP\nWorkForeground.kt\nKotlin\n*S Kotlin\n*F\n+ 1 WorkForeground.kt\nandroidx/work/impl/utils/WorkForegroundKt$workForeground$2\n+ 2 LoggerExt.kt\nandroidx/work/LoggerExtKt\n*L\n1#1,55:1\n19#2:56\n*S KotlinDebug\n*F\n+ 1 WorkForeground.kt\nandroidx/work/impl/utils/WorkForegroundKt$workForeground$2\n*L\n49#1:56\n*E\n"})
/* loaded from: classes.dex */
public final class WorkForegroundKt$workForeground$2 extends SuspendLambda implements Function2 {
final /* synthetic */ Context $context;
final /* synthetic */ ForegroundUpdater $foregroundUpdater;
final /* synthetic */ WorkSpec $spec;
final /* synthetic */ ListenableWorker $worker;
int label;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public WorkForegroundKt$workForeground$2(ListenableWorker listenableWorker, WorkSpec workSpec, ForegroundUpdater foregroundUpdater, Context context, Continuation continuation) {
super(2, continuation);
this.$worker = listenableWorker;
this.$spec = workSpec;
this.$foregroundUpdater = foregroundUpdater;
this.$context = context;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
return new WorkForegroundKt$workForeground$2(this.$worker, this.$spec, this.$foregroundUpdater, this.$context, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) {
return ((WorkForegroundKt$workForeground$2) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
String str;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
ListenableFuture foregroundInfoAsync = this.$worker.getForegroundInfoAsync();
Intrinsics.checkNotNullExpressionValue(foregroundInfoAsync, "worker.getForegroundInfoAsync()");
ListenableWorker listenableWorker = this.$worker;
this.label = 1;
obj = WorkerWrapperKt.awaitWithin(foregroundInfoAsync, listenableWorker, this);
if (obj == 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);
}
ForegroundInfo foregroundInfo = (ForegroundInfo) obj;
if (foregroundInfo == null) {
throw new IllegalStateException("Worker was marked important (" + this.$spec.workerClassName + ") but did not provide ForegroundInfo");
}
str = WorkForegroundKt.TAG;
WorkSpec workSpec = this.$spec;
Logger.get().debug(str, "Updating notification for " + workSpec.workerClassName);
ListenableFuture foregroundAsync = this.$foregroundUpdater.setForegroundAsync(this.$context, this.$worker.getId(), foregroundInfo);
Intrinsics.checkNotNullExpressionValue(foregroundAsync, "foregroundUpdater.setFor…orker.id, foregroundInfo)");
this.label = 2;
obj = ListenableFutureKt.await(foregroundAsync, this);
return obj == coroutine_suspended ? coroutine_suspended : obj;
}
}

View File

@@ -0,0 +1,39 @@
package androidx.work.impl.utils;
import android.content.Context;
import android.os.Build;
import androidx.work.ForegroundUpdater;
import androidx.work.ListenableWorker;
import androidx.work.Logger;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import java.util.concurrent.Executor;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.ExecutorsKt;
/* loaded from: classes.dex */
public final class WorkForegroundKt {
private static final String TAG;
public static final Object workForeground(Context context, WorkSpec workSpec, ListenableWorker listenableWorker, ForegroundUpdater foregroundUpdater, TaskExecutor taskExecutor, Continuation continuation) {
Object coroutine_suspended;
if (!workSpec.expedited || Build.VERSION.SDK_INT >= 31) {
return Unit.INSTANCE;
}
Executor mainThreadExecutor = taskExecutor.getMainThreadExecutor();
Intrinsics.checkNotNullExpressionValue(mainThreadExecutor, "taskExecutor.mainThreadExecutor");
Object withContext = BuildersKt.withContext(ExecutorsKt.from(mainThreadExecutor), new WorkForegroundKt$workForeground$2(listenableWorker, workSpec, foregroundUpdater, context, null), continuation);
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
return withContext == coroutine_suspended ? withContext : Unit.INSTANCE;
}
static {
String tagWithPrefix = Logger.tagWithPrefix("WorkForegroundRunnable");
Intrinsics.checkNotNullExpressionValue(tagWithPrefix, "tagWithPrefix(\"WorkForegroundRunnable\")");
TAG = tagWithPrefix;
}
}

View File

@@ -0,0 +1,61 @@
package androidx.work.impl.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.work.ForegroundInfo;
import androidx.work.ForegroundUpdater;
import androidx.work.ListenableFutureKt;
import androidx.work.Logger;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.foreground.ForegroundProcessor;
import androidx.work.impl.foreground.SystemForegroundDispatcher;
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.UUID;
import kotlin.jvm.functions.Function0;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class WorkForegroundUpdater implements ForegroundUpdater {
private static final String TAG = Logger.tagWithPrefix("WMFgUpdater");
final ForegroundProcessor mForegroundProcessor;
private final TaskExecutor mTaskExecutor;
final WorkSpecDao mWorkSpecDao;
@SuppressLint({"LambdaLast"})
public WorkForegroundUpdater(@NonNull WorkDatabase workDatabase, @NonNull ForegroundProcessor foregroundProcessor, @NonNull TaskExecutor taskExecutor) {
this.mForegroundProcessor = foregroundProcessor;
this.mTaskExecutor = taskExecutor;
this.mWorkSpecDao = workDatabase.workSpecDao();
}
@Override // androidx.work.ForegroundUpdater
@NonNull
public ListenableFuture setForegroundAsync(@NonNull final Context context, @NonNull final UUID uuid, @NonNull final ForegroundInfo foregroundInfo) {
return ListenableFutureKt.executeAsync(this.mTaskExecutor.getSerialTaskExecutor(), "setForegroundAsync", new Function0() { // from class: androidx.work.impl.utils.WorkForegroundUpdater$$ExternalSyntheticLambda0
@Override // kotlin.jvm.functions.Function0
public final Object invoke() {
Void lambda$setForegroundAsync$0;
lambda$setForegroundAsync$0 = WorkForegroundUpdater.this.lambda$setForegroundAsync$0(uuid, foregroundInfo, context);
return lambda$setForegroundAsync$0;
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ Void lambda$setForegroundAsync$0(UUID uuid, ForegroundInfo foregroundInfo, Context context) {
String uuid2 = uuid.toString();
WorkSpec workSpec = this.mWorkSpecDao.getWorkSpec(uuid2);
if (workSpec == null || workSpec.state.isFinished()) {
throw new IllegalStateException("Calls to setForegroundAsync() must complete before a ListenableWorker signals completion of work by returning an instance of Result.");
}
this.mForegroundProcessor.startForeground(uuid2, foregroundInfo);
context.startService(SystemForegroundDispatcher.createNotifyIntent(context, WorkSpecKt.generationalId(workSpec), foregroundInfo));
return null;
}
}

View File

@@ -0,0 +1,74 @@
package androidx.work.impl.utils;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.work.Data;
import androidx.work.ListenableFutureKt;
import androidx.work.Logger;
import androidx.work.ProgressUpdater;
import androidx.work.WorkInfo;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.model.WorkProgress;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.UUID;
import kotlin.jvm.functions.Function0;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class WorkProgressUpdater implements ProgressUpdater {
static final String TAG = Logger.tagWithPrefix("WorkProgressUpdater");
final TaskExecutor mTaskExecutor;
final WorkDatabase mWorkDatabase;
public WorkProgressUpdater(@NonNull WorkDatabase workDatabase, @NonNull TaskExecutor taskExecutor) {
this.mWorkDatabase = workDatabase;
this.mTaskExecutor = taskExecutor;
}
@Override // androidx.work.ProgressUpdater
@NonNull
public ListenableFuture updateProgress(@NonNull Context context, @NonNull final UUID uuid, @NonNull final Data data) {
return ListenableFutureKt.executeAsync(this.mTaskExecutor.getSerialTaskExecutor(), "updateProgress", new Function0() { // from class: androidx.work.impl.utils.WorkProgressUpdater$$ExternalSyntheticLambda0
@Override // kotlin.jvm.functions.Function0
public final Object invoke() {
Void lambda$updateProgress$0;
lambda$updateProgress$0 = WorkProgressUpdater.this.lambda$updateProgress$0(uuid, data);
return lambda$updateProgress$0;
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ Void lambda$updateProgress$0(UUID uuid, Data data) {
String uuid2 = uuid.toString();
Logger logger = Logger.get();
String str = TAG;
logger.debug(str, "Updating progress for " + uuid + " (" + data + ")");
this.mWorkDatabase.beginTransaction();
try {
WorkSpec workSpec = this.mWorkDatabase.workSpecDao().getWorkSpec(uuid2);
if (workSpec != null) {
if (workSpec.state == WorkInfo.State.RUNNING) {
this.mWorkDatabase.workProgressDao().insert(new WorkProgress(uuid2, data));
} else {
Logger.get().warning(str, "Ignoring setProgressAsync(...). WorkSpec (" + uuid2 + ") is not in a RUNNING state.");
}
this.mWorkDatabase.setTransactionSuccessful();
this.mWorkDatabase.endTransaction();
return null;
}
throw new IllegalStateException("Calls to setProgressAsync() must complete before a ListenableWorker signals completion of work by returning an instance of Result.");
} catch (Throwable th) {
try {
Logger.get().error(TAG, "Error updating Worker progress", th);
throw th;
} catch (Throwable th2) {
this.mWorkDatabase.endTransaction();
throw th2;
}
}
}
}

View File

@@ -0,0 +1,103 @@
package androidx.work.impl.utils;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.work.Logger;
import androidx.work.RunnableScheduler;
import androidx.work.impl.model.WorkGenerationalId;
import java.util.HashMap;
import java.util.Map;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class WorkTimer {
private static final String TAG = Logger.tagWithPrefix("WorkTimer");
final RunnableScheduler mRunnableScheduler;
final Map<WorkGenerationalId, WorkTimerRunnable> mTimerMap = new HashMap();
final Map<WorkGenerationalId, TimeLimitExceededListener> mListeners = new HashMap();
final Object mLock = new Object();
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public interface TimeLimitExceededListener {
void onTimeLimitExceeded(@NonNull WorkGenerationalId workGenerationalId);
}
public WorkTimer(@NonNull RunnableScheduler runnableScheduler) {
this.mRunnableScheduler = runnableScheduler;
}
public void startTimer(@NonNull WorkGenerationalId workGenerationalId, long j, @NonNull TimeLimitExceededListener timeLimitExceededListener) {
synchronized (this.mLock) {
Logger.get().debug(TAG, "Starting timer for " + workGenerationalId);
stopTimer(workGenerationalId);
WorkTimerRunnable workTimerRunnable = new WorkTimerRunnable(this, workGenerationalId);
this.mTimerMap.put(workGenerationalId, workTimerRunnable);
this.mListeners.put(workGenerationalId, timeLimitExceededListener);
this.mRunnableScheduler.scheduleWithDelay(j, workTimerRunnable);
}
}
public void stopTimer(@NonNull WorkGenerationalId workGenerationalId) {
synchronized (this.mLock) {
try {
if (this.mTimerMap.remove(workGenerationalId) != null) {
Logger.get().debug(TAG, "Stopping timer for " + workGenerationalId);
this.mListeners.remove(workGenerationalId);
}
} catch (Throwable th) {
throw th;
}
}
}
@NonNull
@VisibleForTesting
public Map<WorkGenerationalId, WorkTimerRunnable> getTimerMap() {
Map<WorkGenerationalId, WorkTimerRunnable> map;
synchronized (this.mLock) {
map = this.mTimerMap;
}
return map;
}
@NonNull
@VisibleForTesting
public Map<WorkGenerationalId, TimeLimitExceededListener> getListeners() {
Map<WorkGenerationalId, TimeLimitExceededListener> map;
synchronized (this.mLock) {
map = this.mListeners;
}
return map;
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static class WorkTimerRunnable implements Runnable {
static final String TAG = "WrkTimerRunnable";
private final WorkGenerationalId mWorkGenerationalId;
private final WorkTimer mWorkTimer;
public WorkTimerRunnable(@NonNull WorkTimer workTimer, @NonNull WorkGenerationalId workGenerationalId) {
this.mWorkTimer = workTimer;
this.mWorkGenerationalId = workGenerationalId;
}
@Override // java.lang.Runnable
public void run() {
synchronized (this.mWorkTimer.mLock) {
try {
if (this.mWorkTimer.mTimerMap.remove(this.mWorkGenerationalId) != null) {
TimeLimitExceededListener remove = this.mWorkTimer.mListeners.remove(this.mWorkGenerationalId);
if (remove != null) {
remove.onTimeLimitExceeded(this.mWorkGenerationalId);
}
} else {
Logger.get().debug(TAG, String.format("Timer with %s is already marked as complete.", this.mWorkGenerationalId));
}
} catch (Throwable th) {
throw th;
}
}
}
}
}

View File

@@ -0,0 +1,22 @@
package androidx.work.impl.utils;
import androidx.core.util.Consumer;
import androidx.work.Logger;
import androidx.work.WorkerExceptionInfo;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
@SourceDebugExtension({"SMAP\nWorkerExceptionUtils.kt\nKotlin\n*S Kotlin\n*F\n+ 1 WorkerExceptionUtils.kt\nandroidx/work/impl/utils/WorkerExceptionUtilsKt\n+ 2 LoggerExt.kt\nandroidx/work/LoggerExtKt\n*L\n1#1,37:1\n32#2:38\n*S KotlinDebug\n*F\n+ 1 WorkerExceptionUtils.kt\nandroidx/work/impl/utils/WorkerExceptionUtilsKt\n*L\n34#1:38\n*E\n"})
/* loaded from: classes.dex */
public final class WorkerExceptionUtilsKt {
public static final void safeAccept(Consumer<WorkerExceptionInfo> consumer, WorkerExceptionInfo info, String tag) {
Intrinsics.checkNotNullParameter(consumer, "<this>");
Intrinsics.checkNotNullParameter(info, "info");
Intrinsics.checkNotNullParameter(tag, "tag");
try {
consumer.accept(info);
} catch (Throwable th) {
Logger.get().error(tag, "Exception handler threw an exception", th);
}
}
}

View File

@@ -0,0 +1,758 @@
package androidx.work.impl.utils.futures;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.concurrent.futures.AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0;
import com.google.common.util.concurrent.ListenableFuture;
import com.ironsource.v8;
import java.util.Locale;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.concurrent.locks.LockSupport;
import java.util.logging.Level;
import java.util.logging.Logger;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public abstract class AbstractFuture<V> implements ListenableFuture {
static final AtomicHelper ATOMIC_HELPER;
private static final Object NULL;
private static final long SPIN_THRESHOLD_NANOS = 1000;
@Nullable
volatile Listener listeners;
@Nullable
volatile Object value;
@Nullable
volatile Waiter waiters;
static final boolean GENERATE_CANCELLATION_CAUSES = Boolean.parseBoolean(System.getProperty("guava.concurrent.generate_cancellation_cause", "false"));
private static final Logger log = Logger.getLogger(AbstractFuture.class.getName());
public void afterDone() {
}
public void interruptTask() {
}
static {
AtomicHelper synchronizedHelper;
try {
synchronizedHelper = new SafeAtomicHelper(AtomicReferenceFieldUpdater.newUpdater(Waiter.class, Thread.class, "thread"), AtomicReferenceFieldUpdater.newUpdater(Waiter.class, Waiter.class, "next"), AtomicReferenceFieldUpdater.newUpdater(AbstractFuture.class, Waiter.class, "waiters"), AtomicReferenceFieldUpdater.newUpdater(AbstractFuture.class, Listener.class, "listeners"), AtomicReferenceFieldUpdater.newUpdater(AbstractFuture.class, Object.class, "value"));
th = null;
} catch (Throwable th) {
th = th;
synchronizedHelper = new SynchronizedHelper();
}
ATOMIC_HELPER = synchronizedHelper;
if (th != null) {
log.log(Level.SEVERE, "SafeAtomicHelper is broken!", th);
}
NULL = new Object();
}
public static final class Waiter {
static final Waiter TOMBSTONE = new Waiter(false);
@Nullable
volatile Waiter next;
@Nullable
volatile Thread thread;
public Waiter(boolean z) {
}
public Waiter() {
AbstractFuture.ATOMIC_HELPER.putThread(this, Thread.currentThread());
}
public void setNext(Waiter waiter) {
AbstractFuture.ATOMIC_HELPER.putNext(this, waiter);
}
public void unpark() {
Thread thread = this.thread;
if (thread != null) {
this.thread = null;
LockSupport.unpark(thread);
}
}
}
private void removeWaiter(Waiter waiter) {
waiter.thread = null;
while (true) {
Waiter waiter2 = this.waiters;
if (waiter2 == Waiter.TOMBSTONE) {
return;
}
Waiter waiter3 = null;
while (waiter2 != null) {
Waiter waiter4 = waiter2.next;
if (waiter2.thread != null) {
waiter3 = waiter2;
} else if (waiter3 != null) {
waiter3.next = waiter4;
if (waiter3.thread == null) {
break;
}
} else if (!ATOMIC_HELPER.casWaiters(this, waiter2, waiter4)) {
break;
}
waiter2 = waiter4;
}
return;
}
}
public static final class Listener {
static final Listener TOMBSTONE = new Listener(null, null);
final Executor executor;
@Nullable
Listener next;
final Runnable task;
public Listener(Runnable runnable, Executor executor) {
this.task = runnable;
this.executor = executor;
}
}
public static final class Failure {
static final Failure FALLBACK_INSTANCE = new Failure(new Throwable("Failure occurred while trying to finish a future.") { // from class: androidx.work.impl.utils.futures.AbstractFuture.Failure.1
@Override // java.lang.Throwable
public synchronized Throwable fillInStackTrace() {
return this;
}
});
final Throwable exception;
public Failure(Throwable th) {
this.exception = (Throwable) AbstractFuture.checkNotNull(th);
}
}
public static final class Cancellation {
static final Cancellation CAUSELESS_CANCELLED;
static final Cancellation CAUSELESS_INTERRUPTED;
@Nullable
final Throwable cause;
final boolean wasInterrupted;
static {
if (AbstractFuture.GENERATE_CANCELLATION_CAUSES) {
CAUSELESS_CANCELLED = null;
CAUSELESS_INTERRUPTED = null;
} else {
CAUSELESS_CANCELLED = new Cancellation(false, null);
CAUSELESS_INTERRUPTED = new Cancellation(true, null);
}
}
public Cancellation(boolean z, @Nullable Throwable th) {
this.wasInterrupted = z;
this.cause = th;
}
}
public static final class SetFuture<V> implements Runnable {
final ListenableFuture future;
final AbstractFuture<V> owner;
public SetFuture(AbstractFuture<V> abstractFuture, ListenableFuture listenableFuture) {
this.owner = abstractFuture;
this.future = listenableFuture;
}
@Override // java.lang.Runnable
public void run() {
if (this.owner.value != this) {
return;
}
if (AbstractFuture.ATOMIC_HELPER.casValue(this.owner, this, AbstractFuture.getFutureValue(this.future))) {
AbstractFuture.complete(this.owner);
}
}
}
@Override // java.util.concurrent.Future
public final V get(long j, TimeUnit timeUnit) throws InterruptedException, TimeoutException, ExecutionException {
long nanos = timeUnit.toNanos(j);
if (Thread.interrupted()) {
throw new InterruptedException();
}
Object obj = this.value;
if ((obj != null) & (!(obj instanceof SetFuture))) {
return getDoneValue(obj);
}
long nanoTime = nanos > 0 ? System.nanoTime() + nanos : 0L;
if (nanos >= 1000) {
Waiter waiter = this.waiters;
if (waiter != Waiter.TOMBSTONE) {
Waiter waiter2 = new Waiter();
do {
waiter2.setNext(waiter);
if (ATOMIC_HELPER.casWaiters(this, waiter, waiter2)) {
do {
LockSupport.parkNanos(this, nanos);
if (Thread.interrupted()) {
removeWaiter(waiter2);
throw new InterruptedException();
}
Object obj2 = this.value;
if ((obj2 != null) & (!(obj2 instanceof SetFuture))) {
return getDoneValue(obj2);
}
nanos = nanoTime - System.nanoTime();
} while (nanos >= 1000);
removeWaiter(waiter2);
} else {
waiter = this.waiters;
}
} while (waiter != Waiter.TOMBSTONE);
}
return getDoneValue(this.value);
}
while (nanos > 0) {
Object obj3 = this.value;
if ((obj3 != null) & (!(obj3 instanceof SetFuture))) {
return getDoneValue(obj3);
}
if (Thread.interrupted()) {
throw new InterruptedException();
}
nanos = nanoTime - System.nanoTime();
}
String abstractFuture = toString();
String obj4 = timeUnit.toString();
Locale locale = Locale.ROOT;
String lowerCase = obj4.toLowerCase(locale);
String str = "Waited " + j + " " + timeUnit.toString().toLowerCase(locale);
if (nanos + 1000 < 0) {
String str2 = str + " (plus ";
long j2 = -nanos;
long convert = timeUnit.convert(j2, TimeUnit.NANOSECONDS);
long nanos2 = j2 - timeUnit.toNanos(convert);
boolean z = convert == 0 || nanos2 > 1000;
if (convert > 0) {
String str3 = str2 + convert + " " + lowerCase;
if (z) {
str3 = str3 + ",";
}
str2 = str3 + " ";
}
if (z) {
str2 = str2 + nanos2 + " nanoseconds ";
}
str = str2 + "delay)";
}
if (isDone()) {
throw new TimeoutException(str + " but future completed as timeout expired");
}
throw new TimeoutException(str + " for " + abstractFuture);
}
@Override // java.util.concurrent.Future
public final V get() throws InterruptedException, ExecutionException {
Object obj;
if (Thread.interrupted()) {
throw new InterruptedException();
}
Object obj2 = this.value;
if ((obj2 != null) & (!(obj2 instanceof SetFuture))) {
return getDoneValue(obj2);
}
Waiter waiter = this.waiters;
if (waiter != Waiter.TOMBSTONE) {
Waiter waiter2 = new Waiter();
do {
waiter2.setNext(waiter);
if (ATOMIC_HELPER.casWaiters(this, waiter, waiter2)) {
do {
LockSupport.park(this);
if (Thread.interrupted()) {
removeWaiter(waiter2);
throw new InterruptedException();
}
obj = this.value;
} while (!((obj != null) & (!(obj instanceof SetFuture))));
return getDoneValue(obj);
}
waiter = this.waiters;
} while (waiter != Waiter.TOMBSTONE);
}
return getDoneValue(this.value);
}
/* JADX WARN: Multi-variable type inference failed */
private V getDoneValue(Object obj) throws ExecutionException {
if (obj instanceof Cancellation) {
throw cancellationExceptionWithCause("Task was cancelled.", ((Cancellation) obj).cause);
}
if (obj instanceof Failure) {
throw new ExecutionException(((Failure) obj).exception);
}
if (obj == NULL) {
return null;
}
return obj;
}
@Override // java.util.concurrent.Future
public final boolean isDone() {
return (!(r0 instanceof SetFuture)) & (this.value != null);
}
@Override // java.util.concurrent.Future
public final boolean isCancelled() {
return this.value instanceof Cancellation;
}
@Override // java.util.concurrent.Future
public final boolean cancel(boolean z) {
Cancellation cancellation;
Object obj = this.value;
if (!(obj == null) && !(obj instanceof SetFuture)) {
return false;
}
if (GENERATE_CANCELLATION_CAUSES) {
cancellation = new Cancellation(z, new CancellationException("Future.cancel() was called."));
} else if (z) {
cancellation = Cancellation.CAUSELESS_INTERRUPTED;
} else {
cancellation = Cancellation.CAUSELESS_CANCELLED;
}
AbstractFuture<V> abstractFuture = this;
boolean z2 = false;
while (true) {
if (ATOMIC_HELPER.casValue(abstractFuture, obj, cancellation)) {
if (z) {
abstractFuture.interruptTask();
}
complete(abstractFuture);
if (!(obj instanceof SetFuture)) {
return true;
}
ListenableFuture listenableFuture = ((SetFuture) obj).future;
if (listenableFuture instanceof AbstractFuture) {
abstractFuture = (AbstractFuture) listenableFuture;
obj = abstractFuture.value;
if (!(obj == null) && !(obj instanceof SetFuture)) {
return true;
}
z2 = true;
} else {
listenableFuture.cancel(z);
return true;
}
} else {
obj = abstractFuture.value;
if (!(obj instanceof SetFuture)) {
return z2;
}
}
}
}
public final boolean wasInterrupted() {
Object obj = this.value;
return (obj instanceof Cancellation) && ((Cancellation) obj).wasInterrupted;
}
@Override // com.google.common.util.concurrent.ListenableFuture
public final void addListener(Runnable runnable, Executor executor) {
checkNotNull(runnable);
checkNotNull(executor);
Listener listener = this.listeners;
if (listener != Listener.TOMBSTONE) {
Listener listener2 = new Listener(runnable, executor);
do {
listener2.next = listener;
if (ATOMIC_HELPER.casListeners(this, listener, listener2)) {
return;
} else {
listener = this.listeners;
}
} while (listener != Listener.TOMBSTONE);
}
executeListener(runnable, executor);
}
public boolean set(@Nullable V v) {
if (v == null) {
v = (V) NULL;
}
if (!ATOMIC_HELPER.casValue(this, null, v)) {
return false;
}
complete(this);
return true;
}
public boolean setException(Throwable th) {
if (!ATOMIC_HELPER.casValue(this, null, new Failure((Throwable) checkNotNull(th)))) {
return false;
}
complete(this);
return true;
}
public boolean setFuture(ListenableFuture listenableFuture) {
Failure failure;
checkNotNull(listenableFuture);
Object obj = this.value;
if (obj == null) {
if (listenableFuture.isDone()) {
if (!ATOMIC_HELPER.casValue(this, null, getFutureValue(listenableFuture))) {
return false;
}
complete(this);
return true;
}
SetFuture setFuture = new SetFuture(this, listenableFuture);
if (ATOMIC_HELPER.casValue(this, null, setFuture)) {
try {
listenableFuture.addListener(setFuture, DirectExecutor.INSTANCE);
} catch (Throwable th) {
try {
failure = new Failure(th);
} catch (Throwable unused) {
failure = Failure.FALLBACK_INSTANCE;
}
ATOMIC_HELPER.casValue(this, setFuture, failure);
}
return true;
}
obj = this.value;
}
if (obj instanceof Cancellation) {
listenableFuture.cancel(((Cancellation) obj).wasInterrupted);
}
return false;
}
public static Object getFutureValue(ListenableFuture listenableFuture) {
if (listenableFuture instanceof AbstractFuture) {
Object obj = ((AbstractFuture) listenableFuture).value;
if (!(obj instanceof Cancellation)) {
return obj;
}
Cancellation cancellation = (Cancellation) obj;
return cancellation.wasInterrupted ? cancellation.cause != null ? new Cancellation(false, cancellation.cause) : Cancellation.CAUSELESS_CANCELLED : obj;
}
boolean isCancelled = listenableFuture.isCancelled();
if ((!GENERATE_CANCELLATION_CAUSES) & isCancelled) {
return Cancellation.CAUSELESS_CANCELLED;
}
try {
Object uninterruptibly = getUninterruptibly(listenableFuture);
return uninterruptibly == null ? NULL : uninterruptibly;
} catch (CancellationException e) {
if (!isCancelled) {
return new Failure(new IllegalArgumentException("get() threw CancellationException, despite reporting isCancelled() == false: " + listenableFuture, e));
}
return new Cancellation(false, e);
} catch (ExecutionException e2) {
return new Failure(e2.getCause());
} catch (Throwable th) {
return new Failure(th);
}
}
private static <V> V getUninterruptibly(Future<V> future) throws ExecutionException {
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;
}
public static void complete(AbstractFuture<?> abstractFuture) {
Listener listener = null;
while (true) {
abstractFuture.releaseWaiters();
abstractFuture.afterDone();
Listener clearListeners = abstractFuture.clearListeners(listener);
while (clearListeners != null) {
listener = clearListeners.next;
Runnable runnable = clearListeners.task;
if (runnable instanceof SetFuture) {
SetFuture setFuture = (SetFuture) runnable;
abstractFuture = setFuture.owner;
if (abstractFuture.value == setFuture) {
if (ATOMIC_HELPER.casValue(abstractFuture, setFuture, getFutureValue(setFuture.future))) {
break;
}
} else {
continue;
}
} else {
executeListener(runnable, clearListeners.executor);
}
clearListeners = listener;
}
return;
}
}
public final void maybePropagateCancellationTo(@Nullable Future<?> future) {
if ((future != null) && isCancelled()) {
future.cancel(wasInterrupted());
}
}
private void releaseWaiters() {
Waiter waiter;
do {
waiter = this.waiters;
} while (!ATOMIC_HELPER.casWaiters(this, waiter, Waiter.TOMBSTONE));
while (waiter != null) {
waiter.unpark();
waiter = waiter.next;
}
}
private Listener clearListeners(Listener listener) {
Listener listener2;
do {
listener2 = this.listeners;
} while (!ATOMIC_HELPER.casListeners(this, listener2, Listener.TOMBSTONE));
Listener listener3 = listener;
Listener listener4 = listener2;
while (listener4 != null) {
Listener listener5 = listener4.next;
listener4.next = listener3;
listener3 = listener4;
listener4 = listener5;
}
return listener3;
}
public String toString() {
String str;
StringBuilder sb = new StringBuilder();
sb.append(super.toString());
sb.append("[status=");
if (isCancelled()) {
sb.append("CANCELLED");
} else if (isDone()) {
addDoneString(sb);
} else {
try {
str = pendingToString();
} catch (RuntimeException e) {
str = "Exception thrown from implementation: " + e.getClass();
}
if (str != null && !str.isEmpty()) {
sb.append("PENDING, info=[");
sb.append(str);
sb.append(v8.i.e);
} else if (isDone()) {
addDoneString(sb);
} else {
sb.append("PENDING");
}
}
sb.append(v8.i.e);
return sb.toString();
}
/* JADX WARN: Multi-variable type inference failed */
@Nullable
public String pendingToString() {
Object obj = this.value;
if (obj instanceof SetFuture) {
return "setFuture=[" + userObjectToString(((SetFuture) obj).future) + v8.i.e;
}
if (!(this instanceof ScheduledFuture)) {
return null;
}
return "remaining delay=[" + ((ScheduledFuture) this).getDelay(TimeUnit.MILLISECONDS) + " ms]";
}
private void addDoneString(StringBuilder sb) {
try {
Object uninterruptibly = getUninterruptibly(this);
sb.append("SUCCESS, result=[");
sb.append(userObjectToString(uninterruptibly));
sb.append(v8.i.e);
} catch (CancellationException unused) {
sb.append("CANCELLED");
} catch (RuntimeException e) {
sb.append("UNKNOWN, cause=[");
sb.append(e.getClass());
sb.append(" thrown from get()]");
} catch (ExecutionException e2) {
sb.append("FAILURE, cause=[");
sb.append(e2.getCause());
sb.append(v8.i.e);
}
}
private String userObjectToString(Object obj) {
return obj == this ? "this future" : String.valueOf(obj);
}
private static void executeListener(Runnable runnable, Executor executor) {
try {
executor.execute(runnable);
} catch (RuntimeException e) {
log.log(Level.SEVERE, "RuntimeException while executing runnable " + runnable + " with executor " + executor, (Throwable) e);
}
}
public static abstract class AtomicHelper {
public abstract boolean casListeners(AbstractFuture<?> abstractFuture, Listener listener, Listener listener2);
public abstract boolean casValue(AbstractFuture<?> abstractFuture, Object obj, Object obj2);
public abstract boolean casWaiters(AbstractFuture<?> abstractFuture, Waiter waiter, Waiter waiter2);
public abstract void putNext(Waiter waiter, Waiter waiter2);
public abstract void putThread(Waiter waiter, Thread thread);
private AtomicHelper() {
}
}
public static final class SafeAtomicHelper extends AtomicHelper {
final AtomicReferenceFieldUpdater<AbstractFuture, Listener> listenersUpdater;
final AtomicReferenceFieldUpdater<AbstractFuture, Object> valueUpdater;
final AtomicReferenceFieldUpdater<Waiter, Waiter> waiterNextUpdater;
final AtomicReferenceFieldUpdater<Waiter, Thread> waiterThreadUpdater;
final AtomicReferenceFieldUpdater<AbstractFuture, Waiter> waitersUpdater;
public SafeAtomicHelper(AtomicReferenceFieldUpdater<Waiter, Thread> atomicReferenceFieldUpdater, AtomicReferenceFieldUpdater<Waiter, Waiter> atomicReferenceFieldUpdater2, AtomicReferenceFieldUpdater<AbstractFuture, Waiter> atomicReferenceFieldUpdater3, AtomicReferenceFieldUpdater<AbstractFuture, Listener> atomicReferenceFieldUpdater4, AtomicReferenceFieldUpdater<AbstractFuture, Object> atomicReferenceFieldUpdater5) {
super();
this.waiterThreadUpdater = atomicReferenceFieldUpdater;
this.waiterNextUpdater = atomicReferenceFieldUpdater2;
this.waitersUpdater = atomicReferenceFieldUpdater3;
this.listenersUpdater = atomicReferenceFieldUpdater4;
this.valueUpdater = atomicReferenceFieldUpdater5;
}
@Override // androidx.work.impl.utils.futures.AbstractFuture.AtomicHelper
public void putThread(Waiter waiter, Thread thread) {
this.waiterThreadUpdater.lazySet(waiter, thread);
}
@Override // androidx.work.impl.utils.futures.AbstractFuture.AtomicHelper
public void putNext(Waiter waiter, Waiter waiter2) {
this.waiterNextUpdater.lazySet(waiter, waiter2);
}
@Override // androidx.work.impl.utils.futures.AbstractFuture.AtomicHelper
public boolean casWaiters(AbstractFuture<?> abstractFuture, Waiter waiter, Waiter waiter2) {
return AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(this.waitersUpdater, abstractFuture, waiter, waiter2);
}
@Override // androidx.work.impl.utils.futures.AbstractFuture.AtomicHelper
public boolean casListeners(AbstractFuture<?> abstractFuture, Listener listener, Listener listener2) {
return AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(this.listenersUpdater, abstractFuture, listener, listener2);
}
@Override // androidx.work.impl.utils.futures.AbstractFuture.AtomicHelper
public boolean casValue(AbstractFuture<?> abstractFuture, Object obj, Object obj2) {
return AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(this.valueUpdater, abstractFuture, obj, obj2);
}
}
public static final class SynchronizedHelper extends AtomicHelper {
public SynchronizedHelper() {
super();
}
@Override // androidx.work.impl.utils.futures.AbstractFuture.AtomicHelper
public void putThread(Waiter waiter, Thread thread) {
waiter.thread = thread;
}
@Override // androidx.work.impl.utils.futures.AbstractFuture.AtomicHelper
public void putNext(Waiter waiter, Waiter waiter2) {
waiter.next = waiter2;
}
@Override // androidx.work.impl.utils.futures.AbstractFuture.AtomicHelper
public boolean casWaiters(AbstractFuture<?> abstractFuture, Waiter waiter, Waiter waiter2) {
synchronized (abstractFuture) {
try {
if (abstractFuture.waiters != waiter) {
return false;
}
abstractFuture.waiters = waiter2;
return true;
} catch (Throwable th) {
throw th;
}
}
}
@Override // androidx.work.impl.utils.futures.AbstractFuture.AtomicHelper
public boolean casListeners(AbstractFuture<?> abstractFuture, Listener listener, Listener listener2) {
synchronized (abstractFuture) {
try {
if (abstractFuture.listeners != listener) {
return false;
}
abstractFuture.listeners = listener2;
return true;
} catch (Throwable th) {
throw th;
}
}
}
@Override // androidx.work.impl.utils.futures.AbstractFuture.AtomicHelper
public boolean casValue(AbstractFuture<?> abstractFuture, Object obj, Object obj2) {
synchronized (abstractFuture) {
try {
if (abstractFuture.value != obj) {
return false;
}
abstractFuture.value = obj2;
return true;
} catch (Throwable th) {
throw th;
}
}
}
}
private static CancellationException cancellationExceptionWithCause(@Nullable String str, @Nullable Throwable th) {
CancellationException cancellationException = new CancellationException(str);
cancellationException.initCause(th);
return cancellationException;
}
@NonNull
public static <T> T checkNotNull(@Nullable T t) {
t.getClass();
return t;
}
}

View File

@@ -0,0 +1,20 @@
package androidx.work.impl.utils.futures;
import androidx.annotation.RestrictTo;
import java.util.concurrent.Executor;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
enum DirectExecutor implements Executor {
INSTANCE;
@Override // java.lang.Enum
public String toString() {
return "DirectExecutor";
}
@Override // java.util.concurrent.Executor
public void execute(Runnable runnable) {
runnable.run();
}
}

View File

@@ -0,0 +1,31 @@
package androidx.work.impl.utils.futures;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import com.google.common.util.concurrent.ListenableFuture;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public final class SettableFuture<V> extends AbstractFuture<V> {
public static <V> SettableFuture<V> create() {
return new SettableFuture<>();
}
@Override // androidx.work.impl.utils.futures.AbstractFuture
public boolean set(@Nullable V v) {
return super.set(v);
}
@Override // androidx.work.impl.utils.futures.AbstractFuture
public boolean setException(Throwable th) {
return super.setException(th);
}
@Override // androidx.work.impl.utils.futures.AbstractFuture
public boolean setFuture(ListenableFuture listenableFuture) {
return super.setFuture(listenableFuture);
}
private SettableFuture() {
}
}

View File

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

View File

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

View File

@@ -0,0 +1,8 @@
package androidx.work.impl.utils.taskexecutor;
import java.util.concurrent.Executor;
/* loaded from: classes.dex */
public interface SerialExecutor extends Executor {
boolean hasPendingTasks();
}

View File

@@ -0,0 +1,26 @@
package androidx.work.impl.utils.taskexecutor;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import java.util.concurrent.Executor;
import kotlinx.coroutines.CoroutineDispatcher;
import kotlinx.coroutines.ExecutorsKt;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public interface TaskExecutor {
@NonNull
Executor getMainThreadExecutor();
@NonNull
SerialExecutor getSerialTaskExecutor();
default void executeOnTaskThread(@NonNull Runnable runnable) {
getSerialTaskExecutor().execute(runnable);
}
@NonNull
default CoroutineDispatcher getTaskCoroutineDispatcher() {
return ExecutorsKt.from(getSerialTaskExecutor());
}
}

View File

@@ -0,0 +1,48 @@
package androidx.work.impl.utils.taskexecutor;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.work.impl.utils.SerialExecutorImpl;
import java.util.concurrent.Executor;
import kotlinx.coroutines.CoroutineDispatcher;
import kotlinx.coroutines.ExecutorsKt;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class WorkManagerTaskExecutor implements TaskExecutor {
private final SerialExecutorImpl mBackgroundExecutor;
private final CoroutineDispatcher mTaskDispatcher;
final Handler mMainThreadHandler = new Handler(Looper.getMainLooper());
private final Executor mMainThreadExecutor = new Executor() { // from class: androidx.work.impl.utils.taskexecutor.WorkManagerTaskExecutor.1
@Override // java.util.concurrent.Executor
public void execute(@NonNull Runnable runnable) {
WorkManagerTaskExecutor.this.mMainThreadHandler.post(runnable);
}
};
@Override // androidx.work.impl.utils.taskexecutor.TaskExecutor
@NonNull
public Executor getMainThreadExecutor() {
return this.mMainThreadExecutor;
}
@Override // androidx.work.impl.utils.taskexecutor.TaskExecutor
@NonNull
public SerialExecutorImpl getSerialTaskExecutor() {
return this.mBackgroundExecutor;
}
@Override // androidx.work.impl.utils.taskexecutor.TaskExecutor
@NonNull
public CoroutineDispatcher getTaskCoroutineDispatcher() {
return this.mTaskDispatcher;
}
public WorkManagerTaskExecutor(@NonNull Executor executor) {
SerialExecutorImpl serialExecutorImpl = new SerialExecutorImpl(executor);
this.mBackgroundExecutor = serialExecutorImpl;
this.mTaskDispatcher = ExecutorsKt.from(serialExecutorImpl);
}
}

View File

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