Any way to monitor apps that is no longer running in the background then restart it? (phone rooted) - General Questions and Answers

I have used systemizer for the app and it will still stop running from time to time (as evident in output of the command 'ps -ef').
Maybe via cron by following something like this https://stackoverflow.com/questions/16747880/how-to-use-crontab-in-android ?
In my case the package that I want to keep alive all the time is com.surfshark.vpnclient.android . When it stops running in the background, it won't detect network status and enable VPN whenever necessary.
But even after setting autostart to on, exclude this app from battery optimization, and systemizing the app, it still fails to restart itself sometimes after it gets killed.
Any help appreciated !

Related

Explanation of Nougat Battery Consumption and Workarounds for Better Battery Life

Hello guys. This topic is pretty long and it is hard to read all of it but try to read all of it till end.
Well, let me begin. The main problem of the nougat update is the dramatic increase of battery consumption (for me at least) But why this is happening?
Actually this is a matter of battery managers. Huawei had created a great phone but obviously they messed things up in the software side. Google announced "Doze" feature with Marshmallow. If we could have a brief explanation of "what doze is" is it is basically a battery protection policy created by google. In Android, apps have the ability to use what’s called a “wakelock” to prevent your phone from going into a power-saving deep sleep mode. This deep sleep mode usually kicks in when your phone’s screen is off, but that can get in the way of how some apps work. For example, if you’re using a fitness tracker, you don’t want your phone turning off GPS or your accelerometer just because your phone is in your pocket with the screen turned off.
In principle, this is a good concept. Apps keep your phone awake and working when they need to, and let it sleep when they don’t. This is a problem, though, when every developer thinks their app is important enough to keep your phone on all the time. That’s why apps like Facebook kill your battery, even when you’re not using them.
Doze helps solve this problem by periodically blocking wakelocks and shutting off network access if your phone goes unused for a while. It will then periodically allow apps to check in during “maintenance windows” every so often (these windows occur less frequently the longer you don’t use your device). Here is a graphical explanation of how doze works versus time:
http://itresan.com/wp-content/uploads/2016/05/doze-header.jpg
Doze helps solve this problem by periodically blocking wakelocks and shutting off network access if your phone goes unused for a while. It will then periodically allow apps to check in during “maintenance windows” every so often (these windows occur less frequently the longer you don’t use your device)
If we turn back to the main topic, as I mentioned before, Huawei has some difficulties combining it's own features with google's. Huawei has its own battery manager. That's why you are not receiving some notifications from facebook or whatsapp. That is because that freaking battery manager shuts everything off but still, since it has a very poor approach, the system drains battery. It is basically a matter of doze does not kicking in. As you can see, the battery usage when the screen is turned on is about the same. However, the same thing cannot be seem when the screen is off.
So what to do in order to save some juice?
-There is some workarounds for doze kicking in like these ones:
https://play.google.com/store/apps/details?id=com.yirgalab.dzzz
https://play.google.com/store/apps/details?id=com.suyashsrijan.forcedoze
These two apps have different approaches. I prefer ForceDoze as it seems the google's intended way.
I want to highlight this item because this might be the most important thing in this topic. If you don’t do anything with your phone, Doze will still do its job. It runs almost invisibly in the background. Occasionally you’ll get a few messages at once, rather than spread over a few minutes, but for the most part there’s no noticeable change. In other words this is a bit different from the conventional full deep sleep and you do not have to afraid from doze as you do with the full deep sleep.
-DO NOT CLEAN YOUR RAM TOO OFTEN. This will cause closed apps re-open and hence, more cpu usage.
-No! Cleaners, Task managers and other stuff does not work! As I mention before, they even lead more battery consumptions.
-Huawei has poor google service implementations. Even one or two implementation has some bugs that causing battery drain(for example: google backup). Try to turn them off.
-Know when to reboot your phone. Too frequent reboots may do the same thing as you cleaning your ram. However, rebooting cleans app caches so the system will work smoother. Once a week or two weeks is fine I suppose.
Please hit the "Thanks" button if you like and please point out the missing things and if you see a mistake please warn me for correcting it. I hope you liked the topic.
Have a nice day!
Doze is problem for me. I don't have push notification by the night.
darrr1 said:
Doze is problem for me. I don't have push notification by the night.
Click to expand...
Click to collapse
It's probably not because of the doze but the huawei's power manager itself.
Problem starts when phone is not active longer than 2-3 hours. In root I removed phone manager and it did not help fix the push notification problem
darrr1 said:
Problem starts when phone is not active longer than 2-3 hours. In root I removed phone manager and it did not help fix the push notification problem
Click to expand...
Click to collapse
Assuming that you are on huawei release (not los releases), untick your app from close apps after screen lock. Then go to apps, settings, special access, and make the system ignore battery optimizations for the spesific app you want to get notification from.
I did everything what I can without succes.
furkey said:
Assuming that you are on huawei release (not los releases), untick your app from close apps after screen lock. Then go to apps, settings, special access, and make the system ignore battery optimizations for the spesific app you want to get notification from.
Click to expand...
Click to collapse
first thanks for this tip. i hate it that i dont receive whatsapp messenges all the time, i hope it will work now.
BTP:
I assume huawei did not remove "doze" from our firmware, but maybe they replaced it with theire own battery manager?
Is there a complete source for doze, so we can check if everything is there? If yes it should not be that hard to activate doze and deactivate the huawei one.
But i guess we need at least the kernel sources to clear things up?
xtcislove said:
first thanks for this tip. i hate it that i dont receive whatsapp messenges all the time, i hope it will work now.
BTP:
I assume huawei did not remove "doze" from our firmware, but maybe they replaced it with theire own battery manager?
Is there a complete source for doze, so we can check if everything is there? If yes it should not be that hard to activate doze and deactivate the huawei one.
But i guess we need at least the kernel sources to clear things up?
Click to expand...
Click to collapse
Doze is not on kernel level but it is on software level. Programmatically we can activate what is left from doze or at least simulate it. However, if there is a certain need for doze we should cook a whole new rom and yes, it requires open source too.
But, let's clear a thing here: Huawei did not completely removed doze. Actually, I think they can't do that if they wish to use Android. Just some settings of Huawei conflicts with doze and prevent its functioning.
I'm using the honor 9 with emui 5.1 (android 7.0) and screebl (app used to control how and when screen locks/times out) is constantly getting killed. I have added it to ignore(=allow to run) in battery optimization and it's activated as a device administrator. It is not selected to close (power intensive app prompt) or instructed to close when screen goes off. Yet it repeatedly is getting killed - is there something else I need to do? I can't seem to find anything else I can do to stop it from being killed and it's a major nuisance.
antimatter.web said:
I'm using the honor 9 with emui 5.1 (android 7.0) and screebl (app used to control how and when screen locks/times out) is constantly getting killed. I have added it to ignore(=allow to run) in battery optimization and it's activated as a device administrator. It is not selected to close (power intensive app prompt) or instructed to close when screen goes off. Yet it repeatedly is getting killed - is there something else I need to do? I can't seem to find anything else I can do to stop it from being killed and it's a major nuisance.
Click to expand...
Click to collapse
Could you finally solve this?
I also have and Honor 9, and have the same problem with aplicacition radardroid. Is getting killed, and also have all configured to prevent this...
Try by having both in the Settings
-Battery/Close apps after lock screen (uncheck in the list)
-Apps/Settings gear/Special access/Ignore battery optimization (make it allowed)
Thank szgfg,
Both are already well configured, but still closing the app.
mikicl said:
Thank szgfg,
Both are already well configured, but still closing the app.
Click to expand...
Click to collapse
Check also is not being closed by the automatic cleanup (so add it to clean whitelisted apps) and that is not being closed due to high consumption...disable that on battery settings... Let the advertisement but do not let phone administrator close that apps automatically
Enviado desde mi EVA-L09 mediante Tapatalk
Hi jcalderonv74,
Thanks for your answer. I didn't know about the clean whitelisted apps, was a surprise to find it. But unfortunetly, everything was well configured.
Option to avoid being closed due to high consumption was already OK.
So nothing to change, everything was as it has to be. Seems more a software problem in EMUI 5.0
After some days without touching anything in the phone's configuration, finally observed that everything is working fine. All aplications configured keep opened, and it's only Radardroid aplication that sometimes closes alone (only sporadically after a recent update)
Seems more an error in Radardroid aplication that in telephone's software. So I'm not worring more about that.

