Skip to content

Commit 70537ee

Browse files
committed
Catch for SecurityException from JobIntentService
* Thrown in rare cases due to know Android issue - https://issuetracker.google.com/issues/63622293 * Fixes issue #673
1 parent bd729fe commit 70537ee

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/JobIntentService.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,17 +333,26 @@ public boolean onStopJob(JobParameters params) {
333333
public JobIntentService.GenericWorkItem dequeueWork() {
334334
JobWorkItem work;
335335
synchronized (mLock) {
336-
if (mParams == null) {
336+
if (mParams == null)
337+
return null;
338+
339+
try {
340+
work = mParams.dequeueWork();
341+
} catch (SecurityException e) {
342+
// Work around for https://issuetracker.google.com/issues/63622293
343+
// https://github.com/OneSignal/OneSignal-Android-SDK/issues/673
344+
// Caller no longer running, last stopped +###ms because: last work dequeued
345+
Log.e(TAG, "Failed to run mParams.dequeueWork()!", e);
337346
return null;
338347
}
339-
work = mParams.dequeueWork();
340348
}
349+
341350
if (work != null) {
342351
work.getIntent().setExtrasClassLoader(mService.getClassLoader());
343352
return new WrapperWorkItem(work);
344-
} else {
345-
return null;
346353
}
354+
else
355+
return null;
347356
}
348357
}
349358

@@ -489,6 +498,7 @@ public IBinder onBind(@NonNull Intent intent) {
489498
@Override
490499
public void onDestroy() {
491500
super.onDestroy();
501+
doStopCurrentWork();
492502
synchronized (mCompatQueue) {
493503
mDestroyed = true;
494504
mCompatWorkEnqueuer.serviceProcessingFinished();

0 commit comments

Comments
 (0)