質問

I have an android app with the following Alarms setup: Alarm A is of type RTC_WAKEUP, uses the commonsguy wakeful pattern to start a service and repeats on an interval of 1 minute. Alarm B is of type RTC, starts a service and repeats on an interval of 10 seconds.

My questions are as follows:

  1. When the phone goes to sleep, for example it is left unused with screen off overnight, is it guaranteed alarm B will get triggered once every minute throughout the night because alarm A wakes up the device every minute? (Ignore the fact that alarm B might not execute fully to completion because it lacks a wakelock)
  2. Is alarm A likely to cause severe battery drain by waking up so regularly and causing an onslaught of other RTC alarms to be triggered? I guess its dependant on other apps having RTC type alarms but how likely is it that you'd have lots of other apps with RTC alarms?
  3. I've been trying to investigate the battery drain impact of this setup by monitoring the device using Battery Monitor Widget. I first monitor the device for a period of time without the app installed and record the average milliampere during that period. I then run the same test with the app installed and compare the results. But I have a suspicion that the amount of drain is dependent on other apps installed and these apps taking advantage of alarm A regularly waking the device up. Is this correct? Any suggestions on better ways to test this?

Hopefully these are easy questions and thanks in advance!

Dom

役に立ちましたか?

解決

Alarm A is of type RTC_WAKEUP, uses the commonsguy wakeful pattern to start a service and repeats on an interval of 1 minute.

Yuck.

Alarm B is of type RTC, starts a service and repeats on an interval of 10 seconds.

More yuck.

When the phone goes to sleep, for example it is left unused with screen off overnight, is it guaranteed alarm B will get triggered once every minute throughout the night because alarm A wakes up the device every minute? (Ignore the fact that alarm B might not execute fully to completion because it lacks a wakelock)

I would not count on it. I would define this behavior as somewhat indeterminate, due to the frequency of the events and the presumably short time window in which A runs.

Is alarm A likely to cause severe battery drain by waking up so regularly and causing an onslaught of other RTC alarms to be triggered?

I doubt it will be pleasant, though (as above) I don't know about the impact of the RTC alarms. The impact of the work you are doing may make things worse.

But I have a suspicion that the amount of drain is dependent on other apps installed and these apps taking advantage of alarm A regularly waking the device up. Is this correct?

It certainly won't help.

Any suggestions on better ways to test this?

Let it run for a day and see what the battery portion of Settings tells you.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top