ubports / ubuntu-touch

Ubuntu Touch's issue inbox is now migrated to GitLab.
https://gitlab.com/ubports/ubuntu-touch
1.29k stars 109 forks source link

Mobile data usage monitoring #66

Open Scym1 opened 7 years ago

Scym1 commented 7 years ago

I think being able to monitor mobile data usage would be a great feature. Some people have phone plans with a bandwidth limit. They could see how much data they use and how much they have left for the month.

Mobile data could also automatically turn itself off when you reach an adjustable threshold to make sure the user don't bust his data cap. There could be a warning at 75% usage, 90% and at 100% it turns itself off automatically.

bastos77 commented 7 years ago

+1

Flohack74 commented 7 years ago

We could try to utilize vnstat. I will take a look

Flohack74 commented 7 years ago

@Scym1 Do you think you can use this cmdline to test if it works?

phablet@ubuntu-phablet:~$ vnstat -i wlan0
Database updated: Tue Jun 20 21:04:11 2017

   wlan0 since 06/20/2017

          rx:  776 KiB      tx:  153 KiB      total:  929 KiB

   monthly
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
       Jun '17       776 KiB |     153 KiB |     929 KiB |    0.00 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated        --     |      --     |      --     |

   daily
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
         today       776 KiB |     153 KiB |     929 KiB |    0.10 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated        --     |      --     |      --     |
phablet@ubuntu-phablet:~$ 

We can probably craft an App for that somehow that will do nice GUI stats... and also offer a reset button.

Flohack74 commented 7 years ago

Oki there is already a DBus interface it seems that we can access: https://bugs.launchpad.net/ubuntu/+source/indicator-network/+bug/1287267 - at the end of the conversation. That means we "just" need to write a DBus server service, and a QML client that can talk to it. Sounds easy haha :)

Scym1 commented 7 years ago

My phone had died from the endless reboot problem so I couldn't test it out. It's fixed now. Do you still want me to test the vnstat cmd?

Flohack74 commented 7 years ago

Well I am currently looking for getting vnstat to write the stats to a writable part of the image, will keep you updated...

dpniel commented 6 years ago

We can just write a simple service for this based on QNetworkSession and log RX/TX data for the currently active QNetworkConfiguration and adapt on configuration changes GSM->WLAN etc. QNetworkSession reads from /sys/class/net/$IFACE/statistics/tx_bytes and rx_bytes.

Should be easy enough to come up with a proof of concept for this

dpniel commented 6 years ago

Where would we want this data to be presented?

Flohack74 commented 6 years ago

Hmm good question. I think there are 2 options, either in system settings, network, make a new pane called 'mobile data usage >' which would lead to a statistics breakdown, or we put it in the indicator. But we dont love indicators currently, so maybe just there? Also question is, if we add this only for network data or also wifi.

ellypsis commented 6 years ago

@Flohack74 I know that on android, data usage is log for network data and wifi. Personally, I use only network data log, but it could be useful for those who have limited wifi plans. I agree too with the fact the indicators is not really nice. Maybe the data usage can be integrate only in a new pane as you suggested.

delijati commented 6 years ago

Is there a repo with a pov or something ?

Danfro commented 6 years ago

Hi, providing data usage numbers would be great! I would prefer a new pane as well. Maybe an option can be added for the user to set a threshold for an usage notification?

mattbel10 commented 5 years ago

Hi, I would like only to inform you that I started to bring the data usage monitoring capability to Ubuntu Touch. My attempt exploits the QNetworkConfigurationManager API. The app is named dataMonitor and can be found: ---->dataMonitor at this link. Before me, also @Danfro started a port of this functionality following a different approach; his app is named uStats, which you can find: ---->uStats at this link.

Kind regards,

Matteo