Customize background process limit

My phone is running lineageos 16.0. Sometimes the touch screen will freeze randomly for a few seconds and it can become extremely annoying. I have found that limiting background processes to 4 in developer options or having the phone being charged removes the issue entirely. Would there be any way I could create a custom background process limit to automatically turn on or off when the phone is disconnected/connected to power?
Set option Limit background process to "No background process" and your phone will work fine, with no hanging problems or no slowness.
Doing so forces Android to stop each process ( read: app ) as soon as it is empty ( that is
when you’re not using the app or any of its services ).
Note that this will also help in saving your battery life, in most cases.
jwoegerbauer said:
Set option Limit background process to "No background process" and your phone will work fine, with no hanging problems or no slowness.
Doing so forces Android to stop each process ( read: app ) as soon as it is empty ( that is
when you’re not using the app or any of its services ).
Note that this will also help in saving your battery life, in most cases.
Click to expand...
Click to collapse
Yes, I am aware of this, though I only want it enabled when my phone is not being charged. Would there be a way to automate this?
All can get automated.
If phone's Android is rooted then you for example can use Tasker app ( or an init.d if Android supports init.d ) to reach your goal.
Road map:
1. Get phone's battery status
2. Depending on this configure Android's LMK
3. Reboot so new LMK's settings get activated
Hello, i know about this command
Code:
service call activity 51 i32 x
Where x is the number of background processes you want.
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

Pixel 4a Android 11 - stop killing/pausing background app ?

