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

84 lines
3.9 KiB
Java

package androidx.work.impl.utils;
import androidx.work.WorkInfo;
import androidx.work.WorkQuery;
import androidx.work.impl.WorkManagerImpl;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.utils.futures.SettableFuture;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
import java.util.UUID;
/* loaded from: classes2.dex */
public abstract class StatusRunnable<T> implements Runnable {
private final SettableFuture<T> mFuture = SettableFuture.create();
public ListenableFuture<T> getFuture() {
return this.mFuture;
}
abstract T runInternal();
@Override // java.lang.Runnable
public void run() {
try {
this.mFuture.set(runInternal());
} catch (Throwable th) {
this.mFuture.setException(th);
}
}
public static StatusRunnable<List<WorkInfo>> forStringIds(final WorkManagerImpl workManager, final List<String> ids) {
return new StatusRunnable<List<WorkInfo>>() { // from class: androidx.work.impl.utils.StatusRunnable.1
@Override // androidx.work.impl.utils.StatusRunnable
public List<WorkInfo> runInternal() {
return WorkSpec.WORK_INFO_MAPPER.apply(WorkManagerImpl.this.getWorkDatabase().workSpecDao().getWorkStatusPojoForIds(ids));
}
};
}
public static StatusRunnable<WorkInfo> forUUID(final WorkManagerImpl workManager, final UUID id) {
return new StatusRunnable<WorkInfo>() { // from class: androidx.work.impl.utils.StatusRunnable.2
/* JADX INFO: Access modifiers changed from: package-private */
/* JADX WARN: Can't rename method to resolve collision */
@Override // androidx.work.impl.utils.StatusRunnable
public WorkInfo runInternal() {
WorkSpec.WorkInfoPojo workStatusPojoForId = WorkManagerImpl.this.getWorkDatabase().workSpecDao().getWorkStatusPojoForId(id.toString());
if (workStatusPojoForId != null) {
return workStatusPojoForId.toWorkInfo();
}
return null;
}
};
}
public static StatusRunnable<List<WorkInfo>> forTag(final WorkManagerImpl workManager, final String tag) {
return new StatusRunnable<List<WorkInfo>>() { // from class: androidx.work.impl.utils.StatusRunnable.3
/* JADX INFO: Access modifiers changed from: package-private */
@Override // androidx.work.impl.utils.StatusRunnable
public List<WorkInfo> runInternal() {
return WorkSpec.WORK_INFO_MAPPER.apply(WorkManagerImpl.this.getWorkDatabase().workSpecDao().getWorkStatusPojoForTag(tag));
}
};
}
public static StatusRunnable<List<WorkInfo>> forUniqueWork(final WorkManagerImpl workManager, final String name) {
return new StatusRunnable<List<WorkInfo>>() { // from class: androidx.work.impl.utils.StatusRunnable.4
/* JADX INFO: Access modifiers changed from: package-private */
@Override // androidx.work.impl.utils.StatusRunnable
public List<WorkInfo> runInternal() {
return WorkSpec.WORK_INFO_MAPPER.apply(WorkManagerImpl.this.getWorkDatabase().workSpecDao().getWorkStatusPojoForName(name));
}
};
}
public static StatusRunnable<List<WorkInfo>> forWorkQuerySpec(final WorkManagerImpl workManager, final WorkQuery querySpec) {
return new StatusRunnable<List<WorkInfo>>() { // from class: androidx.work.impl.utils.StatusRunnable.5
/* JADX INFO: Access modifiers changed from: package-private */
@Override // androidx.work.impl.utils.StatusRunnable
public List<WorkInfo> runInternal() {
return WorkSpec.WORK_INFO_MAPPER.apply(WorkManagerImpl.this.getWorkDatabase().rawWorkInfoDao().getWorkInfoPojos(RawQueries.toRawQuery(querySpec)));
}
};
}
}