Android device and app-wise data usage tracking using NetworkstatsManager return incorrect data

188 views Asked by At

I'm trying to monitor device and app-wise data usage at every 15min interval of time. I found that Android OS aggregating data usage every 2hr (Not mentioned in developer doc). Found aggregation time logic using method queryDetailsForUid(). Does any other method exist to find the aggregation time?

Case 1: Suppose, last aggregation time is 1:30. then, For my querySummary() with start time 2:00 and end time 2:15 (current time), the response will be data usage from 1:30 to 2:15. For my querySummary() with start time 2:15 and end time 2:30 (current time), the response will be data usage from 1:30 to 2:30. Why it behaves like this? It should return data usage in the given interval of time.

Case 2: Suppose, last aggregation time is 3:30 then, Query1: For my querySummary() with start time 2:00 and end time 2:15, the response will be data usage from 1:30 to 3:30 / 8. Query2: For my querySummary() with start time 2:15 and end time 2:30, the response will be data usage from 1:30 to 3:30 / 8. ie; response of Query1 = response of Query2 Note: 8 came from 120min / (end time - start time)

Why it simply divides the data usage? Suppose, I turned Airplane mode ON from 2:00 to 2:15. Data usage of app X from 1:30 to 3:30 is 80MB. When I query app X data usage from 2:00 to 2:15 using querySummary(), then it will return 80/8 = 10MB which is wrong, app X data usage in this time interval is 0.

Case3: Suppose, last aggregation time is 3:30, then, The sum of app-wise data usage from 3:30 and end time 4:30 is not equal to querySummaryForDevice response with start time 3:30 and end time 4:30. Why?

0

There are 0 answers