[HowTo] Alternate way of saving battery when using 4G/LTE
-
@mario-ch In case of Xperia X (maybe it's related to Halium 7.1) we have to set it to "lte" option instead of "any", so the script for your needs (3G<->4G) is here:
#!/bin/bash interface=org.freedesktop.DBus.Properties member=PropertiesChanged dbus-monitor --session "type=signal,interface='${interface}',member='${member}'" | while read -r line; do if [[ ${line} == *"com.canonical.UnityGreeter"* ]]; then read && read && read -r line if [[ ${line} == *"IsActive"* ]]; then read -r line [[ ${line} == *"true"* ]] && /usr/share/ofono/scripts/set-tech-preference /ril_0 umts 1>/dev/null [[ ${line} == *"false"* ]] && /usr/share/ofono/scripts/set-tech-preference /ril_0 lte 1>/dev/null fi fi done
-
@jezek said in [HowTo] Alternate way of saving battery when using 4G/LTE:
which handles all the trouble when receiving MMS while cellular data is off
Hello. You done a huge work..! congratulations.
Does it mean that the main purpose of the work is that MMS could be received normally with cellular data OFF ?
-
@domubpkm said in [HowTo] Alternate way of saving battery when using 4G/LTE:
Does it mean that the main purpose of the work is that MMS could be received normally with cellular data OFF ?
No the purpose is to not loose MMS in any cases and being able to download them when data is back on.
You can't receive MMS without data on, no software tweak can change this.
See there if not already done for full story : https://forums.ubports.com/topic/5100/the-mms-lost-story -
It's not a story, it's a ''bible'' (which I hadn't read) like the amount of work (and surely headaches) put in by @jezek .. Yes, the aim is, rather, to have a delayed download (or to be able to delay downloading the MMS) when the cellular data is reactivated which is great. In short, the idea is to ensure that the MMS is not lost. I think it's more exact.
....and this would be good as it would allow the cellular data to be turned off to save battery power and turned back on when needed to download the MMS.
-
@c4pp4
Hello c4pp4,
so, my device has been running with this customization for almost a week now.
Still, I can't say yet if it causes any improvement in battery life.
But for sure I can confirm that it does not contribute to any degradation.
Thank you again.Translated with www.DeepL.com/Translator (free version)
-
@mario-ch Maybe there is no such difference between G3 and G4 consumption.
-
@c4pp4
I don't use the script but i can tell you that there is a big difference on my phone in battery consumption between 3G and 4G. -
@c4pp4 Ok, so just to confirm (because I have already messed up Anbox and will probably have to reinstall anyway just for that), this script defaults to 3G/4G? So it won't go back to 2G? Because that's what I want. It annoys me to have to switch back to 3G/4G every time I turn my phone back on (2G is virtually unusable where I live but if the phone sleeps too long, it's back on 2G.) I only need the last script from before the "note for the further investigation" part? Just copy into a Seabass, save script and run in terminal?
NOTE: I don't care about battery consumption-- my phone is plugged in a lot-- but I do like my calls crystal clear when I dial without having to be like "ugh, it's on 2G again". Also, I can't get MMS on 2G but on 3G/4G, works fine.
-
@totalrando use the walkthrough from the first post, just change variables to:
primary_preference="lte" saving_preference="umts"
-
Script works good running in the terminal but doesn't seem to work when put in upstart
-
@davedanger What version of UT? There is a regression when using 2G now.
-
@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