[HowTo] Alternate way of saving battery when using 4G/LTE
-
@c4pp4 I'm using OS Ubuntu 16.04 (2021-09-02/2) on a Pixel 3a
-
@davedanger I think it's Halium 9 device therefore it can be affected by https://github.com/ubports/ubuntu-touch/issues/1816
Would you be more specific what you mean by "doesn't seem to work when put in upstart"?
-
@c4pp4 I mean to have the script run at startup through either nano or chrontab @reboot. When I try "start batterysaver" after reboot, it says it's already running. I think the issue is on my end, because I've also tried running a vpn-autoconnect with the same results. It works fine when I copy/paste into the terminal, but when I nano or chrontab @reboot, the vpn switch automatically moves to "on" every 5 secs as scheduled but immediately fails and turns off. So I'm pretty sure the battery saver script is doing the same thing, trying to work but can't quite execute. Hope this was helpful.
-
@davedanger The command "start batterysaver" starts upstart job after its created, after restart it starts automatically, you don't have to start it manually again - that's why "it's already running" message appears. If you see the "L" icon when the screen is unlocked and "2G" when locked, its working.
-
@c4pp4 I understand that, I only tried to manually start it after reboot because it didn't seem to be working, that's when it said it was already running. And if I copy/paste the script into the terminal it goes to 2g when locked and L when unlocked, no problem. It's just when I try to run it as a startup script, then it's running just not executing, and that's any script, not just this one, and I can't figure out why.
-
-
@c4pp4
Hello c4pp4
I had made some battery tests to see how efficient your method is (I didn't actually use your script), and I had found that going down to 2G does increase battery life but that having the data connection turned off is actually more efficient, and I was wonderring if you are able to create a similar script that could enable/disable the data connection, preferebley without the need to actually unlock the phone, so that when the screen is turned on it will connect to the internet so that communications could come through?
I would had made one myself but I have no idea how to.
Here are the battery tests, starting with 4G with data on:
2G with data on:
And 4G with data turned off:
You can see further details here: https://forums.ubports.com/topic/6971/wifi-mobile-data-on-off-according-to-screen-state/29 -
@yoni said in [HowTo] Alternate way of saving battery when using 4G/LTE:
enable/disable the data connection
Do you mean turn it off at all? No connection to receive a call? What is sim slot number in your case?
without the need to actually unlock the phone
I think that's no problem.
-
@c4pp4
I didn't mean flight mode, rather just to have the mobile data turned on and off accordingf to the screen state if possible, if not then according to the phone being locked/unlocked.
That will be so amzing if you can create such a script!
Sim slot 1 out of 2 (Xiaomi mi A2) -
@Yoni
After all I didn't need to know the sim slot number.
Here is your script for testing:#!/bin/bash interface=com.canonical.Unity.Screen member=DisplayPowerStateChange dbus-monitor --system "type=signal,interface='${interface}',member='${member}'" | while read -r line; do if [[ ${line} == *"int32 0" ]]; then read dbus-send --type=method_call --dest=com.ubuntu.connectivity1 /com/ubuntu/connectivity1/Private org.freedesktop.DBus.Properties.Set string:com.ubuntu.connectivity1.Private string:MobileDataEnabled variant:boolean:false elif [[ ${line} == *"int32 1" ]]; then read dbus-send --type=method_call --dest=com.ubuntu.connectivity1 /com/ubuntu/connectivity1/Private org.freedesktop.DBus.Properties.Set string:com.ubuntu.connectivity1.Private string:MobileDataEnabled variant:boolean:true fi done
-
@c4pp4 Hello. I tested your script : it works half for me (Volla OTA-20) ;
-
Cellular data is not disabled when the screen locks (and turns off) AUTOMATICALLY after the inactivity time set in the system settings.
-
The script works when you MANUALLY lock the phone by pressing the dedicated side switch.
Tested and verified by sending an email to myself: case 1: email received black screen ; case 2: email received only when the screen is turned back on by pressing the side switch, which is normal
-
-
I don't like to press the side switch unnecessarily (so as to save it) to turn off the screen. It make me think that, in my opinion, it lacks the option in the "system" drop down menu: "lock and turn off screen", there is only currently the "lock" option (there is a delay before the screen turns off
), or a small .click program, for example like Lock it : Screen off on android, which would be very useful if a developer is able to build that -
@c4pp4
Could you make an app your scripts ?
I mean a "battery saver" app on openstore would have success -
@domubpkm said in [HowTo] Alternate way of saving battery when using 4G/LTE:
- Cellular data is not disabled when the screen locks (and turns off) AUTOMATICALLY after the inactivity time set in the system settings.
fixed
-
@keneda said in [HowTo] Alternate way of saving battery when using 4G/LTE:
Could you make an app your scripts ?
I'm sorry, I'm not going to do it now. Maybe someone else.
-
@c4pp4 Thank you. It is fully functional now. Mails are retrieved automatically once the screen is turned on and combined with the work of @jezek , any mms not received when the screen is off should also be retrievable (untested) once the screen is turned back on. And that's saving battery: useful script
-
-
@c4pp4 ??? Weird. In any case, for the Volla, it is the cellular data that consumes battery power. And your script can help.
-
@c4pp4
Sorry for the late reply.
I didn't have time to check the script yet, and I'm quite surprised by your results, but I would like to thank you very much for your script!
Are you able to see the signal strengths of 2G and 4G in your area to see if that might account for the lack of battery savings?
As you could see in my test turning off the data in 4G quadrupled my battery life when I manually turned it off. -
@yoni There is no lack of battery savings when on 2G. In my case it saves the battery power when using the first script to switch between 4G and 2G. It doesn't save battery power when I turn cellular data off completely. It's weird and I don't know why.
-
@c4pp4
If you have another Android or iPhone to check the signal strength with the same Sim that you use on your UT, there are apps that can show you the actual reception in dBm, so for me at home 4G is at around -90dBm and 2G is around -70dBm. -