Skip to content

High number of scheduled alarms drain battery (possibly unnecessarily) #354

Description

@corneliusroemer

(First of all I absolutely love GDH, great app, so grateful you've developed and are maintaining it and that it's open source so I can even tweak if I want!)

I've been tracking down high battery drain on my phone by using adb and Better Battery Stats.

Across all apps, GDH sets the most scheduled alarms: every minute something fires that prevents Android from being able to doze:

This is what dumpsys alarm shows: 837 alarms, 837 of them wakeups, 100% from TimeAlarmReceiver — 49.5/h over 16.9 h, one every 73 s. This is 26% of all alarms on my phone, and this includes CamAPS FX which handles a) reading Dexcom, b) calculating insulin for my pump, c) talking to pump.

  u0a734:de.michelinside.glucodatahandler +53s740ms running, 837 wakeups:
    +53s740ms 837 wakes 837 alarms, last -8m58s957ms:
      *walarm*:de.michelinside.glucodatahandler/.common.tasks.TimeAlarmReceiver

Those alarms are costly because they abort kernel suspends:

 Wakeup reason 304 da9188-rtc: 24m 15s 44ms (121 times) realtime
 Wakeup reason Abort: Device alarmtimer.4.auto failed to suspend: error -16: 3m 31s 605ms (45 times) realtime

Digging a bit further, there seems to be just one source for these alarms:

 RTC_WAKEUP #12: Alarm{6c2eea5 type 0 origWhen 1788004087000 whenElapsed 61128692 de.michelinside.glucodatahandler}
   tag=*walarm*:de.michelinside.glucodatahandler/.common.tasks.TimeAlarmReceiver
   type=RTC_WAKEUP origWhen=2026-08-29 13:48:07.000 window=0 exactAllowReason=permission repeatInterval=0 count=0 flags=0x9
   policyWhenElapsed: requester=+4m1s43ms app_standby=-2m0s859ms device_idle=-- battery_saver=-2m0s859ms
  • type=RTC_WAKEUP — resumes the SoC from suspend
  • window=0 — exact; opts out of coalescing with any other app's alarm
  • exactAllowReason=permission — granted via SCHEDULE_EXACT_ALARM
  • flags=0x9FLAG_STANDALONE (0x1) + FLAG_ALLOW_WHILE_IDLE_COMPAT (0x8), the
    signature of setExactAndAllowWhileIdle
  • device_idle=--Doze applies no deferral at all

Which matches BackgroundTaskService.kt:312:

alarmManager!!.setExactAndAllowWhileIdle(
    AlarmManager.RTC_WAKEUP,
    nextAlarm.timeInMillis,
    pendingIntent!!
)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions