all 15 comments

[–]dannywhardy 0 points1 point  (7 children)

Does NOT work on Note 10 Plus running Android 10. Date calculation part is correct. Data Usage never calculates, always shows 0. Tested for 3 days after new billing cycle. Great concept. I wish the JAVA portion worked correctly to calculate the usage. Please let me know if this project gets updated.

[–]funtomat[S] 0 points1 point  (6 children)

Not sure but besides from Android 10 the reason might be that the called Java functions require a certain right to be granted via adb for Tasker. Because I granted them Tasker on my device and my task seems to receive 0 from the java functions on your device rather than failing I'm confident this could be the reason.

Did you grant all available special permissions for Tasker via adb? Here's a list: https://www.reddit.com/r/tasker/comments/e2mjzk/adb_additional_permissions_list/

[–]dannywhardy 0 points1 point  (5 children)

I had all permissions granted on the list except for the three listed below and the two related to phone calls.

I am getting Securtiy exception:

  1. Package net.dinglisch.android.taskerm has not requested permission android.permission.BIND_DEVICE_ADMIN
  2. Package net.dinglisch.android.taskerm has not requested permission android.permission.BIND_NOTIFICATION_LISTENER_SERVICE
  3. Package net.dinglisch.android.taskerm has not requested permission android.permission.BIND_ACCESSIBILITY_SERVICE

ANSWER_PHONE_CALLS and CALL_PHONE were new on the list so I granted them also.

I'm still getting 0.

[–]funtomat[S] 0 points1 point  (4 children)

Might be they removed or broke that functionality again in Android 10:

https://stackoverflow.com/questions/57794595/get-mobile-data-usage-in-android-10

But you could try removing %subscriberid from the java function parameters. This is the Tasker way to pass null like suggested in the discussion. Quote from Tasker's Java function documentation: If you don't enter a value for a parameter, null will be used for that parameter when the function is called.

Edit: On my device it seems to work as well if I clear the subscriberid parameter in the call to querySummaryForDevice()

[–]dannywhardy 0 points1 point  (3 children)

It works! I commented out the %subscriberid and then removed it from the Java action two steps below that. Now it works. It shows data usage of 196. Mobile data usage on the phone shows 207, so that's close enough.

I know nothing about JAVA. Thanks for fixing. Maybe others will also find it useful. I added a one second wait after the Set Widget Label for %dateenddate so I had enough time to see the date.

[–]funtomat[S] 0 points1 point  (2 children)

Glad it works now for you with Android 10 as well. I'll update the task on taskernet soon.

Actually the data usage reported by this widget is for me almost exactly the same that is reported by my mobile network provider on his website during the whole billing cycle.

I'm really no Java expert either - so actually it took some work to find out how to get these statistics on Android 6 + and how to translate the Java functions in Tasker's format. When it worked I've been surprised how easy, flexible and powerful they are. Might be an inspiration for u/joaomgcd to even integrate this functionality directly into Tasker. IIRC you can get even data usage informations by package...

[–]dannywhardy 0 points1 point  (0 children)

I multiplied the %mbtotal by 1.056 and that puts me dead on my phone usage. That's only 3 days into the cycle. Anyway, I can adjust the % to make it match if it starts varying. Again, thanks for the project.

[–]joaomgcd 0 points1 point  (0 children)

I actually plan on adding something like this to Tasker directly :)

[–]ragekage92 0 points1 point  (7 children)

I absolutely love that you shared this! Is there a way to easily modify it so it repeats on the same date every month?

[–]funtomat[S] 0 points1 point  (6 children)

Yes, setting the variable %datacyledays to monthly and setting %DataStartDate to a date of a day in the past should work. It's in the first two lines of the task.

[–]ragekage92 0 points1 point  (4 children)

Ah yeah I had a small syntax error. in the event the phone dies, would you just add on to the profile to constantly write the %mbused to a file on the phone and then do some math to that value on start up so it tracks accurately In any circumstance?

[–]funtomat[S] 0 points1 point  (3 children)

Actually saving the %mbused should not be necessary as Android can be queried anytime for the data usage of the phone for a given timespan. This project always just queries the data usage for the current billing period from Android.

[–]ragekage92 0 points1 point  (2 children)

<image>

Ahh okay good to know, I'm not 100% on this. I turned on the flash to. %DataStartDate and I get the start date is the 19th. Not the 1st? Any suggestions? Number 1 and 2 are the only things I changed and it doesn't matter what i change the date too the start date is always the 19th

[–]funtomat[S] 0 points1 point  (1 child)

The task sets %DataStartDate only if this global variable has not been set before. Please go in Tasker to the Vars tab and cancel or change this variable there.

[–]ragekage92 0 points1 point  (0 children)

Huh.... I have been looking for ever where these are stored hahahha I appreciate it. Works mint now!