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?

AndrewS
  • 2,679
  • 2
  • 14
  • 23
  • 2
    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. – CommonsWare Aug 23 '17 at 12:02
  • 1
    @ CommonsWare Thank you. 1) How can I know which libraries used in the project use AlarmManager? – AndrewS Aug 23 '17 at 12:15
  • 1
    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. – CommonsWare Aug 23 '17 at 12:16
  • 1
    @ 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());` – AndrewS Aug 23 '17 at 12:18
  • 1
    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. – CommonsWare Aug 23 '17 at 12:20
  • 1
    @CommonsWare 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? – AndrewS Aug 25 '17 at 07:12
  • 1
    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. – CommonsWare Aug 25 '17 at 11:10
  • 1
    @CommonsWare 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. – AndrewS Aug 25 '17 at 13:30
  • 1
    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](https://github.com/google/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. – CommonsWare Aug 25 '17 at 13:34
  • 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. – Marko Topolnik Mar 19 '18 at 06:34
  • @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? – AndrewS Mar 19 '18 at 08:35
  • 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. – Marko Topolnik Mar 19 '18 at 09:21

0 Answers0