Status Update
Comments
vk...@google.com <vk...@google.com>
al...@gmail.com <al...@gmail.com> #2
I have read that WorkManager 2.7.0 is needed if an app targets API 31/Android 12, and in order to do that, I have added setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
to my OneTimeWorkRequestBuilder
and added the necessary changes in the AndroidManifest as well. Now running my app I've encountered the following error:
java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Expedited WorkRequests require a ListenableWorker to provide an implementation for `getForegroundInfoAsync()`
So I tried looking up info on how to do implement this, and found no examples available from official Google sources (Github, developers.android.com, changelog, etc), but found this
My question is how do you implement the said getForegroundInfoAsync
for RxWorker
when getForegroundInfoAsync
has to return ListenableFuture<ForegroundInfo
>--reading the docs it seems I have to add Guava to my app to do this? Since the docs for ListenableFuture says to Avoid implementing ListenableFuture from scratch. If you can't get by with the standard implementations, prefer to derive a new Future instance with the methods in Futures or, if necessary, to extend AbstractFuture
.
vk...@google.com <vk...@google.com> #3
I also have tried adding a SettableFuture
but it is annotated with @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
vk...@google.com <vk...@google.com>
sh...@gmail.com <sh...@gmail.com> #4
Nvm, I just annotated my implementation of getForegroundInfoAsync
with @SuppressLint("RestrictedApi")
and created a SettableFuture
. It seems to work well.
al...@gmail.com <al...@gmail.com> #5
You're right, we should add Rx support for this method.
In meanwhile, you can use SettableFuture
and allows you avoid dependency on restricted APIs.
cu...@google.com <cu...@google.com>
cu...@google.com <cu...@google.com>
ap...@google.com <ap...@google.com> #6
Thanks for showing that callback. Honestly this whole getForegroundInfoAsync
is still unclear to me--since I'm using RxWorker, I usually create a notification inside createWork
and when the work is ongoing, I display a notification with progress bar via doOnSubscribe
, something like this:
api.doSomeWork()
.doOnSubscribe {
// display notification with progress bar
setForegroundAsync(ForegroundInfo(notificationId, notificationBuilder.build()))
}
So how getForegroundInfoAsync
fits into this, I don't understand. The effect of implementing getForegroundInfoAsync
is that I actually get two notifications, the one that displays a progress bar that's already full, and another one that's actually updated.
Edit: actually never mind, getForegroundInfoAsync
has nothing to do with having two notifs. Just figured it out and getForegroundInfoAsync
is called before createWork
.
Description
That is an issue because apps will start using it as their default authentication method. This includes the AOSP Settings app, which uses BiometricPrompt to authenticate the user when generating a WiFi QR-Code to share (Wi-Fi DPP). When trying to do so on a locked device with no biometric hardware, simply nothing happens.
I propose that BiometricPrompt should fall back to asking for pin/password/pattern.
Alternatively, a new API could be introduced for prompting the user to authenticate, which would call BiometricPrompt if hardware is present, else direclty show a PIN/password/pattern insertion activity.