1

I wrote an app that needs to wake up once per minute as long as it's running using a broadcast receiver declared in the manifest and triggered by AlarmManager.setAlarmClock() since it's the only exact solution that seems to be working on Android 7+ without restrictions on alarm repetition.

I feel like I've followed literally every hint on the net (and especially SO) to keep my app running, but sooner or later it is moved to doze or hibernation state, even though I whitelisted my app using Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS and I'm using a wake lock inside the receiver when scheduling the next alarm.

The process responsible for "freezing" my app is "ash". Where can I find more information on this process? Is it specific to the manufacturer's OS?

How do I disable dozing / hibernating of my app? I cannot for the life of me get this darn app to keep running continuously. Any hint is appreciated!

The device used is a Huawei P8 lite 2017 with Android 7.0. Since the source code has gotten fairly complex, plus I think I'm doing everything right code-wise, I'm not posting any code here right now. (I will, however, provide the corresponding code samples on request.)

The matter at hand seems to be a general problem of the OS itself, since I read about many people not getting this to work. (Which is ridiculous ... trading the abilitiy to set exact timers for slightly improved battery life. WHY, Google?)

The following catlog output shows the action of "ash"; in this case, it froze my app for about half an hour, after having worked properly for about half an hour also. I guess when I turned on and unlocked the phone again, the app continued working again.

06-06 22:37:33.122 I/ash     ( 1772): de.paulwilhelm.limon send broadcast: notify package: de.paulwilhelm.limon, pid: -1
06-06 22:37:33.122 I/ash     ( 1772): screen off de.paulwilhelm.limon H to D, reason:bc_notify_
06-06 22:37:33.122 I/ash     ( 1772): de.paulwilhelm.limon { hibernation duration=60527 } transition to: doze reason:bc_notify_
06-06 22:37:33.155 I/ash     ( 1772): Unfreeze de.paulwilhelm.limon OK !
06-06 22:37:33.160 I/ash     ( 1772): unproxy de.paulwilhelm.limon broadcast OK !
06-06 22:37:33.167 I/ash     ( 1772): Unpending de.paulwilhelm.limon alarm OK !
06-06 22:37:33.169 I/ash     ( 1772): unproxy app:de.paulwilhelm.limon,uid:10118,result:true
06-06 22:37:33.175 I/ash     ( 1772): front app: de.paulwilhelm.limon goes to H
06-06 22:37:33.176 I/ash     ( 1772): ignore front app :de.paulwilhelm.limon screen off:523907ms
06-06 22:37:33.176 I/ash     ( 1772): de.paulwilhelm.limon  is front app
06-06 22:37:33.176 I/ash     ( 1772): ignore front app :de.paulwilhelm.limon screen off:523907ms
06-06 22:37:33.179 I/ash     ( 1772): de.paulwilhelm.limon { doze duration=10 } transition to: hibernation reason:
06-06 22:37:33.180 I/ash     ( 1772): Pending de.paulwilhelm.limon alarm OK !
06-06 22:37:33.181 I/ash     ( 1772): proxy de.paulwilhelm.limon broadcast OK !
06-06 22:37:33.183 I/ash     ( 1772): proxy app:de.paulwilhelm.limon,uid:10118,result:true
06-06 22:37:33.184 I/ash     ( 1772): Freeze de.paulwilhelm.limon OK !
06-06 22:37:33.185 I/ash     ( 1772): add listener de.paulwilhelm.limon net packet OK !,uid:10118
06-06 22:37:33.188 I/ash     ( 1772): has wakelock app: de.paulwilhelm.limon, uid: 10118
shredEngineer
  • 424
  • 4
  • 9
  • "The device used is a Huawei P8 lite 2017 with Android 7.0" -- try other devices, particularly those with less-modified versions of Android. Huawei in particular is fairly notorious for having more aggressive power-saving stuff. – CommonsWare Jun 07 '18 at 11:23
  • Will do. But is there anything I can do on this very device? Is "ash" configurable as root? Are there any resources on how to patch this thing? -- I also tried using Lineage OS 14.1, but BLE didn't work there so now I'm stuck with the stock ROM again. – shredEngineer Jun 07 '18 at 11:27
  • "But is there anything I can do on this very device?" -- I have no idea, sorry. – CommonsWare Jun 07 '18 at 11:38
  • So finally i got enough repo to post a comment. My answer was deleted, but i want to provide this link https://forum.xda-developers.com/mate-9/how-to/guide-huaweis-background-task-freezer-t3728298 i found for this issue. Maybe it helps you in a way. – Thomas Meinhart Sep 04 '18 at 12:00

1 Answers1

1

As a HUAWEI user myself, I also suffered this process "ash" and hibernation mode. What definitely extended (or probably even solved) is using a foreground service (which is probably what you are doing), raising the importance of your notification to IMPORTANCE_MAX, and most importantly, let HUAWEI manage your app's power manually, by going under Settings --> Battery --> Launch. Find your app there, click on it, open every option (which also includes "Run in background") and let it say "Manage manually".

This is what solved my issue, hopefully it will solve yours too.

Furkan Yurdakul
  • 2,801
  • 1
  • 15
  • 37
  • I did the same thing as you mentioned "Manage manually" and IMPORTANCE_MAX but i am still facing a problem with my app. Huawei hibernates the app for 3000 ms. That's the log which I see before my app service handler stops working: `2020-03-27 12:25:10.405 2172-2197/? I/AppFastHibernation: fast H duration: 3000 reason: start activity` Do you found any solution? for this problem? – Mateen Chaudhry Mar 27 '20 at 07:57