This stuff drives me so mad. I recently have noticed higher than usual over-night drain on my phone and decided to investigate a bit. So I connected my phone to my machine, closed out all the apps waited a few seconds and ran adb shell top with a few parameters to see what is actually running.

And would you look at that, despite the phone telling me that nothing is running at all, the microsoft copilot, ebay kleinanzeigen (a german craigslist), google photos and google search either have not been closed or somehow started themselves. Also I have not received any notifications for these Apps in the last few seconds.

First of all, how are these Apps even doing it? With the two Google Apps I kinda get it, since they are System Apps, but in the case of ebay Kleinanzeigen and microsoft copilot it makes 0 sense since they are regular 3rd party Apps. How can they bypass seemingly all optimizations and start themselves (I haven’t used the Microsoft copilot app in months). Also is there any way to prevent this from happening or at the very least get some kind of summary how often these Apps ran in the background. Sadly the Android battery information page is totally useless. With many of these Apps I don’t care about notifications or anything and I never want them to run after I close them in the task manager.

  • Skull giver
    link
    fedilink
    English
    44
    edit-2
    17 days ago

    Android starts apps whenever a broadcast receiver for them gets triggered, unless the app crashed. Broadcast receivers can be messages exchanged between apps, connection events, battery charge events, you name it. Anything the OS might want to update an app for may cause a broadcast event. You cannot disable this mechanism; it’s the reason Android can put apps to sleep for days and still have them respond to important events as if they’re constantly running in the background without actually wasting any CPU on them.

    Most of the time, you don’t want to kill these background tasks. If they’re doing something for more than a few seconds, they’ll need to show a notification (though you won’t see that if you’ve hidden notifications from the app). Killing them will only make the phone restart them the next time an event they’re subscribed to gets triggered, which will cost you CPU time. Force stopping apps may stop services from randomly restarting, but if a notification comes in, the app may get started again.

    To figure out battery drain, check the battery stats in the settings first. That should show you what apps have been active in the foreground/background for how long.

    If that fails, you can start doing a deep dive into Battery Historian and its successors.

    Also make sure you exit any terminal sessions on your phone, if you use them, because terminal emulators often keep a wakelock, which might let the screen turn off but leave the phone running (so the commands don’t get killed when the phone goes to sleep).

    Based on the screenshot you showed, most of the CPU time seems to have gone into the Android system itself (system_server, your launcher, and so on). If you use any widgets, try removing those. Maybe also check if the launcher throws any errors. A simple adb logstat *:E should give a (long) overview of crashes and errors your phone is running into. Some of them may be unimportant, others could be the reason your phone got drained.

    • Avid Amoeba
      link
      fedilink
      English
      7
      edit-2
      16 days ago

      In addition, apps schedule background work through WorkManager or JobScheduler or AlarmManager. Those can wake the app up at specific times designated to do this work. E.g. every X minutes when the screen is off.

      Android has never had the same application execution model as traditional OSes. Both for foreground and background work. This allows it to scale multitasking with the available resources, mostly RAM, without losing app/user data. In other words Android can work on a 512MB RAM device or 8GB device and the only obvious difference would be how many apps are kept in memory. No data will be lost in either case due to apps getting evicted out of RAM. I typically give a 3-hour lecture to my interns on this because they need to know the details but that’s what it boils down to. 😂

    • @aluminiumOP
      link
      English
      417 days ago

      Thanks a lot for the detailed explanation. If I understand it correctly, there is no way to really prevent these Apps from “running” in the background, although “running” just means they sit idle in memory 99.9% of time and don’t do anything unless a broadcast event they are subscribed to gets fired and then they are permitted to do small task.

      So I guess the most likely issue is that either something else on the phone is causing this drain or that some App constantly gets restarted (which is expensive) for some reason instead of just staying idle in memory.

      • Skull giver
        link
        fedilink
        English
        217 days ago

        I’ve had the similar problem on an old tablet running a custom ROM. I believe this was caused by either a kernel bug or some other low-level performance bottleneck in the filesystem. None if the user accessible stats showed why the tablet was constantly running hot and slow as hell. The only fix I’ve found was a factory reset. I don’t know what got corrupted, but I found debugging not to be worth it.

        My guess is that a system component has a bug and is in some sort of a crash/retry loop.

        Another thing you can try, that I just thought of, is to look in the battery stats and look for wake locks. Applications can tell the OS not to go into deep sleep (for instance, a media player may want to keep running after you turn off the screen) and sometimes buggy apps can keep their wakelocks unintentionally. Dumping the wakelocks may help figure out if an app is keeping the device awake for no reason

      • kali
        link
        fedilink
        217 days ago

        You don’t use the Mull browser do you? That caused this issue for me, and I fixed it by uninstalling and switching to another firefox based browser (it was a Mull issue not a firefox issue)

  • @[email protected]
    link
    fedilink
    English
    12
    edit-2
    17 days ago

    And people wonder why I root?

    Its the only realistic way to control broadcast receivers.

    Some apps register for shit like “screen on” or “battery status”, both happen constantly.

    Only other way on a non-rooted phone is to install those apps into the work profile (using an app like Island), and deactivate the work profile when not using those apps.

    • @aluminiumOP
      link
      English
      317 days ago

      thanks, I will give the work profile route a try since I’m not aware of any ways to root my phone (LG G8X)

    • LiveLM
      link
      fedilink
      English
      216 days ago

      And people wonder why I root?

      It’s really maddening having to root just to get a say on what is happening on your device, isn’t it?

      Anyway, what app do you use to control the broadcast receivers?

      • @[email protected]
        link
        fedilink
        English
        214 days ago

        Ugg, right?

        There are lots of them.

        3C Toolbox is probably the easiest to get, but I have a few old ones like Autostarts which may no longer be on Play.

  • Cyborganism
    link
    fedilink
    English
    817 days ago

    Uninstall them maybe? Especially if you don’t use them.

    • @aluminiumOP
      link
      English
      117 days ago

      in the case of the Microsoft copilot app, yes obviously, but there are some Apps which I need like for my bank.

    • @aluminiumOP
      link
      English
      -217 days ago

      deleted by creator

    • @aluminiumOP
      link
      English
      117 days ago

      I have done that but there are certain Services like my Bank or Phone provide that require me to installiert their App. Also with others - Kleinanzeigen, the mobile website is horrible and thus kinda force me to use the App.

  • @[email protected]
    link
    fedilink
    English
    316 days ago

    My samsung S21 has the option to restrict an app and prevent it from ever running in the background, maybe that would do it if your phone has a similar option?

  • @[email protected]
    link
    fedilink
    English
    117 days ago

    I’m in the same boat as you and it drives me up a wall. I’ve found a solution and love getting 2-day battery life out of my 5 year old phone.

    I swear by Greenify and use it religiously. It programmatically force-closes all of your apps that you don’t use, so that they don’t send broadcasts to each other like the other comments mentioned. There are only system apps running on my phone at all times, unless I specifically open other ones.

    With “sensors off” toggled on, no GPS or auto-rotate, the only thing that triggers apps to open is changing networks or receiving a notification.

  • tb_
    link
    English
    116 days ago

    On Samsung I have “deep sleeping apps”, which basically kills any app put on that list when I turn off my phone.

    It will also prevent notifications and such, but it is useful for anything I don’t care running in the background.