Assigned
Status Update
Comments
da...@gmail.com <da...@gmail.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
https://android-review.googlesource.com/1123258
https://goto.google.com/android-sha1/b90079595f33f58fece04026a97faa0d243acdb1
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
pm...@google.com <pm...@google.com> #3
ra...@google.com <ra...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-master-dev
commit bdde5a1a970ddc9007b28de4aa29d60ffa588f08
Author: Yigit Boyar <yboyar@google.com>
Date: Thu Apr 16 16:47:05 2020
Re-factor how errors are dismissed when query is re-written
This CL changes how we handle errors/warnings if query is
re-written.
There was a bug in expandProjection where we would report warnings
for things that Room already fixes automatically ( b/140759491 ).
The solution to that problem (I7659002e5e0d1ef60fc1af2a625c0c36da0664d8)
solved it by deferring validating of columns until after re-write
decision is made. Unfortunately, this required changing PojoRowAdapter
to have a dummy mapping until it is validating, make it hard to use
as it does have a non-null mapping which is not useful.
This CL partially reverts that change and instead rely on the log
deferring logic we have in Context. This way, we don't need to break
the stability of PojoRowAdapter while still having the ability to
drop warnings that room fixes. This will also play nicer when we
have different query re-writing options that can use more information
about the query results.
Bug: 153387066
Bug: 140759491
Test: existing tests pass
Change-Id: I2ec967c763d33d7a3ff02c1a13c6953b460d1e5f
M room/compiler/src/main/kotlin/androidx/room/log/RLog.kt
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
https://android-review.googlesource.com/1288456
Branch: androidx-master-dev
commit bdde5a1a970ddc9007b28de4aa29d60ffa588f08
Author: Yigit Boyar <yboyar@google.com>
Date: Thu Apr 16 16:47:05 2020
Re-factor how errors are dismissed when query is re-written
This CL changes how we handle errors/warnings if query is
re-written.
There was a bug in expandProjection where we would report warnings
for things that Room already fixes automatically (
The solution to that problem (I7659002e5e0d1ef60fc1af2a625c0c36da0664d8)
solved it by deferring validating of columns until after re-write
decision is made. Unfortunately, this required changing PojoRowAdapter
to have a dummy mapping until it is validating, make it hard to use
as it does have a non-null mapping which is not useful.
This CL partially reverts that change and instead rely on the log
deferring logic we have in Context. This way, we don't need to break
the stability of PojoRowAdapter while still having the ability to
drop warnings that room fixes. This will also play nicer when we
have different query re-writing options that can use more information
about the query results.
Bug: 153387066
Bug: 140759491
Test: existing tests pass
Change-Id: I2ec967c763d33d7a3ff02c1a13c6953b460d1e5f
M room/compiler/src/main/kotlin/androidx/room/log/RLog.kt
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 7e530b6212687bf2cc8078419bddf5e87fb27fdb
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Tue Jan 21 15:52:11 2020
Write a lint rule which enforces the correct `foregroundServiceType` is specified.
Test: Added lint tests.
Fixes: b/147873061
Change-Id: I58820df9688ea050107d941379c2cd00aa2fd99f
A work/workmanager-lint/src/main/java/androidx/work/lint/SpecifyForegroundServiceTypeIssueDetector.kt
M work/workmanager-lint/src/main/java/androidx/work/lint/WorkManagerIssueRegistry.kt
A work/workmanager-lint/src/test/java/androidx/work/lint/SpecifyForegroundServiceTypeIssueDetectorTest.kt
M work/workmanager-lint/src/test/java/androidx/work/lint/Stubs.kt
M work/workmanager/src/main/AndroidManifest.xml
https://android-review.googlesource.com/1214207
Branch: androidx-master-dev
commit 7e530b6212687bf2cc8078419bddf5e87fb27fdb
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Tue Jan 21 15:52:11 2020
Write a lint rule which enforces the correct `foregroundServiceType` is specified.
Test: Added lint tests.
Fixes:
Change-Id: I58820df9688ea050107d941379c2cd00aa2fd99f
A work/workmanager-lint/src/main/java/androidx/work/lint/SpecifyForegroundServiceTypeIssueDetector.kt
M work/workmanager-lint/src/main/java/androidx/work/lint/WorkManagerIssueRegistry.kt
A work/workmanager-lint/src/test/java/androidx/work/lint/SpecifyForegroundServiceTypeIssueDetectorTest.kt
M work/workmanager-lint/src/test/java/androidx/work/lint/Stubs.kt
M work/workmanager/src/main/AndroidManifest.xml
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.