2

Is there any way to disable autostart apps at boot time? I need to disable some of them (not all) like Facebook, etc to get quicker boot time. I'm asking how to do this on Android 9.0.

3

Without getting into the details whether or not one should stop autostarting apps, and what could be the consequences as discussed in a plenty of other answers, here are my simple solutions which may work without any third party apps, at least on Android Pie.

ROOT SOLUTION:

Apps use BroadcastRceivers to listen for broadcast ACTION_BOOT_COMPLETED so that they can run on boot. Broadcast receiver is an app component that can be disabled with root privileges.

Using Package Manager list all broadcast receivers listening for BOOT_COMPLETED:

~# pm query-receivers --components -a android.intent.action.BOOT_COMPLETED

It will give a list of broadcast receivers in format package_name/component_name. See dumpsys activity broadcast-stats and dumpsys activity broadcasts for more details.

Now to disable a component:

~# pm disable <package/component>

There are apps like Autostarts (com.elsdoerfer.android.autostarts) and SD Maid (eu.thedarken.sdm) which can do same for you. File /data/system/users/0/package-restrictions.xml can also be edited directly to disable apps or their components, but it's not recommended.
It's possible to disable multiple broadcast receivers of an app, and a single receiver can also possibly listen to multiple types of broadcast events.

NON-ROOT SOLUTION: (non-universal)

In order to receive android.intent.action.BOOT_COMPLETED, apps need android.permission.RECEIVE_BOOT_COMPLETED which is a normal permission and hence can't be revoked by user.

However there is a hidden permission management framework, named AppOps that provides a slightly more fine-grained control of (permission-like) operations. OP_BOOT_COMPLETED is one of those but it's not a part of AOSP, only added by some custom ROMs like LineageOS. If you are on one of such ROMs, you can control the autostart behavior through adb shell:

~$ appops set <package> BOOT_COMPLETED deny

Now the app won't be allowed to receive BOOT_COMPLETED broadcast. There are apps like App Ops (rikka.appops) which can do same for you. Some custom ROMs have built-in front-ends to AppOps with different names like Privacy Guard, AutoStart Manager etc.

Please note that AppOps:

is not generally intended for third party application developers; most features are only available to system applications

So its usage without root may be disallowed or get harder in next Android releases.


Both of the above methods can stop apps from starting on boot only. An app can listen for some other broadcast events too and it can keep on restarting if killed, or run in background continuously (as a service) if it's designed to be so. See dumpsys activity services for more details.

A slightly different approach would be to stop apps from running in background by using OP_RUN_IN_BACKGROUND (introduced in Nougat) and/or RUN_ANY_IN_BACKGROUND (introduced in Pie) which are part of AOSP:

~$ appops set <package> RUN_IN_BACKGROUND deny

They don't have an equivalent manifest permission, but there is an experimental permission with same name.

  • 1
    This question was marked as duplicate but other questions doesn't have good answers as yours. Thanks. I think that AppOps is easy solution. I forgot to add in question, I have rooted my phone. – QkiZ Mar 23 at 10:22
  • @QkiZ yes, provided that your ROM supports it. Or you can go for root option. – Irfan Latif Mar 23 at 12:49
  • since when is pm query-receivers supposed to work? on my Android 7 I get: "Error: unknown command 'query-receivers'" – Frederick Nord Jul 8 at 7:14
  • @FrederickNord seems like this was added in Nougat: android.googlesource.com/platform/frameworks/base/+/…. Also try query-intent-receivers. – Irfan Latif Jul 8 at 7:38
0

Some devices require root access to manage auto start permissions... However Android 5.1 Allows this via Auto Start settings in Security.

  • Open Settings > Security
    security

  • Open Auto Start Settings
    auto

  • Disable the app from Auto Starting
    disable

This option should be available on any system with AppOpps

Also If Not On Android with these settings

  • Open Settings

  • Open Apps

  • Open the desired Application

  • Select Permissions

  • Disable Auto-start permission

  • Which device are you using? I have used stock ROM is Nexus 6 (Android 5.x - 7.x) and OnePlus 6 (Android 8.1) , and I never came across such an option. – Firelord Mar 22 at 21:56
  • @Firelord it's common on custom ROMs to have an AppOps manager builtin. It's not a stock AOSP. – Irfan Latif Mar 23 at 0:04
  • No stock ROM... Not Custom... AppOpps is a part of Stock Androids – Gadget Guru Mar 23 at 6:42
  • Yes, appops is part of AOSP, but that option in the screenshot is not available. That's what I meant. Which device and ROM are you using? – Firelord Mar 23 at 7:06
  • AppOps is part of AOSP, not AppOps managers (GUI). – Irfan Latif Mar 23 at 7:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.