Fixed
Status Update
Comments
su...@google.com <su...@google.com>
su...@google.com <su...@google.com> #2
Thanks for filing the issue.
This is a particularly hard device to come by - do you happen to have access to the device? If so could you provide us with the output of: adb shell dumpsys media.camera > info.txt
Thanks!
This is a particularly hard device to come by - do you happen to have access to the device? If so could you provide us with the output of: adb shell dumpsys media.camera > info.txt
Thanks!
Description
Devices/Android versions reproduced on: Android Emulator api28
I have SyncWorker which I wrap in OneTimeWorkRequest and enqueue by WorkManager but the problem is that this worker is executed only once, no matter how many times I enqueue it.
I create OneTimeWorkRequest.Builder() with common configuration
private val syncWorkBuilder = OneTimeWorkRequest.Builder(SyncWorker::class.java)
.setConstraints(Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build())
.setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 30, TimeUnit.SECONDS)
Then I reuse it by changing some configuration that might wary between invocations and enqueue
fun sync(triggerImmediate: Boolean = false, syncFromScratch: Boolean = false, delay: Int = 0) {
val workManager = WorkManager.getInstance()
if ( workManager == null
|| workManager.getStatusesByTag(SyncWorker.SYNC_FULL_TAG).value
?.find { it.state == State.RUNNING || it.state == State.ENQUEUED } != null) {
return
}
val startDelaySeconds = if (triggerImmediate) 0L else 2L + delay
val syncWork = syncWorkBuilder
.addTag(if (syncFromScratch) SyncWorker.SYNC_INITIAL_TAG else SyncWorker.SYNC_FULL_TAG)
.setInitialDelay(startDelaySeconds, TimeUnit.SECONDS)
.build()
Timber.i("Sync work enqueued $syncWork")
workManager.enqueue(syncWork)
}
It appeared that if I'm not reusing Builder but creating new every time it works fine
I think the problem is in constructor `mId` is crated there and is the same for this instance of builder
public Builder(@NonNull Class<? extends Worker> workerClass) {
mId = UUID.randomUUID();
mWorkSpec = new WorkSpec(mId.toString(), workerClass.getName());
addTag(workerClass.getName());
}