Excessive Alarm Manager wakeups while AlarmManager isn't used in the project
Asked Answered
G

0

9

Google Play Developer Console says:

A signigicant percentage of daily sessions (more than 1.3%) experienced excessive wakeups, thereby placing your app in the lowest 25% of apps for this metric. However, the actual percentage might be lower than 1.3%, the 95% confidence interval is between 0.55% & 11.82%". Displayed for active APKs only.

However AlarmManager isn't used anywhere in the project in the latest app version. What could cause such a warning in the Console except an AlarmManager?

Gumma answered 23/8, 2017 at 11:59 Comment(12)
Any library that you use that uses AlarmManager would count against your app. Also note that waking up the device can be done using other things, such as JobScheduler, holding your own WakeLock, etc.Journey
@ CommonsWare Thank you. 1) How can I know which libraries used in the project use AlarmManager?Gumma
Ask the developers of the libraries. Or, for open source ones, examine the source code of the libraries. You can also use adb shell dumpsys alarm to try to determine if your app has alarms scheduled.Journey
@ CommonsWare Re 2) As far as I understand the following JobScheduler usage doesn't wake up the device, isn't it? JobInfo.Builder builder = new JobInfo.Builder(Constants.JOB_ID, new ComponentName(context, MyJobServiceScheduler.class)); builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) .setMinimumLatency(PERIODICITY_MILLISECONDS) .setPersisted(true) .setRequiresCharging(false); JobScheduler jobScheduler = (JobScheduler) context.getSystemService(android.content.Context.JOB_SCHEDULER_SERVICE); jobScheduler.schedule(builder.build());Gumma
I would not expect that to wake up the device, but the documentation for JobScheduler is fairly limited in this area, so I cannot rule it out. I would expect setOverrideDeadline() to perhaps wake up the device.Journey
@Journey It's strange that all wakeups (or at least the majority of them) are reported from Android 7.1.2. Just in case, can you think of something that could explain it?Gumma
Maybe a library has different behavior on 7.1+, changing the way that it uses AlarmManager. Again, use adb shell dumpsys alarm to try to determine if your app has alarms scheduled.Journey
@Journey Maybe... My app's package name is not present in the adb shell dumpsys alarm results output. Checked several times, on Android 7.1.1 and 5.1.Gumma
Then if the Play Developer Console isn't giving you anything more actionable, your options for identifying the source are kinda limited. You can attempt to use tools like the Battery Historian to make sense of what's going on. Just bear in mind that the output tends to be more at the device level, and so separating your app's effects from those of other apps is difficult.Journey
I'm getting the same reports in the Play Console. Apparently, JobScheduler is itself a client of the AlarmManager API, its alarms appear in the dump. Even if the wakeups are atributed to your app, I think it's a problem in JobScheduler since it should have ensured a proper wekeup schedule.Fredia
@Marko Topolnik Do you use any kind of heartbeat in the project? I mean whether there is a code which is executed periodically to keep something alive and JobScheduler isn't involved in this?Gumma
No, I have nothing but JobScheduler code and I also don't use any frameworks (except for AdMob). One of my jobs has a schedule at one per minute, however on all devices I've analyzed it, the actual schedule is much less frequent---which is precisely the way you're supposed to use the JobScheduler service, stating your wish while it ensures your app behaves well.Fredia

© 2022 - 2024 — McMap. All rights reserved.