itsdrnoob / DataMonitor

Data usage monitoring app for android.
GNU General Public License v3.0
528 stars 49 forks source link

Quota in Smart Data Allocation does not seem to be enforced #240

Open lfos opened 2 months ago

lfos commented 2 months ago

Checklist

Affected app version

v2.4.0

Steps to reproduce the bug

  1. Enable Smart Data Allocation with a custom plan. (Other types of plans may or may not trigger the bug too.)
  2. Enable the Daily Quota Alert feature.
  3. Use up data, beyond the daily quota limit.

Expected behavior

An alert is displayed. If I understand the feature correctly, data should also be throttled/limited.

Actual behavior

Neither an alert seems to be triggered, nor does the data get limited, even when going >200% above the displayed quota.

Screenshots/Screen recordings

No response

Logs

No response

Affected Android/Custom ROM version

Android 14

Affected device model

Pixel 7

Additional context

No response

itsdrnoob commented 2 months ago

So I tested this out and it's working as intended on my end.

photo_2024-04-29 15 38 55

Though I've to test it out on an A14 device to confirm this. Can you make sure Data Monitor has alarm permissions? Also, was the device rebooted during this time?

lfos commented 2 months ago

Can you make sure Data Monitor has alarm permissions? Also, was the device rebooted during this time?

Data Monitor notifications are all enabled in app permissions. The device was not rebooted. However, note that I have disabled the Set up notifications setting in the app; should the quota alert still appear? (I would like to disable sticky notification with current data usage.)

Can you also clarify whether reaching the quota should automatically disable/block mobile data to prevent further data consumption?

Thanks for all the work put into this feature; would love to see a few corner cases fixed here, as Smart Data Allocation is one of the main reasons I'd like to use the app, even if beta!

itsdrnoob commented 1 month ago

Data Monitor notifications are all enabled in app permissions. The device was not rebooted.

Is the app excluded from battery optimisation settings? If not this could cause Alarms & Reminders permission to be automatically denied to the app. You can check this in Apps > Special App Access > Alarms & Reminders. Note that if battery optimisation is disabled for Data Monitor, it won't show up in the list.

I've made changes to handle this behaviour in 704eee4 and 67ae965

Can you also clarify whether reaching the quota should automatically disable/block mobile data to prevent further data consumption?

Right now, no, mobile data won't be turned off when the quota is reached; instead, an alert is shown to notify of this.

Thanks for all the work put into this feature; would love to see a few corner cases fixed here, as Smart Data Allocation is one of the main reasons I'd like to use the app, even if beta!

Thanks :)

lfos commented 1 month ago

Is the app excluded from battery optimisation settings? If not this could cause Alarms & Reminders permission to be automatically denied to the app. You can check this in Apps > Special App Access > Alarms & Reminders. Note that if battery optimisation is disabled for Data Monitor, it won't show up in the list.

Thanks! Data Monitor does not show up in that list indeed. How can it be added/enabled?

Can you also clarify whether reaching the quota should automatically disable/block mobile data to prevent further data consumption?

Right now, no, mobile data won't be turned off when the quota is reached; instead, an alert is shown to notify of this.

Thanks for the clarification. Is the plan to add this, eventually? With that, I am also a bit unclear on what the different configuation toggles for Smart Data Allocation do. What happens if I enable Smart Data Allocation but leave daily quota alerts disabled?

itsdrnoob commented 1 month ago

Data Monitor does not show up in that list indeed. How can it be added/enabled?

If Data Monitor is not in the list, then battery optimisation must be disabled for the app which automatically grants the Alarms & Reminders permission.

Is the plan to add this, eventually?

I'm not planning on adding this to Daily quota alert itself but maybe I can look into adding an additional toggle to automatically turn mobile data off when data limit is reached.

What happens if I enable Smart Data Allocation but leave daily quota alerts disabled?

Smart Data Allocation divides and allocates the data plan into daily quotas and enables the data rollover feature. Daily quota alert is responsible for showing an alert when a day's data quota has been exhausted.

