Issue:
parseDataUsageForUidAndTag() method always calculates diff from last read value of bytes transferred (stored in sPreviousBytes). Consider the following scenario:
We call start sampling, initiate network call, end network call, call end sampling. 'sPreviousBytes' now has the value of rx_bytes from /proc/net/xt_qtaguid/stats file.
We make some other network calls in the app which are NOT sampled. rx_bytes in /proc/net/xt_qtaguid/stats gets updated.
We call start sampling & initiate another network call.
Now in the first call to addSample method , the diff calculated between the current value of rx_bytes and sPreviousBytes is the amount of data transferred in between the 2 sessions. The time duration for this sample is very small as mLastTimeReading is reset in startSampling method. This results in a incorrect data point being logged.
Fix:
Reset the previous bytes value when a sampling session ends.
Issue: parseDataUsageForUidAndTag() method always calculates diff from last read value of bytes transferred (stored in sPreviousBytes). Consider the following scenario:
Now in the first call to addSample method , the diff calculated between the current value of rx_bytes and sPreviousBytes is the amount of data transferred in between the 2 sessions. The time duration for this sample is very small as mLastTimeReading is reset in startSampling method. This results in a incorrect data point being logged.
Fix: Reset the previous bytes value when a sampling session ends.