Repository navigation
Doesn't appear to work on newer versions of Android #5
Description
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.(DexFile.java:80)
W/System.err( 2380): at dalvik.system.DexFile.(DexFile.java:59)
W/System.err( 2380): at de.florian.processlimit.SetProcessLimitActivity.setProcessLimit(SetProcessLimitActivity.java:57)
W/System.err( 2380): at de.florian.processlimit.BootReceiver.onReceive(BootReceiver.java:20)
W/System.err( 2380): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2631)
W/System.err( 2380): at android.app.ActivityThread.access$1700(ActivityThread.java:154)
W/System.err( 2380): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1388)
W/System.err( 2380): at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 2380): at android.os.Looper.loop(Looper.java:135)
W/System.err( 2380): at android.app.ActivityThread.main(ActivityThread.java:5338)
W/System.err( 2380): at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 2380): at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err( 2380): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:917)
W/System.err( 2380): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
W/System.err( 2380): Caused by: java.io.IOException: Failed to open oat file from dex location '/system/priv-app/Settings.apk'
W/System.err( 2380): ... 16 more
W/System.err( 2380): Caused by: java.io.IOException: Failed to open oat file from /system/priv-app/arm/Settings.odex (error Failed to open oat filename for reading: No such file or directory) (no dalvik_cache availible) and relocation failed.
W/System.err( 2380): ... 16 more
W/System.err( 2380): Caused by: java.io.IOException:
W/System.err( 2380): ... 16 more
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
Activity
tech128 commentedon Nov 11, 2015
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.
Add alternative way of setting process limit
flode commentedon Nov 11, 2015
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.
tvierling commentedon Nov 11, 2015
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.)
brainvision commentedon Nov 21, 2016
@flode hi there.. I have 5.1.1_r1 and I tried to use the alternative (manual) way:
service call activity 51 i32 xwhat 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!
bebo-dot-dev commentedon Feb 17, 2018
The
service call activity 51 i32 xoption is looking very promising here on a Sony Bravia Android TV that at the time of writing runs Android TV 7.0My 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 xdoes 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.
ProgierEugene commentedon Feb 6, 2019
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.
Novosti1 commentedon Oct 19, 2019
Is it working for Android 8 ? Can anyone can confirm ?
service call activity 51 i32 xNovosti1 commentedon Oct 20, 2019
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 ?
ProgierEugene commentedon Oct 27, 2019
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
bebo-dot-dev commentedon Oct 27, 2019
Thank you @ProgierEugene, I don't know how you worked this out but
service call activity 42 i32 xworks for me on my Oreo Android TV. Much appreciated thank you.Mitezuss commentedon Sep 15, 2020
For Android Q is: service call activity 40 i32 x
Novosti1 commentedon Feb 23, 2021
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 )
atonement87 commentedon May 12, 2021
Any idea what's the code for A11? Thanks.
z826540272 commentedon Jul 17, 2021
service call activity 44 i32 x
oldman20 commentedon Jun 17, 2022
But now these links broken, Where can i found "x" number in newer android?
Thanks
oldman20 commentedon Jun 17, 2022
im on android Pie!
Mitezuss commentedon Aug 4, 2022
service call activity 47 i32 X
X = process
nor-ric commentedon Feb 12, 2023
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
oldman20 commentedon Feb 17, 2023
nice to see this process still active in 2023
steadfasterX commentedon Feb 24, 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")
jfaure9 commentedon Jan 1, 2024
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!
steadfasterX commentedon Jan 1, 2024
Thats expected behavior and the reason why I linked the automate flow which can do that on every boot automatically
jfaure9 commentedon Jan 1, 2024
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!
Marcus051333 commentedon Aug 15, 2024
Your Automate flow doesn't work with A13. Could you fix that?
steadfasterX commentedon Sep 16, 2024
yes. added in version6 rn