Fixed
Status Update
Comments
ki...@google.com <ki...@google.com>
pk...@google.com <pk...@google.com> #2
Some applications might want to have a different behavior. One example would be to use a custom logger, or upload an analytics event when such a case happens.
Adding another example: I'd like to fail fast and crash the application instead of only learning about issues from my users.
al...@google.com <al...@google.com> #3
I was able to write a workaround in the meantime. Sharing it here if it's useful to anyone else:
class FooWorkerFactory : WorkerFactory() {
override fun createWorker(
appContext: Context,
workerClassName: String,
workerParameters: WorkerParameters
): ListenableWorker {
val worker = …
return ThrowExceptionWorker(worker, workerParameters)
}
// Workaround for https://issuetracker.google.com/issues/261190695.
private class LogExceptionsWorker(
private val delegate: ListenableWorker,
workerParams: WorkerParameters,
) : ListenableWorker(delegate.applicationContext, workerParams) {
override fun startWork(): ListenableFuture<Result> {
return delegate.startWork().also { future ->
future.addListener(
{
try {
future.get()
} catch (e: Throwable) {
Timber.e(e, "Failed to run ${delegate::class.qualifiedName}")
}
},
{ it.run() },
)
}
}
}
}
to...@google.com <to...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit 4bdf321dc846ffdf3eacce9689fe735f423bf0fa
Author: Kuan-Ying Chou <kuanyingchou@google.com>
Date: Tue Jan 09 16:43:41 2024
Add custom exception handlers for Workers
Add workerInitializationExceptionHandler and workerExecutionExceptionHandler to Configuration so that users can set global exception handlers to handle exceptions occurred when constructing or executing a ListenableWorker. The handler will be run using Configuration.taskExecutor.
This CL also makes WorkerFactory.createWorkerWithDefaultFallback non-nullable and throws exceptions in more cases so we can pass the underlying exception to the handler. Throwing exceptions in WorkerFactory.createWorker will no longer crash the application in WorkerWrapper, RemoteWorkerWrapper, and ConstraintTrackingWorker and the exception will be intercepted by the handler.
Relnote: Add custom exception handlers for Workers
Bug: 261190695
Test: WorkerWrapperTest.java
Change-Id: Ib1b740f0503757bcc2baa90482a4e7b8d6002ffb
M work/work-multiprocess/src/androidTest/java/androidx/work/multiprocess/TrackingRemoteWorkerFactory.kt
M work/work-multiprocess/src/main/java/androidx/work/multiprocess/RemoteWorkerWrapper.kt
M work/work-runtime/api/current.txt
M work/work-runtime/api/restricted_current.txt
M work/work-runtime/src/androidTest/java/androidx/work/DefaultWorkerFactoryTest.java
M work/work-runtime/src/androidTest/java/androidx/work/impl/WorkerWrapperTest.java
M work/work-runtime/src/androidTest/java/androidx/work/impl/testutils/TrackingWorkerFactory.kt
A work/work-runtime/src/androidTest/java/androidx/work/worker/ExceptionInConstructionWorker.kt
M work/work-runtime/src/androidTest/java/androidx/work/worker/ExceptionWorker.java
M work/work-runtime/src/main/java/androidx/work/Configuration.kt
A work/work-runtime/src/main/java/androidx/work/WorkerExceptionInfo.kt
M work/work-runtime/src/main/java/androidx/work/WorkerFactory.kt
M work/work-runtime/src/main/java/androidx/work/impl/WorkerWrapper.kt
M work/work-runtime/src/main/java/androidx/work/impl/workers/ConstraintTrackingWorker.kt
M work/work-testing/src/main/java/androidx/work/testing/TestListenableWorkerBuilder.java
https://android-review.googlesource.com/2901049
Branch: androidx-main
commit 4bdf321dc846ffdf3eacce9689fe735f423bf0fa
Author: Kuan-Ying Chou <kuanyingchou@google.com>
Date: Tue Jan 09 16:43:41 2024
Add custom exception handlers for Workers
Add workerInitializationExceptionHandler and workerExecutionExceptionHandler to Configuration so that users can set global exception handlers to handle exceptions occurred when constructing or executing a ListenableWorker. The handler will be run using Configuration.taskExecutor.
This CL also makes WorkerFactory.createWorkerWithDefaultFallback non-nullable and throws exceptions in more cases so we can pass the underlying exception to the handler. Throwing exceptions in WorkerFactory.createWorker will no longer crash the application in WorkerWrapper, RemoteWorkerWrapper, and ConstraintTrackingWorker and the exception will be intercepted by the handler.
Relnote: Add custom exception handlers for Workers
Bug: 261190695
Test: WorkerWrapperTest.java
Change-Id: Ib1b740f0503757bcc2baa90482a4e7b8d6002ffb
M work/work-multiprocess/src/androidTest/java/androidx/work/multiprocess/TrackingRemoteWorkerFactory.kt
M work/work-multiprocess/src/main/java/androidx/work/multiprocess/RemoteWorkerWrapper.kt
M work/work-runtime/api/current.txt
M work/work-runtime/api/restricted_current.txt
M work/work-runtime/src/androidTest/java/androidx/work/DefaultWorkerFactoryTest.java
M work/work-runtime/src/androidTest/java/androidx/work/impl/WorkerWrapperTest.java
M work/work-runtime/src/androidTest/java/androidx/work/impl/testutils/TrackingWorkerFactory.kt
A work/work-runtime/src/androidTest/java/androidx/work/worker/ExceptionInConstructionWorker.kt
M work/work-runtime/src/androidTest/java/androidx/work/worker/ExceptionWorker.java
M work/work-runtime/src/main/java/androidx/work/Configuration.kt
A work/work-runtime/src/main/java/androidx/work/WorkerExceptionInfo.kt
M work/work-runtime/src/main/java/androidx/work/WorkerFactory.kt
M work/work-runtime/src/main/java/androidx/work/impl/WorkerWrapper.kt
M work/work-runtime/src/main/java/androidx/work/impl/workers/ConstraintTrackingWorker.kt
M work/work-testing/src/main/java/androidx/work/testing/TestListenableWorkerBuilder.java
ch...@google.com <ch...@google.com>
ap...@google.com <ap...@google.com> #5
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.work:work-multiprocess:2.10.0-alpha02
androidx.work:work-runtime:2.10.0-alpha02
androidx.work:work-testing:2.10.0-alpha02
ap...@google.com <ap...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-master-dev
commit b309cdeb976c33a91306dbc6ff7851398b4f71c6
Author: Winson <chiuwinson@google.com>
Date: Wed Sep 23 10:52:42 2020
Add PackageInfoCompat signature verification APIs
Create methods for retrieving the Signature[] for a package on device,
as well as verifying that a package has a set of certificates.
Checking by app UID is not supported. Callers must use package name.
This is done to ensure the system doesn't arbitrarily choose a package
to check against.
A matchExact parameter is provided to address compatibility for
un-patched devices that are affected by the certificate reference fake
ID vulnerability. For such devices, all certificates of the package
being checked must be verified.
Bug: 159831205
Test: androidx.core.content.pm.PackageInfoCompatSignaturesTest
Test: androidx.core.content.pm.PackageInfoCompatTest
Relnote: "Added PackageInfoCompat#getSignatures for retrieving the
certificate array for a package"
Relnote: "Added PackageInfoCompat#hasSignatures for verifying package
ceritificates"
Change-Id: I8e9a3ece2d45416abbcbaaa0cf2a0485180997d3
M buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt
M core/core/api/current.txt
M core/core/api/public_plus_experimental_current.txt
M core/core/api/restricted_current.txt
M core/core/build.gradle
A core/core/src/androidTest/java/androidx/core/content/pm/PackageInfoCompatHasSignaturesTest.kt
M core/core/src/androidTest/java/androidx/core/content/pm/PackageInfoCompatTest.java
A core/core/src/androidTest/java/androidx/core/util/mockito/CustomMockMaker.kt
A core/core/src/androidTest/java/androidx/core/util/mockito/CustomStackTraceCleaner.kt
A core/core/src/androidTest/resources/mockito-extensions/org.mockito.plugins.MockMaker
A core/core/src/androidTest/resources/mockito-extensions/org.mockito.plugins.StackTraceCleaner
M core/core/src/main/java/androidx/core/content/pm/PackageInfoCompat.java
M settings.gradle
A testutils/testutils-mockito/build.gradle
A testutils/testutils-mockito/src/main/AndroidManifest.xml
A testutils/testutils-mockito/src/main/java/androidx/testutils/mockito/MockitoUtils.kt
https://android-review.googlesource.com/1439137
Branch: androidx-master-dev
commit b309cdeb976c33a91306dbc6ff7851398b4f71c6
Author: Winson <chiuwinson@google.com>
Date: Wed Sep 23 10:52:42 2020
Add PackageInfoCompat signature verification APIs
Create methods for retrieving the Signature[] for a package on device,
as well as verifying that a package has a set of certificates.
Checking by app UID is not supported. Callers must use package name.
This is done to ensure the system doesn't arbitrarily choose a package
to check against.
A matchExact parameter is provided to address compatibility for
un-patched devices that are affected by the certificate reference fake
ID vulnerability. For such devices, all certificates of the package
being checked must be verified.
Bug: 159831205
Test: androidx.core.content.pm.PackageInfoCompatSignaturesTest
Test: androidx.core.content.pm.PackageInfoCompatTest
Relnote: "Added PackageInfoCompat#getSignatures for retrieving the
certificate array for a package"
Relnote: "Added PackageInfoCompat#hasSignatures for verifying package
ceritificates"
Change-Id: I8e9a3ece2d45416abbcbaaa0cf2a0485180997d3
M buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt
M core/core/api/current.txt
M core/core/api/public_plus_experimental_current.txt
M core/core/api/restricted_current.txt
M core/core/build.gradle
A core/core/src/androidTest/java/androidx/core/content/pm/PackageInfoCompatHasSignaturesTest.kt
M core/core/src/androidTest/java/androidx/core/content/pm/PackageInfoCompatTest.java
A core/core/src/androidTest/java/androidx/core/util/mockito/CustomMockMaker.kt
A core/core/src/androidTest/java/androidx/core/util/mockito/CustomStackTraceCleaner.kt
A core/core/src/androidTest/resources/mockito-extensions/org.mockito.plugins.MockMaker
A core/core/src/androidTest/resources/mockito-extensions/org.mockito.plugins.StackTraceCleaner
M core/core/src/main/java/androidx/core/content/pm/PackageInfoCompat.java
M settings.gradle
A testutils/testutils-mockito/build.gradle
A testutils/testutils-mockito/src/main/AndroidManifest.xml
A testutils/testutils-mockito/src/main/java/androidx/testutils/mockito/MockitoUtils.kt
Description
In API 28+,
PackageInfo
hassigningInfo
andsignatures
is deprecated.Add methods to
PackageInfoCompat
to access commonly available signature info in an API independant way.