- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
310 lines
12 KiB
Java
310 lines
12 KiB
Java
package androidx.work;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import androidx.work.WorkInfo;
|
|
import androidx.work.impl.model.WorkSpec;
|
|
import androidx.work.impl.utils.DurationApi26Impl;
|
|
import csdk.gluads.Consts;
|
|
import java.time.Duration;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import java.util.UUID;
|
|
import java.util.concurrent.TimeUnit;
|
|
import kotlin.collections.CollectionsKt___CollectionsKt;
|
|
import kotlin.collections.SetsKt__SetsKt;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.jvm.internal.SourceDebugExtension;
|
|
import kotlin.text.StringsKt__StringsKt;
|
|
import kotlin.text.StringsKt___StringsKt;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class WorkRequest {
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final long DEFAULT_BACKOFF_DELAY_MILLIS = 30000;
|
|
|
|
@SuppressLint({"MinMaxConstant"})
|
|
public static final long MAX_BACKOFF_MILLIS = 18000000;
|
|
private static final int MAX_TRACE_SPAN_LENGTH = 127;
|
|
|
|
@SuppressLint({"MinMaxConstant"})
|
|
public static final long MIN_BACKOFF_MILLIS = 10000;
|
|
private final UUID id;
|
|
private final Set<String> tags;
|
|
private final WorkSpec workSpec;
|
|
|
|
public UUID getId() {
|
|
return this.id;
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
public final Set<String> getTags() {
|
|
return this.tags;
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
public final WorkSpec getWorkSpec() {
|
|
return this.workSpec;
|
|
}
|
|
|
|
public WorkRequest(UUID id, WorkSpec workSpec, Set<String> tags) {
|
|
Intrinsics.checkNotNullParameter(id, "id");
|
|
Intrinsics.checkNotNullParameter(workSpec, "workSpec");
|
|
Intrinsics.checkNotNullParameter(tags, "tags");
|
|
this.id = id;
|
|
this.workSpec = workSpec;
|
|
this.tags = tags;
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
public final String getStringId() {
|
|
String uuid = getId().toString();
|
|
Intrinsics.checkNotNullExpressionValue(uuid, "id.toString()");
|
|
return uuid;
|
|
}
|
|
|
|
@SourceDebugExtension({"SMAP\nWorkRequest.kt\nKotlin\n*S Kotlin\n*F\n+ 1 WorkRequest.kt\nandroidx/work/WorkRequest$Builder\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,387:1\n1#2:388\n*E\n"})
|
|
public static abstract class Builder<B extends Builder<B, ?>, W extends WorkRequest> {
|
|
private boolean backoffCriteriaSet;
|
|
private UUID id;
|
|
private final Set<String> tags;
|
|
private WorkSpec workSpec;
|
|
private final Class<? extends ListenableWorker> workerClass;
|
|
|
|
public abstract W buildInternal$work_runtime_release();
|
|
|
|
public final boolean getBackoffCriteriaSet$work_runtime_release() {
|
|
return this.backoffCriteriaSet;
|
|
}
|
|
|
|
public final UUID getId$work_runtime_release() {
|
|
return this.id;
|
|
}
|
|
|
|
public final Set<String> getTags$work_runtime_release() {
|
|
return this.tags;
|
|
}
|
|
|
|
public abstract B getThisObject$work_runtime_release();
|
|
|
|
public final WorkSpec getWorkSpec$work_runtime_release() {
|
|
return this.workSpec;
|
|
}
|
|
|
|
public final Class<? extends ListenableWorker> getWorkerClass$work_runtime_release() {
|
|
return this.workerClass;
|
|
}
|
|
|
|
public final void setBackoffCriteriaSet$work_runtime_release(boolean z) {
|
|
this.backoffCriteriaSet = z;
|
|
}
|
|
|
|
public final void setId$work_runtime_release(UUID uuid) {
|
|
Intrinsics.checkNotNullParameter(uuid, "<set-?>");
|
|
this.id = uuid;
|
|
}
|
|
|
|
public final void setWorkSpec$work_runtime_release(WorkSpec workSpec) {
|
|
Intrinsics.checkNotNullParameter(workSpec, "<set-?>");
|
|
this.workSpec = workSpec;
|
|
}
|
|
|
|
public Builder(Class<? extends ListenableWorker> workerClass) {
|
|
Set<String> mutableSetOf;
|
|
Intrinsics.checkNotNullParameter(workerClass, "workerClass");
|
|
this.workerClass = workerClass;
|
|
UUID randomUUID = UUID.randomUUID();
|
|
Intrinsics.checkNotNullExpressionValue(randomUUID, "randomUUID()");
|
|
this.id = randomUUID;
|
|
String uuid = this.id.toString();
|
|
Intrinsics.checkNotNullExpressionValue(uuid, "id.toString()");
|
|
String name = workerClass.getName();
|
|
Intrinsics.checkNotNullExpressionValue(name, "workerClass.name");
|
|
this.workSpec = new WorkSpec(uuid, name);
|
|
String name2 = workerClass.getName();
|
|
Intrinsics.checkNotNullExpressionValue(name2, "workerClass.name");
|
|
mutableSetOf = SetsKt__SetsKt.mutableSetOf(name2);
|
|
this.tags = mutableSetOf;
|
|
}
|
|
|
|
public final B setId(UUID id) {
|
|
Intrinsics.checkNotNullParameter(id, "id");
|
|
this.id = id;
|
|
String uuid = id.toString();
|
|
Intrinsics.checkNotNullExpressionValue(uuid, "id.toString()");
|
|
this.workSpec = new WorkSpec(uuid, this.workSpec);
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
public final B setBackoffCriteria(BackoffPolicy backoffPolicy, long j, TimeUnit timeUnit) {
|
|
Intrinsics.checkNotNullParameter(backoffPolicy, "backoffPolicy");
|
|
Intrinsics.checkNotNullParameter(timeUnit, "timeUnit");
|
|
this.backoffCriteriaSet = true;
|
|
WorkSpec workSpec = this.workSpec;
|
|
workSpec.backoffPolicy = backoffPolicy;
|
|
workSpec.setBackoffDelayDuration(timeUnit.toMillis(j));
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
@RequiresApi(26)
|
|
public final B setBackoffCriteria(BackoffPolicy backoffPolicy, Duration duration) {
|
|
Intrinsics.checkNotNullParameter(backoffPolicy, "backoffPolicy");
|
|
Intrinsics.checkNotNullParameter(duration, "duration");
|
|
this.backoffCriteriaSet = true;
|
|
WorkSpec workSpec = this.workSpec;
|
|
workSpec.backoffPolicy = backoffPolicy;
|
|
workSpec.setBackoffDelayDuration(DurationApi26Impl.toMillisCompat(duration));
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
public final B setConstraints(Constraints constraints) {
|
|
Intrinsics.checkNotNullParameter(constraints, "constraints");
|
|
this.workSpec.constraints = constraints;
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
public final B setInputData(Data inputData) {
|
|
Intrinsics.checkNotNullParameter(inputData, "inputData");
|
|
this.workSpec.input = inputData;
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
public final B addTag(String tag) {
|
|
Intrinsics.checkNotNullParameter(tag, "tag");
|
|
this.tags.add(tag);
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
public final B setTraceTag(String traceTag) {
|
|
Intrinsics.checkNotNullParameter(traceTag, "traceTag");
|
|
this.workSpec.setTraceTag(traceTag);
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
public final B keepResultsForAtLeast(long j, TimeUnit timeUnit) {
|
|
Intrinsics.checkNotNullParameter(timeUnit, "timeUnit");
|
|
this.workSpec.minimumRetentionDuration = timeUnit.toMillis(j);
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
@RequiresApi(26)
|
|
public final B keepResultsForAtLeast(Duration duration) {
|
|
Intrinsics.checkNotNullParameter(duration, "duration");
|
|
this.workSpec.minimumRetentionDuration = DurationApi26Impl.toMillisCompat(duration);
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
public B setInitialDelay(long j, TimeUnit timeUnit) {
|
|
Intrinsics.checkNotNullParameter(timeUnit, "timeUnit");
|
|
this.workSpec.initialDelay = timeUnit.toMillis(j);
|
|
if (Long.MAX_VALUE - System.currentTimeMillis() <= this.workSpec.initialDelay) {
|
|
throw new IllegalArgumentException("The given initial delay is too large and will cause an overflow!".toString());
|
|
}
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
@RequiresApi(26)
|
|
public B setInitialDelay(Duration duration) {
|
|
Intrinsics.checkNotNullParameter(duration, "duration");
|
|
this.workSpec.initialDelay = DurationApi26Impl.toMillisCompat(duration);
|
|
if (Long.MAX_VALUE - System.currentTimeMillis() <= this.workSpec.initialDelay) {
|
|
throw new IllegalArgumentException("The given initial delay is too large and will cause an overflow!".toString());
|
|
}
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
@SuppressLint({"MissingGetterMatchingBuilder"})
|
|
public B setExpedited(OutOfQuotaPolicy policy) {
|
|
Intrinsics.checkNotNullParameter(policy, "policy");
|
|
WorkSpec workSpec = this.workSpec;
|
|
workSpec.expedited = true;
|
|
workSpec.outOfQuotaPolicy = policy;
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
public final W build() {
|
|
W buildInternal$work_runtime_release = buildInternal$work_runtime_release();
|
|
Constraints constraints = this.workSpec.constraints;
|
|
boolean z = constraints.hasContentUriTriggers() || constraints.requiresBatteryNotLow() || constraints.requiresCharging() || constraints.requiresDeviceIdle();
|
|
WorkSpec workSpec = this.workSpec;
|
|
if (workSpec.expedited) {
|
|
if (!(!z)) {
|
|
throw new IllegalArgumentException("Expedited jobs only support network and storage constraints".toString());
|
|
}
|
|
if (workSpec.initialDelay > 0) {
|
|
throw new IllegalArgumentException("Expedited jobs cannot be delayed".toString());
|
|
}
|
|
}
|
|
if (workSpec.getTraceTag() == null) {
|
|
WorkSpec workSpec2 = this.workSpec;
|
|
workSpec2.setTraceTag(WorkRequest.Companion.deriveTraceTagFromClassName(workSpec2.workerClassName));
|
|
}
|
|
UUID randomUUID = UUID.randomUUID();
|
|
Intrinsics.checkNotNullExpressionValue(randomUUID, "randomUUID()");
|
|
setId(randomUUID);
|
|
return buildInternal$work_runtime_release;
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
@VisibleForTesting
|
|
public final B setInitialState(WorkInfo.State state) {
|
|
Intrinsics.checkNotNullParameter(state, "state");
|
|
this.workSpec.state = state;
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
@VisibleForTesting
|
|
public final B setInitialRunAttemptCount(int i) {
|
|
this.workSpec.runAttemptCount = i;
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
@VisibleForTesting
|
|
public final B setLastEnqueueTime(long j, TimeUnit timeUnit) {
|
|
Intrinsics.checkNotNullParameter(timeUnit, "timeUnit");
|
|
this.workSpec.lastEnqueueTime = timeUnit.toMillis(j);
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
@VisibleForTesting
|
|
public final B setScheduleRequestedAt(long j, TimeUnit timeUnit) {
|
|
Intrinsics.checkNotNullParameter(timeUnit, "timeUnit");
|
|
this.workSpec.scheduleRequestedAt = timeUnit.toMillis(j);
|
|
return getThisObject$work_runtime_release();
|
|
}
|
|
}
|
|
|
|
public static final class Companion {
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public final String deriveTraceTagFromClassName(String str) {
|
|
List split$default;
|
|
String str2;
|
|
String take;
|
|
split$default = StringsKt__StringsKt.split$default((CharSequence) str, new String[]{Consts.STRING_PERIOD}, false, 0, 6, (Object) null);
|
|
if (split$default.size() == 1) {
|
|
str2 = (String) split$default.get(0);
|
|
} else {
|
|
str2 = (String) CollectionsKt___CollectionsKt.last(split$default);
|
|
}
|
|
if (str2.length() <= 127) {
|
|
return str2;
|
|
}
|
|
take = StringsKt___StringsKt.take(str2, 127);
|
|
return take;
|
|
}
|
|
}
|
|
}
|