• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
UBports Robot Logo UBports Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

[HowTo] Alternate way of saving battery when using 4G/LTE

Scheduled Pinned Locked Moved Support
89 Posts 16 Posters 28.1k Views 9 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C Offline
      c4pp4 @Yoni
      last edited by 13 Dec 2021, 03:16

      @yoni I'm not expert but I can imagine ubuntu system don't turn off cellular data on android side, so there is no connection within ubuntu, but there is connection in android layer.

      D Y 2 Replies Last reply 13 Dec 2021, 09:14 Reply Quote 0
      • D Offline
        domubpkm @c4pp4
        last edited by 13 Dec 2021, 09:14

        @c4pp4 I'm not an expert too but maybe a total reflash (wipe option) of the smartphone and a reinstallation on a totally clean base would help so as to confirm or not your problem. In any case, in my case I had to do this several times and it solved some instabilities.

        1 Reply Last reply Reply Quote 0
        • Y Offline
          Yoni @c4pp4
          last edited by 13 Dec 2021, 11:31

          @c4pp4
          It definitely turns the data connection off, and it is visible when I checked it with a RF meter.
          Data on (4G):
          UT 4G Data On.JPG
          Data off (4G):
          UT 4G Data Off.JPG
          And it is the reduced transmitions that saves the battery, so your situation does not make sense.

          A 1 Reply Last reply 13 Dec 2021, 13:45 Reply Quote 0
          • A Offline
            AppLee @Yoni
            last edited by 13 Dec 2021, 13:45

            @yoni
            Without the full picture it's hard to judge what makes sense or not.
            The radio is not the only power consumer.
            Depending on the device and the firmware used the behavior can differ.

            Maybe a process is looping to find the modem and prevent the CPU to sleep.
            Maybe also c4pp4's theory is right ; if on Ubuntu Touch's side we kill the data it doesn't kill the modem because you need calls and SMS.
            So depending on vendor's firmware and specific port implementation experience may vary.
            In a port I suppose that turning off the data can be implemented in several different ways with slightly different behaviors.

            Y 1 Reply Last reply 13 Dec 2021, 16:12 Reply Quote 0
            • Y Offline
              Yoni @AppLee
              last edited by 13 Dec 2021, 16:12

              @applee
              Those graphs represent RF activity with and without the data connection, so calls and texts are still available in both scenarios, and on the mi A2 the battery lasted 4 times longer when just the data is turned off, and this principle is the same on Androids and iPhones, but at different battery savings levels.
              There might be something that is causing the cpu to constantly work, thus preventing battery savings, but UT definitely has control over the data connectivity, and it does turn it off.

              A 1 Reply Last reply 13 Dec 2021, 16:32 Reply Quote 0
              • A Offline
                AppLee @Yoni
                last edited by 13 Dec 2021, 16:32

                @yoni
                What I meant is unless you can produce the same graph with C4pp4's device you cannot draw any conclusion on what happens.
                If it's the same model it would be really strange.
                But with another device it's a whole different story.
                No data received by the user (Morph or Teleports for example) does not mean the modem is not working way more than expected.

                Y 1 Reply Last reply 13 Dec 2021, 16:46 Reply Quote 0
                • Y Offline
                  Yoni @AppLee
                  last edited by Yoni 13 Dec 2021, 16:46

                  @applee
                  Both myself and @c4pp4 are using the same device, and @domubpkm also had battery savings using a Volla, there is something starnge happening with c4ppa's phone, and I'm really trying to understand why he is not getting any savings on 4G.

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    domubpkm
                    last edited by 22 Dec 2021, 15:03

                    Redownload mms mecanism works fine on Volla RC 43 : for this feature, thanks to @jezek and @lduboeuf as it is a very usefull nechanism to save battery too !

                    1 Reply Last reply Reply Quote 0
                    • B Offline
                      Bolly
                      last edited by 25 Apr 2022, 17:41

                      Hello @c4pp4,

                      Thank you for the scripts. ♥
                      I found out that if the device doesn't have 4G you have to put "umts" in "primary_preference". (My device is e4.5 - Krillin - )

                      primary_preference="umts"

                      I've taken the liberty of sharing your scripts on my blog to reach more people, I hope you don't mind.

                      https://elcondonrotodegnu.wordpress.com/2022/04/25/scripts-para-ahorrar-bateria-en-ubuntu-touch/

                      Thanks again. 🙂

                      2015-Now (Daily use) : BQ Aquaris E4.5 Ubuntu edition
                      2016-Now (Daily use) : BQ Aquaris M10 FHD Betatester

                      2020-Now : PinePhone Braveheart & CE UBports
                      2020-Now (Family/Daily use): Vollaphone Xenial
                      2022-Now (Family/Daily use): Vollaphone 22 Focal

                      1 Reply Last reply Reply Quote 1
                      • P Offline
                        prog-amateur @Yoni
                        last edited by 4 May 2022, 02:07

                        Hello @c4pp4 thank you VE-RY much for your script. Please, could you edit your 1st post just to inform about the following ?

                        -> Final step : Reboot the phone

                        Reason : I have done the script II and I could not come back to 4G (2G was OK), so I have used the "lte" modification in the script without success. Then I have reboot my phone and the script was working perfectly.

                        @yoni said in [HowTo] Alternate way of saving battery when using 4G/LTE:

                        Here are the battery tests, starting with 4G with data on:
                        badtest.JPG
                        2G with data on:
                        2gbatest.JPG

                        When I see you plots without / with script, it is a day and night ! My Nexus 5 has a battery drain (or the battery is not enough powerful), I just installed the script so I lack of time to feedback but I hope results like yours, it would be wonderful.

                        Again, thank you very much for your kind help, such a topic shall be pinned I think.

                        C 1 Reply Last reply 4 May 2022, 06:37 Reply Quote 0
                        • C Offline
                          c4pp4 @prog-amateur
                          last edited by 4 May 2022, 06:37

                          @prog-amateur said in [HowTo] Alternate way of saving battery when using 4G/LTE:

                          I have used the "lte" modification in the script without success. Then I have reboot my phone and the script was working perfectly.

                          Thank you for the report, you have to use "restart lte-battery-saver" to apply script changes. I will add a note about it. It looks like "lte" is more generic then "any" so I'll change the script.

                          1 Reply Last reply Reply Quote 1
                          • B Br1 referenced this topic on 12 Jun 2022, 06:56
                          • D domubpkm referenced this topic on 31 Oct 2022, 19:29
                          • L Offline
                            lkroll
                            last edited by lkroll 29 Apr 2023, 18:02

                            Battery drain on standby with 4G is still a problem on focal, so I updated the script and created a small systemd service to automatically run the script at startup. Maybe this will be useful for some.


                            The greeter in focal is called "com.lomiri.LomiriGreeter" instead of "com.canonical.UnityGreeter". So i changed that in the script and tested that it indeed still works.

                            I placed the updated script in:
                            /home/phablet/.local/bin

                            #!/bin/bash
                            
                            primary_preference="lte"
                            saving_preference="gsm"
                            sim_slot="/ril_0"
                            
                            interface=org.freedesktop.DBus.Properties
                            member=PropertiesChanged
                            
                            dbus-monitor --session "type=signal,interface='${interface}',member='${member}'" |
                            while read -r line; do
                                    if [[ ${line} == *"com.lomiri.LomiriGreeter"* ]]; then
                                            read; read; read -r line
                                            if [[ ${line} == *"IsActive"* ]]; then
                                                    read -r line
                                                    [[ ${line} == *"true"* ]] && /usr/share/ofono/scripts/set-tech-preference "${sim_slot}" "${saving_preference}" 1>/dev/null
                                                    [[ ${line} == *"false"* ]] && /usr/share/ofono/scripts/set-tech-preference "${sim_slot}" "${primary_preference}" 1>/dev/null
                                            fi
                                    fi
                            done
                            

                            Don't forget to make it executable:

                            chmod u+x /home/phablet/.local/bin/lte-battery-saver.sh
                            

                            Ubuntu 20.04 uses systemd instead of upstart so I created a systemd user service in:
                            /home/phablet/.config/systemd/user/lte-battery-saver.service

                            [Unit]
                            Description=LTE battery saver
                            Requires=dbus.socket
                            After=dbus.socket
                            
                            [Service]
                            ExecStart=/home/phablet/.local/bin/lte-battery-saver.sh
                            
                            [Install]
                            WantedBy=dbus.socket
                            

                            Now to enable the service:

                            systemctl --user enable --now lte-battery-saver
                            

                            Verify that it is running and up:

                            systemctl --user status lte-battery-saver
                            

                            It should return active and enabled:

                            ● lte-battery-saver.service - LTE battery saver
                                 Loaded: loaded (/home/phablet/.config/systemd/user/lte-battery-saver.service; enabled; vendor preset: enabled)
                                 Active: active (running) since Sat 2023-04-29 18:44:27 CEST; 1h 11min ago
                            

                            That's it, now everytime the phone is locked the connection will drop to 2G and back to 4G/LTE once unlocked.
                            I tested and verified it on my Oneplus 5T, but it should work on other devices running focal.

                            A 1 Reply Last reply 19 Sept 2023, 14:47 Reply Quote 4
                            • LuksusL Luksus referenced this topic on 22 May 2023, 07:55
                            • lduboeufL Offline
                              lduboeuf
                              last edited by lduboeuf 9 May 2023, 19:57 4 Sept 2023, 15:41

                              [ Focal only ]
                              If anyone want my dirty hack ( when cellular data off -> then use 2G , when data on -> switch to LTE)

                              You must have a focal device on devel channel, then sudo ubports-qa install focal_-_PR_lomiri-system-settings-cellular_6

                              This will auto toggle LTE when cellular data requested , and back to 2G when off,
                              https://gitlab.com/ubports/development/core/lomiri-system-settings-cellular/-/merge_requests/6

                              ( only work when toggled from the settings, not the indicator )

                              A 1 Reply Last reply 15 Sept 2023, 06:10 Reply Quote 0
                              • A Offline
                                AmauryDBZ @lduboeuf
                                last edited by AmauryDBZ 15 Sept 2023, 06:10

                                @lduboeuf thanks for your 'dirty hack' !
                                after installing it says I have to upgrade, but sudo apt upgrade returns

                                Lecture des listes de paquets... Fait            
                                Construction de l'arbre des dépendances          
                                Lecture des informations d'état... Fait          
                                Calcul de la mise à jour... Fait                 
                                Get more security updates through Ubuntu Pro with 'esm-apps' enabled:                             
                                  libswresample3 libmediainfo0v5 libavcodec58 libavutil56 libopenexr24                            
                                  libsdl2-2.0-0                                  
                                Learn more about Ubuntu Pro at https://ubuntu.com/pro                                             
                                W: Verrou non utilisé pour le fichier /var/lib/dpkg/lock-frontend en lecture seule                
                                W: Verrou non utilisé pour le fichier /var/lib/dpkg/lock en lecture seule                         
                                E: Le répertoire d'archive /var/cache/apt/archives/partial n'existe pas. - Acquire (30: Read-only file system)
                                

                                Any idea how to resolve ?
                                Moreover, is it possible to add an exception when hotspot is on ?

                                lduboeufL 1 Reply Last reply 15 Sept 2023, 07:16 Reply Quote 0
                                • lduboeufL Offline
                                  lduboeuf @AmauryDBZ
                                  last edited by 15 Sept 2023, 07:16

                                  @AmauryDBZ said in [HowTo] Alternate way of saving battery when using 4G/LTE:

                                  @lduboeuf thanks for your 'dirty hack' !
                                  after installing it says I have to upgrade, but sudo apt upgrade returns

                                  Lecture des listes de paquets... Fait            
                                  Construction de l'arbre des dépendances          
                                  Lecture des informations d'état... Fait          
                                  Calcul de la mise à jour... Fait                 
                                  Get more security updates through Ubuntu Pro with 'esm-apps' enabled:                             
                                    libswresample3 libmediainfo0v5 libavcodec58 libavutil56 libopenexr24                            
                                    libsdl2-2.0-0                                  
                                  Learn more about Ubuntu Pro at https://ubuntu.com/pro                                             
                                  W: Verrou non utilisé pour le fichier /var/lib/dpkg/lock-frontend en lecture seule                
                                  W: Verrou non utilisé pour le fichier /var/lib/dpkg/lock en lecture seule                         
                                  E: Le répertoire d'archive /var/cache/apt/archives/partial n'existe pas. - Acquire (30: Read-only file system)
                                  

                                  Any idea how to resolve ?
                                  Moreover, is it possible to add an exception when hotspot is on ?

                                  Well, your device must be up to date before doing any ubports-qa things.
                                  You can either reinstall UT or go by mouting rw the partition and then upgrade.

                                  A 1 Reply Last reply 15 Sept 2023, 07:27 Reply Quote 0
                                  • A Offline
                                    AmauryDBZ @lduboeuf
                                    last edited by 15 Sept 2023, 07:27

                                    @lduboeuf said in [HowTo] Alternate way of saving battery when using 4G/LTE:

                                    by mouting rw the partition and then upgrade.

                                    do you have a tutorial ?

                                    lduboeufL 1 Reply Last reply 15 Sept 2023, 08:02 Reply Quote 0
                                    • lduboeufL Offline
                                      lduboeuf @AmauryDBZ
                                      last edited by 15 Sept 2023, 08:02

                                      @AmauryDBZ said in [HowTo] Alternate way of saving battery when using 4G/LTE:

                                      @lduboeuf said in [HowTo] Alternate way of saving battery when using 4G/LTE:

                                      by mouting rw the partition and then upgrade.

                                      do you have a tutorial ?

                                      Well, if you ask, maybe you don't know the possible consequences ?
                                      If ok then remount rw the partition: sudo mount -o remount,rw /
                                      then sudo apt upgrade

                                      A 1 Reply Last reply 15 Sept 2023, 09:21 Reply Quote 0
                                      • A Offline
                                        AmauryDBZ @lduboeuf
                                        last edited by 15 Sept 2023, 09:21

                                        @lduboeuf you're right I have no idea of what consequence it could have ! Thanks for your help !

                                        To come back on the subject of this topic, would it be possible to add an exception when the hotspot is activated ?

                                        lduboeufL 1 Reply Last reply 15 Sept 2023, 09:35 Reply Quote 0
                                        • lduboeufL Offline
                                          lduboeuf @AmauryDBZ
                                          last edited by 15 Sept 2023, 09:35

                                          @AmauryDBZ said in [HowTo] Alternate way of saving battery when using 4G/LTE:

                                          @lduboeuf you're right I have no idea of what consequence it could have ! Thanks for your help !

                                          To come back on the subject of this topic, would it be possible to add an exception when the hotspot is activated ?

                                          Humm, what would be the bahavior for hotspot, if enable then auto switch to 4G ?

                                          A 1 Reply Last reply 15 Sept 2023, 09:43 Reply Quote 0
                                          • A Offline
                                            AmauryDBZ @lduboeuf
                                            last edited by 15 Sept 2023, 09:43

                                            @lduboeuf I would have say if enable stay on 4G even if the screen shutsdown, but that's the idea.

                                            lduboeufL 1 Reply Last reply 15 Sept 2023, 10:34 Reply Quote 0
                                            • First post
                                              Last post