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.4k 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.
      • Mario.CHM Offline
        Mario.CH @c4pp4
        last edited by

        @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)

        šŸ“± Oneplus Nord N100 UT20.40 (OTA5); then Xperia X (since 2020) at last UT 20.04(OTA5), now out of service due to defective camera
        šŸŽ When you realize you are riding a dead horse, get off!
        My languages skill: šŸ‡ØšŸ‡­šŸ‡¦šŸ‡¹ šŸ‡©šŸ‡Ŗ, and only orally: šŸ‡¬šŸ‡§ šŸ‡¹šŸ‡­

        c4pp4C 1 Reply Last reply Reply Quote 1
        • c4pp4C Offline
          c4pp4 @Mario.CH
          last edited by

          @mario-ch Maybe there is no such difference between G3 and G4 consumption.

          KenedaK TotalRandoT 2 Replies Last reply Reply Quote 0
          • KenedaK Offline
            Keneda @c4pp4
            last edited by

            @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.

            2015-2023 : Meizu MX4 ā˜ ļøāš°ļøāœļø
            2023-2024 : Nexus 5 ā˜ ļøāš°ļøāœļø
            2024-***** : FPOS Fairphone 5 waiting UT for freedom šŸ˜‰
            šŸ‡²šŸ‡«šŸ‡¬šŸ‡§

            1 Reply Last reply Reply Quote 1
            • TotalRandoT Offline
              TotalRando @c4pp4
              last edited by TotalRando

              @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.


              Nerd with UT on a OnePlus One. OnePlus 6T waiting in the wings for VoLTE.

              c4pp4C 1 Reply Last reply Reply Quote 0
              • c4pp4C Offline
                c4pp4 @TotalRando
                last edited by

                @totalrando use the walkthrough from the first post, just change variables to:

                primary_preference="lte"
                saving_preference="umts"
                
                1 Reply Last reply Reply Quote 2
                • D Offline
                  davedanger
                  last edited by

                  Script works good running in the terminal but doesn't seem to work when put in upstart

                  c4pp4C 1 Reply Last reply Reply Quote 0
                  • c4pp4C Offline
                    c4pp4 @davedanger
                    last edited by

                    @davedanger What version of UT? There is a regression when using 2G now.

                    D 1 Reply Last reply Reply Quote 0
                    • D Offline
                      davedanger @c4pp4
                      last edited by

                      @c4pp4 I'm using OS Ubuntu 16.04 (2021-09-02/2) on a Pixel 3a

                      c4pp4C 1 Reply Last reply Reply Quote 0
                      • c4pp4C Offline
                        c4pp4 @davedanger
                        last edited by

                        @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"?

                        D 1 Reply Last reply Reply Quote 0
                        • D Offline
                          davedanger @c4pp4
                          last edited by

                          @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.

                          c4pp4C 1 Reply Last reply Reply Quote 0
                          • c4pp4C Offline
                            c4pp4 @davedanger
                            last edited by

                            @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.

                            L.jpg

                            2G.jpg

                            D 1 Reply Last reply Reply Quote 1
                            • D Offline
                              davedanger @c4pp4
                              last edited by

                              @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.

                              1 Reply Last reply Reply Quote 0
                              • KenedaK Keneda referenced this topic on
                              • Y Offline
                                Yoni @c4pp4
                                last edited by

                                @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:
                                badtest.JPG
                                2G with data on:
                                2gbatest.JPG
                                And 4G with data turned off:
                                batest.JPG
                                You can see further details here: https://forums.ubports.com/topic/6971/wifi-mobile-data-on-off-according-to-screen-state/29

                                c4pp4C P 2 Replies Last reply Reply Quote 1
                                • c4pp4C Offline
                                  c4pp4 @Yoni
                                  last edited by c4pp4

                                  @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.

                                  Y 1 Reply Last reply Reply Quote 0
                                  • Y Offline
                                    Yoni @c4pp4
                                    last edited by Yoni

                                    @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)

                                    c4pp4C 1 Reply Last reply Reply Quote 0
                                    • c4pp4C Offline
                                      c4pp4 @Yoni
                                      last edited by c4pp4

                                      @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
                                      
                                      D KenedaK 2 Replies Last reply Reply Quote 1
                                      • D Offline
                                        domubpkm @c4pp4
                                        last edited by

                                        @c4pp4 Hello. I tested your script : it works half for me (Volla OTA-20) ;

                                        1. Cellular data is not disabled when the screen locks (and turns off) AUTOMATICALLY after the inactivity time set in the system settings.

                                        2. 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 šŸ™‚

                                        c4pp4C 1 Reply Last reply Reply Quote 1
                                        • D Offline
                                          domubpkm
                                          last edited by domubpkm

                                          screenshot20211204_085533538.png

                                          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 šŸ˜‰

                                          1 Reply Last reply Reply Quote 1
                                          • KenedaK Offline
                                            Keneda @c4pp4
                                            last edited by

                                            @c4pp4
                                            Could you make an app your scripts ?
                                            I mean a "battery saver" app on openstore would have success šŸ˜‰

                                            2015-2023 : Meizu MX4 ā˜ ļøāš°ļøāœļø
                                            2023-2024 : Nexus 5 ā˜ ļøāš°ļøāœļø
                                            2024-***** : FPOS Fairphone 5 waiting UT for freedom šŸ˜‰
                                            šŸ‡²šŸ‡«šŸ‡¬šŸ‡§

                                            c4pp4C 1 Reply Last reply Reply Quote 1
                                            • c4pp4C Offline
                                              c4pp4 @domubpkm
                                              last edited by

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

                                              1. Cellular data is not disabled when the screen locks (and turns off) AUTOMATICALLY after the inactivity time set in the system settings.

                                              fixed

                                              D 1 Reply Last reply Reply Quote 2
                                              • First post
                                                Last post