Assigned
Status Update
Comments
pm...@google.com <pm...@google.com> #3
Thank you for the quick fix.
Is there an ETA for the next release?
Is there an ETA for the next release?
ra...@google.com <ra...@google.com> #4
2.2.0-rc01 should be out this week.
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-master-dev
commit a1957df3709a06f4e6482fb0e4d39ded4f230a70
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Mon Jul 29 09:48:05 2019
Workaround NPE in PersistableBundle.getExtras().
Test: Existing unit tests pass. Ran integration test app.
Fixes: b/138441699
Change-Id: I0b48e0009a7d83c343a3d26112b94c057470c281
M work/workmanager/src/main/java/androidx/work/impl/background/systemjob/SystemJobService.java
https://android-review.googlesource.com/1092870
https://goto.google.com/android-sha1/a1957df3709a06f4e6482fb0e4d39ded4f230a70
Branch: androidx-master-dev
commit a1957df3709a06f4e6482fb0e4d39ded4f230a70
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Mon Jul 29 09:48:05 2019
Workaround NPE in PersistableBundle.getExtras().
Test: Existing unit tests pass. Ran integration test app.
Fixes:
Change-Id: I0b48e0009a7d83c343a3d26112b94c057470c281
M work/workmanager/src/main/java/androidx/work/impl/background/systemjob/SystemJobService.java
an...@google.com <an...@google.com> #6
mu...@gmail.com <mu...@gmail.com> #7
> We will explicitly call it out in the documentation.
I'm experiencing the same issue. I looked at the following doc pages, but didn't find this information:
https://developer.android.com/topic/libraries/architecture/workmanager/advanced/long-running
https://developer.android.com/reference/androidx/work/ListenableWorker#setForegroundAsync(androidx.work.ForegroundInfo)
https://developer.android.com/reference/androidx/work/ForegroundInfo#ForegroundInfo(int,%20android.app.Notification,%20int)
Or did I just miss it?
I'm experiencing the same issue. I looked at the following doc pages, but didn't find this information:
Or did I just miss it?
ra...@google.com <ra...@google.com> #8
We have lint rules that actually enforce this. That's why we did not explicitly call this out.
Can you run ./gradlew :app:lintDebug
to confirm?
mu...@gmail.com <mu...@gmail.com> #9
I'm using version 2.4.0-beta01 of WorkManager. lintDebug doesn't show me any warning about WorkManager.
ra...@google.com <ra...@google.com> #10
Which Studio version are you using? That usually determines if lint rules are correctly picked up.
mu...@gmail.com <mu...@gmail.com> #11
Android Studio 4.0
Build #AI-193.6911.18.40.6514223, built on May 20, 2020
Runtime version: 1.8.0_242-release-1644-b01 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 3987M
Cores: 16
Registry: ide.new.welcome.screen.force=true
Non-Bundled Plugins: PythonCore, com.android.tool.sizereduction.plugin, com.google.services.firebase, org.intellij.plugins.markdown
ey...@gmail.com <ey...@gmail.com> #12
if(androidVersionIsAtLeast(Q)) {
setForeground(
ForegroundInfo(
R.id.notification_id,
notifications.createNotification(),
ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION
)
)
}
else {
setForeground(
ForegroundInfo(
R.id.notification_id,
notifications.createNotification()
)
)
}
I don't get a lint warning for the code above. Using 2.4.0-beta01
Android Studio 4.0
Build #AI-193.6911.18.40.6514223, built on May 20, 2020
Runtime version: 1.8.0_242-release-1644-b3-6222593 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.7.1-050701-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 4012M
Cores: 12
Registry: ide.new.welcome.screen.force=true, debugger.watches.in.variables=false, debugger.showTypes=false
Non-Bundled Plugins: Key Promoter X, org.jetbrains.kotlin, com.developerphil.adbidea, com.squareup.sqldelight, detekt
ra...@google.com <ra...@google.com> #13
Lint does not have a stable API. So depending on the version of Studio & the WorkManager version, it may not run in the IDE. Have you tried running ./gradlew :app:lintnDebug
?
ps...@google.com <ps...@google.com> #14
I have encountered the same issue, lint in the IDE does not report the problem.
However, if I run ./gradlew :app:lintDebug I get this
Error: Missing dataSync foregroundServiceType in the AndroidManifest.xml [SpecifyForegroundServiceType from androidx.work]
ForegroundInfo(1, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC)
I think mentioning it in the doc would be nice.
Description
Version used: 2.2.0-rc04
Devices/Android versions reproduced on: Pixel 4 - Android 10
WorkManager now support long running workers with foreground notification:
And the Javadoc for ForegroundInfo clearly shows that I can specify the foregroundServiceType as I would for a standard foreground service:
Except when I do:
setForegroundAsync(
ForegroundInfo(
NOTIFICATION_ID,
syncNotificationManager.createSyncForegroundNotification(),
ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE
or ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
)
)
from my Work I get this exception as soon as I try to run the work:
java.lang.IllegalArgumentException: foregroundServiceType 0x00000011 is not a subset of foregroundServiceType attribute 0x00000000 in service element of manifest file
at android.os.Parcel.createException(Parcel.java:2075)
at android.os.Parcel.readException(Parcel.java:2039)
at android.os.Parcel.readException(Parcel.java:1987)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6136)
at android.app.Service.startForeground(Service.java:742)
at androidx.work.impl.foreground.SystemForegroundService$1.run(SystemForegroundService.java:118)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:1276)
at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:914)
at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:13964)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2784)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2741)
The reason is that the work library still rely on the service manifest which has no foregroundServiceType attribute specified (0x00000000) and i'm requesting a specific foregroundServiceType (0x00000011).
<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:directBootAware="false"
android:enabled="@bool/enable_system_foreground_service_default"
android:exported="false"
tools:targetApi="n" />
my current workaround is to just copy this in my manifest and add my foregroundServiceType.
I briefly tried and seems like it is working as I want but I'm not sure if this is ok. If this is the correct way it should be documented!
This is what I added to my manifest:
<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:directBootAware="false"
android:enabled="@bool/enable_system_foreground_service_default"
android:exported="false"
android:foregroundServiceType="connectedDevice|dataSync"
tools:targetApi="n" />
I copied yours and added
android:foregroundServiceType="connectedDevice|dataSync"
which is what I needed.