Hi all,
I have a Pixel 4a with stock Android 11 (up to date, no root, with Nova Launcher).
I have a rowing machine that comes with an app (ErgData, by concept2) that can connect to the machine via bluetooth or via usb cable: while rowing the app logs the workout data (like pace, heart rate etc).
I wanted to do the following: watch a video while the ErgData app logs my workout, so I started ErgData, connected it to the rower, configured the workout and, once ready to start rowing, I switch to the video player and start rowing.
It worked fine a bunch of times, but one day it stopped working: at the end of the workout (like after 20-30min), when I switch back to ErgData the app is in its default screen (like the one you get at startup) and it has logged nothing. When connecting via bluetooth, the app has also lost the connection to the rower. When connecting via usb the connection is there but the app has still logged nothing.
Things I've done:
disable battery optimization for ErgData, Bluetooth and Bluetooth MIDI
disable adaptive battery
use a different media player (android built-in, VLC)
uninstall / reinstall ErgData
clear Bluetooth storage/cache
disabled "Suspend Execution for Cached App" (developer mode)
No joy.
I tried a different app (ErgZone) and it has the same behavior.
I tried staying with ErgZone foreground for 3min before switching to the video player and in that case, ErgZone logged something, but not the totality of the workout.
So it really seems that somehow, when I switch to the video player, ErgData / ErgZone gets "paused" (killed ? cached ?).
Anything I can try ? Anything the app developers should do to prevent this ?
Thanks !
Sorry for the late response, I normally dont browse this forum. I am rooted and always have been, so all the solution I have used in the past are dependent on root. However, one idea to try is checking if the background app is killed while the phone is plugged into a charger? I know that being plugged in keeps the phone awake even when the screen is off.
HornetMaX said:
So it really seems that somehow, when I switch to the video player, ErgData / ErgZone gets "paused" (killed ? cached ?).
Anything I can try ? Anything the app developers should do to prevent this ?
Click to expand...
Click to collapse
Does the ErgData/Zone app start a persistent notification when recording? That's the way to keep a service running in the background. I had a phone with a tendency to kill anything not in the foreground, but it never killed active apps (including background with persistent notification).
If the app dies despite this, there may be a hint in the logcat. You have to enable developer mode to fetch that.
a1291762 said:
Does the ErgData/Zone app start a persistent notification when recording? That's the way to keep a service running in the background. I had a phone with a tendency to kill anything not in the foreground, but it never killed active apps (including background with persistent notification).
If the app dies despite this, there may be a hint in the logcat. You have to enable developer mode to fetch that.
Click to expand...
Click to collapse
No, ErgData/ErgZone do not have a persistent notification. Guess that's a potential solution then.
At the moment my workaround is to use the "pop-up" feature of VLC so that I have the video on top of the other app (ErgData/ErgZone), so that the other app stays foreground. That works, but it's not a real solution.
Hmm they gave me a beta version of the app with the persistent notification thingy and it works perfectly.

Any reliable way to disable Android 11's "sleep/doze/whatever it's called" when the phone is locked?

Here's my issue. I have a smartwatch that's connected via bluetooth and periodically polls the phone to refresh it's data. If the phone is locked for a few minutes, it stops working. If I simply turn the screen on it starts working fine again. I need to disable this behavior and I don't really care about the impact on battery life
I have completely disabled any battery optimization on the device, running stock kernel. I have tried "dumpsys deviceidle disable".
How can I fix this? Really annoying that android decides to shut down certain background apps on its own without giving me a choice. It looks like it's unrelated to battery optimization. Perhaps there's a separate setting for bluetooth that I'm missing?

Question How to prevent apps from auto starting at boot

Hello,
All is in the topic, I've got an app that starts automatically when my phone is powered on.
It is Aircall, an app I use for passing and receiving calls at work.
I would like this app not to start automatically each time I power on the phone.
Is there a setting for disabling some apps to autostart ? Or an app you can advise ?
Thanks for your help.
Check the app's preferences to see if there are options.
In the Android settings, go to Apps > See All > (your app. eg Air Call) > App battery usage and set it to 'restricted.' This will greatly restrict an app's ability to do many things in the background.
Other than that, you'd have to root your device to get any more control over the app using something like Servicely (Google Play Store), My Android Tools (apkmirror.com), Permission Manager X (fdroid), AppOppsX (fdroid), or Blocker (fdroid) to control the app's broadcast receivers. Apps can choose to respond to various phone states such as when a boot is completed, when network connectivity changes, power is connected/disconnected, etc. It can take some aggressive action to fully prevent an app from always running.
If you're just annoyed by a notification icon in your notification area you can always disable that app's notification so it doesn't appear.
I have tried all of these things to control apps but if apps use a lot of various broadcast receivers they will find ways to keep running. You may find stopping it to have unintended consequences. It being a work app, I'd consider simply disabling the app's notificaiton if it has a persistent notifcation or something. The next step would be to restrict the app as in 2. The most aggressive thing is to root and tinker with its broadcast receivers.
Hello jawz101,
Thank you very much for this very complete answer.
All your precise instructions are very interesting.
I'll have a look at all these solutions.
Thanks again.
I am not sure about straight forward solution. But I would like to use Greenify app. Add apps to it once and run it once everytime you restart your phone.

Categories

Resources