lfos commented 1 month ago

Data Monitor does not show up in that list indeed. How can it be added/enabled?

If Data Monitor is not in the list, then battery optimisation must be disabled for the app which automatically grants the Alarms & Reminders permission.

I believe I had battery optimization disabled but I must admit I don't fully understand how battery optimization settings work. When I disable battery background usage for Data Monitor, the app now shows up in the Alarms & Reminders list but when opening the app, I get the expected warning that Data Monitor can't work with battery optimization disabled. When I enable battery background usage again, Data Monitor disappears from the Alarms & Reminders` list again.

Is the plan to add this, eventually?

I'm not planning on adding this to Daily quota alert itself but maybe I can look into adding an additional toggle to automatically turn mobile data off when data limit is reached.

That sounds awesome!

What happens if I enable Smart Data Allocation but leave daily quota alerts disabled?

Smart Data Allocation divides and allocates the data plan into daily quotas and enables the data rollover feature. Daily quota alert is responsible for showing an alert when a day's data quota has been exhausted.

Right, but what exactly does "divides and allocates the data plan into daily quotas and enables the data rollover feature" mean if the quota doesn't trigger alerts and doesn't limit data? Just that the numbers are computed and displayed when the app is opened; without having any real effect? (If true, that is quite surprising behavior from a UX perspective: When I hear that "my data is allocated with daily quota", I implicitly assume the quota is also applied, and data is limited accordingly. There might be an opportunity to improve either functionality or documentation here.)

Thanks again!

itsdrnoob commented 1 month ago

When I disable battery background usage for Data Monitor, the app now shows up in the Alarms & Reminders list but when opening the app, I get the expected warning that Data Monitor can't work with battery optimization disabled. When I enable battery background usage again, Data Monitor disappears from the Alarms & Reminders` list again.

This is the intended behaviour in Android 14. When battery optimisation is disabled for an app, it's by default granted the Alarms & Reminders permission and is not shown in the list. On the other hand, when enabled, the app has restrictions on background operations including the Alarms & Reminders permission, which can now be granted or denied.

Right, but what exactly does "divides and allocates the data plan into daily quotas and enables the data rollover feature" mean if the quota doesn't trigger alerts and doesn't limit data?

There are certain data plans with a daily limit, but if that limit is not reached, the remaining data is carried over to the next day's limit, hence the rollover feature. A separate toggle for alert helps the user decide whether or not to receive an alert in such a situation.

lfos commented 1 month ago

When I disable battery background usage for Data Monitor, the app now shows up in the Alarms & Reminders list but when opening the app, I get the expected warning that Data Monitor can't work with battery optimization disabled. When I enable battery background usage again, Data Monitor disappears from the Alarms & Reminders` list again.

This is the intended behaviour in Android 14. When battery optimisation is disabled for an app, it's by default granted the Alarms & Reminders permission and is not shown in the list. On the other hand, when enabled, the app has restrictions on background operations including the Alarms & Reminders permission, which can now be granted or denied.

Thanks for the explanation. Any other ideas as to why the notifications are not showing? (If I understand correctly, my permission settings look correct.)

Right, but what exactly does "divides and allocates the data plan into daily quotas and enables the data rollover feature" mean if the quota doesn't trigger alerts and doesn't limit data?

There are certain data plans with a daily limit, but if that limit is not reached, the remaining data is carried over to the next day's limit, hence the rollover feature. A separate toggle for alert helps the user decide whether or not to receive an alert in such a situation.

Gotcha. I think it'd be good to explain/document the current state better. When I read "allocate plan into quotas", I am implicitly assuming the quota are effective, i.e., data is limited once it reaches the given amount.

itsdrnoob commented 1 month ago

Any other ideas as to why the notifications are not showing?

Still need to figure that out. Does this happen every time? Also, do other notifications, such as custom plan expiry or renewal, show up correctly?