SetAndroidProcessLimit
SetAndroidProcessLimit copied to clipboard
Doesn't appear to work on newer versions of Android
Well apparently lollipop breaks this app.
I'm running the latest 5.1.1 and it runs, but when it boots and tries to change the limit, it breaks pretty hard.
I/art ( 2380): Late-enabling -Xcheck:jni
I/ActivityManager( 519): Start proc 2380:de.florian.processlimit/u0a25 for broadcast de.florian.processlimit/.BootReceiver
D/de.florian.processlimit( 2380): New limit: 4
W/System.err( 2380): java.io.IOException: Unable to open '/system/priv-app/Settings.apk' : No such file or directory
W/System.err( 2380): at dalvik.system.DexFile.openDexFileNative(Native Method)
W/System.err( 2380): at dalvik.system.DexFile.openDexFile(DexFile.java:295)
W/System.err( 2380): at dalvik.system.DexFile.
I'm pretty sure it's because of the hardcoded /system/priv-app/Settings.apk
That file is now in /system/priv-app/Settings/Settings.apk
Because this issue annoyed me so much, I decided to find a non-code way to set the process limit.
It can be done with root access with a single command.
service call activity 51 i32 x
Where x is the number of background processes you want.
Hopefully you can let people know on the main page here.
If the API changes in the future, it's easy to look it up again.
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4.4_r1/android/app/IActivityManager.java?av=f
Look for the line with SET_PROCESS_LIMIT_TRANSACTION
Then just extrapolate that info to http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/DESIRED_ANDROID_VERSION/android/app/IActivityManager.java?av=f
Replacing DESIRED_ANDROID_VERSION with the version you're interested in.
I added the alternative way to the main page. I don't know why the app doesn't work, there's no hardcoded path to Settings.apk, the system chooses that automatically.
For Tasker users, another app-based mechanism to set this value is via Secure Settings, which does work for me on all of Android 2.3 ... 4.4 as of this writing (I have no 5.x devices to test):
https://play.google.com/store/apps/details?id=com.intangibleobject.securesettings.plugin
The function is Root Actions -> Background App Processes and offers the usual set of default/none/1/2/3/4 options. Secure Settings can be used without Tasker by creating a shortcut, but to run at boot, you need Tasker (or Locale or similar) to use Secure Settings as a plugin, or some other app capable of launching shortcuts at boot to trigger a Secure Settings shortcut action.
(Tasker's profile context for boot-complete is Event -> System -> System Boot. The task it executes should contain an action Plugins -> Secure Settings using the above Secure Settings function.)
@flode hi there.. I have 5.1.1_r1 and I tried to use the alternative (manual) way:
service call activity 51 i32 x
what I don't understand is I have to use 50 or 51.. You also said in fact that we should check SET_PROCESS_LIMIT_TRANSACTION line, and that's what I did, but it reports 50 NOT 51.. I also checked it for the 4.4 and it already was 50..
Did I miss something?
BTW I launched two commands using both 50 both 51 from my terminal and it works great!
service call activity 51 i32 x
@tech128 Many thanks for the command, it works great specially in an init.d script.
Tested on a Lt26i (aka Xperia S), Android 4.1.2 with init.d support.
The service call activity 51 i32 x
option is looking very promising here on a Sony Bravia Android TV that at the time of writing runs Android TV 7.0
My TV is not rooted (I'm not even sure if anyone has found a way to root a Sony Android TV yet) however service call activity 51 i32 x
does appear to be working as expected when executed in an adb shell.
I'm hopeful that I can now find a way to run this in a shell script on boot. Many thanks for this project and special thanks to @tech128 for finding and mentioning this option.
Hi everyone! Unfortunately, "service call activity 51 i32 4" not working on Android Pie, so can anybody help me to make it working? I can't find necessary strings in android pie source code to understand how to modify the command, grepcode.com is down and I can't figure out how to find necessary strings in a new AOSP repository. I'll be very happy if anybody helps me with it, cause I want to enter this value to custom rom of my phone to make one work much smoother, clearly 2gb of RAM is not enough to run Android Pie smooth.
Is it working for Android 8 ? Can anyone can confirm ?
service call activity 51 i32 x
If the API changes in the future, it's easy to look it up again.
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4.4_r1/android/app/IActivityManager.java?av=f
Look for the line with SET_PROCESS_LIMIT_TRANSACTION
Then just extrapolate that info to http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/DESIRED_ANDROID_VERSION/android/app/IActivityManager.java?av=f
### LINKS NOT WORKING, anyone help ?
I can confirm it doesn't work on Android 9. Also tried those links to and they appear dead.
I tried different numbers and found that right number for Oreo is 42 (service call activity 42 i32 x) and for pie is 47 (service call activity 42 i32 x). I usually use 15-18 apps values, it's optimal for both multitasking and interface smoothness
Thank you @ProgierEugene, I don't know how you worked this out but service call activity 42 i32 x
works for me on my Oreo Android TV. Much appreciated thank you.
For Android Q is: service call activity 40 i32 x
service call activity 51 i32 x - Android 7 ( good with 6 also ) service call activity 42 i32 x - Android 8 service call activity 47 i32 x - Android 9 ( not confirmed )
Any idea what's the code for A11? Thanks.
Any idea what's the code for A11? Thanks.
service call activity 44 i32 x
Because this issue annoyed me so much, I decided to find a non-code way to set the process limit.
It can be done with root access with a single command.
service call activity 51 i32 x
Where x is the number of background processes you want.
Hopefully you can let people know on the main page here.
If the API changes in the future, it's easy to look it up again.
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4.4_r1/android/app/IActivityManager.java?av=f
Look for the line with SET_PROCESS_LIMIT_TRANSACTION
Then just extrapolate that info to http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/DESIRED_ANDROID_VERSION/android/app/IActivityManager.java?av=f
Replacing DESIRED_ANDROID_VERSION with the version you're interested in.
But now these links broken, Where can i found "x" number in newer android? Thanks
im on android Pie!
im on android Pie!
service call activity 47 i32 X
X = process
For A11 it's actually 43. I've updated a script to catch the command number for future Android releases: https://stackoverflow.com/a/75424165/16725644
For A11 it's actually 43. I've updated a script to catch the command number for future Android releases: https://stackoverflow.com/a/75424165/16725644
nice to see this process still active in 2023
great stuff here. Accidentally struggled over a problem with a background process limit and wanted to increase it more then the max in developer options.. Thanks all for figuring out the id's and @flode for the initial bring-up.
for those interested I made an Automate flow for that. Currently supports Android 6 - 11 and if someone would tell me the values for Android 12 and 13 I can easily extend it :)
Have fun: https://llamalab.com/automate/community/flows/44550 (Flow name: "Set max background processes")
Hi all,
I'm on Lineage 20/Android 13 and thks to this I managed to determine that the proper code on this level is 44 (@steadfasterX) and thus was able to run the shell command described above using adb.
However, contrary to what I was expecting, the change to the max number of bg processes is NOT persisted (i.e. : on reboot it's back to "standard"): what am I missing? Is this normal?
Thanks in advance for your help!
Thats expected behavior and the reason why I linked the automate flow which can do that on every boot automatically
Thats expected behavior and the reason why I linked the automate flow which can do that on every boot automatically
Oh... My bad. I misunderstood the README and thought the command line method was bypassing the "reset on boot" behavior. Thanks for the automate flow!