File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/common Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import android.content.Context
5
5
import androidx.work.Configuration
6
6
import androidx.work.WorkManager
7
7
import androidx.work.impl.WorkManagerImpl
8
+ import com.onesignal.debug.internal.logging.Logging
8
9
9
10
object OSWorkManagerHelper {
10
11
/* *
@@ -34,11 +35,15 @@ object OSWorkManagerHelper {
34
35
fun getInstance (context : Context ): WorkManager {
35
36
if (! isInitialized()) {
36
37
try {
37
- // Initialization can fail if another thread initializes in the small time gap
38
- // https://android.googlesource.com/platform/frameworks/support/+/60ae0eec2a32396c22ad92502cde952c80d514a0/work/workmanager/src/main/java/androidx/work/impl/WorkManagerImpl.java#177
39
38
WorkManager .initialize(context, Configuration .Builder ().build())
40
39
} catch (e: IllegalStateException ) {
41
- // Admittedly starting to get hacky
40
+ /*
41
+ This catch is meant for the exception -
42
+ https://android.googlesource.com/platform/frameworks/support/+/60ae0eec2a32396c22ad92502cde952c80d514a0/work/workmanager/src/main/java/androidx/work/impl/WorkManagerImpl.java#177
43
+ 1. We lost the race with another call to WorkManager.initialize outside of OneSignal.
44
+ 2. It is possible for some other unexpected error is thrown from WorkManager.
45
+ */
46
+ Logging .error(" OSWorkManagerHelper initializing WorkManager failed: " , e)
42
47
}
43
48
}
44
49
return WorkManager .getInstance(context)
You can’t perform that action at this time.
0 commit comments