WorkManager throws SecurityException on some Samsung devices

Viewed 524

Description

The WorkManager lib schedules and alarm to track if it was force stopped. This happens in the ForceStopRunnable class (see also: https://android.googlesource.com/platform/frameworks/support/+/a9ac247af2afd4115c3eb6d16c05bc92737d6305/work/workmanager/src/main/java/androidx/work/impl/utils/ForceStopRunnable.java) which will run during initialization of the WorkManager. On some Samsung devices this will trigger a SecurityException, and as far as I know Samsung throws this exceptions when your apps schedules more than 500 alarms. The app isn't full of alarms, so i think FLAG_UPDATE_CURRENT will keep an old instance in memory of the cancelled version. But I haven't been able to reproduce this, and I don't see multiple copies of the alarm scheduled either.

Happens only on SDK 28 and some rare cases on SDK 29

Question

Does anyone else here have the same experience working with the WorkManager Library and knows a way how to reproduce this issue?

Is there a work-around for this issue?

Crashlog

java.lang.SecurityException: at android.os.Parcel.createException (Parcel.java:1966) at android.os.Parcel.readException (Parcel.java:1934) at android.os.Parcel.readException (Parcel.java:1884) at android.app.IAlarmManager$Stub$Proxy.set (IAlarmManager.java:240) at android.app.AlarmManager.setImpl (AlarmManager.java:722) at android.app.AlarmManager.setExact (AlarmManager.java:571) at androidx.work.impl.utils.ForceStopRunnable.setAlarm (ForceStopRunnable.java:292) at androidx.work.impl.utils.ForceStopRunnable.isForceStopped (ForceStopRunnable.java:151) at androidx.work.impl.utils.ForceStopRunnable.forceStopRunnable (ForceStopRunnable.java:169) at androidx.work.impl.utils.ForceStopRunnable.run (ForceStopRunnable.java:101) at androidx.work.impl.utils.SerialExecutor$Task.run (SerialExecutor.java:91) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641) at java.lang.Thread.run (Thread.java:764) Caused by: android.os.RemoteException: at com.android.server.SamsungAlarmManagerService.checkMaliciousAppLocked (SamsungAlarmManagerService.java:333) at com.android.server.AlarmManagerService.setImpl (AlarmManagerService.java:1758) at com.android.server.AlarmManagerService$2.set (AlarmManagerService.java:2100) at android.app.IAlarmManager$Stub.onTransact (IAlarmManager.java:92) at android.os.Binder.execTransact (Binder.java:739)

Source: https://github.com/minvws/nl-covid19-notification-app-android

2 Answers

This usually happens if the application is creating too many alarms. This is not an WorkManager issue.

Related