UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login
    1. Home
    2. c4pp4
    3. Best
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 125
    • Groups 0

    Posts

    Recent Best Controversial
    • [HowTo] Alternate way of saving battery when using 4G/LTE

      What it does:

      1. Script I: Switch to 2G when screen is locked and switch back to 4G when screen is unlocked. TELEports or Dekko notifications work well.
      2. Alternative script II: Switch to 2G when screen is off and switch back to 4G when screen is on (regardless of screen lock). TELEports or Dekko notifications work well.
      3. Alternative script III: Turn off cellular data when screen is off and turn on cellular data again when screen is on (regardless of screen lock). No TELEports or Dekko notifications when screen is off.

      Precondition: Working 4G connection which drains battery when device is inactive (screen is locked or off).
      Originally made for Xiaomi Mi A2 and tested on it but can be useful for any device.


      Create a script "/home/phablet/lte-battery-saver"
      Script I:

      #!/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.canonical.UnityGreeter"* ]]; 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
      

      Make script executable

      chmod u+x /home/phablet/lte-battery-saver
      

      Create an upstart session job "/home/phablet/.config/upstart/lte-battery-saver.conf"

      description "LTE battery saver"
      
      start on started dbus
      stop on stopped dbus
      
      exec /home/phablet/lte-battery-saver
      

      Start the job

      start lte-battery-saver
      

      or reboot the phone.


      NOTES (Script I and Alternative script II):

      • Change "/ril_0" to "/ril_1" if your data SIM is in slot 2 (see sim_slot variable)
      • If switching back doesn't work, try to set primary_preference variable to "any"
      • To switch between 3G and 2G replace "lte" with "umts" (see primary_preference variable)
      • To switch between 4G and 3G replace "gsm" with "umts" (see saving_preference variable)

      To apply the changes, restart the job

      restart lte-battery-saver
      

      or reboot the phone.


      To remove all changes

      stop lte-battery-saver
      rm /home/phablet/.config/upstart/lte-battery-saver.conf
      rm /home/phablet/lte-battery-saver
      

      Alternative script II:

      #!/bin/bash
      
      primary_preference="lte"
      saving_preference="gsm"
      sim_slot="/ril_0"
      
      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
      		/usr/share/ofono/scripts/set-tech-preference "${sim_slot}" "${saving_preference}" 1>/dev/null
      	elif [[ ${line} == *"int32 1" ]]; then
      		read
      		/usr/share/ofono/scripts/set-tech-preference "${sim_slot}" "${primary_preference}" 1>/dev/null
      	fi
      done
      

      Alternative script III:

      #!/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
      
      posted in Support
      c4pp4C
      c4pp4
    • [HowTo] Using Anbox manually to reduce battery drain

      I. Disable Anbox via anbox-tool:

      anbox-tool disable
      

      or make it disabled manually:

      rm /home/phablet/anbox-data/.enable
      stop anbox-session
      sudo stop anbox-container
      

      or alternatively configure Upstart to ignore the start on / stop on stanzas:

      sudo mount -o remount,rw /
      echo "manual" | sudo tee /etc/init/anbox-container.override
      echo "manual" | sudo tee /usr/share/upstart/sessions/anbox-session.override
      sudo sync
      sudo mount -o remount,ro /
      stop anbox-session
      sudo stop anbox-container
      

      II. Remove Anbox icons:

      rm /home/phablet/.local/share/applications/anbox-*
      

      III. Create start script:

      #!/bin/bash
      sudo start anbox-container
      start anbox-session
      

      and stop script:

      #!/bin/bash
      stop anbox-session
      sudo stop anbox-container
      rm /home/phablet/.local/share/applications/anbox-*
      

      IV. Start or stop Anbox:

      bash <nameofscript>
      
      posted in Support
      c4pp4C
      c4pp4
    • RE: One method to encrypt /home/phablet

      @ernest said in One method to encrypt /home/phablet:

      Seems that lightdm doesn't restart with the latest OTA. Any tips ?

      Hi, I'm using the following script (tested on OTA-15 and OTA-16 devel):

      #!/bin/bash
      if ! dpkg-query -l cryptsetup | grep ^ii 1>/dev/null; then
      	mount -o remount,rw /
      	apt-get update && \
      	apt-get -y install cryptsetup
      	sync
      	mount -o remount,ro /
      fi
      
      cryptsetup luksOpen /home/phablet.img phablet
      e2fsck /dev/mapper/phablet
      mount /dev/mapper/phablet /home/phablet && \
      nohup /etc/init.d/lightdm force-reload </dev/null >/dev/null 2>&1 &
      

      run as root: sudo bash <nameofscript>

      posted in Support
      c4pp4C
      c4pp4
    • RE: Sony Xperia X (suzu/F5121 & F5122)

      @japsi said in Sony Xperia X (suzu/F5121 & F5122):

      As I see that Anbox should work in X is there any instructions how to install it? It's not on "supported devices" list yet.

      Just follow http://docs.ubports.com/en/latest/userguide/dailyuse/anbox.html and skip "flash a specific boot image" step.

      In my case (F5122) it works. I used UT Terminal app:

      sudo mount -o rw,remount /
      sudo apt update
      sudo apt install anbox-ubuntu-touch
      anbox-tool install
      sudo apt install android-tools-adb
      sudo mount -o ro,remount /
      cd /home/phablet/Downloads
      wget https://f-droid.org/FDroid.apk
      adb install FDroid.apk
      

      and reboot... (not sure if it's needed)

      There is no sound by default, see https://github.com/anbox/anbox/issues/904. You need to override system/etc/media_codecs.xml file. I was trying to figure it out via rootfs-overlay (https://docs.anbox.io/userguide/advanced/rootfs_overlay.html) with no luck. I repacked android.img with fixed media_codecs.xml file and now there is a sound and even choppy video via NewPipe app. I used this fixed media_codecs.xml file: http://dpaste.com/2H2CP58, it's all in one from these files: https://github.com/anbox/anbox/tree/master/android/media because "Include" and "Included" tags don't work yet.

      Is there a way to apply anbox rootfs-overlay?

      posted in Sony Xperia X (F5121 & F5122)
      c4pp4C
      c4pp4
    • RE: Icon Library

      I have given a try (OSM Scout Server icon):

      osmscout-server.svg
      https://dpaste.com/DG5BG4GEX

      scout.png

      posted in Design
      c4pp4C
      c4pp4
    • RE: App menu double entries w/Anbox

      Try to refresh the Drawer by pulling down and releasing.

      posted in Support
      c4pp4C
      c4pp4
    • RE: Sony Xperia X (suzu/F5121 & F5122)

      @henri2h You can't modify the file directly, it's Squashfs filesystem (see https://en.wikipedia.org/wiki/SquashFS). The best way to override it is via rootfs-overlay as I wrote.

      To repack the image, you need some linux distro. Download the right android filesystem image from https://cdimage.ubports.com/anbox-images/. According to https://cdimage.ubports.com/anbox-images/devices.json it's android-armhf-64binder.img. You also need to have installed squashfs-tools package.

      Uncompress the filesystem as root to keep uid and gid identities:

      sudo unsquashfs android-armhf-64binder.img
      

      you will see something like this:

      Parallel unsquashfs: Using 4 processors
      1429 inodes (5270 blocks) to write
      
      [=================================-] 5270/5270 100%
      
      created 1239 files
      created 274 directories
      created 190 symlinks
      created 0 devices
      created 0 fifos
      

      it creates squashfs-root folder, locate squashfs-root/system/etc/media_codecs.xml file, rewrite it (as root) by the fixed one (http://dpaste.com/2H2CP58) and set the right owner:

      sudo chown 100000:100000 media_codecs.xml
      

      compress the filesystem into android.img:

      sudo mksquashfs squashfs-root/ android.img -noappend -no-xattrs -comp xz
      

      you will see something like this:

      Parallel mksquashfs: Using 4 processors
      Creating 4.0 filesystem on android.img, block size 131072.
      [=================================\] 5080/5080 100%
      
      Exportable Squashfs 4.0 filesystem, xz compressed, data block size 131072
      	compressed data, compressed metadata, compressed fragments,
      	no xattrs, compressed ids
      	duplicates are removed
      Filesystem size 212128.35 Kbytes (207.16 Mbytes)
      	39.95% of uncompressed filesystem size (531034.87 Kbytes)
      Inode table size 23934 bytes (23.37 Kbytes)
      	33.61% of uncompressed inode table size (71204 bytes)
      Directory table size 16322 bytes (15.94 Kbytes)
      	43.33% of uncompressed directory table size (37666 bytes)
      Number of duplicate files found 38
      Number of inodes 1703
      Number of files 1239
      Number of fragments 229
      Number of symbolic links  190
      Number of device nodes 0
      Number of fifo nodes 0
      Number of socket nodes 0
      Number of directories 274
      Number of ids (unique uids + gids) 4
      Number of uids 2
      	unknown (100000)
      	unknown (101000)
      Number of gids 4
      	unknown (100000)
      	unknown (102000)
      	unknown (101000)
      	unknown (101003)
      

      Copy the new created android.img file into the phone's home folder into anbox-data and rewrite the original one.

      posted in Sony Xperia X (F5121 & F5122)
      c4pp4C
      c4pp4
    • RE: [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
      
      posted in Support
      c4pp4C
      c4pp4
    • RE: Waydroid reboots my phone connected by wifi

      @stanwood
      Hi, thank you, I talked to him and it looks like there is no problem with missing kernel option. I made an issue: https://github.com/waydroid/waydroid/issues/268

      posted in Waydroid
      c4pp4C
      c4pp4
    • RE: [HowTo] Alternate way of saving battery when using 4G/LTE

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

      primary_preference="lte"
      saving_preference="umts"
      
      posted in Support
      c4pp4C
      c4pp4
    • RE: [HowTo] Alternate way of saving battery when using 4G/LTE

      @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

      posted in Support
      c4pp4C
      c4pp4
    • RE: Camera issues

      First of all - set camera resolution to 4:2 or 4:3. After that switch to video and give it a try.

      posted in Xiaomi Mi A2
      c4pp4C
      c4pp4
    • RE: Clock App Survey

      a) I open the Clock App when I want: alarm
      b) I normally open the Clock App from: indicator-datetime
      c) I think Clock App misses: alarm volume fade in

      d) Clock (the time): 1
      e) World Clock (more than 1 city clock): 1
      f) Alarm (wake me up): 4
      g) Chronometer (timer with laps): 2
      h) Timer (count down): 2

      i) I have been using Ubuntu touch as my main device since: April 2020

      posted in Design
      c4pp4C
      c4pp4
    • RE: [HowTo] Alternate way of saving battery when using 4G/LTE

      @mario-ch Hello,
      what kind of connections are available in your case? I can help you to tweak the script for your needs.

      Anyway to take back the changes, remove both files:

      rm /home/phablet/lte-battery-saver
      rm /home/phablet/.config/upstart/lte-battery-saver.conf
      
      posted in Support
      c4pp4C
      c4pp4
    • RE: Sony Xperia X (suzu/F5121 & F5122)

      Audio is crackling... speakers, headphones... doesn't matter. Is it only in my case?

      posted in Sony Xperia X (F5121 & F5122)
      c4pp4C
      c4pp4
    • RE: Clock App Survey

      c) I think Clock App misses:

      • When you are setting an alarm, I'd like to click on it and set it via num-keyboard. Now it's like playing some kind of roller game. 🙂

      • When the alarm is ringing, I'd like to stop it via 3 seconds of holding the button "OK"

      posted in Design
      c4pp4C
      c4pp4
    • RE: [HowTo] Alternate way of saving battery when using 4G/LTE

      @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

      posted in Support
      c4pp4C
      c4pp4
    • RE: Sony Xperia X (suzu/F5121 & F5122)

      @wdehoog

      This commit brings back almost everything in that commit back, except
      modify it so that it actually respect suspend inhibitions when pressing
      power button.

      posted in Sony Xperia X (F5121 & F5122)
      c4pp4C
      c4pp4
    • RE: Icon Library

      Not sure if it's the right place to ask but can someone please rework OSM Scout Server icon to be a regular square? I think it's pretty ugly now.

      https://github.com/rinigus/osmscout-server/blob/master/icons/osmscout-server.svg

      scout.png

      posted in Design
      c4pp4C
      c4pp4
    • RE: [HowTo] Alternate way of saving battery when using 4G/LTE

      @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
      
      posted in Support
      c4pp4C
      c4pp4